[Dive4elements-commits] [PATCH] Add kind handling for floodplains and crossectiontracks
Wald Commits
scm-commit at wald.intevation.org
Tue Mar 12 11:30:09 CET 2013
# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1363084150 -3600
# Node ID 88e3473a38467e8b5bb7d99e92c3f1a795515bf5
# Parent 31b464f173925c26f181e79239431a2222838461
Add kind handling for floodplains and crossectiontracks
getFloodplain / getCrossection now return only the "current" one
1 is current
0 is misc
diff -r 31b464f17392 -r 88e3473a3846 flys-backend/contrib/shpimporter/crosssectiontracks.py
--- a/flys-backend/contrib/shpimporter/crosssectiontracks.py Tue Mar 12 10:58:35 2013 +0100
+++ b/flys-backend/contrib/shpimporter/crosssectiontracks.py Tue Mar 12 11:29:10 2013 +0100
@@ -37,6 +37,12 @@
newFeat.SetGeometry(feat.GetGeometryRef())
newFeat.SetField("name", args['name'])
+ if args['path'].lower().endswith("/qps.shp") and \
+ not "sonstige" in args['path'].lower():
+ newFeat.SetField("kind_id", 1) # offical
+ else:
+ newFeat.SetField("kind_id", 0) # misc
+
if self.IsFieldSet(feat, "river_id"):
newFeat.SetField("river_id", feat.GetField("river_id"))
else:
diff -r 31b464f17392 -r 88e3473a3846 flys-backend/contrib/shpimporter/floodplains.py
--- a/flys-backend/contrib/shpimporter/floodplains.py Tue Mar 12 10:58:35 2013 +0100
+++ b/flys-backend/contrib/shpimporter/floodplains.py Tue Mar 12 11:29:10 2013 +0100
@@ -39,6 +39,12 @@
newFeat.SetGeometry(geometry)
newFeat.SetField("name", args['name'])
+ if args['path'].lower().endswith("/talaue.shp") and \
+ not "sonstige" in args['path'].lower():
+ newFeat.SetField("kind_id", 1) # offical
+ else:
+ newFeat.SetField("kind_id", 0) # misc
+
if self.IsFieldSet(feat, "river_id"):
newFeat.SetField("river_id", feat.GetField("river_id"))
else:
diff -r 31b464f17392 -r 88e3473a3846 flys-backend/src/main/java/de/intevation/flys/backend/FLYSCredentials.java
--- a/flys-backend/src/main/java/de/intevation/flys/backend/FLYSCredentials.java Tue Mar 12 10:58:35 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/backend/FLYSCredentials.java Tue Mar 12 11:29:10 2013 +0100
@@ -17,6 +17,7 @@
import de.intevation.flys.model.CrossSectionLine;
import de.intevation.flys.model.CrossSectionPoint;
import de.intevation.flys.model.CrossSectionTrack;
+import de.intevation.flys.model.CrossSectionTrackKind;
import de.intevation.flys.model.DGM;
import de.intevation.flys.model.Depth;
import de.intevation.flys.model.DischargeTable;
@@ -28,6 +29,7 @@
import de.intevation.flys.model.Fixpoint;
import de.intevation.flys.model.Floodmaps;
import de.intevation.flys.model.Floodplain;
+import de.intevation.flys.model.FloodplainKind;
import de.intevation.flys.model.FlowVelocityMeasurement;
import de.intevation.flys.model.FlowVelocityMeasurementValue;
import de.intevation.flys.model.FlowVelocityModel;
@@ -134,6 +136,7 @@
CrossSectionLine.class,
CrossSectionPoint.class,
CrossSectionTrack.class,
+ CrossSectionTrackKind.class,
Depth.class,
DGM.class,
DischargeTable.class,
@@ -144,6 +147,7 @@
FedState.class,
Fixpoint.class,
Floodplain.class,
+ FloodplainKind.class,
Floodmaps.class,
FlowVelocityMeasurement.class,
FlowVelocityMeasurementValue.class,
diff -r 31b464f17392 -r 88e3473a3846 flys-backend/src/main/java/de/intevation/flys/model/CrossSectionTrack.java
--- a/flys-backend/src/main/java/de/intevation/flys/model/CrossSectionTrack.java Tue Mar 12 10:58:35 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/model/CrossSectionTrack.java Tue Mar 12 11:29:10 2013 +0100
@@ -152,6 +152,7 @@
Query query = session.createQuery(
"from CrossSectionTrack where river.name =:river " +
+ "and kind_id = 1 " +
"order by abs( km - :mykm)");
query.setParameter("river", river);
query.setParameter("mykm", new BigDecimal(km));
diff -r 31b464f17392 -r 88e3473a3846 flys-backend/src/main/java/de/intevation/flys/model/CrossSectionTrackKind.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/model/CrossSectionTrackKind.java Tue Mar 12 11:29:10 2013 +0100
@@ -0,0 +1,45 @@
+package de.intevation.flys.model;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+ at Entity
+ at Table(name = "cross_section_track_kinds")
+public class CrossSectionTrackKind implements Serializable {
+ private Integer id;
+ private String name;
+
+ @Id
+ @Column(name = "id")
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ /**
+ * Get name.
+ *
+ * @return The name of the Cross section kind as String.
+ */
+ @Column(name = "name")
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Set name.
+ *
+ * @param name the value to set.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+}
+
diff -r 31b464f17392 -r 88e3473a3846 flys-backend/src/main/java/de/intevation/flys/model/Floodplain.java
--- a/flys-backend/src/main/java/de/intevation/flys/model/Floodplain.java Tue Mar 12 10:58:35 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/model/Floodplain.java Tue Mar 12 11:29:10 2013 +0100
@@ -24,11 +24,13 @@
public class Floodplain
implements Serializable
{
- private Integer id;
+ private Integer id;
- private River river;
+ private FloodplainKind kind;
- private Polygon geom;
+ private River river;
+
+ private Polygon geom;
public Floodplain() {
@@ -55,6 +57,16 @@
this.river = river;
}
+ @OneToOne
+ @JoinColumn(name = "kind_id")
+ public FloodplainKind getKind() {
+ return kind;
+ }
+
+ public void setKind(FloodplainKind kind) {
+ this.kind = kind;
+ }
+
@Column(name = "geom")
@Type(type = "org.hibernatespatial.GeometryUserType")
public Polygon getGeom() {
@@ -69,8 +81,10 @@
public static Floodplain getFloodplain(String river) {
Session session = SessionHolder.HOLDER.get();
+ // kind_id 0 -> Offical
+ // kind_id 1 -> Misc.
Query query = session.createQuery(
- "from Floodplain where river.name =:river");
+ "from Floodplain where river.name =:river and kind_id=1");
query.setParameter("river", river);
List<Floodplain> result = query.list();
diff -r 31b464f17392 -r 88e3473a3846 flys-backend/src/main/java/de/intevation/flys/model/FloodplainKind.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/model/FloodplainKind.java Tue Mar 12 11:29:10 2013 +0100
@@ -0,0 +1,45 @@
+package de.intevation.flys.model;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+ at Entity
+ at Table(name = "floodplain_kinds")
+public class FloodplainKind implements Serializable {
+ private Integer id;
+ private String name;
+
+ @Id
+ @Column(name = "id")
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ /**
+ * Get name.
+ *
+ * @return The name of the Floodplain Kind as String.
+ */
+ @Column(name = "name")
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Set name.
+ *
+ * @param name the value to set.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+}
+
More information about the Dive4elements-commits
mailing list