Mercurial > dive4elements > river
changeset 3421:c44ff50f4970
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
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 19 Jul 2012 21:12:57 +0000 |
parents | 7f7ab030a4e3 |
children | 118fe1cc8cc8 |
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/GaugeFinderFactory.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/GaugeRange.java |
diffstat | 4 files changed, 89 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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 <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/artifacts/model/FixingsOverview.java: + Add a list of gauges which intersect the range of the selected columns: + + <fixings> + <gauges from="..." to="..." name="..."/> + ... + <gauges from="..." to="..." name="..."/> + </fixings> + + * 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 <sascha.teichmann@intevation.de> * src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisCalculation.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<Fixing.Column> 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");
--- 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); }
--- 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<String, Double> 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<String, Double>(); sectors = new ArrayList<Sector>(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: [");