[PATCH] Added datacage select and chart display for river bed collision counts loaded from database
Wald Commits
scm-commit at wald.intevation.org
Mon Jun 4 17:32:08 CEST 2018
# HG changeset patch
# User mschaefer
# Date 1528126311 -7200
# Node ID 623b51bf03d7fd4222c54dfadd588b2a504d43ad
# Parent edc3958b3ed2e5df339134d28764635fb31dc5e0
Added datacage select and chart display for river bed collision counts loaded from database
diff -r edc3958b3ed2 -r 623b51bf03d7 artifacts/doc/conf/conf.xml
--- a/artifacts/doc/conf/conf.xml Mon Jun 04 12:50:39 2018 +0200
+++ b/artifacts/doc/conf/conf.xml Mon Jun 04 17:31:51 2018 +0200
@@ -202,6 +202,9 @@
<artifact-factory name="infrastructuref" description="Factory to create an artifact used in sinfo datacage."
ttl="3600000"
artifact="org.dive4elements.river.artifacts.sinfo.flood_duration.InfrastructureArtifact">org.dive4elements.artifactdatabase.DefaultArtifactFactory</artifact-factory>
+ <artifact-factory name="collisionf" description="Factory to create an artifact used in sinfo datacage."
+ ttl="3600000"
+ artifact="org.dive4elements.river.artifacts.sinfo.collision.CollisionArtifact">org.dive4elements.artifactdatabase.DefaultArtifactFactory</artifact-factory>
</artifact-factories>
diff -r edc3958b3ed2 -r 623b51bf03d7 artifacts/doc/conf/generators/longitudinal-diagram-defaults.xml
--- a/artifacts/doc/conf/generators/longitudinal-diagram-defaults.xml Mon Jun 04 12:50:39 2018 +0200
+++ b/artifacts/doc/conf/generators/longitudinal-diagram-defaults.xml Mon Jun 04 17:31:51 2018 +0200
@@ -18,6 +18,7 @@
<axis name="tkhAxis" include-zero="true" />
<axis name="flowdepthDevelopmentAxis"/>
<axis name="flowdepthDevelopmentPerYearAxis"/>
+ <axis name="countAxis" include-zero="true"/>
<domain-axis key="chart.longitudinal.section.xaxis.label" default="Fluss-Km" inverted="org.dive4elements.river.exports.IsKmUpEvaluator()">
<arg expr="artifact.river"/>
@@ -63,6 +64,8 @@
<processor class="org.dive4elements.river.artifacts.sinfo.common.PredefinedDepthEvolPerYearProcessor" axis="flowdepthDevelopmentPerYearAxis"/>
<processor class="org.dive4elements.river.artifacts.sinfo.common.PredefinedFlowDepthProcessor" axis="flowdepthAxis"/>
<processor class="org.dive4elements.river.artifacts.sinfo.common.InfrastructureHeightProcessor" axis="W"/>
+ <processor class="org.dive4elements.river.artifacts.sinfo.common.CollisionCountProcessor" axis="countAxis"/>
+ <processor class="org.dive4elements.river.artifacts.sinfo.common.CollisionGaugeWProcessor" axis="W"/>
<chartextender class="org.dive4elements.river.artifacts.sinfo.flowdepth.FlowDepthChartExtender" />
</longitudinal-defaults>
\ No newline at end of file
diff -r edc3958b3ed2 -r 623b51bf03d7 artifacts/doc/conf/meta-data.xml
--- a/artifacts/doc/conf/meta-data.xml Mon Jun 04 12:50:39 2018 +0200
+++ b/artifacts/doc/conf/meta-data.xml Mon Jun 04 17:31:51 2018 +0200
@@ -1614,6 +1614,10 @@
<dc:call-macro name="sinfo_predefined_flowdepth-m"/>
</sinfo_predefined_flowdepths>
+ <sinfo_collisions>
+ <dc:call-macro name="sinfo_collisions"/>
+ </sinfo_collisions>
+
<sinfo_predefined_channel>
<dc:call-macro name="sinfo_predefined_channel"/>
</sinfo_predefined_channel>
@@ -3579,5 +3583,27 @@
</dc:context>
</dc:macro>
+ <!-- collisions imported from CSV-files for S-INFO -->
+ <dc:macro name="sinfo_collisions">
+ <dc:context>
+ <dc:statement>
+ SELECT s.id AS id, MIN(s.filename) AS seriesname, MIN(v.station) AS km_min, MAX(v.station) AS km_max, MIN(s.year) AS year,
+ MIN(s.filename) || '<br />'
+ || MIN(s.kmrange_info) || '<br />'
+ || MIN(s.year) || '<br />' AS info
+ FROM collision s INNER JOIN collision_values v ON s.id=v.collision_id
+ WHERE (s.river_id=${river_id})
+ AND (v.station BETWEEN ${fromkm}-0.0001 AND ${tokm}+0.0001)
+ GROUP BY s.id
+ ORDER BY MIN(s.year) ASC;
+ </dc:statement>
+ <dc:if test="dc:has-result()">
+ <dc:for-each>
+ <collisionseries name="{$seriesname}" ids="collisionx-{$id}-{$year}-{${$seriesname}" factory="collisionf" target_out="{$out}" info="{$info}"/>
+ </dc:for-each>
+ </dc:if>
+ </dc:context>
+ </dc:macro>
+
</datacage>
</dc:template>
\ No newline at end of file
diff -r edc3958b3ed2 -r 623b51bf03d7 artifacts/doc/conf/themes.xml
--- a/artifacts/doc/conf/themes.xml Mon Jun 04 12:50:39 2018 +0200
+++ b/artifacts/doc/conf/themes.xml Mon Jun 04 17:31:51 2018 +0200
@@ -448,5 +448,7 @@
<mapping from="sinfo_facet_predefined_depthevol_per_year" to="SInfoPredefinedDepthEvolPerYear" />
<mapping from="sinfo_facet_predefined_flowdepth" to="SInfoPredefinedFlowDepth" />
<mapping from="sinfo_facet_infrastructure_height" to="SInfoInfrastructureHeight" />
+ <mapping from="sinfo_facet_collision_count" to="SInfoCollisionCount" />
+ <mapping from="sinfo_facet_collision_gaugew" to="SInfoCollisionGaugeW" />
</mappings>
</themes>
\ No newline at end of file
diff -r edc3958b3ed2 -r 623b51bf03d7 artifacts/doc/conf/themes/default.xml
--- a/artifacts/doc/conf/themes/default.xml Mon Jun 04 12:50:39 2018 +0200
+++ b/artifacts/doc/conf/themes/default.xml Mon Jun 04 17:31:51 2018 +0200
@@ -3054,4 +3054,22 @@
<field name="pointcolor" type="Color" display="Punktfarbe" default="0, 192, 0" />
</fields>
</theme>
+ <theme name="SInfoCollisionCount">
+ <inherits>
+ <inherit from="LongitudinalSectionPoints" />
+ </inherits>
+ <fields>
+ <field name="pointsize" type="int" display="Punktdicke" default="3" />
+ <field name="pointcolor" type="Color" display="Punktfarbe" default="48, 96, 255" />
+ </fields>
+ </theme>
+ <theme name="SInfoCollisionGaugeW">
+ <inherits>
+ <inherit from="LongitudinalSectionPoints" />
+ </inherits>
+ <fields>
+ <field name="pointsize" type="int" display="Punktdicke" default="3" />
+ <field name="pointcolor" type="Color" display="Linienfarbe" default="64, 64, 128" />
+ </fields>
+ </theme>
</themegroup>
\ No newline at end of file
diff -r edc3958b3ed2 -r 623b51bf03d7 artifacts/doc/conf/themes/second.xml
--- a/artifacts/doc/conf/themes/second.xml Mon Jun 04 12:50:39 2018 +0200
+++ b/artifacts/doc/conf/themes/second.xml Mon Jun 04 17:31:51 2018 +0200
@@ -3041,4 +3041,22 @@
<field name="pointcolor" type="Color" display="Punktfarbe" default="0, 128, 0" />
</fields>
</theme>
+ <theme name="SInfoCollisionCount">
+ <inherits>
+ <inherit from="LongitudinalSectionPoints" />
+ </inherits>
+ <fields>
+ <field name="pointsize" type="int" display="Punktdicke" default="3" />
+ <field name="pointcolor" type="Color" display="Punktfarbe" default="48, 96, 192" />
+ </fields>
+ </theme>
+ <theme name="SInfoCollisionGaugeW">
+ <inherits>
+ <inherit from="LongitudinalSectionPoints" />
+ </inherits>
+ <fields>
+ <field name="pointsize" type="int" display="Punktdicke" default="3" />
+ <field name="pointcolor" type="Color" display="Linienfarbe" default="64, 64, 96" />
+ </fields>
+ </theme>
</themegroup>
\ No newline at end of file
diff -r edc3958b3ed2 -r 623b51bf03d7 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/SInfoI18NStrings.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/SInfoI18NStrings.java Mon Jun 04 12:50:39 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/SInfoI18NStrings.java Mon Jun 04 17:31:51 2018 +0200
@@ -79,4 +79,8 @@
String CSV_INFRASTRUCTURE_HEIGHT_HEADER = "sinfo.export.csv.header.infrastructure.height";
+ String CSV_COLLISION_COUNT_HEADER = "sinfo.export.csv.header.collision.count";
+
+ String CSV_COLLISION_GAUGEW_HEADER = "sinfo.export.csv.header.collision.gaugew";
+
}
\ No newline at end of file
diff -r edc3958b3ed2 -r 623b51bf03d7 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/SInfoResultType.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/SInfoResultType.java Mon Jun 04 12:50:39 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/SInfoResultType.java Mon Jun 04 17:31:51 2018 +0200
@@ -465,4 +465,34 @@
}
};
+ public static final SInfoResultType collisionCount = new SInfoResultType(I18NStrings.UNIT_NONE, SInfoI18NStrings.CSV_COLLISION_COUNT_HEADER) {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String exportValue(final CallContext context, final Object value) {
+ final double doubleValue = asDouble(value);
+ return exportDoubleValue(context, doubleValue);
+ }
+
+ @Override
+ protected NumberFormat createFormatter(final CallContext context) {
+ return Formatter.getCollisionCount(context);
+ }
+ };
+
+ public static final SInfoResultType collisionGaugeW = new SInfoResultType(I18NStrings.UNIT_CM, SInfoI18NStrings.CSV_COLLISION_GAUGEW_HEADER) {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String exportValue(final CallContext context, final Object value) {
+ final double doubleValue = asDouble(value);
+ return exportDoubleValue(context, doubleValue);
+ }
+
+ @Override
+ protected NumberFormat createFormatter(final CallContext context) {
+ return Formatter.getCollisionGaugeW(context);
+ }
+ };
+
}
\ No newline at end of file
diff -r edc3958b3ed2 -r 623b51bf03d7 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/InfrastructureQueryCalculationResult.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/InfrastructureQueryCalculationResult.java Mon Jun 04 12:50:39 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/InfrastructureQueryCalculationResult.java Mon Jun 04 17:31:51 2018 +0200
@@ -15,7 +15,7 @@
import org.dive4elements.river.artifacts.sinfo.common.AbstractSInfoCalculationResult;
/**
- * Contains the results of a database query of a river channel width series
+ * Contains the results of a database query of a river infrastructure series
*
* @author Matthias Schäfer
*/
diff -r edc3958b3ed2 -r 623b51bf03d7 artifacts/src/main/java/org/dive4elements/river/utils/Formatter.java
--- a/artifacts/src/main/java/org/dive4elements/river/utils/Formatter.java Mon Jun 04 12:50:39 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/utils/Formatter.java Mon Jun 04 17:31:51 2018 +0200
@@ -414,4 +414,12 @@
public static NumberFormat getInfrastructureHeight(final CallContext context) {
return getFormatter(context.getMeta(), 2, 2);
}
+
+ public static NumberFormat getCollisionCount(final CallContext context) {
+ return getFormatter(context.getMeta(), 0, 0);
+ }
+
+ public static NumberFormat getCollisionGaugeW(final CallContext context) {
+ return getFormatter(context.getMeta(), 0, 2); // cm
+ }
}
\ No newline at end of file
diff -r edc3958b3ed2 -r 623b51bf03d7 artifacts/src/main/resources/messages.properties
--- a/artifacts/src/main/resources/messages.properties Mon Jun 04 12:50:39 2018 +0200
+++ b/artifacts/src/main/resources/messages.properties Mon Jun 04 17:31:51 2018 +0200
@@ -1089,6 +1089,11 @@
sinfo.export.csv.header.infrastructure.height = Infrastrukturh\u00f6he
infrastructure.height.title = Geod. H\u00f6he
+sinfo.export.csv.header.collision.count = Anzahl der Grundber\u00fchrungen
+collision.count.title = Anzahl Grundber\u00fchrungen {0}
+sinfo.export.csv.header.collision.gaugew = W am Pegel
+collision.gaugew.title = W am Pegel {0}
+
bundu_bezugswst = Bezugswasserst\u00e4nde
bundu_analysis = Fixinganalysis
bundu_vollmer = relocated Waterlevel Calculation
diff -r edc3958b3ed2 -r 623b51bf03d7 artifacts/src/main/resources/messages_de.properties
--- a/artifacts/src/main/resources/messages_de.properties Mon Jun 04 12:50:39 2018 +0200
+++ b/artifacts/src/main/resources/messages_de.properties Mon Jun 04 17:31:51 2018 +0200
@@ -1089,6 +1089,11 @@
sinfo.export.csv.header.infrastructure.height = Infrastrukturh\u00f6he
infrastructure.height.title = Geod. H\u00f6he
+sinfo.export.csv.header.collision.count = Anzahl der Grundber\u00fchrungen
+collision.count.title = Anzahl Grundber\u00fchrungen {0}
+sinfo.export.csv.header.collision.gaugew = W am Pegel
+collision.gaugew.title = W am Pegel {0}
+
bundu_bezugswst = Bezugswasserst\u00e4nde
bundu_analysis = Fixierungsanalyse
bundu_vollmer = ausgelagerte Wasserspiegellage
diff -r edc3958b3ed2 -r 623b51bf03d7 backend/src/main/java/org/dive4elements/river/model/sinfo/Collision.java
--- a/backend/src/main/java/org/dive4elements/river/model/sinfo/Collision.java Mon Jun 04 12:50:39 2018 +0200
+++ b/backend/src/main/java/org/dive4elements/river/model/sinfo/Collision.java Mon Jun 04 17:31:51 2018 +0200
@@ -25,7 +25,10 @@
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
+import org.dive4elements.river.backend.SessionHolder;
import org.dive4elements.river.model.River;
+import org.hibernate.Query;
+import org.hibernate.Session;
/**
* Hibernate binding for the DB table collision
@@ -145,4 +148,14 @@
public void addValue(final CollisionValue value) {
this.values.add(value);
}
+
+ /**
+ * Get data series by id
+ */
+ public static Collision getSeries(final int id) {
+ final Session session = SessionHolder.HOLDER.get();
+ final Query query = session.createQuery("FROM Collision WHERE (id=:id)");
+ query.setParameter("id", id);
+ return (Collision) query.list().get(0);
+ }
}
\ No newline at end of file
diff -r edc3958b3ed2 -r 623b51bf03d7 backend/src/main/java/org/dive4elements/river/model/sinfo/CollisionAggregateValue.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/backend/src/main/java/org/dive4elements/river/model/sinfo/CollisionAggregateValue.java Mon Jun 04 17:31:51 2018 +0200
@@ -0,0 +1,125 @@
+/* Copyright (C) 2017 by Bundesanstalt für Gewässerkunde
+ * Software engineering by
+ * Björnsen Beratende Ingenieure GmbH
+ * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt
+ *
+ * This file is Free Software under the GNU AGPL (>=v3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out the
+ * documentation coming with Dive4Elements River for details.
+ */
+
+package org.dive4elements.river.model.sinfo;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.dive4elements.river.backend.SessionHolder;
+import org.hibernate.SQLQuery;
+import org.hibernate.Session;
+import org.hibernate.type.StandardBasicTypes;
+
+
+/**
+ * Aggregation of collision_values
+ *
+ * @author Matthias Schäfer
+ *
+ */
+public class CollisionAggregateValue implements Serializable {
+
+ /***** FIELDS *****/
+
+ private static final long serialVersionUID = 1;
+
+ private Collision parent;
+
+ private double station;
+
+ // private CollisionType collisionType;
+
+ private Date minDate;
+
+ private Date maxDate;
+
+ private int count;
+
+ private double gaugeW;
+
+
+ /***** CONSTRUCTORS *****/
+
+ public CollisionAggregateValue() {
+ }
+
+ public CollisionAggregateValue(final Collision collision, final double station, final Date minDate, final Date maxDate, final int count,
+ final double gaugeW) {
+ this.parent = collision;
+ this.station = station;
+ // this.collisionType = collisionType;
+ this.minDate = minDate;
+ this.maxDate = maxDate;
+ this.count = count;
+ this.gaugeW = gaugeW;
+ }
+
+
+ /***** METHODS *****/
+
+ public int getCount() {
+ return this.count;
+ }
+
+ public Collision getCollision() {
+ return this.parent;
+ }
+
+ public double getStation() {
+ return this.station;
+ }
+
+ // public CollisionType getCollisionType() {
+ // return this.collisionType;
+ // }
+
+ public Date getMinDate() {
+ return this.minDate;
+ }
+
+ public Date getMaxDate() {
+ return this.maxDate;
+ }
+
+ public Double getGaugeW() {
+ return this.gaugeW;
+ }
+
+ /**
+ * Selects the collision aggregate values of a data series in a km range from the database
+ */
+ public static List<CollisionAggregateValue> getValuesByKm(final Collision parent, final double kmLo, final double kmHi) {
+ final Session session = SessionHolder.HOLDER.get();
+ final SQLQuery query = session.createSQLQuery("SELECT FLOOR(station+0.4999) AS station, COUNT(*) AS count,"
+ + " MIN(event_date) AS date_min, MAX(event_date) AS date_max,"
+ + " AVG(gauge_w) AS gauge_w"
+ + " FROM collision_values v INNER JOIN collision s ON v.collision_id=s.id"
+ + " WHERE (collision_id=:parent)"
+ + " AND (station BETWEEN (:kmLo - 0.0001) AND (:kmHi + 0.0001))"
+ + " GROUP BY FLOOR(station+0.4999);").addScalar("station", StandardBasicTypes.DOUBLE)
+ .addScalar("count", StandardBasicTypes.INTEGER).addScalar("date_min", StandardBasicTypes.DATE)
+ .addScalar("date_max", StandardBasicTypes.DATE).addScalar("gauge_w", StandardBasicTypes.DOUBLE);
+ query.setInteger("parent", parent.getId());
+ query.setDouble("kmLo", new Double(kmLo));
+ query.setDouble("kmHi", new Double(kmHi));
+ final List<CollisionAggregateValue> values = new ArrayList();
+ final List<Object[]> rows = query.list();
+ if (rows != null) {
+ for (int i = 0; i <= rows.size() - 1; i++) {
+ values.add(new CollisionAggregateValue(parent, (double) rows.get(i)[0], (Date) rows.get(i)[2], (Date) rows.get(i)[3],
+ (int) rows.get(i)[1], (double) rows.get(i)[4]));
+ }
+ }
+ return values;
+ }
+}
diff -r edc3958b3ed2 -r 623b51bf03d7 backend/src/main/java/org/dive4elements/river/model/sinfo/CollisionValue.java
--- a/backend/src/main/java/org/dive4elements/river/model/sinfo/CollisionValue.java Mon Jun 04 12:50:39 2018 +0200
+++ b/backend/src/main/java/org/dive4elements/river/model/sinfo/CollisionValue.java Mon Jun 04 17:31:51 2018 +0200
@@ -12,6 +12,7 @@
import java.io.Serializable;
import java.util.Date;
+import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
@@ -23,6 +24,10 @@
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
+import org.dive4elements.river.backend.SessionHolder;
+import org.hibernate.Query;
+import org.hibernate.Session;
+
/**
* Hibernate binding for the DB table collision_values
@@ -146,4 +151,17 @@
public void setGaugeW(final Double gaugeW) {
this.gaugeW = gaugeW;
}
+
+ /**
+ * Selects the collision values of a data series in a km range from the database
+ */
+ public static List<CollisionValue> getValues(final Collision parent, final double kmLo, final double kmHi) {
+ final Session session = SessionHolder.HOLDER.get();
+ final Query query = session.createQuery("FROM CollisionValue WHERE (collision=:parent)"
+ + " AND (station >= :kmLo - 0.0001) AND (station <= :kmHi + 0.0001)");
+ query.setParameter("parent", parent);
+ query.setParameter("kmLo", new Double(kmLo));
+ query.setParameter("kmHi", new Double(kmHi));
+ return query.list();
+ }
}
diff -r edc3958b3ed2 -r 623b51bf03d7 gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java Mon Jun 04 12:50:39 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java Mon Jun 04 17:31:51 2018 +0200
@@ -1503,6 +1503,8 @@
String sinfo_infrastructure();
+ String sinfo_collisions();
+
String uinfo();
String uinfo_salix_line_export();
diff -r edc3958b3ed2 -r 623b51bf03d7 gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties Mon Jun 04 12:50:39 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties Mon Jun 04 17:31:51 2018 +0200
@@ -805,6 +805,8 @@
sinfo_infrastructure = Infrastrukturen BWaStr
+sinfo_collisions = Grundber\u00fchrungen
+
uinfo = U-INFO
uinfo_inundation_duration_export = \u00dcberflutungsdauern Export
uinfo_salix_line_export = Salix-Linie Export
diff -r edc3958b3ed2 -r 623b51bf03d7 gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties Mon Jun 04 12:50:39 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties Mon Jun 04 17:31:51 2018 +0200
@@ -805,6 +805,8 @@
sinfo_infrastructure = Infrastrukturen BWaStr
+sinfo_collisions = Grundber\u00fchrungen
+
uinfo = U-INFO
uinfo_inundation_duration_export = \u00dcberflutungsdauern Export
uinfo_salix_line_export = Salix-Linie Export
More information about the Dive4Elements-commits
mailing list