[PATCH 1 of 2] no tkh bug fixed
Wald Commits
scm-commit at wald.intevation.org
Tue Jul 31 17:18:00 CEST 2018
# HG changeset patch
# User gernotbelger
# Date 1533050223 -7200
# Node ID 0c8f170945d7960e0d73d77b0b24f60488159ee0
# Parent 08f46ccd37ba97fdfd2d662c2a995573c50facba
no tkh bug fixed
diff -r 08f46ccd37ba -r 0c8f170945d7 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculationResult.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculationResult.java Tue Jul 31 16:04:01 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculationResult.java Tue Jul 31 17:17:03 2018 +0200
@@ -55,28 +55,28 @@
}
@Override
- public void writeCSVHeader(final ExportContextCSV exportContextCSV, final RiverInfo river) {
+ public void writeCSVHeader(final ExportContextCSV exportContext, final RiverInfo river) {
// getLog().info("FlowDepthExporter.writeCSVHeader");
final Collection<String> header = new ArrayList<>(11);
- header.add(exportContextCSV.formatCsvHeader(GeneralResultType.station));
- header.add(exportContextCSV.msgUnitCSV(SInfoResultType.flowdepth));
+ header.add(exportContext.formatCsvHeader(GeneralResultType.station));
+ header.add(exportContext.msgUnitCSV(SInfoResultType.flowdepth));
- if (this.hasTkh()) {
- header.add(exportContextCSV.msgUnitCSV(SInfoResultType.flowdepthtkh));
- header.add(exportContextCSV.msgUnitCSV(SInfoResultType.tkh));
+ if (((FlowDepthCalculationResults) exportContext.getResults()).hasTkh()) {
+ header.add(exportContext.msgUnitCSV(SInfoResultType.flowdepthtkh));
+ header.add(exportContext.msgUnitCSV(SInfoResultType.tkh));
}
- header.add(exportContextCSV.msgUnitCSV(SInfoResultType.waterlevel, river.getWstUnit()));
- header.add(exportContextCSV.msgUnitCSV(SInfoResultType.discharge));
- header.add(exportContextCSV.formatCsvHeader(GeneralResultType.waterlevelLabel));
- header.add(exportContextCSV.formatCsvHeader(GeneralResultType.gaugeLabel));
- header.add(exportContextCSV.formatCsvHeader(SInfoResultType.meanBedHeight));
- header.add(exportContextCSV.formatCsvHeader(SInfoResultType.soundingLabel));
- header.add(exportContextCSV.formatCsvHeader(GeneralResultType.location));
+ header.add(exportContext.msgUnitCSV(SInfoResultType.waterlevel, river.getWstUnit()));
+ header.add(exportContext.msgUnitCSV(SInfoResultType.discharge));
+ header.add(exportContext.formatCsvHeader(GeneralResultType.waterlevelLabel));
+ header.add(exportContext.formatCsvHeader(GeneralResultType.gaugeLabel));
+ header.add(exportContext.formatCsvHeader(SInfoResultType.meanBedHeight));
+ header.add(exportContext.formatCsvHeader(SInfoResultType.soundingLabel));
+ header.add(exportContext.formatCsvHeader(GeneralResultType.location));
- exportContextCSV.writeCSVLine(header.toArray(new String[header.size()]));
+ exportContext.writeCSVLine(header.toArray(new String[header.size()]));
}
@@ -134,7 +134,9 @@
lines.add(exportContext.formatRowValue(row, SInfoResultType.flowdepth));
final FlowDepthCalculationResults results = exportContext.getResults();
- if (mode == ExportMode.pdf || results.isUseTkh()) {
+ // REMARK: for csv: only remove tkh columns, if no result has tkh
+ // for pdf: adding by default is necessary. If there is no tkh, columns will be removed later in the exporter.
+ if (mode == ExportMode.pdf || results.hasTkh()) {
lines.add(exportContext.formatRowValue(row, SInfoResultType.flowdepthtkh));
lines.add(exportContext.formatRowValue(row, SInfoResultType.tkh));
}
diff -r 08f46ccd37ba -r 0c8f170945d7 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculationResults.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculationResults.java Tue Jul 31 16:04:01 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculationResults.java Tue Jul 31 17:17:03 2018 +0200
@@ -34,4 +34,12 @@
return this.useTkh;
}
+ public boolean hasTkh() {
+ for (final FlowDepthCalculationResult result : getResults()) {
+ if (result.hasTkh())
+ return true;
+ }
+
+ return false;
+ }
}
\ No newline at end of file
More information about the Dive4Elements-commits
mailing list