Mercurial > dive4elements > river
changeset 2194:05984871520f
Call the "Bezugslinienverfahren" from the WINFOArtifact.
flys-artifacts/trunk@3809 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 27 Jan 2012 15:43:04 +0000 |
parents | 73490b828a90 |
children | e14beb93a854 |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.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 | 6 files changed, 120 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Fri Jan 27 14:21:51 2012 +0000 +++ b/flys-artifacts/ChangeLog Fri Jan 27 15:43:04 2012 +0000 @@ -1,3 +1,14 @@ +2012-01-27 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java: + Call the 'Bezugslinienverfahren'. + + * src/main/resources/messages.properties, + src/main/resources/messages_de_DE.properties, + src/main/resources/messages_en.properties, + src/main/resources/messages_de.properties: + I18N for the 'Bezugslinienverfahren' error messages. + 2012-01-27 Felix Wolfsteller <felix.wolfsteller@intevation.de> * doc/conf/themes.xml: Better theme for manual points.
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Fri Jan 27 14:21:51 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Fri Jan 27 15:43:04 2012 +0000 @@ -1,7 +1,5 @@ package de.intevation.flys.artifacts; -import java.awt.geom.Point2D; - import de.intevation.artifactdatabase.ProtocolUtils; import de.intevation.artifactdatabase.data.StateData; @@ -18,8 +16,9 @@ import de.intevation.artifacts.common.ArtifactNamespaceContext; +import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator; + import de.intevation.artifacts.common.utils.XMLUtils; -import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator; import de.intevation.flys.artifacts.context.FLYSContext; @@ -27,23 +26,25 @@ import de.intevation.flys.artifacts.model.Calculation2; import de.intevation.flys.artifacts.model.Calculation3; import de.intevation.flys.artifacts.model.Calculation4; +import de.intevation.flys.artifacts.model.Calculation5; import de.intevation.flys.artifacts.model.Calculation; +import de.intevation.flys.artifacts.model.CalculationMessage; import de.intevation.flys.artifacts.model.CalculationResult; import de.intevation.flys.artifacts.model.DischargeTables; import de.intevation.flys.artifacts.model.FacetTypes; import de.intevation.flys.artifacts.model.MainValuesFactory; import de.intevation.flys.artifacts.model.Segment; import de.intevation.flys.artifacts.model.WQKms; +import de.intevation.flys.artifacts.model.WW; import de.intevation.flys.artifacts.model.WstValueTable; import de.intevation.flys.artifacts.model.WstValueTableFactory; -import de.intevation.flys.model.FastCrossSectionLine; - import de.intevation.flys.artifacts.states.DefaultState; import de.intevation.flys.artifacts.states.LocationDistanceSelect; import de.intevation.flys.geom.Lines; +import de.intevation.flys.model.FastCrossSectionLine; import de.intevation.flys.model.Gauge; import de.intevation.flys.model.River; @@ -52,6 +53,8 @@ import gnu.trove.TDoubleArrayList; +import java.awt.geom.Point2D; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -65,8 +68,6 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; -import de.intevation.flys.artifacts.model.CalculationMessage; - /** * The default WINFO artifact. * @@ -645,6 +646,94 @@ return calc4.calculate(table, range[0], range[1], range[2]); } + /** + * Returns the data that is computed by a reference curve computation. + * + * @return the data computed by a reference curve computation. + */ + public CalculationResult getReferenceCurveData() { + + Double startKm = getReferenceStartKm(); + + if (startKm == null) { + return error(new WW[0], "no.reference.start.km"); + } + + double [] endKms = getReferenceEndKms(); + + if (endKms == null || endKms.length == 0) { + return error(new WW[0], "no.reference.end.kms"); + } + + Calculation5 calc5 = new Calculation5(startKm, endKms); + + River r = FLYSUtils.getRiver(this); + if (r == null) { + return error(new WW[0], "no.river.found"); + } + + WstValueTable wst = WstValueTableFactory.getTable(r); + if (wst == null) { + return error(new WW[0], "no.wst.for.river"); + } + + return calc5.calculate(wst); + } + + protected Double getReferenceStartKm() { + StateData sd = getData("reference_start"); + + if (sd == null) { + logger.warn("no reference start given."); + return null; + } + + String input = (String)sd.getValue(); + + if (input == null | (input = input.trim()).length() == 0) { + logger.warn("reference start string is empty."); + return null; + } + + try { + return Double.valueOf(input); + } + catch (NumberFormatException nfe) { + logger.warn("reference start string is not numeric."); + } + + return null; + } + + protected double [] getReferenceEndKms() { + + StateData sd = getData("reference_end"); + + if (sd == null) { + logger.warn("no reference end given."); + return null; + } + + String input = (String)sd.getValue(); + + if (input == null | (input = input.trim()).length() == 0) { + logger.warn("reference end string is empty."); + return null; + } + + TDoubleArrayList endKms = new TDoubleArrayList(); + + for (String part: input.split("\\s+")) { + try { + endKms.add(Double.parseDouble(part)); + } + catch (NumberFormatException nfe) { + logger.warn("reference end string is not numeric."); + } + } + + return endKms.toNativeArray(); + } public List<Segment> getSegments() { StateData wqValues = getData("wq_values");
--- a/flys-artifacts/src/main/resources/messages.properties Fri Jan 27 14:21:51 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages.properties Fri Jan 27 15:43:04 2012 +0000 @@ -173,3 +173,6 @@ no.values.given = No values given. cannot.interpolate.wq = Cannot interpolate W/Q. manualpoints = Manual Points + +no.reference.start.km = No reference start station given. +no.reference.end.kms = No reference end station(s) given.
--- a/flys-artifacts/src/main/resources/messages_de.properties Fri Jan 27 14:21:51 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages_de.properties Fri Jan 27 15:43:04 2012 +0000 @@ -174,3 +174,6 @@ cannot.interpolate.wq = W/Q-Wert konnte nicht interpoliert werden. manualpoints = Manuelle Punkte + +no.reference.start.km = Keine Startkilometerstation angegeben. +no.reference.end.kms = Keine Endkilometerstation(en) angegeben.
--- a/flys-artifacts/src/main/resources/messages_de_DE.properties Fri Jan 27 14:21:51 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages_de_DE.properties Fri Jan 27 15:43:04 2012 +0000 @@ -174,3 +174,6 @@ cannot.interpolate.wq = W/Q-Wert konnte nicht interpoliert werden. manualpoints = Manuelle Punkte + +no.reference.start.km = Keine Startkilometerstation angegeben. +no.reference.end.kms = Keine Endkilometerstation(en) angegeben.
--- a/flys-artifacts/src/main/resources/messages_en.properties Fri Jan 27 14:21:51 2012 +0000 +++ b/flys-artifacts/src/main/resources/messages_en.properties Fri Jan 27 15:43:04 2012 +0000 @@ -170,3 +170,7 @@ cannot.interpolate.wq = Cannot interpolate W/Q. manualpoints = Manual Points + +no.reference.start.km = No reference start station given. +no.reference.end.kms = No reference end station(s) given. +