comparison artifacts/src/main/java/org/dive4elements/river/artifacts/states/WDifferencesState.java @ 8552:fa57a2cb1dfa

(issue1754) Add km filtering for winfo anf fixanal results in difference calculations
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 16 Feb 2015 15:31:17 +0100
parents 04367906f158
children 0f6f702742b4
comparison
equal deleted inserted replaced
8551:11646c8dfa61 8552:fa57a2cb1dfa
122 if (d4eArtifact == null) { 122 if (d4eArtifact == null) {
123 log.warn("One of the artifacts (1) for diff calculation could not be loaded"); 123 log.warn("One of the artifacts (1) for diff calculation could not be loaded");
124 return null; 124 return null;
125 } 125 }
126 126
127 WKms retval = null;
127 if (d4eArtifact instanceof StaticWKmsArtifact) { 128 if (d4eArtifact instanceof StaticWKmsArtifact) {
128 StaticWKmsArtifact staticWKms = (StaticWKmsArtifact) d4eArtifact; 129 StaticWKmsArtifact staticWKms = (StaticWKmsArtifact) d4eArtifact;
129 log.debug("WDifferencesState obtain data from StaticWKms"); 130 log.debug("WDifferencesState obtain data from StaticWKms");
130 WKms wkms = staticWKms.getWKms(idx, from, to); 131 WKms wkms = staticWKms.getWKms(idx, from, to);
131 if (wkms == null) { 132 if (wkms == null) {
132 log.error("No WKms from Static artifact for this range."); 133 log.error("No WKms from Static artifact for this range.");
133 return new WQKms(); 134 return new WQKms();
134 } 135 }
135 return wkms; 136 return wkms; /* No need for additional km filtering */
136 } else if (d4eArtifact instanceof WINFOArtifact) { 137 } else if (d4eArtifact instanceof WINFOArtifact) {
137 log.debug("Get WKms from WINFOArtifact"); 138 log.debug("Get WKms from WINFOArtifact");
138 WINFOArtifact flys = (WINFOArtifact) d4eArtifact; 139 WINFOArtifact flys = (WINFOArtifact) d4eArtifact;
139 140
140 WKms[] wkms = (WKms[]) flys.getWaterlevelData(context). 141 WKms[] wkms = (WKms[]) flys.getWaterlevelData(context).
142 if (wkms == null || wkms.length == 0) { 143 if (wkms == null || wkms.length == 0) {
143 log.warn("no waterlevels in artifact"); 144 log.warn("no waterlevels in artifact");
144 } 145 }
145 else if (wkms.length < idx+1) { 146 else if (wkms.length < idx+1) {
146 log.warn("Not enough waterlevels in artifact."); 147 log.warn("Not enough waterlevels in artifact.");
147 return new WQKms(); 148 retval = new WQKms();
148 } 149 }
149 return wkms[idx]; 150 retval = wkms[idx];
150 } else if (d4eArtifact instanceof MINFOArtifact) { 151 } else if (d4eArtifact instanceof MINFOArtifact) {
151 log.warn("Get WKms from MINFOArtifact not implemented!"); 152 log.warn("Get WKms from MINFOArtifact not implemented!");
152 // CalculationResult r = (CalculationResult) 153 // CalculationResult r = (CalculationResult)
153 // d4eArtifact.compute(context, ComputeType.ADVANCE, false); 154 // d4eArtifact.compute(context, ComputeType.ADVANCE, false);
154 } else if (d4eArtifact instanceof FixationArtifact) { 155 } else if (d4eArtifact instanceof FixationArtifact) {
155 log.debug ("Get WKms from FixationArtifact."); 156 log.debug ("Get WKms from FixationArtifact.");
156 CalculationResult r = (CalculationResult) 157 CalculationResult r = (CalculationResult)
157 d4eArtifact.compute(context, ComputeType.ADVANCE, false); 158 d4eArtifact.compute(context, ComputeType.ADVANCE, false);
158 FixRealizingResult frR = (FixRealizingResult) r.getData(); 159 FixRealizingResult frR = (FixRealizingResult) r.getData();
159 return frR.getWQKms()[idx]; 160 retval = frR.getWQKms()[idx];
160 } 161 }
161 162
162 log.error("Do not know how to handle (getWKms) minuend/subtrahend"); 163
163 return null; 164 if (retval == null) {
165 log.error("Do not know how to handle (getWKms) minuend/subtrahend");
166 } else if (!Double.isNaN(from) && !Double.isNaN(to)) {
167 /* Filter out only the relevant data points for calulation results.*/
168 log.debug("Before filter: " + retval.size());
169 retval = retval.filteredKms(from, to);
170 log.debug("After filter: " + retval.size());
171 }
172
173 return retval;
164 } 174 }
165 175
166 176
167 /** 177 /**
168 * Return CalculationResult with Array of WKms that are difference of 178 * Return CalculationResult with Array of WKms that are difference of

http://dive4elements.wald.intevation.org