[Dive4elements-commits] [PATCH 1 of 2] Add jetties importer

Wald Commits scm-commit at wald.intevation.org
Wed Mar 20 17:58:50 CET 2013


# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1363798553 -3600
# Node ID d086ce6c13d381bb94624c26cf4662c4a7f6a45d
# Parent  f1009aa7dcd1d87ca3bdbe9bf87e2ebab45ee938
Add jetties importer

diff -r f1009aa7dcd1 -r d086ce6c13d3 flys-backend/contrib/run_geo.sh
--- a/flys-backend/contrib/run_geo.sh	Wed Mar 20 17:20:19 2013 +0100
+++ b/flys-backend/contrib/run_geo.sh	Wed Mar 20 17:55:53 2013 +0100
@@ -26,6 +26,7 @@
 SKIP_CATCHMENTS=0
 SKIP_UESG=0
 SKIP_DGM=0
+SKIP_JETTIES=0
 
 # There should be no need to change anything below this line
 
@@ -61,4 +62,5 @@
     --skip_uesgs $SKIP_UESG \
     --skip_hws_lines $SKIP_HWS_LINES \
     --skip_hws_points $SKIP_HWS_POINTS \
-    --skip_dgm $SKIP_DGM
+    --skip_dgm $SKIP_DGM \
+    --skip_jetties $SKIP_JETTIES
diff -r f1009aa7dcd1 -r d086ce6c13d3 flys-backend/contrib/shpimporter/jetties.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-backend/contrib/shpimporter/jetties.py	Wed Mar 20 17:55:53 2013 +0100
@@ -0,0 +1,69 @@
+# -*- coding: utf-8 -*-
+import os
+
+try:
+    from osgeo import ogr
+except ImportError:
+    import ogr
+
+from importer import Importer
+import utils
+
+import logging
+logger = logging.getLogger("Jetties")
+
+PATH="Geodaesie/Bauwerke"
+NAME="Jetties"
+
+# strings need to be lowercase
+JETTY_KIND = {
+        "buhnenkopf" : 0,
+        "buhnenfuß" : 1,
+        "buhnenwurzel" : 2,
+    }
+
+class Jetties(Importer):
+    fieldmap = {
+            "^station$" : "km",
+            "^z$" : "z",
+        }
+
+    def getPath(self, base):
+        return "%s/%s" % (base, PATH)
+
+    def getTablename(self):
+        return "jetties"
+
+    def getName(self):
+        return "JETTIES"
+
+    def isGeometryValid(self, geomType):
+        return geomType == ogr.wkbPoint or geomType == ogr.wkbPoint25D
+
+    def isShapeRelevant(self, name, path):
+        if not path.endswith("Buhnen.shp"):
+            return False
+        shp = ogr.Open(path)
+        return self.isGeometryValid(shp.GetLayerByName(name).GetGeomType())
+
+    def createNewFeature(self, featureDef, feat, **args):
+        newFeat  = ogr.Feature(featureDef)
+        geometry = feat.GetGeometryRef()
+        geometry.SetCoordinateDimension(2)
+
+        self.copyFields(feat, newFeat, self.fieldmap)
+
+        newFeat.SetGeometry(geometry)
+
+        artname = self.searchField("^type$")
+        if self.IsFieldSet(feat, artname):
+            self.handled(artname)
+            kind_id = JETTY_KIND.get(feat.GetField(artname).lower())
+            if not kind_id:
+                logger.warn("Unknown Type: %s" % \
+                        feat.GetField(artname))
+            else:
+                newFeat.SetField("kind_id", kind_id)
+
+        return newFeat
+
diff -r f1009aa7dcd1 -r d086ce6c13d3 flys-backend/contrib/shpimporter/shpimporter.py
--- a/flys-backend/contrib/shpimporter/shpimporter.py	Wed Mar 20 17:20:19 2013 +0100
+++ b/flys-backend/contrib/shpimporter/shpimporter.py	Wed Mar 20 17:55:53 2013 +0100
@@ -18,6 +18,7 @@
 from boundaries import HydrBoundary, HydrBoundaryPoly
 from hws import HWSLines, HWSPoints
 from gauges import GaugeLocation
+from jetties import Jetties
 from dgm import insertRiverDgm
 
 logger = logging.getLogger("shpimporter")
@@ -46,6 +47,7 @@
         HWSLines(river_id, dbconn, dry_run),
         HWSPoints(river_id, dbconn, dry_run),
         GaugeLocation(river_id, dbconn, dry_run),
+        Jetties(river_id, dbconn, dry_run),
         UESG(river_id, dbconn, dry_run)
         ]
 
@@ -73,6 +75,7 @@
     parser.add_option("--skip_kms", type="int")
     parser.add_option("--skip_uesgs", type="int")
     parser.add_option("--skip_dgm", type="int")
+    parser.add_option("--skip_jetties", type="int")
     (config, args) = parser.parse_args()
 
     if config.verbose > 1:
@@ -121,6 +124,8 @@
         return True
     elif config.skip_gauge_locations == 1 and isinstance(importer, GaugeLocation):
         return True
+    elif config.skip_jetties == 1 and isinstance(importer, Jetties):
+        return True
     elif config.skip_kms == 1 and isinstance(importer, KM):
         return True
     elif config.skip_uesgs == 1 and isinstance(importer, UESG):
diff -r f1009aa7dcd1 -r d086ce6c13d3 flys-backend/doc/documentation/de/importer-geodaesie.tex
--- a/flys-backend/doc/documentation/de/importer-geodaesie.tex	Wed Mar 20 17:20:19 2013 +0100
+++ b/flys-backend/doc/documentation/de/importer-geodaesie.tex	Wed Mar 20 17:55:53 2013 +0100
@@ -257,9 +257,6 @@
 \textbf{SKIP\_HWS\_POINTS}
 \\Bei gesetztem Wert `1` werden kein Hochwasserschutz Punktdaten importiert.
 
-\textbf{SKIP\_GAUGE\_LOCATION}
-\\Bei gesetztem Wert `1` werden keine Pegelorte importiert.
-
 \textbf{SKIP\_CATCHMENTS}
 \\Bei gesetztem Wert `1` werden keine Einzugsgebiete importiert.
 
@@ -269,6 +266,8 @@
 \textbf{SKIP\_DGM}
 \\Bei gesetztem Wert `1` werden keine Informationen über Digitale Geländemodelle importiert.
 
+\textbf{SKIP\_JETTIES}
+\\Bei gesetztem Wert `1` werden keine Informationen über Buhnen importiert.
 
 \subsection{Starten des Geodaten Importers}
 \label{Starten des Geodaten Importers}


More information about the Dive4elements-commits mailing list