Mercurial > dive4elements > river
changeset 9351:0c8f170945d7
no tkh bug fixed
author | gernotbelger |
---|---|
date | Tue, 31 Jul 2018 17:17:03 +0200 (2018-07-31) |
parents | 08f46ccd37ba |
children | 9ea0e3522695 |
files | artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculationResult.java artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculationResults.java |
diffstat | 2 files changed, 25 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- 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)); }
--- 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