# HG changeset patch # User gernotbelger # Date 1540225565 -7200 # Node ID 33ce8eba9806385c914822943aaabaeb9885f4d2 # Parent c3ed5dcd5e082c5f660bf000af202a2e9e8c9964 waterlevel export W/am Pegel / "Bezeichnung" fixes diff -r c3ed5dcd5e08 -r 33ce8eba9806 artifacts/doc/conf/jasper/templates/waterlevel.jrxml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/doc/conf/jasper/templates/waterlevel.jrxml Mon Oct 22 18:26:05 2018 +0200 @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <band height="169" splitType="Stretch"> + <textField> + <reportElement style="htmlStyle" x="0" y="0" width="515" height="30"/> + <textElement> + <font size="18"/> + </textElement> + <textFieldExpression><![CDATA[$F{meta:header} + " " + $F{meta:river}]]></textFieldExpression> + </textField> + <textField> + <reportElement style="htmlStyle" x="0" y="39" width="165" height="20"/> + <textFieldExpression><![CDATA[$F{meta:calcMode}]]></textFieldExpression> + </textField> + <textField> + <reportElement style="htmlStyle" x="0" y="69" width="123" height="20"/> + <textFieldExpression><![CDATA[$F{meta:version_label} + ":"]]></textFieldExpression> + </textField> + <textField> + <reportElement style="htmlStyle" x="123" y="69" width="392" height="20"/> + <textFieldExpression><![CDATA[$F{meta:version}]]></textFieldExpression> + </textField> + <textField> + <reportElement style="htmlStyle" x="0" y="89" width="123" height="20"/> + <textFieldExpression><![CDATA[$F{meta:user_label} + ":"]]></textFieldExpression> + </textField> + <textField> + <reportElement style="htmlStyle" x="123" y="89" width="392" height="20"/> + <textFieldExpression><![CDATA[$F{meta:user}]]></textFieldExpression> + </textField> + <textField> + <reportElement style="htmlStyle" x="0" y="109" width="123" height="20"/> + <textFieldExpression><![CDATA[$F{meta:date_label} + ":"]]></textFieldExpression> + </textField> + <textField> + <reportElement style="htmlStyle" x="123" y="109" width="392" height="20"/> + <textFieldExpression><![CDATA[$F{meta:date}]]></textFieldExpression> + </textField> + <textField> + <reportElement style="htmlStyle" x="0" y="129" width="123" height="20"/> + <textFieldExpression><![CDATA[$F{meta:river_label} + ":"]]></textFieldExpression> + </textField> + <textField> + <reportElement style="htmlStyle" x="123" y="129" width="392" height="20"/> + <textFieldExpression><![CDATA[$F{meta:river}]]></textFieldExpression> + </textField> + <textField> + <reportElement style="htmlStyle" x="0" y="149" width="123" height="20"/> + <textFieldExpression><![CDATA[$F{meta:range_label} + ":"]]></textFieldExpression> + </textField> + <textField> + <reportElement style="htmlStyle" x="123" y="149" width="392" height="20"/> + <textFieldExpression><![CDATA[$F{meta:range}]]></textFieldExpression> + </textField> + </band> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r c3ed5dcd5e08 -r 33ce8eba9806 artifacts/doc/conf/jasper/templates/waterlevel_new.jrxml --- a/artifacts/doc/conf/jasper/templates/waterlevel_new.jrxml Mon Oct 22 16:33:10 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,272 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <band height="169" splitType="Stretch"> - <textField> - <reportElement style="htmlStyle" x="0" y="0" width="515" height="30"/> - <textElement> - <font size="18"/> - </textElement> - <textFieldExpression><![CDATA[$F{meta:header} + " " + $F{meta:river}]]></textFieldExpression> - </textField> - <textField> - <reportElement style="htmlStyle" x="0" y="39" width="165" height="20"/> - <textFieldExpression><![CDATA[$F{meta:calcMode}]]></textFieldExpression> - </textField> - <textField> - <reportElement style="htmlStyle" x="0" y="69" width="123" height="20"/> - <textFieldExpression><![CDATA[$F{meta:version_label} + ":"]]></textFieldExpression> - </textField> - <textField> - <reportElement style="htmlStyle" x="123" y="69" width="392" height="20"/> - <textFieldExpression><![CDATA[$F{meta:version}]]></textFieldExpression> - </textField> - <textField> - <reportElement style="htmlStyle" x="0" y="89" width="123" height="20"/> - <textFieldExpression><![CDATA[$F{meta:user_label} + ":"]]></textFieldExpression> - </textField> - <textField> - <reportElement style="htmlStyle" x="123" y="89" width="392" height="20"/> - <textFieldExpression><![CDATA[$F{meta:user}]]></textFieldExpression> - </textField> - <textField> - <reportElement style="htmlStyle" x="0" y="109" width="123" height="20"/> - <textFieldExpression><![CDATA[$F{meta:date_label} + ":"]]></textFieldExpression> - </textField> - <textField> - <reportElement style="htmlStyle" x="123" y="109" width="392" height="20"/> - <textFieldExpression><![CDATA[$F{meta:date}]]></textFieldExpression> - </textField> - <textField> - <reportElement style="htmlStyle" x="0" y="129" width="123" height="20"/> - <textFieldExpression><![CDATA[$F{meta:river_label} + ":"]]></textFieldExpression> - </textField> - <textField> - <reportElement style="htmlStyle" x="123" y="129" width="392" height="20"/> - <textFieldExpression><![CDATA[$F{meta:river}]]></textFieldExpression> - </textField> - <textField> - <reportElement style="htmlStyle" x="0" y="149" width="123" height="20"/> - <textFieldExpression><![CDATA[$F{meta:range_label} + ":"]]></textFieldExpression> - </textField> - <textField> - <reportElement style="htmlStyle" x="123" y="149" width="392" height="20"/> - <textFieldExpression><![CDATA[$F{meta:range}]]></textFieldExpression> - </textField> - </band> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r c3ed5dcd5e08 -r 33ce8eba9806 artifacts/src/main/java/org/dive4elements/river/artifacts/model/Calculation4.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/Calculation4.java Mon Oct 22 16:33:10 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/Calculation4.java Mon Oct 22 18:26:05 2018 +0200 @@ -236,7 +236,7 @@ } } } - final String custom = Resources.format(meta, "common.custom"); + final String custom = Resources.getMsg(meta, "common.custom"); // Backjump correction for (int i = 0; i < results.length; ++i) { diff -r c3ed5dcd5e08 -r 33ce8eba9806 artifacts/src/main/java/org/dive4elements/river/exports/FixWaterlevelExporter.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/FixWaterlevelExporter.java Mon Oct 22 16:33:10 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/FixWaterlevelExporter.java Mon Oct 22 18:26:05 2018 +0200 @@ -47,17 +47,15 @@ /** Write an csv-row at gauge location. */ @Override protected void writeRow6(final CSVWriter writer, final double wqkm[], final String wOrQDesc, final D4EArtifact flys, final String gaugeName, - final Gauge gauge, final boolean isQ) { + final String wAtGauge, final boolean isQ) { if (!isQ) { - super.writeRow6(writer, wqkm, wOrQDesc, flys, gaugeName, gauge, isQ); + super.writeRow6(writer, wqkm, wOrQDesc, flys, gaugeName, wAtGauge, isQ); } else { final NumberFormat kmf = getKmFormatter(); final NumberFormat wf = getWFormatter(); final NumberFormat qf = getQFormatter(); - final String waterlevel = getWaterlevel(wqkm[1], gauge); - - writer.writeNext(new String[] { kmf.format(wqkm[2]), wf.format(wqkm[0]), waterlevel, qf.format(RiverUtils.roundQ(wqkm[1])), wOrQDesc, + writer.writeNext(new String[] { kmf.format(wqkm[2]), wf.format(wqkm[0]), wAtGauge, qf.format(RiverUtils.roundQ(wqkm[1])), wOrQDesc, RiverUtils.getLocationDescription(flys, wqkm[2]), gaugeName }); } } diff -r c3ed5dcd5e08 -r 33ce8eba9806 artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java Mon Oct 22 16:33:10 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java Mon Oct 22 18:26:05 2018 +0200 @@ -534,7 +534,7 @@ /** Write an csv-row at gauge location. */ protected void writeRow6(final CSVWriter writer, final double wqkm[], final String wOrQDesc, final D4EArtifact flys, final String gaugeName, - final Gauge gauge, final boolean isQ) { + final String wAtGauge, final boolean isQ) { final NumberFormat kmf = getKmFormatter(); final NumberFormat wf = getWFormatter(); final NumberFormat qf = getQFormatter(); @@ -615,24 +615,18 @@ if (gauge == null) gauge = rangeAccess.getRiver().determineRefGauge(wqkms.getKms(), rangeAccess.isRange()); - final String gaugeName = gauge.getName(); // RANDOMLY CHRASHES HERE, gauge is randomly null (especially on heavy load) - on production system as well - // (it seems to) - // REMARK "randomly" crashes: see REMARK above + final String notinrange = msg(CSV_NOT_IN_GAUGE_RANGE, DEFAULT_CSV_NOT_IN_GAUGE_RANGE); + final String gaugeName = gauge != null ? gauge.getName() : notinrange; - String desc = ""; - final String notinrange = msg(CSV_NOT_IN_GAUGE_RANGE, DEFAULT_CSV_NOT_IN_GAUGE_RANGE); + final double a = gauge != null ? gauge.getRange().getA().doubleValue() : Double.NaN; + final double b = gauge != null ? gauge.getRange().getB().doubleValue() : Double.NaN; - final double a = gauge.getRange().getA().doubleValue(); - final double b = gauge.getRange().getB().doubleValue(); final long startTime = System.currentTimeMillis(); - desc = getDesc(wqkms, isQ); + String desc = getDesc(wqkms, isQ); - boolean isFixRealize = false; final List segments = getSegments(flys); - if (segments != null && !segments.isEmpty()) { - isFixRealize = true; - } + final boolean isFixRealize = isFixrealize(segments); if (atGauge) { // "At gauge" needs more output. // Kms tend to be close together so caching the last sector @@ -644,10 +638,12 @@ for (int i = 0; i < size; ++i) { result = wqkms.get(i, result); - final double km = result[2]; + + final double station = result[2]; + final double q = result[1]; if (segments != null) { - final Segment found = lastSegment != null && lastSegment.inside(km) ? lastSegment : findSegment(km, segments); + final Segment found = lastSegment != null && lastSegment.inside(station) ? lastSegment : findSegment(station, segments); if (found != null) { desc = nf.format(found.getValues()[0]); @@ -656,16 +652,22 @@ } String gaugeN; + final String wAtGauge; if (isFixRealize) { - final Gauge found = lastGauge != null && lastGauge.getRange().contains(km) ? lastGauge : findGauge(km, gauges); + final Gauge found = lastGauge != null && lastGauge.getRange().contains(station) ? lastGauge : findGauge(station, gauges); gaugeN = found != null ? found.getName() : notinrange; lastGauge = found; + + wAtGauge = this.getWaterlevel(q, found); // THIS IS NEW (and makes common super method difficult) } else { // TODO issue1114: Take correct gauge - gaugeN = km >= a && km <= b ? gaugeName : notinrange; + gaugeN = station >= a && station <= b ? gaugeName : notinrange; + + wAtGauge = ""; } - writeRow6(writer, result, desc, flys, gaugeN, gauge, isQ); + + writeRow6(writer, result, desc, flys, gaugeN, wAtGauge, isQ); } } else { // Not at gauge. for (int i = 0; i < size; ++i) { @@ -681,6 +683,14 @@ } } + private boolean isFixrealize(final List segments) { + boolean isFixRealize = false; + if (segments != null && !segments.isEmpty()) { + isFixRealize = true; + } + return isFixRealize; + } + /** * Generates the output in WST format. */ @@ -782,18 +792,17 @@ final boolean isQ = isQ(); final MetaAndTableJRDataSource source = new MetaAndTableJRDataSource(); - final String jasperFile = !isQ ? "/jasper/templates/waterlevel_new.jrxml" : "/jasper/templates/fix_waterlevel.jrxml"; + + final boolean isFixationAnalysis = this.master instanceof AbstractFixBunduArtifact; + final boolean doWaterlevelAtGaugeOutput = isQ && isFixationAnalysis; + + final String jasperFile = doWaterlevelAtGaugeOutput ? "/jasper/templates/fix_waterlevel.jrxml" : "/jasper/templates/waterlevel.jrxml"; ((D4EArtifact) this.master).getData("calculation.mode"); if ((this.master instanceof WINFOArtifact)) { - addMetaData(source, "calc.surface.curve"); // Wasserspiegellage - } else if - - (this.master instanceof AbstractFixBunduArtifact) { - addMetaData(source, ((AbstractFixBunduArtifact) this.master).getCalculationModeString());// "calculation.vollmer"); // ausgelagerte - // Wasserspiegellage - // else - // addMetaData(source, "calculation.analysis"); // Fixierungsanalyse + addMetaData(source, "calc.surface.curve", isQ); // Wasserspiegellage + } else if (this.master instanceof AbstractFixBunduArtifact) { + addMetaData(source, ((AbstractFixBunduArtifact) this.master).getCalculationModeString(), isQ); } try { @@ -876,30 +885,42 @@ final D4EArtifact flys = (D4EArtifact) this.master; final RangeAccess rangeAccess = new RangeAccess(flys); - final Gauge gauge = rangeAccess.getRiver().determineRefGauge(rangeAccess.getKmRange(), rangeAccess.isRange()); + final List gauges = RiverUtils.getGauges(flys); + + Gauge gauge = rangeAccess.getRiver().determineRefGauge(rangeAccess.getKmRange(), rangeAccess.isRange()); + // REMARK gauge may be null when rangeAccess starts outside any gauge range + if (gauge == null) + gauge = rangeAccess.getRiver().determineRefGauge(wqkms.getKms(), rangeAccess.isRange()); final String notinrange = msg(CSV_NOT_IN_GAUGE_RANGE, DEFAULT_CSV_NOT_IN_GAUGE_RANGE); final String gaugeName = gauge != null ? gauge.getName() : notinrange; - String desc = ""; - final Double a = gauge != null ? gauge.getRange().getA().doubleValue() : Double.NaN; - final Double b = gauge != null ? gauge.getRange().getB().doubleValue() : Double.NaN; + final double a = gauge != null ? gauge.getRange().getA().doubleValue() : Double.NaN; + final double b = gauge != null ? gauge.getRange().getB().doubleValue() : Double.NaN; + final WaterlevelDescriptionBuilder wldb = new WaterlevelDescriptionBuilder(flys, this.context); - desc = wldb.getDesc(wqkms);// class getDesc(wqkms, isQ); + String desc = wldb.getDesc(wqkms);// class getDesc(wqkms, isQ); Segment lastSegment = null; - final Gauge lastGauge = null; + final List segments = getSegments(flys); + final boolean isFixRealize = isFixrealize(segments); + final NumberFormat nf = Formatter.getFormatter(this.context.getMeta(), 0, 0); + Gauge lastGauge = null; + for (int i = 0; i < size; ++i) { result = wqkms.get(i, result); - final double km = result[2]; + + final double station = result[2]; + final double q = result[1]; + final double w = result[0]; if (segments != null) { - final Segment found = lastSegment != null && lastSegment.inside(km) ? lastSegment : findSegment(km, segments); + final Segment found = lastSegment != null && lastSegment.inside(station) ? lastSegment : findSegment(station, segments); if (found != null) { desc = nf.format(found.getValues()[0]); @@ -907,23 +928,34 @@ lastSegment = found; } - final double q = result[1]; - final String waterlevel = this.getWaterlevel(q, gauge); // THIS IS NEW (and makes common super method - // difficult) - if (atGauge) { - list.add(new String[] { kmf.format(result[2]), wf.format(result[0]), waterlevel, qf.format(RiverUtils.roundQ(result[1])), desc, - RiverUtils.getLocationDescription(flys, result[2]), result[2] >= a && result[2] <= b ? gaugeName : notinrange }); + String gaugeN; + final String wAtGauge; + if (isFixRealize) { + final Gauge found = lastGauge != null && lastGauge.getRange().contains(station) ? lastGauge : findGauge(station, gauges); + + gaugeN = found != null ? found.getName() : notinrange; + lastGauge = found; + + wAtGauge = this.getWaterlevel(q, found); // THIS IS NEW (and makes common super method difficult) } else { - list.add(new String[] { kmf.format(result[2]), wf.format(result[0]), waterlevel, qf.format(RiverUtils.roundQ(result[1])), desc, - RiverUtils.getLocationDescription(flys, result[2]), result[2] >= a && result[2] <= b ? gaugeName : notinrange }); + // TODO issue1114: Take correct gauge + gaugeN = station >= a && station <= b ? gaugeName : notinrange; + wAtGauge = ""; } + if (atGauge) { + list.add(new String[] { kmf.format(station), wf.format(w), wAtGauge, qf.format(RiverUtils.roundQ(q)), desc, + RiverUtils.getLocationDescription(flys, station), gaugeN }); + } else { + list.add(new String[] { kmf.format(station), wf.format(w), wAtGauge, qf.format(RiverUtils.roundQ(q)), desc, + RiverUtils.getLocationDescription(flys, station), gaugeN }); + } } return list; } - protected final void addMetaData(final MetaAndTableJRDataSource source, final String calculation) { + protected final void addMetaData(final MetaAndTableJRDataSource source, final String calculation, final boolean isQ) { final D4EArtifact flys = (D4EArtifact) this.master; final String user = CalculationUtils.findArtifactUser(this.context, flys); final RangeAccess ra = new RangeAccess(flys); @@ -939,10 +971,15 @@ contextPdf.addJRMetadata(source, "fix_w", msg(CSV_W_HEADER, DEFAULT_CSV_W_HEADER, new Object[] { ri.getWstUnit() })); contextPdf.addJRMetadata(source, "w_at_gauge_header", msg("fix.export.csv.w_at_gauge")); contextPdf.addJRMetadata(source, "fix_q", msg(CSV_Q_HEADER)); + contextPdf.addJRMetadata(source, "waterlevel_name_header", msg("common.export.csv.header.mainvalue_label")); contextPdf.addJRMetadata(source, "location_header", msg("common.export.csv.header.location")); - contextPdf.addJRMetadata(source, "w_at_gauge_header_2", msg("export.waterlevel.csv.header.w.desc")); + // FIXME: use WaterlevelDescriptionBuilder instead and also remove all this duplicate code. + final String waterlevelOrBezeichnung = (isQ ? msg(CSV_Q_DESC_HEADER, DEFAULT_CSV_Q_DESC_HEADER) : msg(CSV_W_DESC_HEADER, DEFAULT_CSV_W_DESC_HEADER)); + contextPdf.addJRMetadata(source, "w_at_gauge_header_2", waterlevelOrBezeichnung); + + // msg("export.waterlevel.csv.header.w.desc")); (old. delete) contextPdf.addJRMetadata(source, "location_header", msg("common.export.csv.header.location")); contextPdf.addJRMetadata(source, "gauge_header", msg("common.export.csv.header.gauge")); @@ -1096,6 +1133,4 @@ } return this.gaugeQ_W_Map.get(key); } - -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : +} \ No newline at end of file