diff flys-backend/contrib/shpimporter/hws.py @ 4884:b457532dae63

Importer: Move copy fields into importer class and track imported/unimported fields
author Andre Heinecke <aheinecke@intevation.de>
date Mon, 28 Jan 2013 12:25:24 +0100
parents 9b03cf6b85c9
children 60b026b4340e
line wrap: on
line diff
--- a/flys-backend/contrib/shpimporter/hws.py	Fri Jan 25 15:43:05 2013 +0100
+++ b/flys-backend/contrib/shpimporter/hws.py	Mon Jan 28 12:25:24 2013 +0100
@@ -119,7 +119,7 @@
         geometry = feat.GetGeometryRef()
         geometry.SetCoordinateDimension(2)
 
-        utils.copyFields(feat, newFeat, self.fieldmap)
+        self.copyFields(feat, newFeat, self.fieldmap)
 
         newFeat.SetGeometry(geometry)
 
@@ -128,6 +128,7 @@
         newFeat.SetField("ogr_fid", feat.GetFID())
 
         if self.IsFieldSet(feat, "Art"):
+            self.handled("Art")
             kind_id = HWS_KIND.get(feat.GetField("Art"))
             if not kind_id:
                 print ("Unbekannte Art: %s" % \
@@ -136,6 +137,7 @@
                 newFeat.SetField("kind_id", kind_id)
 
         if self.IsFieldSet(feat, "Bundesland"):
+            self.handled("Bundesland")
             fed_id = FED_STATES.get(feat.GetField("Bundesland"))
 
             if not fed_id:
@@ -145,6 +147,7 @@
                 newFeat.SetField("fed_state_id", fed_id)
 
         if self.IsFieldSet(feat, "river_id"):
+            self.handled("river_id")
             if feat.GetField("river_id") != self.river_id:
                 print ("River_id mismatch between shapefile and"
                      " importer parameter.")
@@ -153,6 +156,7 @@
             newFeat.SetField("river_id", self.river_id)
 
         if self.IsFieldSet(feat, "Ufer"):
+            self.handled("Ufer")
             shoreString = feat.GetField("Ufer")
             if "links" in shoreString.lower():
                 newFeat.SetField("shore_side", True)
@@ -160,9 +164,11 @@
                 newFeat.SetField("shore_side", False)
 
         if not self.IsFieldSet(feat, "Name"):
+            self.handled("Name")
             newFeat.SetField("name", args['name'])
 
         if self.IsFieldSet(feat, "offiziell"):
+            self.handled("offiziell")
             offiziell = feat.GetField("offiziell")
             if offiziell == "1" or offiziell == 1:
                 newFeat.SetField("offiziell", True)
@@ -171,6 +177,7 @@
 
         if self.IsFieldSet(newFeat, "z") and \
             self.IsFieldSet(newFeat, "rated_level"):
+            self.handled("Freibord_m")
             z = newFeat.GetFieldAsDouble("z")
             rl = newFeat.GetFieldAsDouble("rated_level")
             newFeat.SetField("freeboard", z - rl)

http://dive4elements.wald.intevation.org