# HG changeset patch # User Sascha L. Teichmann # Date 1365012961 -7200 # Node ID f3b270e5462ed65b12873d40df3766f5df20d11f # Parent b09c095a0b7ece4ec56daf97298f1d156eddb544 Wst Parser: Another attempt to fix the order of the Q ranges. diff -r b09c095a0b7e -r f3b270e5462e flys-backend/src/main/java/de/intevation/flys/importer/ImportRange.java --- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportRange.java Wed Apr 03 17:59:11 2013 +0200 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportRange.java Wed Apr 03 20:16:01 2013 +0200 @@ -40,6 +40,12 @@ return a.compareTo(b); } + public void fixRangesOrder() { + if (compare(a, b) > 0) { + BigDecimal t = a; a = b; b = t; + } + } + public int compareTo(ImportRange other) { int cmp = compare(a, other.a); if (cmp != 0) return cmp; diff -r b09c095a0b7e -r f3b270e5462e flys-backend/src/main/java/de/intevation/flys/importer/ImportWst.java --- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportWst.java Wed Apr 03 17:59:11 2013 +0200 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportWst.java Wed Apr 03 20:16:01 2013 +0200 @@ -98,6 +98,12 @@ session.flush(); } + public void fixRangesOrder() { + for (ImportWstColumn column: columns) { + column.fixRangesOrder(); + } + } + /** Get corresponding mapped wst (from database). */ public Wst getPeer(River river) { if (peer == null) { diff -r b09c095a0b7e -r f3b270e5462e flys-backend/src/main/java/de/intevation/flys/importer/ImportWstColumn.java --- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportWstColumn.java Wed Apr 03 17:59:11 2013 +0200 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportWstColumn.java Wed Apr 03 20:16:01 2013 +0200 @@ -150,5 +150,11 @@ } return peer; } + + public void fixRangesOrder() { + for (ImportWstColumnQRange wcqr: columnQRanges) { + wcqr.fixRangesOrder(); + } + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r b09c095a0b7e -r f3b270e5462e flys-backend/src/main/java/de/intevation/flys/importer/ImportWstColumnQRange.java --- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportWstColumnQRange.java Wed Apr 03 17:59:11 2013 +0200 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportWstColumnQRange.java Wed Apr 03 20:16:01 2013 +0200 @@ -44,6 +44,10 @@ this.qRange = qRange; } + public void fixRangesOrder() { + qRange.fixRangesOrder(); + } + public WstColumnQRange getPeer(River river) { if (peer == null) { WstColumn c = wstColumn.getPeer(river); diff -r b09c095a0b7e -r f3b270e5462e flys-backend/src/main/java/de/intevation/flys/importer/ImportWstQRange.java --- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportWstQRange.java Wed Apr 03 17:59:11 2013 +0200 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportWstQRange.java Wed Apr 03 20:16:01 2013 +0200 @@ -45,6 +45,10 @@ this.q = q; } + public void fixRangesOrder() { + range.fixRangesOrder(); + } + public WstQRange getPeer(River river) { if (peer == null) { Range r = range.getPeer(river); diff -r b09c095a0b7e -r f3b270e5462e flys-backend/src/main/java/de/intevation/flys/importer/parsers/WstParser.java --- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/WstParser.java Wed Apr 03 17:59:11 2013 +0200 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/WstParser.java Wed Apr 03 20:16:01 2013 +0200 @@ -316,11 +316,13 @@ } } - } + } // for all lines in WST file wst.setUnit(new ImportUnit(einheit)); addInterval(minKm, maxKm, aktAbfluesse); + + fixRangesOrder(); } finally { if (in != null) { @@ -329,6 +331,10 @@ } } + protected void fixRangesOrder() { + wst.fixRangesOrder(); + } + protected void addValue(BigDecimal km, BigDecimal w, int index) { if (w != null) { ImportWstColumn column = wst.getColumn(index); @@ -360,10 +366,6 @@ return; } - if (to.compareTo(from) < 0) { - BigDecimal t = from; from = to; to = t; - } - ImportRange range = new ImportRange(from, to); // little workaround to make the q ranges tightly fit.