Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/WINFOArtifact.java @ 9479:2b83d3a96703
i18n TODO "benutzerdefiniert" = "custom" fixed
author | gernotbelger |
---|---|
date | Mon, 10 Sep 2018 15:31:55 +0200 |
parents | 3f49835a00c3 |
children | b380a5693514 |
comparison
equal
deleted
inserted
replaced
9478:7e2eebc14e1f | 9479:2b83d3a96703 |
---|---|
16 import org.dive4elements.artifactdatabase.data.StateData; | 16 import org.dive4elements.artifactdatabase.data.StateData; |
17 import org.dive4elements.artifactdatabase.state.Facet; | 17 import org.dive4elements.artifactdatabase.state.Facet; |
18 import org.dive4elements.artifactdatabase.state.FacetActivity; | 18 import org.dive4elements.artifactdatabase.state.FacetActivity; |
19 import org.dive4elements.artifacts.Artifact; | 19 import org.dive4elements.artifacts.Artifact; |
20 import org.dive4elements.artifacts.CallContext; | 20 import org.dive4elements.artifacts.CallContext; |
21 import org.dive4elements.artifacts.CallMeta; | |
21 import org.dive4elements.artifacts.common.utils.StringUtils; | 22 import org.dive4elements.artifacts.common.utils.StringUtils; |
22 import org.dive4elements.river.artifacts.access.Calculation4Access; | 23 import org.dive4elements.river.artifacts.access.Calculation4Access; |
23 import org.dive4elements.river.artifacts.access.ComputationRangeAccess; | 24 import org.dive4elements.river.artifacts.access.ComputationRangeAccess; |
24 import org.dive4elements.river.artifacts.access.RangeAccess; | 25 import org.dive4elements.river.artifacts.access.RangeAccess; |
25 import org.dive4elements.river.artifacts.access.RiverAccess; | 26 import org.dive4elements.river.artifacts.access.RiverAccess; |
135 */ | 136 */ |
136 public CalculationResult getWaterlevelData() { | 137 public CalculationResult getWaterlevelData() { |
137 return this.getWaterlevelData(null); | 138 return this.getWaterlevelData(null); |
138 } | 139 } |
139 | 140 |
140 private CalculationResult getDischargeLongitudinalSectionData() { | 141 private CalculationResult getDischargeLongitudinalSectionData(final CallMeta meta) { |
141 // TODO: This caluclation should be cached as it is quite expensive. | 142 // TODO: This caluclation should be cached as it is quite expensive. |
142 return new Calculation4(new Calculation4Access(this)).calculate(); | 143 return new Calculation4(new Calculation4Access(this)).calculate(meta); |
143 } | 144 } |
144 | 145 |
145 /** | 146 /** |
146 * Returns the data that is computed by a waterlevel computation. | 147 * Returns the data that is computed by a waterlevel computation. |
147 * | 148 * |
153 final String calculationMode = getDataAsString("calculation_mode"); | 154 final String calculationMode = getDataAsString("calculation_mode"); |
154 | 155 |
155 // If this WINFO-Artifact has a calculation trait. | 156 // If this WINFO-Artifact has a calculation trait. |
156 if (calculationMode != null) { | 157 if (calculationMode != null) { |
157 if (calculationMode.equals("calc.discharge.longitudinal.section")) | 158 if (calculationMode.equals("calc.discharge.longitudinal.section")) |
158 return getDischargeLongitudinalSectionData(); | 159 return getDischargeLongitudinalSectionData(context.getMeta()); |
159 | 160 |
160 if (calculationMode.equals("calc.extreme.curve")) | 161 if (calculationMode.equals("calc.extreme.curve")) |
161 return (CalculationResult) this.compute(context, ComputeType.ADVANCE, false); | 162 return (CalculationResult) this.compute(context, ComputeType.ADVANCE, false); |
162 | 163 |
163 if (calculationMode.equals("calc.w.differences")) | 164 if (calculationMode.equals("calc.w.differences")) |
484 } | 485 } |
485 | 486 |
486 /** | 487 /** |
487 * Get corrected waterline against surface/profile. | 488 * Get corrected waterline against surface/profile. |
488 */ | 489 */ |
489 private double waterLineC(final int idx, final double currentKm) { | 490 private double waterLineC(final int idx, final double currentKm, final CallMeta meta) { |
490 | 491 |
491 final WQKms[] wqckms = (WQKms[]) getDischargeLongitudinalSectionData().getData(); | 492 final WQKms[] wqckms = (WQKms[]) getDischargeLongitudinalSectionData(meta).getData(); |
492 | 493 |
493 // Find index of km. | 494 // Find index of km. |
494 final double wishKM = currentKm; | 495 final double wishKM = currentKm; |
495 | 496 |
496 // Find W/C at km, linear naive approach. | 497 // Find W/C at km, linear naive approach. |
553 return Double.NaN; | 554 return Double.NaN; |
554 } | 555 } |
555 | 556 |
556 if (wqkms.length <= idx) { | 557 if (wqkms.length <= idx) { |
557 log.error("getWaterLines() requested index (" + idx + " not found."); | 558 log.error("getWaterLines() requested index (" + idx + " not found."); |
558 return waterLineC(idx, currentKm); | 559 return waterLineC(idx, currentKm, context.getMeta()); |
559 } | 560 } |
560 | 561 |
561 // Find W at km, linear naive approach. | 562 // Find W at km, linear naive approach. |
562 final WQKms triple = wqkms[idx]; | 563 final WQKms triple = wqkms[idx]; |
563 | 564 |
643 final TDoubleArrayList outQs = new TDoubleArrayList(ws.length); | 644 final TDoubleArrayList outQs = new TDoubleArrayList(ws.length); |
644 final TDoubleArrayList outWs = new TDoubleArrayList(ws.length); | 645 final TDoubleArrayList outWs = new TDoubleArrayList(ws.length); |
645 | 646 |
646 boolean generatedWs = false; | 647 boolean generatedWs = false; |
647 | 648 |
648 for (int i = 0; i < ws.length; ++i) { | 649 for (final double w : ws) { |
649 final double w = ws[i]; | |
650 if (debug) { | 650 if (debug) { |
651 log.debug("getQsForWs: lookup Q for W: " + w); | 651 log.debug("getQsForWs: lookup Q for W: " + w); |
652 } | 652 } |
653 // There could be more than one Q per W. | 653 // There could be more than one Q per W. |
654 final double[] qs = wst.findQsForW(km, w, report); | 654 final double[] qs = wst.findQsForW(km, w, report); |
655 for (int j = 0; j < qs.length; ++j) { | 655 for (final double element : qs) { |
656 outWs.add(ws[i]); | 656 outWs.add(w); |
657 outQs.add(qs[j]); | 657 outQs.add(element); |
658 } | 658 } |
659 generatedWs |= qs.length != 1; | 659 generatedWs |= qs.length != 1; |
660 } | 660 } |
661 | 661 |
662 if (debug) { | 662 if (debug) { |
692 final TDoubleArrayList wsOut = new TDoubleArrayList(ws.length); | 692 final TDoubleArrayList wsOut = new TDoubleArrayList(ws.length); |
693 final TDoubleArrayList qsOut = new TDoubleArrayList(ws.length); | 693 final TDoubleArrayList qsOut = new TDoubleArrayList(ws.length); |
694 | 694 |
695 boolean generatedWs = false; | 695 boolean generatedWs = false; |
696 | 696 |
697 for (int i = 0; i < ws.length; i++) { | 697 for (final double element : ws) { |
698 if (Double.isNaN(ws[i])) { | 698 if (Double.isNaN(element)) { |
699 log.warn("W is NaN: ignored"); | 699 log.warn("W is NaN: ignored"); |
700 continue; | 700 continue; |
701 } | 701 } |
702 final double[] qs = DischargeTables.getQsForW(values, ws[i]); | 702 final double[] qs = DischargeTables.getQsForW(values, element); |
703 | 703 |
704 if (qs.length == 0) { | 704 if (qs.length == 0) { |
705 log.warn("No Qs found for W = " + ws[i]); | 705 log.warn("No Qs found for W = " + element); |
706 } else { | 706 } else { |
707 for (final double q : qs) { | 707 for (final double q : qs) { |
708 wsOut.add(ws[i]); | 708 wsOut.add(element); |
709 qsOut.add(q); | 709 qsOut.add(q); |
710 } | 710 } |
711 } | 711 } |
712 generatedWs |= qs.length != 1; | 712 generatedWs |= qs.length != 1; |
713 } | 713 } |