From cd0fefb42b1e58fb06f76c02d9bcce12a27e25c1 Mon Sep 17 00:00:00 2001 From: Piotr Pociask Date: Mon, 17 Oct 2016 13:45:51 +0200 Subject: [PATCH] [processing] Update voronoi classes for Python3; update expected data for multipoint Delaunay traingulation test --- .../plugins/processing/algs/qgis/Delaunay.py | 2 + .../plugins/processing/algs/qgis/voronoi.py | 38 +++--- .../testdata/expected/multipoint_delaunay.gfs | 31 +++++ .../testdata/expected/multipoint_delaunay.gml | 110 ++++++++---------- 4 files changed, 104 insertions(+), 77 deletions(-) create mode 100644 python/plugins/processing/tests/testdata/expected/multipoint_delaunay.gfs diff --git a/python/plugins/processing/algs/qgis/Delaunay.py b/python/plugins/processing/algs/qgis/Delaunay.py index 2a266c06a7f..ad2cc63794a 100644 --- a/python/plugins/processing/algs/qgis/Delaunay.py +++ b/python/plugins/processing/algs/qgis/Delaunay.py @@ -82,6 +82,8 @@ class Delaunay(GeoAlgorithm): total = 100.0 / len(features) for current, inFeat in enumerate(features): geom = QgsGeometry(inFeat.geometry()) + if geom.isEmpty(): + continue if geom.isMultipart(): points = geom.asMultiPoint() else: diff --git a/python/plugins/processing/algs/qgis/voronoi.py b/python/plugins/processing/algs/qgis/voronoi.py index e05d2095c06..3336cc83b22 100644 --- a/python/plugins/processing/algs/qgis/voronoi.py +++ b/python/plugins/processing/algs/qgis/voronoi.py @@ -391,17 +391,18 @@ class Site(object): # fix_print_with_import print("Site #%d (%g, %g)" % (self.sitenum, self.x, self.y)) - def __cmp__(self, other): + def __eq__(self, other): + return (self.x==other.x) and (self.y==other.y) + + def __lt__(self, other): if self.y < other.y: - return -1 + return True elif self.y > other.y: - return 1 + return False elif self.x < other.x: - return -1 + return True elif self.x > other.x: - return 1 - else: - return 0 + return False def distance(self, other): dx = self.x - other.x @@ -505,17 +506,18 @@ class Halfedge(object): # fix_print_with_import print("ystar: ", self.ystar) - def __cmp__(self, other): - if self.ystar > other.ystar: - return 1 - elif self.ystar < other.ystar: - return -1 - elif self.vertex.x > other.vertex.x: - return 1 + def __eq__(self, other): + return (self.vertex.x==other.vertex.x) and (self.ystar==other.ystar) + + def __lt__(self, other): + if self.ystar < other.ystar: + return True + elif self.ystar > other.ystar: + return False elif self.vertex.x < other.vertex.x: - return -1 - else: - return 0 + return True + elif self.vertex.x > other.vertex.x: + return False def leftreg(self, default): if not self.edge: @@ -791,7 +793,7 @@ class SiteList(object): def __iter__(this): return this - def next(this): + def __next__(this): try: return next(this.generator) except StopIteration: diff --git a/python/plugins/processing/tests/testdata/expected/multipoint_delaunay.gfs b/python/plugins/processing/tests/testdata/expected/multipoint_delaunay.gfs new file mode 100644 index 00000000000..768fa5b251a --- /dev/null +++ b/python/plugins/processing/tests/testdata/expected/multipoint_delaunay.gfs @@ -0,0 +1,31 @@ + + + mp + mp + + 3 + EPSG:4326 + + 9 + 0.00000 + 8.00000 + -5.00000 + 3.00000 + + + POINTA + POINTA + Real + + + POINTB + POINTB + Real + + + POINTC + POINTC + Real + + + diff --git a/python/plugins/processing/tests/testdata/expected/multipoint_delaunay.gml b/python/plugins/processing/tests/testdata/expected/multipoint_delaunay.gml index eeaaf78f544..639be1c39f5 100644 --- a/python/plugins/processing/tests/testdata/expected/multipoint_delaunay.gml +++ b/python/plugins/processing/tests/testdata/expected/multipoint_delaunay.gml @@ -14,81 +14,73 @@ 7,-1 8,-1 0,-5 7,-1 - 8.000000000000000 - 7.000000000000000 - 6.000000000000000 + 7.000000000000000 + 6.000000000000000 + 5.000000000000000 0,-5 4,1 7,-1 0,-5 - 6.000000000000000 - 5.000000000000000 - 8.000000000000000 + 5.000000000000000 + 4.000000000000000 + 7.000000000000000 0,-1 4,1 0,-5 0,-1 - 9.000000000000000 - 5.000000000000000 - 6.000000000000000 - - - - - 1,1 0,-1 0,0 1,1 - 1.000000000000000 - 9.000000000000000 - 0.000000000000000 - - - - - 1,1 4,1 0,-1 1,1 - 1.000000000000000 - 5.000000000000000 - 9.000000000000000 - - - - - 2,2 4,1 1,1 2,2 - 2.000000000000000 - 5.000000000000000 - 1.000000000000000 - - - - - 5,2 7,-1 4,1 5,2 - 4.000000000000000 - 8.000000000000000 - 5.000000000000000 - - - - - 3,3 4,1 2,2 3,3 - 3.000000000000000 - 5.000000000000000 - 2.000000000000000 - - - - - 3,3 5,2 4,1 3,3 - 3.000000000000000 + 8.000000000000000 4.000000000000000 5.000000000000000 - - 5,2 8,-1 7,-1 5,2 - 4.000000000000000 - 7.000000000000000 + + 1,1 4,1 0,-1 1,1 + 0.000000000000000 + 4.000000000000000 8.000000000000000 + + + 2,2 4,1 1,1 2,2 + 1.000000000000000 + 4.000000000000000 + 0.000000000000000 + + + + + 5,2 7,-1 4,1 5,2 + 3.000000000000000 + 7.000000000000000 + 4.000000000000000 + + + + + 3,3 4,1 2,2 3,3 + 2.000000000000000 + 4.000000000000000 + 1.000000000000000 + + + + + 3,3 5,2 4,1 3,3 + 2.000000000000000 + 3.000000000000000 + 4.000000000000000 + + + + + 5,2 8,-1 7,-1 5,2 + 3.000000000000000 + 6.000000000000000 + 7.000000000000000 + +