# HG changeset patch # User Ingo Weinzierl # Date 1317222153 0 # Node ID 7d11ad5a52d515dcfdbb95fae0aabb04494833f5 # Parent 91d038c7aae5da212839ddd96b89ea6d645629bc Bugfix: #332 Made AT-exports compatible with desktop FLYS. flys-artifacts/trunk@2856 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 91d038c7aae5 -r 7d11ad5a52d5 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Wed Sep 28 14:01:00 2011 +0000 +++ b/flys-artifacts/ChangeLog Wed Sep 28 15:02:33 2011 +0000 @@ -1,3 +1,20 @@ +2011-09-28 Ingo Weinzierl + + flys/issue332 (W-INFO / Berechnung Abflusskurve, Export, FLYS 2.5) + + * src/main/java/de/intevation/flys/exports/ATExporter.java: Store the + master Artifact which is set via setMasterArtifact(). This is required + for meta information used while preparing the header row of AT exports. + + * src/main/java/de/intevation/flys/exports/ATWriter.java: Print a header + row into the AT export for being compatible with desktop FLYS. + + * src/main/resources/messages.properties, + src/main/resources/messages_de_DE.properties, + src/main/resources/messages_en.properties, + src/main/resources/messages_de.properties: Added header row for AT + export files. + 2011-09-28 Ingo Weinzierl flys/issue328 (W-INFO / ÜSK: Auswahl der Wasserspiegellage / Auswahlunterstützung) diff -r 91d038c7aae5 -r 7d11ad5a52d5 flys-artifacts/src/main/java/de/intevation/flys/exports/ATExporter.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ATExporter.java Wed Sep 28 14:01:00 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ATExporter.java Wed Sep 28 15:02:33 2011 +0000 @@ -17,6 +17,9 @@ import de.intevation.flys.artifacts.model.WQ; +import de.intevation.flys.utils.FLYSUtils; + + public class ATExporter implements OutGenerator { @@ -27,6 +30,7 @@ protected WQ data; protected CallContext context; protected OutputStream out; + protected FLYSArtifact master; public ATExporter() { } @@ -39,7 +43,7 @@ @Override public void setMasterArtifact(Artifact master) { - // not needed + this.master = (FLYSArtifact) master; } @Override @@ -72,7 +76,14 @@ throw new IOException(iae); } - at.write(new OutputStreamWriter(out, DEFAULT_ENCODING)); + String river = FLYSUtils.getRiver(master).getName(); + double[] kms = FLYSUtils.getLocations(master); + + at.write( + new OutputStreamWriter(out, DEFAULT_ENCODING), + context.getMeta(), + river, + kms[0]); } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 91d038c7aae5 -r 7d11ad5a52d5 flys-artifacts/src/main/java/de/intevation/flys/exports/ATWriter.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ATWriter.java Wed Sep 28 14:01:00 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ATWriter.java Wed Sep 28 15:02:33 2011 +0000 @@ -6,7 +6,10 @@ import java.util.Locale; +import de.intevation.artifacts.CallMeta; + import de.intevation.flys.artifacts.model.WQ; +import de.intevation.flys.artifacts.resources.Resources; import org.apache.commons.math.analysis.UnivariateRealFunction; @@ -25,6 +28,9 @@ public static final int COLUMNS = 10; + public static final String I18N_AT_HEADER = + "export.discharge.curve.at.header"; + public static final String EMPTY = " "; protected double minW; @@ -98,10 +104,30 @@ out.printf(Locale.US, format, q); } - public void write(Writer writer) throws IOException { + protected static void printHeader( + PrintWriter out, + CallMeta callMeta, + String river, + double km + ) { + out.println(Resources.getMsg( + callMeta, + I18N_AT_HEADER, + I18N_AT_HEADER, + new Object[] { river, km } )); + } + + + public void write(Writer writer, CallMeta meta, String river, double km) + 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); + double rest = Math.abs(minW % COLUMNS); double startW = Math.round(minW*10.0)/10.0; diff -r 91d038c7aae5 -r 7d11ad5a52d5 flys-artifacts/src/main/resources/messages.properties --- a/flys-artifacts/src/main/resources/messages.properties Wed Sep 28 14:01:00 2011 +0000 +++ b/flys-artifacts/src/main/resources/messages.properties Wed Sep 28 15:02:33 2011 +0000 @@ -73,6 +73,7 @@ export.discharge.longitudinal.section.csv.header.w = W [NN + m] 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} floodmap.wmsbackground = Background Map floodmap.riveraxis = River Axis diff -r 91d038c7aae5 -r 7d11ad5a52d5 flys-artifacts/src/main/resources/messages_de.properties --- a/flys-artifacts/src/main/resources/messages_de.properties Wed Sep 28 14:01:00 2011 +0000 +++ b/flys-artifacts/src/main/resources/messages_de.properties Wed Sep 28 15:02:33 2011 +0000 @@ -74,6 +74,7 @@ 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} floodmap.wmsbackground = Hintergrundkarte floodmap.riveraxis = Flussachse diff -r 91d038c7aae5 -r 7d11ad5a52d5 flys-artifacts/src/main/resources/messages_de_DE.properties --- a/flys-artifacts/src/main/resources/messages_de_DE.properties Wed Sep 28 14:01:00 2011 +0000 +++ b/flys-artifacts/src/main/resources/messages_de_DE.properties Wed Sep 28 15:02:33 2011 +0000 @@ -73,6 +73,7 @@ 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} floodmap.wmsbackground = Hintergrundkarte floodmap.riveraxis = Flussachse diff -r 91d038c7aae5 -r 7d11ad5a52d5 flys-artifacts/src/main/resources/messages_en.properties --- a/flys-artifacts/src/main/resources/messages_en.properties Wed Sep 28 14:01:00 2011 +0000 +++ b/flys-artifacts/src/main/resources/messages_en.properties Wed Sep 28 15:02:33 2011 +0000 @@ -71,6 +71,7 @@ export.discharge.longitudinal.section.csv.header.w = W [NN + m] 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} floodmap.wmsbackground = Background Map floodmap.riveraxis = River Axis