[Dive4elements-commits] [PATCH 11 of 15] (importer) calculate freeboard and expect sql

Wald Commits scm-commit at wald.intevation.org
Mon Jan 28 12:27:38 CET 2013


# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1359124663 -3600
# Node ID 9b03cf6b85c93b656ecb057d4731c7e3b8ef54ea
# Parent  a5669cc576b4cd1551151c9fbb5071a210701f8f
(importer) calculate freeboard and expect sql

diff -r a5669cc576b4 -r 9b03cf6b85c9 flys-backend/contrib/shpimporter/hws.py
--- a/flys-backend/contrib/shpimporter/hws.py	Fri Jan 25 10:48:11 2013 +0100
+++ b/flys-backend/contrib/shpimporter/hws.py	Fri Jan 25 15:37:43 2013 +0100
@@ -85,13 +85,15 @@
 class HWSPoints(Importer):
     fieldmap = {
             "Name" : "name",
-            "Freibord_m" : "freeboard",
             "Quelle" : "source",
             "Anmerkung" : "description",
             "Stand" : "status_date",
             "Verband" : "agency",
             "Deich_KM" : "dike_km",
             "Bereich" : "range",
+            "Höhe_SOLL" : "z_target",
+            "WSP_BfG100" : "rated_level",
+            "Hoehe_IST" : "z",
         }
 
     def getPath(self, base):
@@ -107,7 +109,6 @@
         return geomType == 1
 
     def isShapeRelevant(self, name, path):
-        print "Checking relevancy of %s" % path
         if "punkte" in os.path.basename(path).lower():
             return True
         else:
@@ -116,7 +117,7 @@
     def createNewFeature(self, featureDef, feat, **args):
         newFeat  = ogr.Feature(featureDef)
         geometry = feat.GetGeometryRef()
-        geometry.SetCoordinateDimension(3)
+        geometry.SetCoordinateDimension(2)
 
         utils.copyFields(feat, newFeat, self.fieldmap)
 
@@ -161,8 +162,18 @@
         if not self.IsFieldSet(feat, "Name"):
             newFeat.SetField("name", args['name'])
 
-        # TODO:
-        # offical
+        if self.IsFieldSet(feat, "offiziell"):
+            offiziell = feat.GetField("offiziell")
+            if offiziell == "1" or offiziell == 1:
+                newFeat.SetField("offiziell", True)
+            else:
+                newFeat.SetField("offiziell", False)
+
+        if self.IsFieldSet(newFeat, "z") and \
+            self.IsFieldSet(newFeat, "rated_level"):
+            z = newFeat.GetFieldAsDouble("z")
+            rl = newFeat.GetFieldAsDouble("rated_level")
+            newFeat.SetField("freeboard", z - rl)
 
         return newFeat
 


More information about the Dive4elements-commits mailing list