# HG changeset patch # User Sascha L. Teichmann # Date 1342732377 0 # Node ID c44ff50f4970c769e4e19fbdecd0e561f606d85b # Parent 7f7ab030a4e3987dcae67bc61068c031c99719f2 FixA: Added a list of gauges to the output of the fixings overview service which intersect the selected fixings. flys-artifacts/trunk@5075 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 7f7ab030a4e3 -r c44ff50f4970 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Thu Jul 19 16:57:44 2012 +0000 +++ b/flys-artifacts/ChangeLog Thu Jul 19 21:12:57 2012 +0000 @@ -1,3 +1,20 @@ +2012-07-19 Sascha L. Teichmann + + * src/main/java/de/intevation/flys/artifacts/model/FixingsOverview.java: + Add a list of gauges which intersect the range of the selected columns: + + + + ... + + + + * src/main/java/de/intevation/flys/artifacts/model/GaugeRange.java: + Store the name of the gauge, too. + + * src/main/java/de/intevation/flys/artifacts/model/GaugeFinderFactory.java: + Load the names of the gauges from database, too. + 2012-07-19 Sascha L. Teichmann * src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisCalculation.java: diff -r 7f7ab030a4e3 -r c44ff50f4970 flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FixingsOverview.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FixingsOverview.java Thu Jul 19 16:57:44 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FixingsOverview.java Thu Jul 19 21:12:57 2012 +0000 @@ -78,7 +78,6 @@ " wst_column_id = :column_id"; - public static class QRange extends Range { protected double q; @@ -688,6 +687,47 @@ return allColumns; } + protected static Range realRange(List columns) { + Range range = null; + for (Fixing.Column column: columns) { + if (range == null) { + range = new Range(column); + } + else { + range.extend(column); + } + } + return range; + } + + protected Element intersectingGauges(Document document, Range range) { + Element gauges = document.createElement("gauges"); + + if (range == null) { + return gauges; + } + + GaugeFinderFactory gff = GaugeFinderFactory.getInstance(); + + GaugeFinder gf = gff.getGaugeFinder(riverId, isKmUp); + + if (gf == null) { + return gauges; + } + + for (GaugeRange gr: gf.getGauges()) { + if (gr.intersects(range)) { + Element gauge = document.createElement("gauge"); + gauge.setAttribute("from", String.valueOf(gr.getStart())); + gauge.setAttribute("to", String.valueOf(gr.getEnd())); + gauge.setAttribute("name", gr.getName()); + gauges.appendChild(gauge); + } + } + + return gauges; + } + public void generateOverview( Document document, Range range, @@ -706,6 +746,11 @@ fixingsElement.appendChild(riverElement); + fixingsElement.appendChild( + intersectingGauges( + document, + realRange(allColumns))); + SimpleDateFormat df = new SimpleDateFormat(DATE_FORMAT); Element esE = document.createElement("events"); diff -r 7f7ab030a4e3 -r c44ff50f4970 flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/GaugeFinderFactory.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/GaugeFinderFactory.java Thu Jul 19 16:57:44 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/GaugeFinderFactory.java Thu Jul 19 21:12:57 2012 +0000 @@ -28,6 +28,7 @@ public static final String SQL_GAUGES = "SELECT" + " g.id AS gauge_id," + + " g.name AS name," + " r.a AS a," + " r.b AS b " + "FROM gauges g" + @@ -89,6 +90,7 @@ ) { SQLQuery query = session.createSQLQuery(SQL_GAUGES) .addScalar("gauge_id", StandardBasicTypes.INTEGER) + .addScalar("name", StandardBasicTypes.STRING) .addScalar("a", StandardBasicTypes.DOUBLE) .addScalar("b", StandardBasicTypes.DOUBLE); @@ -105,9 +107,10 @@ for (Object [] row: list) { int gaugeId = (Integer)row[0]; - double start = (Double) row[1]; - double end = (Double) row[2]; - GaugeRange gauge = new GaugeRange(start, end, gaugeId); + String name = (String) row[1]; + double start = (Double) row[2]; + double end = (Double) row[3]; + GaugeRange gauge = new GaugeRange(start, end, name, gaugeId); gauges.add(gauge); } diff -r 7f7ab030a4e3 -r c44ff50f4970 flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/GaugeRange.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/GaugeRange.java Thu Jul 19 16:57:44 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/GaugeRange.java Thu Jul 19 21:12:57 2012 +0000 @@ -25,6 +25,8 @@ } } // class Sector + protected String name; + protected int gaugeId; protected Map mainValues; @@ -34,7 +36,17 @@ } public GaugeRange(double start, double end, int gaugeId) { + this(start, end, null, gaugeId); + } + + public GaugeRange( + double start, + double end, + String name, + int gaugeId + ) { super(start, end); + this.name = name; this.gaugeId = gaugeId; mainValues = new HashMap(); sectors = new ArrayList(3); @@ -95,6 +107,14 @@ return sectors.size(); } + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + public String toString() { StringBuilder sb = new StringBuilder("sectors: [");