Mercurial > dive4elements > river
changeset 5707:53134ccc4a64
Backend: Import Flow Velocity Model: Use unique km for station.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Mon, 15 Apr 2013 15:45:18 +0200 |
parents | 8a198db28de0 |
children | e8469247dc6b |
files | flys-backend/src/main/java/de/intevation/flys/importer/ImportFlowVelocityModelValue.java flys-backend/src/main/java/de/intevation/flys/importer/parsers/FlowVelocityModelParser.java |
diffstat | 2 files changed, 17 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportFlowVelocityModelValue.java Mon Apr 15 12:56:43 2013 +0200 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportFlowVelocityModelValue.java Mon Apr 15 15:45:18 2013 +0200 @@ -49,7 +49,7 @@ Query query = session.createQuery( "from FlowVelocityModelValue where " + " flowVelocity=:model and " + - " station=:station" + " station between :station - 0.00001 and :station + 0.00001" ); query.setParameter("model", model);
--- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/FlowVelocityModelParser.java Mon Apr 15 12:56:43 2013 +0200 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/FlowVelocityModelParser.java Mon Apr 15 15:45:18 2013 +0200 @@ -8,6 +8,7 @@ import java.text.ParseException; import java.util.ArrayList; import java.util.List; +import java.util.TreeSet; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -16,6 +17,7 @@ import de.intevation.flys.importer.ImportDischargeZone; import de.intevation.flys.importer.ImportFlowVelocityModel; import de.intevation.flys.importer.ImportFlowVelocityModelValue; +import de.intevation.flys.utils.EpsilonComparator; public class FlowVelocityModelParser extends LineParser { @@ -54,9 +56,12 @@ protected String description; + protected TreeSet<Double> kmExists; + public FlowVelocityModelParser() { models = new ArrayList<ImportFlowVelocityModel>(); + kmExists = new TreeSet<Double>(EpsilonComparator.CMP); } @@ -231,7 +236,15 @@ } try { - double km = nf.parse(cols[0]).doubleValue(); + double km = nf.parse(cols[0]).doubleValue(); + + Double key = Double.valueOf(km); + + if (kmExists.contains(key)) { + log.warn("duplicate stattion '" + km + "': -> ignored"); + return; + } + double q = nf.parse(cols[1]).doubleValue(); double total = nf.parse(cols[2]).doubleValue(); double main = nf.parse(cols[3]).doubleValue(); @@ -244,6 +257,8 @@ new BigDecimal(main), new BigDecimal(stress) )); + + kmExists.add(key); } catch (ParseException pe) { log.warn("Unparseable flow velocity values:", pe);