Mercurial > dive4elements > river
diff flys-backend/contrib/shpimporter/utils.py @ 5296:55122db34cd0
merge
author | Bettina Gruenbauer <bettina@intevation.de> |
---|---|
date | Thu, 14 Mar 2013 12:53:36 +0100 |
parents | 3f35d9db48c1 |
children |
line wrap: on
line diff
--- a/flys-backend/contrib/shpimporter/utils.py Thu Mar 14 12:49:41 2013 +0100 +++ b/flys-backend/contrib/shpimporter/utils.py Thu Mar 14 12:53:36 2013 +0100 @@ -108,3 +108,15 @@ geometry.AssignSpatialReference(srs) feature.SetGeometry(geometry) return feature + +def convertToMultiPolygon(feature): + """ + Converts a feature to a multiline feature. + """ + geometry = feature.GetGeometryRef() + # SRS information is lost while forcing to multiline + srs = geometry.GetSpatialReference() + geometry = ogr.ForceToMultiPolygon(geometry) + geometry.AssignSpatialReference(srs) + feature.SetGeometry(geometry) + return feature