Mercurial > dive4elements > river
changeset 3401:086326be721c
FixA: Overview: classify Q ranges by intersecting gauges.
flys-artifacts/trunk@5042 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 18 Jul 2012 14:44:29 +0000 |
parents | 2eea676ba48f |
children | 0336132ec9db |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FixingsOverview.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/GaugeFinder.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Range.java |
diffstat | 4 files changed, 46 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Wed Jul 18 13:11:41 2012 +0000 +++ b/flys-artifacts/ChangeLog Wed Jul 18 14:44:29 2012 +0000 @@ -1,3 +1,14 @@ +2012-07-18 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/artifacts/model/FixingsOverview.java: + Classify each discharge range by the gauges which intersect it. + + * src/main/java/de/intevation/flys/artifacts/model/Range.java: + Added convinience constructor. + + * src/main/java/de/intevation/flys/artifacts/model/GaugeFinder.java: + Added method to return all gauges. + 2012-07-18 Felix Wolfsteller <felix.wolfsteller@intevation.de> * src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FixingsOverview.java Wed Jul 18 13:11:41 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FixingsOverview.java Wed Jul 18 14:44:29 2012 +0000 @@ -105,6 +105,10 @@ sector = other.sector; } + public SectorRange(Range range) { + super(range); + } + public SectorRange(double start, double end, int sector) { super(start, end); this.sector = sector; @@ -114,6 +118,10 @@ return sector; } + public void setSector(int sector) { + this.sector = sector; + } + public boolean enlarge(SectorRange other) { if (sector == other.sector && Math.abs(end-other.start) < EPSILON) { @@ -207,17 +215,24 @@ return -1; } - public void buildSectors(GaugeRange gauge, List<QRange> qRanges) { - + public void buildSectors( + GaugeFinder gaugeFinder, + List<QRange> qRanges + ) { for (QRange qRange: qRanges) { - SectorRange sector = new SectorRange( - qRange.start, qRange.end, - gauge.classify(qRange.q)); - if (sectors.isEmpty() - || !sectors.get(sectors.size()-1).enlarge(sector)) { - sectors.add(sector); - } - } + for (GaugeRange gRange: gaugeFinder.getGauges()) { + SectorRange sector = new SectorRange(qRange); + if (!sector.clip(gRange)) { + continue; + } + sector.setSector(gRange.classify(qRange.q)); + + if (sectors.isEmpty() + || !sectors.get(sectors.size()-1).enlarge(sector)) { + sectors.add(sector); + } + } // for all gauges + } // for all Q ranges } public void loadKmRange(SQLQuery query) { @@ -254,14 +269,7 @@ } } - GaugeRange gauge = gaugeFinder.find(this); - - if (gauge != null) { - buildSectors(gauge, qRanges); - } - else { - log.warn("No gauge found for column " + columnId + "."); - } + buildSectors(gaugeFinder, qRanges); } } // class Column
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/GaugeFinder.java Wed Jul 18 13:11:41 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/GaugeFinder.java Wed Jul 18 14:44:29 2012 +0000 @@ -84,6 +84,10 @@ return null; } + public List<GaugeRange> getGauges() { + return gauges; + } + public boolean loadDischargeSectors(Session session, int riverId) { SQLQuery query = session.createSQLQuery(SQL_DISCHARGE_SECTORS)
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Range.java Wed Jul 18 13:11:41 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Range.java Wed Jul 18 14:44:29 2012 +0000 @@ -12,6 +12,11 @@ public Range() { } + public Range(Range other) { + start = other.start; + end = other.end; + } + public Range(double start, double end) { this.start = start; this.end = end;