Mercurial > dive4elements > river
changeset 2423:ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
flys-artifacts/tags/2.6.1@4083 c6561f87-3c4e-4783-a992-168aeb5c3f6f
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Fri Feb 17 11:29:41 2012 +0000 +++ b/flys-artifacts/ChangeLog Fri Feb 17 12:59:56 2012 +0000 @@ -1,3 +1,45 @@ +2012-02-17 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java(getMinMaxW): + Added signature to give w extend for a given km range. + +2012-02-17 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java(getMinMaxW): + Added method to find the w extent for a given km. Useful + for validating "W auf freier Strecke". + + * src/main/java/de/intevation/flys/artifacts/model/HYKFactory.java: + Removed superfluous import. + +2012-02-17 Raimund Renkert <raimund.renkert@intevation.de> + + * src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java, + src/main/java/de/intevation/flys/artifacts/states/WQAdapted.java, + src/main/java/de/intevation/flys/artifacts/states/WQSelect.java, + src/main/java/de/intevation/flys/utils/FLYSUtils.java, + doc/conf/artifacts/winfo.xml: + Renamed state data fields: wq_mode -> wq_isq + wq_free -> wq_isfree + wq_selection -> wq_isrange + +2012-02-17 Raimund Renkert <raimund.renkert@intevation.de> + + * src/main/java/de/intevation/flys/exports/WaterlevelExporter.java: + Write the description instead of the Q value to CSV file. + + * src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionExporter.java: + Added parameter to overriden method. + + * src/main/java/de/intevation/flys/utils/FLYSUtils.java: + Get Qs without range. + + * src/main/resources/messages.properties, + src/main/resources/messages_de_DE.properties, + src/main/resources/messages_en.properties, + src/main/resources/messages_de.properties: + Adjusted i18n string for CSV metadata. + 2012-02-17 Ingo Weinzierl <ingo@intevation.de> Part II/III flys/issue497 (Diagrammeigenschaften in Zeitseriendiagrammen)
--- a/flys-artifacts/doc/conf/artifacts/winfo.xml Fri Feb 17 11:29:41 2012 +0000 +++ b/flys-artifacts/doc/conf/artifacts/winfo.xml Fri Feb 17 12:59:56 2012 +0000 @@ -154,9 +154,9 @@ </transition> <state id="state.winfo.wq" description="state.winfo.wq" state="de.intevation.flys.artifacts.states.WQSelect"> - <data name="wq_mode" type="String" /> - <data name="wq_free" type="Boolean" /> - <data name="wq_selection" type="String" /> + <data name="wq_isq" type="Boolean" /> + <data name="wq_isfree" type="Boolean" /> + <data name="wq_isrange" type="Boolean" /> <data name="wq_from" type="Double" /> <data name="wq_to" type="Double" /> <data name="wq_step" type="Double" /> @@ -165,7 +165,7 @@ <state id="state.winfo.wq_adapted" description="state.winfo.wq_adapted" state="de.intevation.flys.artifacts.states.WQAdapted"> <!-- TODO Add data objects --> - <data name="wq_mode" type="String" /> + <data name="wq_isq" type="String" /> <data name="wq_values" type="WQTriple" /> </state>
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Fri Feb 17 11:29:41 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Fri Feb 17 12:59:56 2012 +0000 @@ -1116,8 +1116,8 @@ * @return the selected Q values or null, if no Q values are selected. */ public double[] getQs() { - StateData dMode = getData("wq_mode"); - StateData dSelection = getData("wq_selection"); + StateData dMode = getData("wq_isq"); + StateData dSelection = getData("wq_isrange"); boolean isRange = dSelection != null ? Boolean.valueOf((String)dSelection.getValue()) @@ -1139,13 +1139,13 @@ public boolean isQ() { - StateData mode = getData("wq_mode"); + StateData mode = getData("wq_isq"); String value = (mode != null) ? (String) mode.getValue() : null; return value != null ? Boolean.valueOf(value) : false; } public boolean isW() { - StateData mode = getData("wq_mode"); + StateData mode = getData("wq_isq"); String value = (mode != null) ? (String) mode.getValue() : null; return value != null ? !Boolean.valueOf(value) : false; } @@ -1154,7 +1154,7 @@ if(!isW()) { return false; } - StateData mode = getData("wq_free"); + StateData mode = getData("wq_isfree"); String value = (mode != null) ? (String) mode.getValue() : null; return value != null ? Boolean.valueOf(value) : false; @@ -1173,7 +1173,7 @@ if(!isQ()) { return false; } - StateData mode = getData("wq_free"); + StateData mode = getData("wq_isfree"); String value = (mode != null) ? (String) mode.getValue() : null; logger.debug("isFreeQ: " + value); @@ -1190,7 +1190,7 @@ * @return an array of Q values. */ public double[] getQs(double[] range) { - StateData dMode = getData("wq_mode"); + StateData dMode = getData("wq_isq"); if (isQ()) { return getWQForDist(range);
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/HYKFactory.java Fri Feb 17 11:29:41 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/HYKFactory.java Fri Feb 17 12:59:56 2012 +0000 @@ -3,8 +3,6 @@ import java.util.ArrayList; import java.util.List; -import java.math.BigDecimal; - import java.io.Serializable; import net.sf.ehcache.Cache;
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java Fri Feb 17 11:29:41 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java Fri Feb 17 12:59:56 2012 +0000 @@ -496,6 +496,28 @@ return qs.toNativeArray(); } + + public double [] getMinMaxW(double [] result) { + double minW = Double.MAX_VALUE; + double maxW = -Double.MAX_VALUE; + for (int i = 0; i < ws.length; ++i) { + double w = ws[i]; + if (w < minW) minW = w; + if (w > maxW) maxW = w; + } + result[0] = minW; + result[1] = maxW; + return result; + } + + public double [] getMinMaxW(Row other, double km, double [] result) { + double [] m1 = this .getMinMaxW(new double [2]); + double [] m2 = other.getMinMaxW(new double [2]); + double factor = Linear.factor(km, this.km, other.km); + result[0] = Linear.weight(factor, m1[0], m2[0]); + result[1] = Linear.weight(factor, m1[1], m2[1]); + return result; + } } // class Row /** Rows in table. */ @@ -585,6 +607,64 @@ return ws; } + public double [] getMinMaxW(double km) { + return getMinMaxW(km, new double [2]); + + } + public double [] getMinMaxW(double km, double [] result) { + int rowIndex = Collections.binarySearch(rows, new Row(km)); + + if (rowIndex >= 0) { + return rows.get(rowIndex).getMinMaxW(result); + } + + rowIndex = -rowIndex -1; + + if (rowIndex < 1 || rowIndex >= rows.size()) { + // do not extrapolate + return null; + } + + Row r1 = rows.get(rowIndex-1); + Row r2 = rows.get(rowIndex); + + return r1.getMinMaxW(r2, km, result); + } + + public double [] getMinMaxW(double from, double to, double step) { + double [] result = new double[2]; + + double minW = Double.MAX_VALUE; + double maxW = -Double.MAX_VALUE; + + if (from > to) { + double tmp = from; + from = to; + to = tmp; + } + + step = Math.max(Math.abs(step), 0.0001); + + double d = from; + for (; d <= to; d += step) { + if (getMinMaxW(d, result) != null) { + if (result[0] < minW) minW = result[0]; + if (result[1] > maxW) maxW = result[1]; + } + } + + if (d != to) { + if (getMinMaxW(to, result) != null) { + if (result[0] < minW) minW = result[0]; + if (result[1] > maxW) maxW = result[1]; + } + } + + return minW < Double.MAX_VALUE + ? new double [] { minW, maxW } + : null; + } + /** * Interpolate W and Q values at a given km. */
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQAdapted.java Fri Feb 17 11:29:41 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQAdapted.java Fri Feb 17 12:59:56 2012 +0000 @@ -38,7 +38,7 @@ private static Logger logger = Logger.getLogger(WQAdapted.class); - public static final String FIELD_WQ_MODE = "wq_mode"; + public static final String FIELD_WQ_MODE = "wq_isq"; public static final String FIELD_WQ_VALUES = "wq_values";
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQSelect.java Fri Feb 17 11:29:41 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQSelect.java Fri Feb 17 12:59:56 2012 +0000 @@ -48,13 +48,13 @@ public static final int MAX_STEPS = 30; /** The name of the 'mode' field. */ - public static final String WQ_MODE = "wq_mode"; + public static final String WQ_MODE = "wq_isq"; /** Them name fo the 'free' field. */ - public static final String WQ_FREE = "wq_free"; + public static final String WQ_FREE = "wq_isfree"; /** The name of the 'selection' field. */ - public static final String WQ_SELECTION = "wq_selection"; + public static final String WQ_SELECTION = "wq_isrange"; /** The name of the 'from' field. */ public static final String WQ_FROM = "wq_from"; @@ -89,8 +89,8 @@ return super.createStaticData(flys, creator, cc, name, value, type); } - boolean isQ = flys.getDataAsBoolean(WQ_MODE); - boolean isFree = flys.getDataAsBoolean(WQ_FREE); + Boolean isQ = flys.getDataAsBoolean(WQ_MODE); + Boolean isFree = flys.getDataAsBoolean(WQ_FREE); WINFOArtifact winfo = (WINFOArtifact) flys; @@ -454,10 +454,12 @@ WINFOArtifact flys = (WINFOArtifact) artifact; StateData data = getData(flys, WQ_SELECTION); - boolean isRange = data != null + boolean isRange = data != null ? Boolean.valueOf((String) data.getValue()) : false; + + if (!isRange) { return validateSingle(artifact); }
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionExporter.java Fri Feb 17 11:29:41 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionExporter.java Fri Feb 17 12:59:56 2012 +0000 @@ -71,7 +71,8 @@ CSVWriter writer, WQKms wqkms, boolean atGauge, - boolean isQ + boolean isQ, + boolean isRange ) { logger.debug("WaterlevelExporter.wQKms2CSV");
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/WaterlevelExporter.java Fri Feb 17 11:29:41 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/WaterlevelExporter.java Fri Feb 17 12:59:56 2012 +0000 @@ -261,16 +261,19 @@ protected void writeCSVData(CSVWriter writer) { logger.info("WaterlevelExporter.writeData"); - WQ_MODE mode = FLYSUtils.getWQMode((FLYSArtifact)master); - boolean atGauge = mode == WQ_MODE.QGAUGE || mode == WQ_MODE.WGAUGE; - boolean isQ = mode == WQ_MODE.QGAUGE || mode == WQ_MODE.QFREE; + WQ_MODE mode = FLYSUtils.getWQMode((FLYSArtifact)master); + boolean atGauge = mode == WQ_MODE.QGAUGE || mode == WQ_MODE.WGAUGE; + boolean isQ = mode == WQ_MODE.QGAUGE || mode == WQ_MODE.QFREE; + FLYSUtils.WQ_INPUT input + = FLYSUtils.getWQInputMode((FLYSArtifact)master); + boolean isRange = input == FLYSUtils.WQ_INPUT.RANGE; writeCSVMeta(writer); writeCSVHeader(writer, atGauge, isQ); for (WQKms[] tmp: data) { for (WQKms wqkms: tmp) { - wQKms2CSV(writer, wqkms, atGauge, isQ); + wQKms2CSV(writer, wqkms, atGauge, isQ, isRange); } } } @@ -338,13 +341,22 @@ FLYSUtils.WQ_MODE wq = FLYSUtils.getWQMode(flys); if (wq == FLYSUtils.WQ_MODE.QFREE || wq == FLYSUtils.WQ_MODE.QGAUGE) { double[] qs = FLYSUtils.getQs(flys); + FLYSUtils.WQ_INPUT input = FLYSUtils.getWQInputMode(flys); - String lower = ""; - String upper = ""; + String data = ""; - if (qs != null && qs.length > 0) { - lower = String.valueOf(qs[0]); - upper = String.valueOf(qs[qs.length-1]); + if ((input == FLYSUtils.WQ_INPUT.ADAPTED || + input == FLYSUtils.WQ_INPUT.RANGE) && + qs != null && qs.length > 0) + { + data = String.valueOf(qs[0]); + data += " - " + String.valueOf(qs[qs.length-1]); + } + else if (input == FLYSUtils.WQ_INPUT.SINGLE && qs != null){ + data = String.valueOf(qs[0]); + for (int i = 1; i < qs.length; i++) { + data += ", " + String.valueOf(qs[i]); + } } else { logger.warn("Could not determine Q range!"); @@ -355,7 +367,7 @@ meta, CSV_META_Q, CSV_META_Q, - new Object[] { lower, upper }) + new Object[] {data}) }); } else { @@ -419,7 +431,8 @@ CSVWriter writer, WQKms wqkms, boolean atGauge, - boolean isQ + boolean isQ, + boolean isRange ) { logger.debug("WaterlevelExporter.wQKms2CSV"); @@ -456,11 +469,15 @@ result = wqkms.get(i, result); if (atGauge) { + String tmp = desc; + if (!isRange) { + tmp = FLYSUtils.getNamedMainValue((WINFOArtifact)flys, wqkms.getRawValue()); + } writer.writeNext(new String[] { kmf.format(result[2]), wf.format(result[0]), qf.format(result[1]), - desc, + tmp, FLYSUtils.getLocationDescription(flys, result[2]), result[2] >= a && result[2] <= b ? gaugeName
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/FLYSUtils.java Fri Feb 17 11:29:41 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/FLYSUtils.java Fri Feb 17 12:59:56 2012 +0000 @@ -163,7 +163,7 @@ /** * This method returns an WQ_MODE enum which is based on the parameters - * stored in <i>flys</i> Artifact. If there is no <i>wq_mode</i> parameter + * stored in <i>flys</i> Artifact. If there is no <i>wq_isq</i> parameter * existing, WQ_MODE.NONE is returned. * * @param flys The FLYSArtifact that stores wq mode relevant parameters. @@ -176,13 +176,13 @@ } String values = flys.getDataAsString("wq_values"); - Boolean isQ = flys.getDataAsBoolean("wq_mode"); + Boolean isQ = flys.getDataAsBoolean("wq_isq"); if (values != null) { return isQ ? WQ_MODE.QGAUGE : WQ_MODE.WGAUGE; } - Boolean isFree = flys.getDataAsBoolean("wq_free"); + Boolean isFree = flys.getDataAsBoolean("wq_isfree"); if (isQ) { return isFree ? WQ_MODE.QFREE : WQ_MODE.QGAUGE; @@ -201,7 +201,7 @@ return WQ_INPUT.NONE; } - Boolean selection = flys.getDataAsBoolean("wq_selection"); + Boolean selection = flys.getDataAsBoolean("wq_isrange"); String adapted = flys.getDataAsString("wq_values"); if(adapted != null && adapted.length() > 0) { @@ -345,11 +345,9 @@ * @return the Qs. */ public static double[] getQs(FLYSArtifact flys) { - double[] kmRange = getKmRange(flys); - // XXX this is not nice! if (flys instanceof WINFOArtifact) { - return ((WINFOArtifact) flys).getQs(kmRange); + return ((WINFOArtifact) flys).getQs(); } logger.warn("This method currently supports WINFOArtifact only!");
--- a/flys-artifacts/src/main/resources/messages.properties Fri Feb 17 11:29:41 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages.properties Fri Feb 17 12:59:56 2012 +0000 @@ -119,7 +119,7 @@ export.waterlevel.csv.meta.river = # River: {0} export.waterlevel.csv.meta.range = # Location/Range (km): {0} - {1} export.waterlevel.csv.meta.gauge = # Gauge: {0} -export.waterlevel.csv.meta.q = # Q (m\u00b3/s): {0} - {1} +export.waterlevel.csv.meta.q = # Q (m\u00b3/s): {0} export.waterlevel.csv.meta.w = # W (NN + m): {0} - {1} export.waterlevel.csv.not.in.gauge.range = Outside selected gauge export.computed.discharge.curve.csv.header.w = W [NN + m]
--- a/flys-artifacts/src/main/resources/messages_de.properties Fri Feb 17 11:29:41 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages_de.properties Fri Feb 17 12:59:56 2012 +0000 @@ -119,7 +119,7 @@ export.waterlevel.csv.meta.river = # Gew\u00e4sser: {0} export.waterlevel.csv.meta.range = # Ort/Bereich (km): {0} - {1} export.waterlevel.csv.meta.gauge = # Bezugspegel: {0} -export.waterlevel.csv.meta.q = # Q (m\u00b3/s): {0} - {1} +export.waterlevel.csv.meta.q = # Q (m\u00b3/s): {0} export.waterlevel.csv.meta.w = # W (NN + m): {0} - {1} export.waterlevel.csv.not.in.gauge.range = au\u00dferhalb gew\u00e4hlter Bezugspegels export.computed.discharge.curve.csv.header.w = W [NN + m]
--- a/flys-artifacts/src/main/resources/messages_de_DE.properties Fri Feb 17 11:29:41 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages_de_DE.properties Fri Feb 17 12:59:56 2012 +0000 @@ -119,7 +119,7 @@ export.waterlevel.csv.meta.river = # Gew\u00e4sser: {0} export.waterlevel.csv.meta.range = # Ort/Bereich (km): {0} - {1} export.waterlevel.csv.meta.gauge = # Bezugspegel: {0} -export.waterlevel.csv.meta.q = # Q (m\u00b3/s): {0} - {1} +export.waterlevel.csv.meta.q = # Q (m\u00b3/s): {0} export.waterlevel.csv.meta.w = # W (NN + m): {0} - {1} export.waterlevel.csv.not.in.gauge.range = au\u00dferhalb gew\u00e4hlter Bezugspegels export.computed.discharge.curve.csv.header.w = W [NN + m]
--- a/flys-artifacts/src/main/resources/messages_en.properties Fri Feb 17 11:29:41 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages_en.properties Fri Feb 17 12:59:56 2012 +0000 @@ -115,7 +115,7 @@ export.waterlevel.csv.meta.river = # River: {0} export.waterlevel.csv.meta.range = # Location/Range (km): {0} - {1} export.waterlevel.csv.meta.gauge = # Gauge: {0} -export.waterlevel.csv.meta.q = # Q (m\u00b3/s): {0} - {1} +export.waterlevel.csv.meta.q = # Q (m\u00b3/s): {0} export.waterlevel.csv.meta.w = # W (NN + m): {0} - {1} export.waterlevel.csv.not.in.gauge.range = Outside selected gauge export.computed.discharge.curve.csv.header.w = W [NN + m]