diff options
author | Guilhem Moulin <guilhem@fripost.org> | 2024-06-22 01:26:21 +0200 |
---|---|---|
committer | Guilhem Moulin <guilhem@fripost.org> | 2024-06-22 01:27:04 +0200 |
commit | 8c73990de91e22021e28ea29c0be6819f5d09eac (patch) | |
tree | cb15e52bbb5526446650d324e0f5c38383fa524b | |
parent | 58ec5a4544f55c53921bd553633733d153910e7a (diff) |
Cf. for instance
$ ogrinfo ./LST.vbk_projekteringsomraden.shp -sql "SELECT * FROM \"LST.vbk_projekteringsomraden\" WHERE OMRID = '1452-V-008'"
[…]
Layer name: LST.vbk_projekteringsomraden
Geometry: Polygon
Feature Count: 1
Extent: (-907106.000000, 727.000000) - (914131.738200, 7573766.311200)
Layer SRS WKT:
PROJCRS["SWEREF99 TM",
[…]
OGRFeature(LST.vbk_projekteringsomraden):2043
OMRID (String) = 1452-V-008
PROJNAMN (String) = Grimsås Äspås
ANTALVERK (Integer64) = 0
AntalejXY (Integer64) = (null)
CALPROD (Real) = 0.000000000000000
PBYGGSTART (String) = (null)
PDRIFT (String) = (null)
Andringsan (String) = (null)
UnderByggn (String) = (null)
ORGNAMN (String) = Kraftö AB
ORGNR (String) = 556708-7456
EJAKTUELL (String) = Yes
KOMNAMN (String) = Tranemo
LANSNAMN (String) = Västra Götalands l
EL_NAMN (String) = (null)
Raderat (String) = No
ArendeStat (String) = (null)
-rwxr-xr-x | webmap-import | 46 |
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()}') |