Mercurial > dive4elements > river
view artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculationResult.java @ 9259:66b003701546
Added infrastructure height and Q annotation to S-Info flood duration curve chart
author | mschaefer |
---|---|
date | Mon, 16 Jul 2018 08:43:07 +0200 |
parents | a4121ec450d6 |
children | 740d65e4aa14 |
line wrap: on
line source
/* Copyright (C) 2017 by Bundesanstalt für Gewässerkunde * Software engineering by * Björnsen Beratende Ingenieure GmbH * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt * * This file is Free Software under the GNU AGPL (>=v3) * and comes with ABSOLUTELY NO WARRANTY! Check out the * documentation coming with Dive4Elements River for details. */ package org.dive4elements.river.artifacts.sinfo.flowdepth; import java.util.ArrayList; import java.util.Collection; import org.dive4elements.river.artifacts.common.ExportContextCSV; import org.dive4elements.river.artifacts.common.ExportContextPDF; import org.dive4elements.river.artifacts.common.GeneralResultType; import org.dive4elements.river.artifacts.common.IExportContext; import org.dive4elements.river.artifacts.common.MetaAndTableJRDataSource; import org.dive4elements.river.artifacts.common.ResultRow; import org.dive4elements.river.artifacts.sinfo.common.AbstractTkhCalculationResult; import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType; import org.dive4elements.river.artifacts.sinfo.util.BedHeightInfo; import org.dive4elements.river.artifacts.sinfo.util.RiverInfo; import org.dive4elements.river.artifacts.sinfo.util.WstInfo; /** * Contains the results of a {@link FloodDurationCalculation}. * * @author Gernot Belger */ final class FlowDepthCalculationResult extends AbstractTkhCalculationResult { private static final long serialVersionUID = 1L; private enum ExportMode { // TODO; nicht ständig kopieren pdf, csv } private static final String JASPER_FILE = "/jasper/templates/sinfo.flowdepth.jrxml"; // TODO use jrxml-path all over the project private final BedHeightInfo sounding; public FlowDepthCalculationResult(final String label, final WstInfo wst, final BedHeightInfo sounding, final boolean hasTkh, final Collection<ResultRow> rows) { super(label, wst, hasTkh, rows); this.sounding = sounding; } public BedHeightInfo getSounding() { return this.sounding; } @Override public void writeCSVHeader(final ExportContextCSV exportContextCSV, 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)); if (this.hasTkh()) { header.add(exportContextCSV.msgUnitCSV(SInfoResultType.flowdepthtkh)); header.add(exportContextCSV.msgUnitCSV(SInfoResultType.tkh)); } header.add(exportContextCSV.msgUnitCSV(SInfoResultType.waterlevel, river.getWstUnit())); header.add(exportContextCSV.msgUnitCSV(SInfoResultType.discharge)); header.add(exportContextCSV.formatCsvHeader(SInfoResultType.waterlevelLabel)); header.add(exportContextCSV.formatCsvHeader(SInfoResultType.gaugeLabel)); header.add(exportContextCSV.formatCsvHeader(SInfoResultType.meanBedHeight)); header.add(exportContextCSV.formatCsvHeader(SInfoResultType.soundingLabel)); header.add(exportContextCSV.formatCsvHeader(SInfoResultType.location)); exportContextCSV.writeCSVLine(header.toArray(new String[header.size()])); } @Override protected void writeCSVResultMetadata(final ExportContextCSV exportContextCSV) { exportContextCSV.writeCSVSoundingMetadata(this.sounding); exportContextCSV.writeBlankLine();// .writeNext(new String[] { "" }); // break line exportContextCSV.writeCSVWaterlevelMetadata(super.getWst()); // TODO move to super exportContextCSV.writeBlankLine();// .writeNext(new String[] { "" }); // break line } @Override protected String getJasperFile() { return JASPER_FILE; } @Override protected String[] formatCSVRow(final ExportContextCSV exportContextCSV, final ResultRow row) { return formatRow(ExportMode.csv, exportContextCSV, row); } @Override protected String[] formatPDFRow(final ExportContextPDF exportContextPDF, final ResultRow row) { return formatRow(ExportMode.pdf, exportContextPDF, row); } @Override protected void addJRTableHeader(final ExportContextPDF exportContextPDF, final MetaAndTableJRDataSource source) { /* column headings */ exportContextPDF.addJRMetadata(source, "station_header", GeneralResultType.station); exportContextPDF.addJRMetadata(source, "flowdepth_header", SInfoResultType.flowdepth); exportContextPDF.addJRMetadata(source, "flowdepth_tkh_header", SInfoResultType.flowdepthtkh); exportContextPDF.addJRMetadata(source, "tkh_header", SInfoResultType.tkh); exportContextPDF.addJRMetadata(source, "waterlevel_header", SInfoResultType.waterlevel); exportContextPDF.addJRMetadata(source, "discharge_header", SInfoResultType.discharge); exportContextPDF.addJRMetadata(source, "waterlevel_name_header", SInfoResultType.waterlevelLabel); exportContextPDF.addJRMetadata(source, "gauge_header", SInfoResultType.gaugeLabel); exportContextPDF.addJRMetadata(source, "bedheight_header", SInfoResultType.meanBedHeight); exportContextPDF.addJRMetadata(source, "sounding_name_header", SInfoResultType.soundingLabel); exportContextPDF.addJRMetadata(source, "location_header", SInfoResultType.location); } private String[] formatRow(final ExportMode mode, final IExportContext exportContext, final ResultRow row) { final Collection<String> lines = new ArrayList<>(11); lines.add(exportContext.formatRowValue(row, GeneralResultType.station)); lines.add(exportContext.formatRowValue(row, SInfoResultType.flowdepth)); final FlowDepthCalculationResults results = exportContext.getResults(); if (mode == ExportMode.pdf || results.isUseTkh()) { lines.add(exportContext.formatRowValue(row, SInfoResultType.flowdepthtkh)); lines.add(exportContext.formatRowValue(row, SInfoResultType.tkh)); } lines.add(exportContext.formatRowValue(row, SInfoResultType.waterlevel)); lines.add(exportContext.formatRowValue(row, SInfoResultType.discharge)); lines.add(exportContext.formatRowValue(row, SInfoResultType.waterlevelLabel)); lines.add(exportContext.formatRowValue(row, SInfoResultType.gaugeLabel)); lines.add(exportContext.formatRowValue(row, SInfoResultType.meanBedHeight)); lines.add(exportContext.formatRowValue(row, SInfoResultType.soundingLabel)); lines.add(exportContext.formatRowValue(row, SInfoResultType.location)); return lines.toArray(new String[lines.size()]); } }