Mercurial > dive4elements > river
diff flys-backend/contrib/shpimporter/importer.py @ 4974:a92241d40228 dami
Handle transformation errors
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Wed, 13 Feb 2013 17:45:35 +0100 |
parents | 174fbaa3d344 |
children | 998b29c8d2fd |
line wrap: on
line diff
--- a/flys-backend/contrib/shpimporter/importer.py Wed Feb 13 12:07:10 2013 +0100 +++ b/flys-backend/contrib/shpimporter/importer.py Wed Feb 13 17:45:35 2013 +0100 @@ -104,7 +104,8 @@ return feat transformer = osr.CoordinateTransformation(src_srs, self.dest_srs) - geometry.Transform(transformer) + if geometry.Transform(transformer): + return None return feat @@ -193,11 +194,15 @@ if newFeat is not None: newFeat.SetField("path", utils.getUTF8Path(path)) newFeat = self.transform(newFeat) - res = destLayer.CreateFeature(newFeat) - if res is None or res > 0: - shpimporter.ERROR("Unable to insert feature. Error: %r" % res) + if newFeat: + res = destLayer.CreateFeature(newFeat) + if res is None or res > 0: + shpimporter.ERROR("Unable to insert feature. Error: %r" % res) + else: + success = success + 1 else: - success = success + 1 + shpimporter.ERROR("Could not transform feature: %s " % feat.GetFID()) + creationFailed += 1 else: creationFailed = creationFailed + 1 else: