Mercurial > dive4elements > river
changeset 4944:529a3d873809
Merge
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Thu, 31 Jan 2013 18:21:05 +0100 |
parents | 04c68af45534 (diff) 840250040a7d (current diff) |
children | 859278918eb1 |
files | |
diffstat | 8 files changed, 86 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java Thu Jan 31 18:18:05 2013 +0100 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java Thu Jan 31 18:21:05 2013 +0100 @@ -174,11 +174,11 @@ protected void initialize(Artifact artifact, Object context, CallMeta meta) { logger.debug("MainValuesArtifact.initialize"); FLYSArtifact winfo = (FLYSArtifact) artifact; - RangeAccess rangeAccess = new RangeAccess(this, null); + RangeAccess rangeAccess = new RangeAccess(winfo, null); double [] locations = rangeAccess.getLocations(); if (locations != null) { double location = locations[0]; - addData("location", new DefaultStateData("location", null, null, + addData("ld_locations", new DefaultStateData("ld_locations", null, null, String.valueOf(location))); } else { @@ -245,7 +245,7 @@ River river = FLYSUtils.getRiver(this); // TODO use helper to get location as double - String locationStr = getDataAsString("location"); + String locationStr = getDataAsString("ld_locations"); if (river == null || locationStr == null) { return null; @@ -262,7 +262,7 @@ * @return the location. */ public double getLocation() { - double location = Double.parseDouble(getDataAsString("location")); + double location = Double.parseDouble(getDataAsString("ld_locations")); return location; }
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ATExporter.java Thu Jan 31 18:18:05 2013 +0100 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ATExporter.java Thu Jan 31 18:21:05 2013 +0100 @@ -3,6 +3,7 @@ import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.IOException; +import java.util.List; import org.w3c.dom.Document; @@ -19,6 +20,9 @@ import de.intevation.flys.artifacts.model.WQ; import de.intevation.flys.collections.FLYSArtifactCollection; +import de.intevation.flys.model.Gauge; +import de.intevation.flys.model.River; +import de.intevation.flys.model.TimeInterval; import de.intevation.flys.utils.FLYSUtils; import de.intevation.flys.artifacts.access.RangeAccess; @@ -83,15 +87,38 @@ throw new IOException(iae); } - String river = FLYSUtils.getRiver(master).getName(); + River river = FLYSUtils.getRiver(master); RangeAccess rangeAccess = new RangeAccess(master, context); double[] kms = rangeAccess.getLocations(); - at.write( - new OutputStreamWriter(out, DEFAULT_ENCODING), - context.getMeta(), - river, - kms[0]); + Gauge gauge = river.determineGaugeByPosition(kms[0]); + if (kms[0] == gauge.getStation().doubleValue() + 1e-4) { + // at gauge. + TimeInterval interval = + gauge.fetchMasterDischargeTable().getTimeInterval(); + at.write( + new OutputStreamWriter(out, DEFAULT_ENCODING), + context.getMeta(), + river.getName(), + kms[0], + gauge.getName(), + gauge.getDatum(), + interval.getStartTime(), + 100d); + } + else { + // at km + at.write( + new OutputStreamWriter(out), + context.getMeta(), + river.getName(), + kms[0], + null, + null, + null, + 0d); + } + }
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ATWriter.java Thu Jan 31 18:18:05 2013 +0100 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ATWriter.java Thu Jan 31 18:21:05 2013 +0100 @@ -3,7 +3,11 @@ import java.io.IOException; import java.io.Writer; import java.io.PrintWriter; +import java.math.BigDecimal; +import java.text.DateFormat; +import java.util.Calendar; +import java.util.Date; import java.util.Locale; import de.intevation.artifacts.CallMeta; @@ -31,6 +35,9 @@ public static final String I18N_AT_HEADER = "export.discharge.curve.at.header"; + public static final String I18N_AT_GAUGE_HEADER = + "export.discharge.curve.at.gauge.header"; + public static final String EMPTY = " "; protected double minW; @@ -105,12 +112,31 @@ } + protected static void printGaugeHeader( + PrintWriter out, + CallMeta callMeta, + String river, + double km, + String gName, + BigDecimal datum, + Date date + ) { + DateFormat f = DateFormat.getDateInstance(); + out.print(Resources.getMsg( + callMeta, + I18N_AT_GAUGE_HEADER, + I18N_AT_GAUGE_HEADER, + new Object[] { river, gName, f.format(date), datum } )); + out.print("\r\n"); + } + protected static void printHeader( PrintWriter out, CallMeta callMeta, String river, double km ) { + DateFormat f = DateFormat.getDateInstance(); out.print(Resources.getMsg( callMeta, I18N_AT_HEADER, @@ -119,15 +145,27 @@ out.print("\r\n"); } - - public void write(Writer writer, CallMeta meta, String river, double km) + public void write( + Writer writer, + CallMeta meta, + String river, + double km, + String gName, + BigDecimal datum, + Date date, + double scale) throws IOException { PrintWriter out = new PrintWriter(writer); // a header is required, because the desktop version of FLYS will skip // the first row. - printHeader(out, meta, river, km); + if (gName != null) { + printGaugeHeader(out, meta, river, km, gName, datum, date); + } + else { + printHeader(out, meta, river, km); + } double rest = (minW * 100.0) % 10.0; @@ -141,7 +179,7 @@ int col = 0; for (double w = startW; w <= maxW; w += 0.01) { if (col == 0) { - out.printf(Locale.US, "%8d", (int)Math.round(w*100.0)); + out.printf(Locale.US, "%8d", (int)Math.round(w * scale)); } if (w < minW) {
--- a/flys-artifacts/src/main/resources/messages.properties Thu Jan 31 18:18:05 2013 +0100 +++ b/flys-artifacts/src/main/resources/messages.properties Thu Jan 31 18:21:05 2013 +0100 @@ -325,6 +325,7 @@ export.discharge.longitudinal.section.csv.header.cw = W corr. export.discharge.longitudinal.section.csv.header.q = Q [m\u00b3/s] export.discharge.curve.at.header = Computed Discharge Curve for {0} {0}-km: {1} +export.discharge.curve.at.gauge.header = Discharge Table for {1}/{0} since {2} PNP[NN+m] = {3} export.historical.discharge.csv.header.timerange = Timerange export.historical.discharge.csv.header.waterlevel = Waterlevel [cm] export.historical.discharge.csv.header.discharge = Discharge [m\u00b3/s]
--- a/flys-artifacts/src/main/resources/messages_de.properties Thu Jan 31 18:18:05 2013 +0100 +++ b/flys-artifacts/src/main/resources/messages_de.properties Thu Jan 31 18:21:05 2013 +0100 @@ -314,7 +314,8 @@ export.discharge.longitudinal.section.csv.header.w = W [NN + m] export.discharge.longitudinal.section.csv.header.cw = W korr. export.discharge.longitudinal.section.csv.header.q = Q [m\u00b3/s] -export.discharge.curve.at.header = Berechnete Abflusskurve f\u00fcr {0} {0}-km: {1} +export.discharge.curve.at.header = Berechnete Abflusstafel f\u00fcr {0}, km {1} +export.discharge.curve.at.gauge.header = Abflusstafel f\u00fcr {1}/{0} ab {2} PNP[NN+m] = {3} export.historical.discharge.csv.header.timerange = Zeitraum export.historical.discharge.csv.header.waterlevel = Wasserstand [cm] export.historical.discharge.csv.header.discharge = Abfluss [m\u00b3/s]
--- a/flys-artifacts/src/main/resources/messages_de_DE.properties Thu Jan 31 18:18:05 2013 +0100 +++ b/flys-artifacts/src/main/resources/messages_de_DE.properties Thu Jan 31 18:21:05 2013 +0100 @@ -323,7 +323,8 @@ export.discharge.longitudinal.section.csv.header.w = W [NN + m] export.discharge.longitudinal.section.csv.header.cw = W korr. export.discharge.longitudinal.section.csv.header.q = Q [m\u00b3/s] -export.discharge.curve.at.header = Berechnete Abflusskurve f\u00fcr {0} {0}-km: {1} +export.discharge.curve.at.gauge.header = Abflusstafel f\u00fcr {1}/{0} ab {2} PNP[NN+m] = {3} +export.discharge.curve.at.header = Berechnete Abflusstafel f\u00fcr {0}, km {1} export.historical.discharge.csv.header.timerange = Zeitraum export.historical.discharge.csv.header.waterlevel = Wasserstand [cm] export.historical.discharge.csv.header.discharge = Abfluss [m\u00b3/s]
--- a/flys-artifacts/src/main/resources/messages_en.properties Thu Jan 31 18:18:05 2013 +0100 +++ b/flys-artifacts/src/main/resources/messages_en.properties Thu Jan 31 18:21:05 2013 +0100 @@ -327,6 +327,7 @@ export.discharge.longitudinal.section.csv.header.cw = W corr. export.discharge.longitudinal.section.csv.header.q = Q [m\u00b3/s] export.discharge.curve.at.header = Computed Discharge Curve for {0} {0}-km: {1} +export.discharge.curve.at.gauge.header = Dischargetable for {1}/{0} since {2} Datum[NN+m] = {3} export.historical.discharge.csv.header.timerange = Timerange export.historical.discharge.csv.header.waterlevel = Waterlevel [cm] export.historical.discharge.csv.header.discharge = Discharge [m\u00b3/s]
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Thu Jan 31 18:18:05 2013 +0100 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Thu Jan 31 18:21:05 2013 +0100 @@ -207,7 +207,7 @@ computed_discharge_curves = Abflusskurven longitudinal_section = L\u00e4ngsschnitt duration_curve = Dauerlinie -discharge_longitudinal_section = W f\u00fcr ungleichwertigen Abflussl\u00e4ngsschnitt +discharge_longitudinal_section = W f\u00fcr benutzerdefinierten Abflussl\u00e4ngsschnitt floodmap = \u00dcberschwemmungsfl\u00e4che historical_discharge = Zeit Diagramm historical_discharge_wq = WQ Diagramm