comparison 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
comparison
equal deleted inserted replaced
4971:fc7ebf104779 4974:a92241d40228
102 if src_srs is None: 102 if src_srs is None:
103 shpimporter.ERROR("No source SRS given! No transformation possible!") 103 shpimporter.ERROR("No source SRS given! No transformation possible!")
104 return feat 104 return feat
105 105
106 transformer = osr.CoordinateTransformation(src_srs, self.dest_srs) 106 transformer = osr.CoordinateTransformation(src_srs, self.dest_srs)
107 geometry.Transform(transformer) 107 if geometry.Transform(transformer):
108 return None
108 109
109 return feat 110 return feat
110 111
111 def handled(self, field): 112 def handled(self, field):
112 """ 113 """
191 path=path) 192 path=path)
192 193
193 if newFeat is not None: 194 if newFeat is not None:
194 newFeat.SetField("path", utils.getUTF8Path(path)) 195 newFeat.SetField("path", utils.getUTF8Path(path))
195 newFeat = self.transform(newFeat) 196 newFeat = self.transform(newFeat)
196 res = destLayer.CreateFeature(newFeat) 197 if newFeat:
197 if res is None or res > 0: 198 res = destLayer.CreateFeature(newFeat)
198 shpimporter.ERROR("Unable to insert feature. Error: %r" % res) 199 if res is None or res > 0:
200 shpimporter.ERROR("Unable to insert feature. Error: %r" % res)
201 else:
202 success = success + 1
199 else: 203 else:
200 success = success + 1 204 shpimporter.ERROR("Could not transform feature: %s " % feat.GetFID())
205 creationFailed += 1
201 else: 206 else:
202 creationFailed = creationFailed + 1 207 creationFailed = creationFailed + 1
203 else: 208 else:
204 unsupported = unsupported + 1 209 unsupported = unsupported + 1
205 210

http://dive4elements.wald.intevation.org