diff flys-backend/contrib/shpimporter/hws.py @ 4881:9b03cf6b85c9

(importer) calculate freeboard and expect sql
author Andre Heinecke <aheinecke@intevation.de>
date Fri, 25 Jan 2013 15:37:43 +0100
parents 37fa93f65971
children b457532dae63
line wrap: on
line diff
--- 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
 

http://dive4elements.wald.intevation.org