Mercurial > dive4elements > river
changeset 2714:2952f6dee5cf
Added an exporter for middle bed height values.
flys-artifacts/trunk@4438 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 18 May 2012 10:51:04 +0000 |
parents | b60751cfdd6c |
children | 250a370c377d |
files | flys-artifacts/ChangeLog flys-artifacts/doc/conf/conf.xml flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/MiddleBedHeightData.java flys-artifacts/src/main/java/de/intevation/flys/exports/MiddleBedHeightExporter.java flys-artifacts/src/main/java/de/intevation/flys/utils/Formatter.java flys-artifacts/src/main/resources/messages.properties flys-artifacts/src/main/resources/messages_de.properties flys-artifacts/src/main/resources/messages_de_DE.properties flys-artifacts/src/main/resources/messages_en.properties |
diffstat | 9 files changed, 308 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Fri May 18 09:18:39 2012 +0000 +++ b/flys-artifacts/ChangeLog Fri May 18 10:51:04 2012 +0000 @@ -1,3 +1,23 @@ +2012-05-18 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/artifacts/model/MiddleBedHeightData.java: + Added new methods that create names for singles and epochs. + + * src/main/java/de/intevation/flys/utils/Formatter.java: Added number + formatters used to export middle bed heights values. + + * src/main/java/de/intevation/flys/exports/MiddleBedHeightExporter.java: + New exporter for middle bed heights values. + + * doc/conf/conf.xml: Registered new output generator for middle bed height + exports. + + * src/main/resources/messages.properties, + src/main/resources/messages_de_DE.properties, + src/main/resources/messages_en.properties, + src/main/resources/messages_de.properties: New i18n strings for middle + bed height facets and csv export. + 2012-05-18 Ingo Weinzierl <ingo@intevation.de> * src/main/java/de/intevation/flys/artifacts/model/MiddleBedHeightData.java:
--- a/flys-artifacts/doc/conf/conf.xml Fri May 18 09:18:39 2012 +0000 +++ b/flys-artifacts/doc/conf/conf.xml Fri May 18 10:51:04 2012 +0000 @@ -230,6 +230,7 @@ <output-generator name="flow_velocity">de.intevation.flys.exports.FlowVelocityGenerator</output-generator> <output-generator name="flow_velocity_chartinfo">de.intevation.flys.exports.FlowVelocityInfoGenerator</output-generator> <output-generator name="flow_velocity_export">de.intevation.flys.exports.FlowVelocityExporter</output-generator> + <output-generator name="bedheight_middle_export">de.intevation.flys.exports.MiddleBedHeightExporter</output-generator> <!-- Error report generators. --> <output-generator name="discharge_longitudinal_section_report">de.intevation.flys.exports.ReportGenerator</output-generator> <output-generator name="waterlevel_report">de.intevation.flys.exports.ReportGenerator</output-generator>
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/MiddleBedHeightData.java Fri May 18 09:18:39 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/MiddleBedHeightData.java Fri May 18 10:51:04 2012 +0000 @@ -4,9 +4,16 @@ import gnu.trove.TDoubleArrayList; +import de.intevation.artifacts.CallContext; + +import de.intevation.flys.artifacts.resources.Resources; + public class MiddleBedHeightData implements Serializable { + public static final String I18N_SINGLE_NAME = "facet.bedheight_middle.single"; + public static final String I18N_EPOCH_NAME = "facet.bedheight_middle.epoch"; + private int startYear; private int endYear; private String evaluatedBy; @@ -115,4 +122,24 @@ return points; } + + + public String getSoundingName(CallContext context) { + if (getStartYear() == getEndYear()) { + return Resources.getMsg( + context.getMeta(), + I18N_SINGLE_NAME, + I18N_SINGLE_NAME, + new Object[] { getStartYear() } + ); + } + else { + return Resources.getMsg( + context.getMeta(), + I18N_EPOCH_NAME, + I18N_EPOCH_NAME, + new Object[] { getStartYear(), getEndYear() } + ); + } + } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/MiddleBedHeightExporter.java Fri May 18 10:51:04 2012 +0000 @@ -0,0 +1,158 @@ +package de.intevation.flys.exports; + +import java.io.OutputStream; +import java.text.NumberFormat; +import java.util.ArrayList; +import java.util.List; + +import org.w3c.dom.Document; + +import org.apache.log4j.Logger; + +import au.com.bytecode.opencsv.CSVWriter; + +import de.intevation.artifacts.CallContext; + +import de.intevation.flys.artifacts.FLYSArtifact; +import de.intevation.flys.artifacts.model.CalculationResult; +import de.intevation.flys.artifacts.model.MiddleBedHeightData; +import de.intevation.flys.utils.FLYSUtils; +import de.intevation.flys.utils.Formatter; + + +/** + * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> + */ +public class MiddleBedHeightExporter extends AbstractExporter { + + private static final Logger logger = + Logger.getLogger(MiddleBedHeightExporter.class); + + + public static final String CSV_KM = + "export.bedheight_middle.csv.header.km"; + + public static final String CSV_SOUNDING = + "export.bedheight_middle.csv.header.sounding"; + + public static final String CSV_HEIGHT = + "export.bedheight_middle.csv.header.height"; + + public static final String CSV_UNCERTAINTY = + "export.bedheight_middle.csv.header.uncertainty"; + + public static final String CSV_DATA_GAP = + "export.bedheight_middle.csv.header.datagap"; + + public static final String CSV_SOUNDING_WIDTH = + "export.bedheight_middle.csv.header.soundingwidth"; + + public static final String CSV_WIDTH = + "export.bedheight_middle.csv.header.width"; + + public static final String CSV_LOCATIONS = + "export.bedheight_middle.csv.header.locations"; + + + protected List<MiddleBedHeightData[]> data; + + + public void init(Document request, OutputStream out, CallContext cc) { + super.init(request, out, cc); + data = new ArrayList<MiddleBedHeightData[]>(); + } + + + @Override + protected void addData(Object d) { + if (d instanceof CalculationResult) { + d = ((CalculationResult) d).getData(); + + if (d instanceof MiddleBedHeightData[]) { + logger.debug("Add new data of type MiddleBedHeightData"); + data.add((MiddleBedHeightData[]) d); + } + } + } + + + @Override + protected void writeCSVData(CSVWriter writer) { + logger.info("MiddleBedHeightExporter.writeCSVData"); + logger.debug("CSV gets " + data.size() + " MiddleBedHeightData objects."); + + writeCSVHeader(writer); + + for (MiddleBedHeightData[] d: data) { + data2CSV(writer, d); + } + } + + + protected void writeCSVHeader(CSVWriter writer) { + writer.writeNext(new String[] { + msg(CSV_KM, CSV_KM), + msg(CSV_SOUNDING, CSV_SOUNDING), + msg(CSV_HEIGHT, CSV_HEIGHT), + msg(CSV_UNCERTAINTY, CSV_UNCERTAINTY), + msg(CSV_DATA_GAP, CSV_DATA_GAP), + msg(CSV_SOUNDING_WIDTH, CSV_SOUNDING_WIDTH), + msg(CSV_WIDTH, CSV_WIDTH), + msg(CSV_LOCATIONS, CSV_LOCATIONS) + }); + } + + + protected void data2CSV(CSVWriter writer, MiddleBedHeightData[] mData) { + logger.debug("Add next MiddleBedHeightData to CSV"); + + FLYSArtifact flys = (FLYSArtifact) master; + + NumberFormat kmF = Formatter.getMiddleBedHeightKM(context); + NumberFormat heightF = Formatter.getMiddleBedHeightHeight(context); + NumberFormat uncertF = Formatter.getMiddleBedHeightUncert(context); + NumberFormat gapF = Formatter.getMiddleBedHeightDataGap(context); + NumberFormat soundF = Formatter.getMiddleBedHeightSounding(context); + NumberFormat widthF = Formatter.getMiddleBedHeightWidth(context); + + for (MiddleBedHeightData data: mData) { + for (int i = 0, n = data.size(); i < n; i++) { + int start = data.getStartYear(); + int end = data.getEndYear(); + + if (start == end) { + writer.writeNext(new String[] { + kmF.format(data.getKM(i)), + data.getSoundingName(context), + heightF.format(data.getMiddleHeight(i)), + uncertF.format(data.getUncertainty(i)), + gapF.format(data.getDataGap(i)) + "%", + soundF.format(data.getSoundingWidth(i)), + widthF.format(data.getWidth(i)), + FLYSUtils.getLocationDescription(flys, data.getKM(i)), + }); + } + else { + writer.writeNext(new String[] { + kmF.format(data.getKM(i)), + data.getSoundingName(context), + heightF.format(data.getMiddleHeight(i)), + "", + "", + "", + "", + FLYSUtils.getLocationDescription(flys, data.getKM(i)), + }); + } + + } + } + } + + + @Override + protected void writePDF(OutputStream out) { + logger.error("TODO: Implement FlowVelocityExporter.writePDF"); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/Formatter.java Fri May 18 09:18:39 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/Formatter.java Fri May 18 10:51:04 2012 +0000 @@ -57,6 +57,20 @@ public static final int FLOW_VELOCITY_Q_MAX_DIGITS = 2; + // MIDDLE BED HEIGHT FORMATTER CONSTANTS + public static final int MIDDLE_BED_HEIGHT_KM_MIN_DIGITS = 3; + public static final int MIDDLE_BED_HEIGHT_KM_MAX_DIGITS = 3; + public static final int MIDDLE_BED_HEIGHT_HEIGHT_MIN_DIGITS = 3; + public static final int MIDDLE_BED_HEIGHT_HEIGHT_MAX_DIGITS = 3; + public static final int MIDDLE_BED_HEIGHT_UNCERT_MIN_DIGITS = 3; + public static final int MIDDLE_BED_HEIGHT_UNCERT_MAX_DIGITS = 3; + public static final int MIDDLE_BED_HEIGHT_DATAGAP_MIN_DIGITS = 2; + public static final int MIDDLE_BED_HEIGHT_DATAGAP_MAX_DIGITS = 2; + public static final int MIDDLE_BED_HEIGHT_SOUNDING_WIDTH_MIN_DIGITS = 0; + public static final int MIDDLE_BED_HEIGHT_SOUNDING_WIDTH_MAX_DIGITS = 0; + public static final int MIDDLE_BED_HEIGHT_WIDTH_MIN_DIGITS = 3; + public static final int MIDDLE_BED_HEIGHT_WIDTH_MAX_DIGITS = 3; + public static NumberFormat getFormatter(CallMeta m, int min, int max){ Locale locale = Resources.getLocale(m); NumberFormat nf = NumberFormat.getInstance(locale); @@ -266,5 +280,53 @@ FLOW_VELOCITY_Q_MIN_DIGITS, FLOW_VELOCITY_Q_MAX_DIGITS); } + + + public static NumberFormat getMiddleBedHeightKM(CallContext context) { + return getFormatter( + context, + MIDDLE_BED_HEIGHT_KM_MIN_DIGITS, + MIDDLE_BED_HEIGHT_KM_MAX_DIGITS); + } + + + public static NumberFormat getMiddleBedHeightHeight(CallContext context) { + return getFormatter( + context, + MIDDLE_BED_HEIGHT_HEIGHT_MIN_DIGITS, + MIDDLE_BED_HEIGHT_HEIGHT_MAX_DIGITS); + } + + + public static NumberFormat getMiddleBedHeightUncert(CallContext context) { + return getFormatter( + context, + MIDDLE_BED_HEIGHT_UNCERT_MIN_DIGITS, + MIDDLE_BED_HEIGHT_UNCERT_MAX_DIGITS); + } + + + public static NumberFormat getMiddleBedHeightDataGap(CallContext context) { + return getFormatter( + context, + MIDDLE_BED_HEIGHT_DATAGAP_MIN_DIGITS, + MIDDLE_BED_HEIGHT_DATAGAP_MAX_DIGITS); + } + + + public static NumberFormat getMiddleBedHeightSounding(CallContext context) { + return getFormatter( + context, + MIDDLE_BED_HEIGHT_SOUNDING_WIDTH_MIN_DIGITS, + MIDDLE_BED_HEIGHT_SOUNDING_WIDTH_MAX_DIGITS); + } + + + public static NumberFormat getMiddleBedHeightWidth(CallContext context) { + return getFormatter( + context, + MIDDLE_BED_HEIGHT_WIDTH_MIN_DIGITS, + MIDDLE_BED_HEIGHT_WIDTH_MAX_DIGITS); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/resources/messages.properties Fri May 18 09:18:39 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages.properties Fri May 18 10:51:04 2012 +0000 @@ -129,6 +129,8 @@ facet.flow_velocity.mainchannel = v Mainchannel at {0} facet.flow_velocity.totalchannel = v Totalchannel at {0} facet.flow_velocity.tauchannel = TAU Mainchannel at {0} +facet.bedheight_middle.single = Bed Height {0,number,####} +facet.bedheight_middle.epoch = Bed Height Epoch {0,number,####} - {1,number,####} export.waterlevel.csv.header.km = River-Km export.waterlevel.csv.header.w = W [NN + m] @@ -186,6 +188,14 @@ export.flow_velocity.csv.header.tau_main = TAU Main Channel export.flow_velocity.csv.header.q = Q [m\u00b3/s] export.flow_velocity.csv.header.locations = Location +export.bedheight_middle.csv.header.km = River km +export.bedheight_middle.csv.header.sounding = Sounding / Epoch +export.bedheight_middle.csv.header.height = middle Bed Height +export.bedheight_middle.csv.header.uncertainty = Uncertainty [m] +export.bedheight_middle.csv.header.datagap = Data Gap +export.bedheight_middle.csv.header.soundingwidth = Sounding Width [m] +export.bedheight_middle.csv.header.width = morphological active width [m] +export.bedheight_middle.csv.header.locations = Location floodmap.wmsbackground = Background Map floodmap.riveraxis = River Axis
--- a/flys-artifacts/src/main/resources/messages_de.properties Fri May 18 09:18:39 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages_de.properties Fri May 18 10:51:04 2012 +0000 @@ -128,6 +128,8 @@ facet.flow_velocity.mainchannel = v Hauptgerinne bei {0} facet.flow_velocity.totalchannel = v Gesamtgerinne bei {0} facet.flow_velocity.tauchannel = TAU Hauptgerinne bei {0} +facet.bedheight_middle.single = Sohlh\u00f6he {0,number,####} +facet.bedheight_middle.epoch = Sohlh\u00f6he Epoche {0,number,####} - {1,number,####} export.waterlevel.csv.header.km = Fluss-Km export.waterlevel.csv.header.w = W [NN + m] @@ -186,6 +188,14 @@ export.flow_velocity.csv.header.tau_main = TAU Hauptgerinne export.flow_velocity.csv.header.q = Q [m\u00b3/s] export.flow_velocity.csv.header.locations = Streckendaten +export.bedheight_middle.csv.header.km = Fluss-km +export.bedheight_middle.csv.header.sounding = Peilung / Epoche +export.bedheight_middle.csv.header.height = gemittelte Sohl\u00f6he +export.bedheight_middle.csv.header.uncertainty = Unsicherheit [m] +export.bedheight_middle.csv.header.datagap = Datenl\u00fccke +export.bedheight_middle.csv.header.soundingwidth = Peilbreite [m] +export.bedheight_middle.csv.header.width = morphologisch aktive Breite [m] +export.bedheight_middle.csv.header.locations = Streckendaten floodmap.wmsbackground = Hintergrundkarte floodmap.riveraxis = Flussachse
--- a/flys-artifacts/src/main/resources/messages_de_DE.properties Fri May 18 09:18:39 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages_de_DE.properties Fri May 18 10:51:04 2012 +0000 @@ -126,6 +126,8 @@ facet.flow_velocity.mainchannel = v Hauptgerinne bei {0} facet.flow_velocity.totalchannel = v Gesamtgerinne bei {0} facet.flow_velocity.tauchannel = TAU Hauptgerinne bei {0} +facet.bedheight_middle.single = Sohlh\u00f6he {0,number,####} +facet.bedheight_middle.epoch = Sohlh\u00f6he Epoche {0,number,####} - {1,number,####} export.waterlevel.csv.header.km = Fluss-Km export.waterlevel.csv.header.w = W [NN + m] @@ -183,6 +185,14 @@ export.flow_velocity.csv.header.tau_main = TAU Hauptgerinne export.flow_velocity.csv.header.q = Q [m\u00b3/s] export.flow_velocity.csv.header.locations = Streckendaten +export.bedheight_middle.csv.header.km = Fluss-km +export.bedheight_middle.csv.header.sounding = Peilung / Epoche +export.bedheight_middle.csv.header.height = gemittelte Sohl\u00f6he +export.bedheight_middle.csv.header.uncertainty = Unsicherheit [m] +export.bedheight_middle.csv.header.datagap = Datenl\u00fccke +export.bedheight_middle.csv.header.soundingwidth = Peilbreite [m] +export.bedheight_middle.csv.header.width = morphologisch aktive Breite [m] +export.bedheight_middle.csv.header.locations = Streckendaten floodmap.wmsbackground = Hintergrundkarte floodmap.riveraxis = Flussachse
--- a/flys-artifacts/src/main/resources/messages_en.properties Fri May 18 09:18:39 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages_en.properties Fri May 18 10:51:04 2012 +0000 @@ -128,6 +128,8 @@ facet.flow_velocity.mainchannel = v Mainchannel at {0} facet.flow_velocity.totalchannel = v Totalchannel at {0} facet.flow_velocity.tauchannel = TAU Mainchannel at {0} +facet.bedheight_middle.single = Bed Height {0,number,####} +facet.bedheight_middle.epoch = Bed Height Epoch {0,number,####} - {1,number,####} export.waterlevel.csv.header.km = River-Km export.waterlevel.csv.header.w = W [NN + m] @@ -185,6 +187,14 @@ export.flow_velocity.csv.header.tau_main = TAU Main Channel export.flow_velocity.csv.header.q = Q [m\u00b3/s] export.flow_velocity.csv.header.locations = Location +export.bedheight_middle.csv.header.km = River km +export.bedheight_middle.csv.header.sounding = Sounding / Epoch +export.bedheight_middle.csv.header.height = middle Bed Height +export.bedheight_middle.csv.header.uncertainty = Uncertainty [m] +export.bedheight_middle.csv.header.datagap = Data Gap +export.bedheight_middle.csv.header.soundingwidth = Sounding Width [m] +export.bedheight_middle.csv.header.width = morphological active width [m] +export.bedheight_middle.csv.header.locations = Location floodmap.wmsbackground = Background Map floodmap.riveraxis = River Axis