changeset 4995:998b29c8d2fd dami

Improve debug output for unsupported features and skipped shapefiles
author Andre Heinecke <aheinecke@intevation.de>
date Fri, 15 Feb 2013 11:51:58 +0100
parents 71e1b96f4794
children d19c07c10986
files flys-backend/contrib/shpimporter/importer.py flys-backend/contrib/shpimporter/utils.py
diffstat 2 files changed, 38 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/flys-backend/contrib/shpimporter/importer.py	Thu Feb 14 17:45:13 2013 +0100
+++ b/flys-backend/contrib/shpimporter/importer.py	Fri Feb 15 11:51:58 2013 +0100
@@ -77,15 +77,18 @@
 
     def walkOverShapes(self, shape):
         (name, path) = shape
-        if not self.isShapeRelevant(name, path):
-            shpimporter.INFO("Skip shapefile '%s'" % path)
-            return
 
         shp = ogr.Open(shape[1])
         if shp is None:
             shpimporter.ERROR("Shapefile '%s' could not be opened!" % path)
             return
 
+        if not self.isShapeRelevant(name, path):
+            shpimporter.INFO("Skip shapefile: '%s' of Type: %s" % (path,
+                utils.getWkbString(shp.GetLayerByName(name).GetGeomType())))
+            return
+
+
         shpimporter.INFO("Processing shapefile '%s'" % path)
         srcLayer = shp.GetLayerByName(name)
 
@@ -172,7 +175,7 @@
 
         geomType    = -1
         success     = 0
-        unsupported = 0
+        unsupported = {}
         creationFailed = 0
         featureDef  = destLayer.GetLayerDefn()
 
@@ -206,11 +209,13 @@
                 else:
                     creationFailed = creationFailed + 1
             else:
-                unsupported = unsupported + 1
+                unsupported[utils.getWkbString(geomType)] = \
+                        unsupported.get(utils.getWkbString(geomType), 0) + 1
 
         shpimporter.INFO("Inserted %i features" % success)
         shpimporter.INFO("Failed to create %i features" % creationFailed)
-        shpimporter.INFO("Found %i unsupported features" % unsupported)
+        for key, value in unsupported:
+            shpimporter.INFO("Found %i unsupported features of type: %s" % (value, key))
 
         if self.tracking_import:
             unhandled = []
--- a/flys-backend/contrib/shpimporter/utils.py	Thu Feb 14 17:45:13 2013 +0100
+++ b/flys-backend/contrib/shpimporter/utils.py	Fri Feb 15 11:51:58 2013 +0100
@@ -60,3 +60,30 @@
     except UnicodeDecodeError:
         # Probably European Windows names so lets try again
         return unicode.encode(unicode(path, "cp1252"), "UTF-8")
+
+WKB_MAP = {
+    ogr.wkb25Bit :                'wkb25Bit',
+    ogr.wkbGeometryCollection :   'wkbGeometryCollection',
+    ogr.wkbGeometryCollection25D :'wkbGeometryCollection25D',
+    ogr.wkbLineString :           'wkbLineString',
+    ogr.wkbLineString25D :        'wkbLineString25D',
+    ogr.wkbLinearRing :           'wkbLinearRing',
+    ogr.wkbMultiLineString :      'wkbMultiLineString',
+    ogr.wkbMultiLineString25D :   'wkbMultiLineString25D',
+    ogr.wkbMultiPoint :           'wkbMultiPoint',
+    ogr.wkbMultiPoint25D :        'wkbMultiPoint25D',
+    ogr.wkbMultiPolygon :         'wkbMultiPolygon',
+    ogr.wkbMultiPolygon25D :      'wkbMultiPolygon25D',
+    ogr.wkbNDR :                  'wkbNDR',
+    ogr.wkbNone :                 'wkbNone',
+    ogr.wkbPoint :                'wkbPoint',
+    ogr.wkbPoint25D :             'wkbPoint25D',
+    ogr.wkbPolygon :              'wkbPolygon',
+    ogr.wkbPolygon25D :           'wkbPolygon25D',
+    ogr.wkbUnknown :              'wkbUnknown',
+    ogr.wkbXDR :                  'wkbXDR'
+}
+
+def getWkbString(type):
+    return WKB_MAP.get(type) or "Unknown"
+

http://dive4elements.wald.intevation.org