# HG changeset patch # User Sascha L. Teichmann # Date 1329848526 0 # Node ID 72f77b2210c28ac9d4828bcc82eb467ad7465218 # Parent 3f038d54bc870572c29c8c75b35a3a6fc650ba92 FixingsOverview: Added XSL transformation which directly converts the output of the fixings overview service into an HTML representation. flys-artifacts/trunk@4091 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 3f038d54bc87 -r 72f77b2210c2 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Mon Feb 20 19:13:19 2012 +0000 +++ b/flys-artifacts/ChangeLog Tue Feb 21 18:22:06 2012 +0000 @@ -1,3 +1,21 @@ +2012-02-21 Sascha L. Teichmann + + * src/main/java/de/intevation/flys/artifacts/model/FixingsOverview.java: + - Calculate the extent of the river by the extents of the fixings. + Reason: The river Elbe has only has fixings up to km 351. The other half + of the river is empty which results in a sparse looking overview. + - Add the name of the river as name attribute to resulting element. + + * contrib/fixoverview2html.xsl: New. Demo XSL transformation to turn + the output of the overview service directly into HTML. Used in the + client a variant of this script could be used for producing the content + of the assistance widget. Usage: + + $ curl http://localhost:8181/service/fixings-overview \ + -d @fix-overview.xml | \ + xsltproc contrib/fixoverview2html.xsl - \ + > fixings-overview.html + 2012-02-20 Sascha L. Teichmann * src/main/java/de/intevation/flys/artifacts/services/FixingsOverviewService.java: diff -r 3f038d54bc87 -r 72f77b2210c2 flys-artifacts/contrib/fixoverview2html.xsl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/contrib/fixoverview2html.xsl Tue Feb 21 18:22:06 2012 +0000 @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + width: + + + + + %;float:left + + +
+
+
+
+ + + + + +
+ + background: + + green + blue + magenta + red + black + + ;width: + + + + % + ;float:left + + + km + + - + + + +
+
+ + + + + + + + + + + + + + + + + + + + +
+
+ + + + + Fixierungen: + + + + + + + + + + +
diff -r 3f038d54bc87 -r 72f77b2210c2 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 Mon Feb 20 19:13:19 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FixingsOverview.java Tue Feb 21 18:22:06 2012 +0000 @@ -40,16 +40,6 @@ "WHERE" + " name = :name"; - public static final String SQL_RIVER_EXTENT = - "SELECT" + - " MIN(wcv.position) AS start_km," + - " MAX(wcv.position) AS end_km " + - "FROM wst_column_values wcv" + - " JOIN wst_columns wc ON wcv.wst_column_id = wc.id " + - " JOIN wsts w ON wc.wst_id = w.id " + - "WHERE" + - " w.kind = 0 AND w.river_id = :river_id"; - public static final String SQL_GAUGES = "SELECT" + " g.id AS gauge_id," + @@ -153,6 +143,11 @@ return !disjoint(other); } + public void extend(Range other) { + if (other.start < start) start = other.start; + if (other.end > end ) end = other.end; + } + public boolean clip(Range other) { if (disjoint(other)) return false; @@ -539,6 +534,12 @@ } } + public void adjustExtent(Range extent) { + for (Column column: columns) { + extent.extend(column); + } + } + public void loadColumnsQRanges( SQLQuery query, GaugeFinder gaugeFinder @@ -570,6 +571,7 @@ public FixingsOverview() { fixings = new ArrayList(); + extent = new Range(Double.MAX_VALUE, -Double.MAX_VALUE); } public FixingsOverview(String riverName) { @@ -599,26 +601,6 @@ return true; } - protected boolean loadRiverExtent(Session session) { - SQLQuery query = session.createSQLQuery(SQL_RIVER_EXTENT) - .addScalar("start_km", StandardBasicTypes.DOUBLE) - .addScalar("end_km", StandardBasicTypes.DOUBLE); - - query.setInteger("river_id", riverId); - - List list = query.list(); - - if (list.isEmpty()) { - log.warn("River " + riverId + " has no extent."); - return false; - } - - Object [] row = list.get(0); - extent = new Range((Double)row[0], (Double)row[1]); - - return true; - } - protected GaugeFinder loadGauges(Session session) { SQLQuery query = session.createSQLQuery(SQL_GAUGES) .addScalar("gauge_id", StandardBasicTypes.INTEGER) @@ -705,10 +687,15 @@ } } + protected void adjustExtent() { + for (Fixing fixing: fixings) { + fixing.adjustExtent(extent); + } + } + public boolean load(Session session) { - if (!loadRiver(session) - || !loadRiverExtent(session)) { + if (!loadRiver(session)) { return false; } @@ -722,6 +709,9 @@ loadFixings(session); loadFixingsColumns(session); loadFixingsColumnsKmRange(session); + + adjustExtent(); + loadFixingsColumnsQRanges(session, gaugeFinder); return true; @@ -883,6 +873,7 @@ riverElement.setAttribute("from", String.valueOf(extent.start)); riverElement.setAttribute("to", String.valueOf(extent.end)); riverElement.setAttribute("rid", String.valueOf(riverId)); + riverElement.setAttribute("name", riverName); fixingsElement.appendChild(riverElement);