Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/CrossSectionArtifact.java @ 2036:c03aeb0cf46b
Initialize km of cross-section artifact to a better value (not all cases covered, yet).
flys-artifacts/trunk@3509 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 21 Dec 2011 11:29:59 +0000 |
parents | 07b176b14205 |
children | 986820795c3b |
comparison
equal
deleted
inserted
replaced
2035:3ebbe497d7f7 | 2036:c03aeb0cf46b |
---|---|
82 } | 82 } |
83 else { | 83 else { |
84 throw new IllegalArgumentException("No attribute 'ids' found!"); | 84 throw new IllegalArgumentException("No attribute 'ids' found!"); |
85 } | 85 } |
86 | 86 |
87 // Assume we start at km 0. | 87 |
88 addStringData(DATA_KM, "0"); | |
89 addStringData(DATA_IS_MASTER, "0"); | 88 addStringData(DATA_IS_MASTER, "0"); |
90 | 89 |
91 List<Facet> fs = new ArrayList<Facet>(); | 90 List<Facet> fs = new ArrayList<Facet>(); |
92 CrossSection cs = CrossSectionFactory.getCrossSection(Integer.valueOf(ids)); | 91 CrossSection cs = CrossSectionFactory.getCrossSection(Integer.valueOf(ids)); |
92 CrossSectionLine csl = cs.getLines().get(0); | |
93 // Find min-km of cross sections, than set DATA_KM to min(DATA_KM, minCross). | |
94 if (csl != null) { | |
95 double masterKm = Double.valueOf(getDataAsString(DATA_KM)); | |
96 if (masterKm < csl.getKm().doubleValue()) { | |
97 addStringData(DATA_KM, csl.getKm().toString()); | |
98 } | |
99 } | |
93 fs.add(new CrossSectionFacet(0, cs.getDescription())); | 100 fs.add(new CrossSectionFacet(0, cs.getDescription())); |
94 | 101 |
95 StaticState state = (StaticState) getCurrentState(context); | 102 StaticState state = (StaticState) getCurrentState(context); |
96 | 103 |
97 if (!fs.isEmpty()) { | 104 if (!fs.isEmpty()) { |
98 facets.put(getCurrentStateId(), fs); | 105 facets.put(getCurrentStateId(), fs); |
99 } | 106 } |
100 } | 107 } |
101 | 108 |
102 | 109 |
103 /** Do not copy data from daddyfact. */ | 110 /** Copy km where master-artifact "starts". */ |
104 @Override | 111 @Override |
105 protected void initialize( | 112 protected void initialize( |
106 Artifact artifact, | 113 Artifact artifact, |
107 Object context, | 114 Object context, |
108 CallMeta callMeta) | 115 CallMeta callMeta) |
109 { | 116 { |
110 // do nothing | 117 WINFOArtifact winfo = (WINFOArtifact) artifact; |
118 this.addStringData(DATA_KM, winfo.getDataAsString("ld_from")); | |
111 } | 119 } |
112 | 120 |
113 | 121 |
114 /** | 122 /** |
115 * Create and return a new StaticState with charting output. | 123 * Create and return a new StaticState with charting output. |