Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WDifferencesState.java @ 1652:46a2a5dc98b7
In W-Difference-calculation, respect indices of selected facets.
flys-artifacts/trunk@2844 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Tue, 27 Sep 2011 14:03:06 +0000 |
parents | ff7bffb7d5f0 |
children | d251e5929860 |
comparison
equal
deleted
inserted
replaced
1651:a7def20539fb | 1652:46a2a5dc98b7 |
---|---|
62 return true; | 62 return true; |
63 } | 63 } |
64 | 64 |
65 | 65 |
66 /** | 66 /** |
67 * Return List of WKms that are difference of pairs. | 67 * Return CalculationResult with Array of WKms that are difference of |
68 * Waterlevels. Add respective facets (DifferencesCurveFacet, DataFacet). | |
68 */ | 69 */ |
69 @Override | 70 @Override |
70 public Object computeAdvance( | 71 public Object computeAdvance( |
71 FLYSArtifact artifact, | 72 FLYSArtifact artifact, |
72 String hash, | 73 String hash, |
95 } | 96 } |
96 | 97 |
97 List<WKms> wkmss = new ArrayList<WKms>(); | 98 List<WKms> wkmss = new ArrayList<WKms>(); |
98 | 99 |
99 for(int i = 0; i < datas.length /2; i++) { | 100 for(int i = 0; i < datas.length /2; i++) { |
100 String uuid1 = WaterlevelSelectState.strip(datas[i+0]).split(";")[0]; | 101 // e.g.: |
101 String uuid2 = WaterlevelSelectState.strip(datas[i+1]).split(";")[0]; | 102 // 42537f1e-3522-42ef-8968-635b03d8e9c6;longitudinal_section.w;1 |
103 String[] def1 = WaterlevelSelectState.strip(datas[i+0]).split(";"); | |
104 String[] def2 = WaterlevelSelectState.strip(datas[i+1]).split(";"); | |
105 String uuid1 = def1[0]; | |
106 String uuid2 = def2[0]; | |
107 int idx1 = Integer.parseInt(def1[2]); | |
108 int idx2 = Integer.parseInt(def2[2]); | |
102 | 109 |
103 WINFOArtifact flys1 = (WINFOArtifact) FLYSUtils.getArtifact( | 110 WINFOArtifact flys1 = (WINFOArtifact) FLYSUtils.getArtifact( |
104 uuid1, | 111 uuid1, |
105 context); | 112 context); |
106 WINFOArtifact flys2 = (WINFOArtifact) FLYSUtils.getArtifact( | 113 WINFOArtifact flys2 = (WINFOArtifact) FLYSUtils.getArtifact( |
125 getData(); | 132 getData(); |
126 | 133 |
127 if (datas.length > 2) { | 134 if (datas.length > 2) { |
128 logger.error("Cannot keep more than one calculation."); | 135 logger.error("Cannot keep more than one calculation."); |
129 } | 136 } |
130 facetName = "W (" + minuend[0].getName() + ") - W (" + subtrahend[0].getName() + ")"; | 137 facetName = "W (" + minuend[idx1].getName() + ") - W (" + subtrahend[idx2].getName() + ")"; |
131 WKms wkms = WKmsOperation.SUBTRACTION.operate(minuend[0], subtrahend[0]); | 138 WKms wkms = WKmsOperation.SUBTRACTION.operate(minuend[idx1], subtrahend[idx2]); |
132 wkms.setName(facetName); | 139 wkms.setName(facetName); |
133 wkmss.add(wkms); | 140 wkmss.add(wkms); |
134 logger.debug("WKMSSubtraction happened"); | 141 logger.debug("WKMSSubtraction happened"); |
135 } | 142 } |
136 | 143 |
137 if (facets != null) { | 144 if (facets != null) { |
138 // TODO: pass computetype and state id. | |
139 //, ComputeType.ADVANCE, getID(), hash)); | |
140 //facets.add(new DataFacet(W_DIFFERENCES, facetName)); | |
141 facets.add(new DifferenceCurveFacet(i, W_DIFFERENCES, facetName, | 145 facets.add(new DifferenceCurveFacet(i, W_DIFFERENCES, facetName, |
142 ComputeType.ADVANCE, id, hash)); | 146 ComputeType.ADVANCE, id, hash)); |
143 //facets.add(new WaterlevelFacet | |
144 facets.add(new DataFacet(CSV, "CSV data")); | 147 facets.add(new DataFacet(CSV, "CSV data")); |
145 } | 148 } |
146 else { | 149 else { |
147 logger.debug("Not adding facets in WDifferencesState."); | 150 logger.debug("Not adding facets in WDifferencesState."); |
148 } | 151 } |
149 } | 152 } |
150 | 153 |
151 CalculationResult result = new CalculationResult(); | 154 // TODO Evaluate whether null is okay as reports. |
152 WKms[] diffs = wkmss.toArray(new WKms[wkmss.size()]); | 155 WKms[] diffs = wkmss.toArray(new WKms[wkmss.size()]); |
153 result.setData(diffs); | 156 CalculationResult result = new CalculationResult(diffs, null); |
154 return result; | 157 return result; |
155 } | 158 } |
156 } | 159 } |
157 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : | 160 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |