# HG changeset patch # User Andre Heinecke # Date 1360925518 -3600 # Node ID 998b29c8d2fdaaa2515a3ea64f617388846762aa # Parent 71e1b96f47948a92a57cc93148912c21ebe7af33 Improve debug output for unsupported features and skipped shapefiles diff -r 71e1b96f4794 -r 998b29c8d2fd flys-backend/contrib/shpimporter/importer.py --- 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 = [] diff -r 71e1b96f4794 -r 998b29c8d2fd flys-backend/contrib/shpimporter/utils.py --- 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" +