# HG changeset patch # User Sascha L. Teichmann # Date 1327678984 0 # Node ID 05984871520f6e3e7513128e4013854191e1c889 # Parent 73490b828a9022d42a7e8a12281cf6a31d64635b Call the "Bezugslinienverfahren" from the WINFOArtifact. flys-artifacts/trunk@3809 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 73490b828a90 -r 05984871520f flys-artifacts/ChangeLog --- 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 + + * 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 * doc/conf/themes.xml: Better theme for manual points. diff -r 73490b828a90 -r 05984871520f flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java --- 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 getSegments() { StateData wqValues = getData("wq_values"); diff -r 73490b828a90 -r 05984871520f flys-artifacts/src/main/resources/messages.properties --- 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. diff -r 73490b828a90 -r 05984871520f flys-artifacts/src/main/resources/messages_de.properties --- 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. diff -r 73490b828a90 -r 05984871520f flys-artifacts/src/main/resources/messages_de_DE.properties --- 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. diff -r 73490b828a90 -r 05984871520f flys-artifacts/src/main/resources/messages_en.properties --- 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. +