changeset 5242:88e3473a3846 2.9.12

Add kind handling for floodplains and crossectiontracks getFloodplain / getCrossection now return only the "current" one 1 is current 0 is misc
author Andre Heinecke <aheinecke@intevation.de>
date Tue, 12 Mar 2013 11:29:10 +0100
parents 31b464f17392
children 2e519b08cff3
files flys-backend/contrib/shpimporter/crosssectiontracks.py flys-backend/contrib/shpimporter/floodplains.py flys-backend/src/main/java/de/intevation/flys/backend/FLYSCredentials.java flys-backend/src/main/java/de/intevation/flys/model/CrossSectionTrack.java flys-backend/src/main/java/de/intevation/flys/model/CrossSectionTrackKind.java flys-backend/src/main/java/de/intevation/flys/model/Floodplain.java flys-backend/src/main/java/de/intevation/flys/model/FloodplainKind.java
diffstat 7 files changed, 125 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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:
--- 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:
--- 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,
--- 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));
--- /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;
+
+@Entity
+@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;
+    }
+}
+
--- 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();
--- /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;
+
+@Entity
+@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;
+    }
+}
+

http://dive4elements.wald.intevation.org