Mercurial > dive4elements > river
diff artifacts/src/main/java/org/dive4elements/river/exports/FlowVelocityExporter.java @ 9312:740d65e4aa14
Q [m³/s] one message
author | gernotbelger |
---|---|
date | Thu, 26 Jul 2018 15:54:20 +0200 |
parents | 5e38e2924c07 |
children |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/FlowVelocityExporter.java Thu Jul 26 11:16:06 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/FlowVelocityExporter.java Thu Jul 26 15:54:20 2018 +0200 @@ -14,48 +14,37 @@ import java.util.List; import org.apache.log4j.Logger; - -import au.com.bytecode.opencsv.CSVWriter; - import org.dive4elements.river.artifacts.D4EArtifact; import org.dive4elements.river.artifacts.model.CalculationResult; import org.dive4elements.river.artifacts.model.FlowVelocityData; +import org.dive4elements.river.utils.Formatter; import org.dive4elements.river.utils.RiverUtils; -import org.dive4elements.river.utils.Formatter; +import au.com.bytecode.opencsv.CSVWriter; /** * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ public class FlowVelocityExporter extends AbstractExporter { - private static final Logger log = - Logger.getLogger(FlowVelocityExporter.class); - - - public static final String CSV_KM = - "export.flow_velocity.csv.header.km"; - - public static final String CSV_V_TOTAL = - "export.flow_velocity.csv.header.v_total"; + private static final Logger log = Logger.getLogger(FlowVelocityExporter.class); - public static final String CSV_V_MAIN = - "export.flow_velocity.csv.header.v_main"; - - public static final String CSV_TAU_MAIN = - "export.flow_velocity.csv.header.tau_main"; + public static final String CSV_KM = "export.flow_velocity.csv.header.km"; - public static final String CSV_Q = - "export.flow_velocity.csv.header.q"; + public static final String CSV_V_TOTAL = "export.flow_velocity.csv.header.v_total"; - public static final String CSV_LOCATIONS = - "export.flow_velocity.csv.header.locations"; + public static final String CSV_V_MAIN = "export.flow_velocity.csv.header.v_main"; + public static final String CSV_TAU_MAIN = "export.flow_velocity.csv.header.tau_main"; + + public static final String CSV_Q = "common.export.csv.header.q"; + + public static final String CSV_LOCATIONS = "export.flow_velocity.csv.header.locations"; protected List<FlowVelocityData[]> data; public FlowVelocityExporter() { - data = new ArrayList<FlowVelocityData[]>(); + this.data = new ArrayList<>(); } @Override @@ -65,76 +54,56 @@ if (d instanceof FlowVelocityData[]) { log.debug("Add new data of type FlowVelocityData"); - data.add((FlowVelocityData[]) d); + this.data.add((FlowVelocityData[]) d); } } } - @Override - protected void writeCSVData(CSVWriter writer) { + protected void writeCSVData(final CSVWriter writer) { log.info("FlowVelocityExporter.writeCSVData"); - log.debug("CSV gets " + data.size() + " FlowVelocityData objects."); + log.debug("CSV gets " + this.data.size() + " FlowVelocityData objects."); writeCSVHeader(writer); - for (FlowVelocityData[] d: data) { + for (final FlowVelocityData[] d : this.data) { data2CSV(writer, d); } } - - protected void writeCSVHeader(CSVWriter writer) { - writer.writeNext(new String[] { - msg(CSV_KM, CSV_KM), - msg(CSV_V_MAIN, CSV_V_MAIN), - msg(CSV_V_TOTAL, CSV_V_TOTAL), - msg(CSV_TAU_MAIN, CSV_TAU_MAIN), - msg(CSV_Q, CSV_Q), - msg(CSV_LOCATIONS, CSV_LOCATIONS) - }); + protected void writeCSVHeader(final CSVWriter writer) { + writer.writeNext(new String[] { msg(CSV_KM, CSV_KM), msg(CSV_V_MAIN, CSV_V_MAIN), msg(CSV_V_TOTAL, CSV_V_TOTAL), msg(CSV_TAU_MAIN, CSV_TAU_MAIN), + msg(CSV_Q, CSV_Q), msg(CSV_LOCATIONS, CSV_LOCATIONS) }); } - - protected void data2CSV(CSVWriter writer, FlowVelocityData[] fData) { + protected void data2CSV(final CSVWriter writer, final FlowVelocityData[] fData) { log.debug("Add next FlowVelocityData to CSV"); - D4EArtifact flys = (D4EArtifact) master; + final D4EArtifact flys = (D4EArtifact) this.master; - for (FlowVelocityData data: fData) { + for (final FlowVelocityData data : fData) { for (int i = 0, n = data.size(); i < n; i++) { - NumberFormat kmF = Formatter.getFlowVelocityKM(context); - NumberFormat valF = Formatter.getFlowVelocityValues(context); - NumberFormat qF = Formatter.getFlowVelocityQ(context); + final NumberFormat kmF = Formatter.getFlowVelocityKM(this.context); + final NumberFormat valF = Formatter.getFlowVelocityValues(this.context); + final NumberFormat qF = Formatter.getFlowVelocityQ(this.context); String vMain = ""; String vTotal = ""; - if (data.getType().equals("main") - || data.getType().equals("main_total") - ) { + if (data.getType().equals("main") || data.getType().equals("main_total")) { vMain = valF.format(data.getVMain(i)); } - if (data.getType().equals("total") - || data.getType().equals("main_total") - ) { + if (data.getType().equals("total") || data.getType().equals("main_total")) { vTotal = valF.format(data.getVTotal(i)); } - writer.writeNext(new String[] { - kmF.format(data.getKM(i)), - vMain, - vTotal, - valF.format(data.getTauMain(i)), - qF.format(data.getQ(i)) + "=" + data.getZone(), - RiverUtils.getLocationDescription(flys, data.getKM(i)), - }); + writer.writeNext(new String[] { kmF.format(data.getKM(i)), vMain, vTotal, valF.format(data.getTauMain(i)), + qF.format(data.getQ(i)) + "=" + data.getZone(), RiverUtils.getLocationDescription(flys, data.getKM(i)), }); } } } - @Override - protected void writePDF(OutputStream out) { + protected void writePDF(final OutputStream out) { log.error("TODO: Implement FlowVelocityExporter.writePDF"); } }