From 53e2db4de93b614e242edcf1c1e2c79203b46f44 Mon Sep 17 00:00:00 2001 From: mdouchin Date: Thu, 10 Nov 2016 11:36:57 +0100 Subject: [PATCH] [BUGFIX] Handle errors when retrieving geometry data Add a try/except to avoid the plugin to fail creating the fts data. --- core/project_finder.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/core/project_finder.py b/core/project_finder.py index 6d9b774..de982a4 100644 --- a/core/project_finder.py +++ b/core/project_finder.py @@ -307,16 +307,19 @@ def expressionIterator(self, layer, expression, geometryStorage): evaluated = unicode(qgsExpression.evaluate(f)) if qgsExpression.hasEvalError(): continue - if f.geometry() is None or f.geometry().centroid() is None: + try: + if f.geometry() is None or f.geometry().centroid() is None: + continue + centroid = f.geometry().centroid().asPoint() + if geometryStorage == 'wkb': + geom = binascii.b2a_hex(f.geometry().asWkb()) + elif geometryStorage == 'wkt': + geom = f.geometry().exportToWkt() + else: + geom = f.geometry().boundingBox().asWktPolygon() + yield ( evaluated, centroid.x(), centroid.y(), geom ) + except: continue - centroid = f.geometry().centroid().asPoint() - if geometryStorage == 'wkb': - geom = binascii.b2a_hex(f.geometry().asWkb()) - elif geometryStorage == 'wkt': - geom = f.geometry().exportToWkt() - else: - geom = f.geometry().boundingBox().asWktPolygon() - yield ( evaluated, centroid.x(), centroid.y(), geom ) def stop_record(self): self.stopLoop = True