aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xwebmap-import46
1 files changed, 25 insertions, 21 deletions
diff --git a/webmap-import b/webmap-import
index c1d07a3..37826cf 100755
--- a/webmap-import
+++ b/webmap-import
@@ -1133,27 +1133,31 @@ def importSource2(lyr_dst, path, args={}, basedir=None, extent=None):
feature2.SetFromWithMap(feature, False, fieldMap)
geom = feature2.GetGeometryRef()
- if ct is not None and geom.Transform(ct) != ogr.OGRERR_NONE:
- raise Exception('Could not apply coordinate transformation')
-
- eGType = geom.GetGeometryType()
- if eGType != eGType_dst and not dGeomIsUnknown:
- # Promote to multi, cf. apps/ogr2ogr_lib.cpp:ConvertType()
- eGType2 = eGType
- if eGType == ogr.wkbTriangle or eGType == ogr.wkbTIN or eGType == ogr.wkbPolyhedralSurface:
- eGType2 = ogr.wkbMultiPolygon
- elif not ogr.GT_IsSubClassOf(eGType, ogr.wkbGeometryCollection):
- eGType2 = ogr.GT_GetCollection(eGType)
-
- eGType2 = ogr.GT_SetModifier(eGType2, eGType_dst_HasZ, eGType_dst_HasM)
- if eGType2 == eGType_dst:
- mismatch[eGType] = mismatch.get(eGType, 0) + 1
- geom = ogr.ForceTo(geom, eGType_dst)
- # TODO call MakeValid()?
- else:
- raise Exception(f'Conversion from {ogr.GeometryTypeToName(eGType)} '
- f'to {ogr.GeometryTypeToName(eGType_dst)} not implemented')
- feature2.SetGeometryDirectly(geom)
+ if geom is None:
+ if eGType_dst != ogr.wkbNone:
+ logging.warning('Source feature #%d has no geometry, trying to transfer anyway', feature.GetFID())
+ else:
+ if ct is not None and geom.Transform(ct) != ogr.OGRERR_NONE:
+ raise Exception('Could not apply coordinate transformation')
+
+ eGType = geom.GetGeometryType()
+ if eGType != eGType_dst and not dGeomIsUnknown:
+ # Promote to multi, cf. apps/ogr2ogr_lib.cpp:ConvertType()
+ eGType2 = eGType
+ if eGType == ogr.wkbTriangle or eGType == ogr.wkbTIN or eGType == ogr.wkbPolyhedralSurface:
+ eGType2 = ogr.wkbMultiPolygon
+ elif not ogr.GT_IsSubClassOf(eGType, ogr.wkbGeometryCollection):
+ eGType2 = ogr.GT_GetCollection(eGType)
+
+ eGType2 = ogr.GT_SetModifier(eGType2, eGType_dst_HasZ, eGType_dst_HasM)
+ if eGType2 == eGType_dst:
+ mismatch[eGType] = mismatch.get(eGType, 0) + 1
+ geom = ogr.ForceTo(geom, eGType_dst)
+ # TODO call MakeValid()?
+ else:
+ raise Exception(f'Conversion from {ogr.GeometryTypeToName(eGType)} '
+ f'to {ogr.GeometryTypeToName(eGType_dst)} not implemented')
+ feature2.SetGeometryDirectly(geom)
if lyr_dst.CreateFeature(feature2) != ogr.OGRERR_NONE:
raise Exception(f'Could not transfer source feature #{feature.GetFID()}')