Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java @ 4482:b5624ef2808f
Merged
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Tue, 13 Nov 2012 16:14:44 +0100 |
parents | 5fc7df736634 |
children | 6d3426aba65d |
comparison
equal
deleted
inserted
replaced
4481:d9e3660fa462 | 4482:b5624ef2808f |
---|---|
26 import de.intevation.flys.artifacts.model.WQCKms; | 26 import de.intevation.flys.artifacts.model.WQCKms; |
27 import de.intevation.flys.artifacts.model.WQKms; | 27 import de.intevation.flys.artifacts.model.WQKms; |
28 import de.intevation.flys.artifacts.model.WW; | 28 import de.intevation.flys.artifacts.model.WW; |
29 import de.intevation.flys.artifacts.model.WstValueTable; | 29 import de.intevation.flys.artifacts.model.WstValueTable; |
30 import de.intevation.flys.artifacts.model.WstValueTableFactory; | 30 import de.intevation.flys.artifacts.model.WstValueTableFactory; |
31 | 31 import de.intevation.flys.artifacts.model.extreme.ExtremeResult; |
32 | |
33 import de.intevation.flys.artifacts.states.DefaultState.ComputeType; | |
32 import de.intevation.flys.artifacts.states.LocationDistanceSelect; | 34 import de.intevation.flys.artifacts.states.LocationDistanceSelect; |
33 | 35 |
34 import de.intevation.flys.model.DischargeTable; | 36 import de.intevation.flys.model.DischargeTable; |
35 import de.intevation.flys.model.FastCrossSectionLine; | 37 import de.intevation.flys.model.FastCrossSectionLine; |
36 import de.intevation.flys.model.Gauge; | 38 import de.intevation.flys.model.Gauge; |
155 | 157 |
156 | 158 |
157 // | 159 // |
158 // METHODS FOR RETRIEVING COMPUTED DATA FOR DIFFERENT CHART TYPES | 160 // METHODS FOR RETRIEVING COMPUTED DATA FOR DIFFERENT CHART TYPES |
159 // | 161 // |
160 | 162 // |
161 /** | 163 /** |
162 * Returns the data that is computed by a waterlevel computation. | 164 * Returns the data that is computed by a waterlevel computation. |
163 * | 165 * |
164 * @return an array of data triples that consist of W, Q and Kms. | 166 * @return an array of data triples that consist of W, Q and Kms. |
165 */ | 167 */ |
166 public CalculationResult getWaterlevelData() | 168 public CalculationResult getWaterlevelData() { |
169 return this.getWaterlevelData(null); | |
170 } | |
171 | |
172 /** | |
173 * Returns the data that is computed by a waterlevel computation. | |
174 * | |
175 * @return an array of data triples that consist of W, Q and Kms. | |
176 */ | |
177 public CalculationResult getWaterlevelData(CallContext context) | |
167 { | 178 { |
168 logger.debug("WINFOArtifact.getWaterlevelData"); | 179 logger.debug("WINFOArtifact.getWaterlevelData"); |
169 | 180 |
170 if (getDataAsString("calculation_mode") | 181 String calculationMode = getDataAsString("calculation_mode"); |
171 .equals("calc.discharge.longitudinal.section") | 182 |
183 if (calculationMode.equals("calc.discharge.longitudinal.section") | |
172 ) { | 184 ) { |
173 return getDischargeLongitudinalSectionData(); | 185 return getDischargeLongitudinalSectionData(); |
186 } | |
187 else if (calculationMode.equals("calc.extreme.curve")) { | |
188 return (CalculationResult) this.compute(context, ComputeType.ADVANCE, false); | |
174 } | 189 } |
175 | 190 |
176 River river = FLYSUtils.getRiver(this); | 191 River river = FLYSUtils.getRiver(this); |
177 if (river == null) { | 192 if (river == null) { |
178 return error(new WQKms[0], "no.river.selected"); | 193 return error(new WQKms[0], "no.river.selected"); |
623 * @return an array holding coordinates of points of surface of water ( | 638 * @return an array holding coordinates of points of surface of water ( |
624 * in the form {{x1, x2} {y1, y2}} ). | 639 * in the form {{x1, x2} {y1, y2}} ). |
625 */ | 640 */ |
626 @Override | 641 @Override |
627 public Lines.LineData getWaterLines(int idx, FastCrossSectionLine csl, | 642 public Lines.LineData getWaterLines(int idx, FastCrossSectionLine csl, |
628 double nextIgnored, double prevIgnored) { | 643 double nextIgnored, double prevIgnored, CallContext context) { |
629 logger.debug("getWaterLines(" + idx + ")"); | 644 logger.debug("getWaterLines(" + idx + ")"); |
630 | 645 |
631 List<Point2D> points = csl.getPoints(); | 646 List<Point2D> points = csl.getPoints(); |
632 | 647 |
633 // Need W at km | 648 // Need W at km |
634 WQKms [] wqkms = (WQKms[]) getWaterlevelData().getData(); | 649 Object waterlevelResult = getWaterlevelData(context).getData(); |
650 WQKms [] wqkms; | |
651 | |
652 if (waterlevelResult instanceof ExtremeResult) { | |
653 wqkms = ((ExtremeResult) waterlevelResult).getWQKms(); | |
654 } | |
655 else { | |
656 wqkms = (WQKms[]) waterlevelResult; | |
657 } | |
658 | |
635 if (wqkms.length == 0) { | 659 if (wqkms.length == 0) { |
636 logger.error("No WQKms found."); | 660 logger.error("No WQKms found."); |
637 return Lines.createWaterLines(points, 0.0f); | 661 return Lines.createWaterLines(points, 0.0f); |
638 } | 662 } |
639 | 663 |
641 logger.error("getWaterLines() requested index (" | 665 logger.error("getWaterLines() requested index (" |
642 + idx + " not found."); | 666 + idx + " not found."); |
643 return waterLineC(idx, csl); | 667 return waterLineC(idx, csl); |
644 } | 668 } |
645 | 669 |
670 // Find W at km, linear naive approach. | |
671 WQKms triple = wqkms[idx]; | |
672 | |
646 // Find index of km. | 673 // Find index of km. |
647 double wishKM = csl.getKm(); | 674 double wishKM = csl.getKm(); |
648 | |
649 // Find W at km, linear naive approach. | |
650 WQKms triple = wqkms[idx]; | |
651 | 675 |
652 if (triple.size() == 0) { | 676 if (triple.size() == 0) { |
653 logger.warn("Calculation of waterline is empty."); | 677 logger.warn("Calculation of waterline is empty."); |
654 return Lines.createWaterLines(points, 0.0f); | 678 return Lines.createWaterLines(points, 0.0f); |
655 } | 679 } |