# HG changeset patch # User Tom Gottfried # Date 1412171687 -7200 # Node ID 839032ac152359e872acea8366fe2d70b936a8e5 # Parent c494f9a614907aca2501ee2cb596660f2e8c9f9e Purge obsolete representation of reference system for discharge tables. diff -r c494f9a61490 -r 839032ac1523 artifacts/src/main/java/org/dive4elements/river/artifacts/model/GaugeDischargeCurveFacet.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/GaugeDischargeCurveFacet.java Wed Oct 01 15:42:55 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/GaugeDischargeCurveFacet.java Wed Oct 01 15:54:47 2014 +0200 @@ -82,7 +82,7 @@ Object pnpObject = context.getContextValue(PNP); if (!(pnpObject instanceof Number)) { - return new WQKms(kms, values[0], values[1], name, W.CENTIMETER_AT_GAUGE); + return new WQKms(kms, values[0], values[1], name); } double pnp = ((Number)pnpObject).doubleValue(); double[] ws = transformToM(values[1], pnp); diff -r c494f9a61490 -r 839032ac1523 artifacts/src/main/java/org/dive4elements/river/artifacts/model/W.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/W.java Wed Oct 01 15:42:55 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/W.java Wed Oct 01 15:54:47 2014 +0200 @@ -22,12 +22,6 @@ protected TDoubleArrayList ws; - public static final int METER_OVER_REFPOINT = 0; - - public static final int CENTIMETER_AT_GAUGE = 1; - - protected int referenceSystem; - public W() { ws = new TDoubleArrayList(); } @@ -42,39 +36,10 @@ } public W(int capacity, String name) { - this(capacity, "", METER_OVER_REFPOINT); - } - - public W(int capacity, String name, int referenceSystem) { super(name); - this.referenceSystem = referenceSystem; ws = new TDoubleArrayList(capacity); } - /** Sets the used reference system for W. - * If the W's refer to values in meters over a reference - * point (e.g. NN+m) they are in meter. If they are - * relative to the PNP of a gauge they are in centimeter. */ - public void setReferenceSystem(int val) { - referenceSystem = val; - } - - /** Return the used reference system for W. - * If the W's refer to values in meters over a reference - * point (e.g. NN+m) they are in meter. If they are - * relative to the PNP of a gauge they are in centimeter. */ - public int getReferenceSystem() { - return referenceSystem; - } - - /** Convenience function to get the correct unit for W values. */ - public String getWUnit() { - if (getReferenceSystem() == CENTIMETER_AT_GAUGE) { - return "cm"; - } - return "m"; - } - public void add(double value) { ws.add(value); } diff -r c494f9a61490 -r 839032ac1523 artifacts/src/main/java/org/dive4elements/river/artifacts/model/WQ.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/WQ.java Wed Oct 01 15:42:55 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/WQ.java Wed Oct 01 15:54:47 2014 +0200 @@ -121,23 +121,15 @@ * If a conversion takes place converted is set to true */ public static WQ getFixedWQforExportAtGauge(WQ wq, BigDecimal datum) { - if (wq.getReferenceSystem() == W.CENTIMETER_AT_GAUGE) { - // Do nothing - return wq; - } // If we convert we work on a copy to avoid side effects. WQ ret = new WQ(wq.size(), wq.getName()); - ret.setReferenceSystem(W.CENTIMETER_AT_GAUGE); - // When we convert and have a datum we have a calculated - // result at a gauge so we must subtract the datum. double subtractDatum = datum == null ? 0 : datum.doubleValue(); double [] data = new double[8]; for (int i = 0, WQ = wq.size(); i < WQ; i++) { wq.get(i, data); ret.add((data[0] - subtractDatum)*100d, data[1]); } - log.debug("Converted W values to centimeter and substracted: " + subtractDatum); return ret; } } diff -r c494f9a61490 -r 839032ac1523 artifacts/src/main/java/org/dive4elements/river/artifacts/model/WQKms.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/WQKms.java Wed Oct 01 15:42:55 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/WQKms.java Wed Oct 01 15:54:47 2014 +0200 @@ -57,25 +57,18 @@ this(kms, qs, ws, ""); } - - public WQKms(double [] kms, double [] qs, double [] ws, String name) { - this(kms, qs, ws, name, 0); - } - public WQKms(double []kms, WQ wq) { - this(kms, wq.getQs(), wq.getWs(), wq.getName(), wq.getReferenceSystem()); + this(kms, wq.getQs(), wq.getWs(), wq.getName()); } public WQKms(TDoubleArrayList kms, TDoubleArrayList qs, TDoubleArrayList ws, String name) { super(qs, ws, name); this.kms = kms; - setReferenceSystem(0); } - public WQKms(double [] kms, double [] qs, double [] ws, String name, int wReferenceSystem) { + public WQKms(double [] kms, double [] qs, double [] ws, String name) { super(qs, ws, name); this.kms = new TDoubleArrayList(kms); - setReferenceSystem(wReferenceSystem); } /** Create a WQKms from WKms, filling the Qs with given q. */ diff -r c494f9a61490 -r 839032ac1523 artifacts/src/main/java/org/dive4elements/river/exports/ATWriter.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/ATWriter.java Wed Oct 01 15:42:55 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/ATWriter.java Wed Oct 01 15:54:47 2014 +0200 @@ -46,9 +46,6 @@ public static final String I18N_AT_GAUGE_HEADER = "export.discharge.curve.at.gauge.header"; - public static final String I18N_AT_CALC_GAUGE_HEADER = - "export.discharge.curve.at.gauge.calc.header"; - public static final String EMPTY = " "; public static double getQ(int w, UnivariateRealFunction qFunc) { @@ -75,24 +72,6 @@ out.printf(Locale.US, format, q); } - protected static void printCalculatedGaugeHeader( - PrintWriter out, - CallMeta callMeta, - String river, - double km, - String gName, - BigDecimal datum, - Date date, - String unit - ) { - out.print("*" + Resources.getMsg( - callMeta, - I18N_AT_CALC_GAUGE_HEADER, - I18N_AT_CALC_GAUGE_HEADER, - new Object[] { river, gName, datum, unit } )); - out.print("\r\n"); - } - protected static void printGaugeHeader( PrintWriter out, CallMeta callMeta, @@ -148,20 +127,8 @@ WQ wq = WQ.getFixedWQforExportAtGauge(values, datum); - // If we converted to centimeter we know that the WQ table is - // calculated because of the assumption that all calculations - // are in Meter and only the discharge tables data is in meter. - boolean isCalculation = wq.getReferenceSystem() != values.getReferenceSystem(); - int [] bounds = wq.longestIncreasingWRangeIndices(); - if (log.isDebugEnabled()) { - log.debug("exporting " + (isCalculation ? "calculated " : "") + - "w between indices " + bounds[0] + " and " + bounds[1] + " (" + - (int)Math.ceil(wq.getW(bounds[0])) + ", " + - (int)Math.floor(wq.getW(bounds[1]))+ ")"); - } - if (bounds[1]-bounds[0] < 1) { // Only first w can be written out. minW = maxW = (int)Math.round(wq.getW(bounds[0])); minQ = maxQ = wq.getQ(bounds[0]); @@ -195,11 +162,7 @@ // A header is required, because the desktop version of FLYS will skip // the first row. if (gName != null) { - if (isCalculation) { - printCalculatedGaugeHeader(out, meta, river, km, gName, datum, date, unit); - } else { - printGaugeHeader(out, meta, river, km, gName, datum, date, unit); - } + printGaugeHeader(out, meta, river, km, gName, datum, date, unit); } else { printHeader(out, meta, river, km); diff -r c494f9a61490 -r 839032ac1523 artifacts/src/main/java/org/dive4elements/river/exports/ComputedDischargeCurveExporter.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/ComputedDischargeCurveExporter.java Wed Oct 01 15:42:55 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/ComputedDischargeCurveExporter.java Wed Oct 01 15:54:47 2014 +0200 @@ -47,6 +47,7 @@ import org.dive4elements.river.utils.RiverUtils; import org.dive4elements.river.utils.Formatter; +import static org.dive4elements.river.exports.injector.InjectorConstants.PNP; /** * @author Ingo Weinzierl @@ -76,7 +77,6 @@ protected String riverUnit; protected String gaugeName; protected double gaugeDatum; - protected boolean isCalculated; protected Date validSince; public ComputedDischargeCurveExporter() { @@ -104,7 +104,6 @@ return; } if (referenceWQ != null) { - wUnit = referenceWQ.getWUnit(); D4EArtifact arti = (D4EArtifact)master; River river = RiverUtils.getRiver(arti); riverUnit = river.getWstUnit().getName(); @@ -113,15 +112,11 @@ double[] kms = rangeAccess.getKmRange(); Gauge gauge = river.determineGaugeByPosition(kms[0]); - log.debug("Kms 0: " + kms[0]); - if (Math.abs(kms[0] - gauge.getStation().doubleValue()) < 1e-4) { + if (context.getContextValue(PNP) instanceof Number) { + wUnit = "cm"; gaugeName = gauge.getName(); gaugeDatum = gauge.getDatum().doubleValue(); - // Assumption is that values at a gauge that are in the meter - // reference system are calculated. - isCalculated = wUnit.equals("m"); - // Now convert the data to cm because we are at gauge List newData = new ArrayList(); for (WQKms d2: data) { @@ -129,7 +124,6 @@ WQ.getFixedWQforExportAtGauge((WQ)d2, gauge.getDatum()))); } data = newData; // All hail the garbage collector - wUnit = "cm"; validSince = gauge.fetchMasterDischargeTable().getTimeInterval().getStartTime(); } else { @@ -260,16 +254,14 @@ source.addMetaData("date", df.format(new Date())); - source.addMetaData("wUnit", wUnit.equals("m") ? riverUnit : "cm"); + source.addMetaData("wUnit", wUnit.equals("cm") ? "cm" : riverUnit); RangeAccess rangeAccess = new RangeAccess(flys); double[] kms = rangeAccess.getKmRange(); source.addMetaData("range", Formatter.getCalculationKm(context.getMeta()).format(kms[0])); - // When w is in meter we are not at a gauge so our values - // must be calculated - if (isCalculated || wUnit.equals("m")) { + if (!(context.getContextValue(PNP) instanceof Number)) { source.addMetaData("valid_since", ""); source.addMetaData("calculation", Resources.getMsg( locale, diff -r c494f9a61490 -r 839032ac1523 artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java Wed Oct 01 15:42:55 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java Wed Oct 01 15:54:47 2014 +0200 @@ -383,7 +383,6 @@ int firstIdx = first > last ? wqkms.size() - 1 : 0; int lastIdx = first > last ? 0 : wqkms.size() -1; WQKms filtered = new WQKms (wqkms.size()); - filtered.setReferenceSystem(wqkms.getReferenceSystem()); filtered.setName(wqkms.getName()); double [] dp = new double [3]; diff -r c494f9a61490 -r 839032ac1523 artifacts/src/main/resources/messages.properties --- a/artifacts/src/main/resources/messages.properties Wed Oct 01 15:42:55 2014 +0200 +++ b/artifacts/src/main/resources/messages.properties Wed Oct 01 15:54:47 2014 +0200 @@ -393,7 +393,6 @@ 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[{4}] = {3} -export.discharge.curve.at.gauge.calc.header = Computed Discharge Curve for {0}, Gauge: {1} PNP[{3}] = {2} 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] diff -r c494f9a61490 -r 839032ac1523 artifacts/src/main/resources/messages_de.properties --- a/artifacts/src/main/resources/messages_de.properties Wed Oct 01 15:42:55 2014 +0200 +++ b/artifacts/src/main/resources/messages_de.properties Wed Oct 01 15:54:47 2014 +0200 @@ -394,7 +394,6 @@ export.discharge.longitudinal.section.csv.header.q = Q [m\u00b3/s] 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[{4}] = {3} -export.discharge.curve.at.gauge.calc.header = Berechnete Abflusstafel f\u00fcr {0}, Pegel: {1} PNP[{3}] = {2} 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] diff -r c494f9a61490 -r 839032ac1523 artifacts/src/main/resources/messages_de_DE.properties --- a/artifacts/src/main/resources/messages_de_DE.properties Wed Oct 01 15:42:55 2014 +0200 +++ b/artifacts/src/main/resources/messages_de_DE.properties Wed Oct 01 15:54:47 2014 +0200 @@ -391,7 +391,6 @@ export.discharge.longitudinal.section.csv.header.cw = W korr. [NN + m] export.discharge.longitudinal.section.csv.header.q = Q [m\u00b3/s] export.discharge.curve.at.gauge.header = Abflusstafel f\u00fcr {1}/{0} ab {2} PNP[{4}] = {3} -export.discharge.curve.at.gauge.calc.header = Berechnete Abflusstafel f\u00fcr {0}, Pegel: {1} PNP[{3}] = {2} 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] diff -r c494f9a61490 -r 839032ac1523 artifacts/src/main/resources/messages_en.properties --- a/artifacts/src/main/resources/messages_en.properties Wed Oct 01 15:42:55 2014 +0200 +++ b/artifacts/src/main/resources/messages_en.properties Wed Oct 01 15:54:47 2014 +0200 @@ -395,7 +395,6 @@ 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[{4}] = {3} -export.discharge.curve.at.gauge.calc.header = Computed discharge curve for {0}, gauge: {1} datum[{3}] = {2} 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]