# 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 @@
org.dive4elements.artifactdatabase.DefaultArtifactFactory
+ org.dive4elements.artifactdatabase.DefaultArtifactFactory
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 @@
+
@@ -63,6 +64,8 @@
+
+
\ 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 @@
+
+
+
+
@@ -3579,5 +3583,27 @@
+
+
+
+
+ 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;
+
+
+
+
+
+
+
+
+
\ 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 @@
+
+
\ 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 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ 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 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ 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 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 values = new ArrayList();
+ final List