Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java @ 8856:5e38e2924c07 3.2.x
Fix code style.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Thu, 18 Jan 2018 20:12:01 +0100 |
parents | 2faf6cef6f5f |
children | 8731c3dabb56 0a5239a1e46e |
comparison
equal
deleted
inserted
replaced
8855:d7c005e12af0 | 8856:5e38e2924c07 |
---|---|
159 /* Check for official fixings. They should also be included in the | 159 /* Check for official fixings. They should also be included in the |
160 * export but only the calculation result is added with addData */ | 160 * export but only the calculation result is added with addData */ |
161 | 161 |
162 officalFixings = new ArrayList<WQKms>(); | 162 officalFixings = new ArrayList<WQKms>(); |
163 | 163 |
164 for (Artifact art: collection.getArtifactsByName(STATICWQKMSNAME, context)) { | 164 for (Artifact art: collection.getArtifactsByName( |
165 STATICWQKMSNAME, context) | |
166 ) { | |
165 if (art instanceof StaticWQKmsArtifact) { | 167 if (art instanceof StaticWQKmsArtifact) { |
166 IsOfficialAccess access = new IsOfficialAccess((D4EArtifact)art); | 168 IsOfficialAccess access = |
169 new IsOfficialAccess((D4EArtifact)art); | |
167 StaticWQKmsArtifact sart = (StaticWQKmsArtifact) art; | 170 StaticWQKmsArtifact sart = (StaticWQKmsArtifact) art; |
168 if (!access.isOfficial()) { | 171 if (!access.isOfficial()) { |
169 continue; | 172 continue; |
170 } | 173 } |
171 | 174 |
535 boolean atGauge, | 538 boolean atGauge, |
536 boolean isQ | 539 boolean isQ |
537 ) { | 540 ) { |
538 log.info("WaterlevelExporter.writeCSVHeader"); | 541 log.info("WaterlevelExporter.writeCSVHeader"); |
539 | 542 |
540 String unit = RiverUtils.getRiver((D4EArtifact) master).getWstUnit().getName(); | 543 String unit = RiverUtils.getRiver( |
544 (D4EArtifact) master).getWstUnit().getName(); | |
541 | 545 |
542 if (atGauge) { | 546 if (atGauge) { |
543 writer.writeNext(new String[] { | 547 writer.writeNext(new String[] { |
544 msg(CSV_KM_HEADER, DEFAULT_CSV_KM_HEADER), | 548 msg(CSV_KM_HEADER, DEFAULT_CSV_KM_HEADER), |
545 msg(CSV_W_HEADER, DEFAULT_CSV_W_HEADER, new Object[] { unit }), | 549 msg(CSV_W_HEADER, DEFAULT_CSV_W_HEADER, new Object[] { unit }), |
627 } | 631 } |
628 | 632 |
629 if (flys instanceof WINFOArtifact) { | 633 if (flys instanceof WINFOArtifact) { |
630 if (wqkms != null && wqkms.getRawValue() != null) { | 634 if (wqkms != null && wqkms.getRawValue() != null) { |
631 WINFOArtifact winfo = (WINFOArtifact) flys; | 635 WINFOArtifact winfo = (WINFOArtifact) flys; |
632 colDesc = RiverUtils.getNamedMainValue(winfo, wqkms.getRawValue()); | 636 colDesc = RiverUtils.getNamedMainValue( |
637 winfo, wqkms.getRawValue()); | |
633 // For 'W am Pegel' s | 638 // For 'W am Pegel' s |
634 if (colDesc == null) { | 639 if (colDesc == null) { |
635 Double value = RiverUtils.getValueFromWQ(wqkms); | 640 Double value = RiverUtils.getValueFromWQ(wqkms); |
636 colDesc = (value != null) ? | 641 colDesc = (value != null) ? |
637 Formatter.getWaterlevelW(context).format(value) : null; | 642 Formatter.getWaterlevelW(context).format(value) : null; |
832 int idx = officialKms.indexOf(km); | 837 int idx = officialKms.indexOf(km); |
833 if (idx != -1) { | 838 if (idx != -1) { |
834 entry.getValue().add(wqkms.getW(idx), wqkms.getQ(idx)); | 839 entry.getValue().add(wqkms.getW(idx), wqkms.getQ(idx)); |
835 } | 840 } |
836 } | 841 } |
837 | |
838 /* Variant: Interpolate the values | |
839 // Now get the lines for the of the calculation | |
840 Map <Double, WstLine> calcLines = writer.getLines(); | |
841 | |
842 // Create an interpolater for the official KM -> W relation | |
843 UnivariateRealFunction wFunc = new LinearInterpolator( | |
844 ).interpolate(wqkms.allKms().toNativeArray(), | |
845 wqkms.allWs().toNativeArray()); | |
846 | |
847 // Now for each calculated point add the interpolated official | |
848 for (Map.Entry<Double, WstLine> entry : calcLines.entrySet()) { | |
849 try { | |
850 double wVal = wFunc.value(entry.getKey().doubleValue()); | |
851 // Matching Q's are guranteed otherwise we would | |
852 // not have an official line | |
853 entry.getValue().add(wVal, entry.getValue().getQ(0)); | |
854 } | |
855 catch (FunctionEvaluationException aode) { | |
856 // should not happen | |
857 log.error("spline interpolation failed", aode); | |
858 // entry.getValue().add(Double.NaN, entry.getValue().getQ(0)); | |
859 } | |
860 }*/ | |
861 | |
862 /* Variant: Add all official fixings | |
863 // Warning the WSTWriter does not handle this properly | |
864 // as it writes the points for which only a calculation | |
865 // exists in the first column | |
866 int size = wqkms.size(); | |
867 result = new double[4]; | |
868 for (int i = 0; i < size; i++) { | |
869 result = wqkms.get(i, result); | |
870 writer.add(result); | |
871 } | |
872 */ | |
873 } | 842 } |
874 } | 843 } |
875 | 844 |
876 | 845 |
877 /** | 846 /** |