Skip to content

Commit

Permalink
[processing] qgis voronoi test
Browse files Browse the repository at this point in the history
  • Loading branch information
ghtmtt authored and m-kuhn committed Feb 3, 2017
1 parent 7619cba commit 74c65c8
Show file tree
Hide file tree
Showing 5 changed files with 234 additions and 4 deletions.
26 changes: 26 additions & 0 deletions python/plugins/processing/tests/testdata/expected/voronoi.gfs
@@ -0,0 +1,26 @@
<GMLFeatureClassList>
<GMLFeatureClass>
<Name>voronoi</Name>
<ElementPath>voronoi</ElementPath>
<!--POLYGON-->
<GeometryType>3</GeometryType>
<SRSName>EPSG:4326</SRSName>
<DatasetSpecificInfo>
<FeatureCount>9</FeatureCount>
<ExtentXMin>0.00000</ExtentXMin>
<ExtentXMax>8.00000</ExtentXMax>
<ExtentYMin>-5.00000</ExtentYMin>
<ExtentYMax>3.00000</ExtentYMax>
</DatasetSpecificInfo>
<PropertyDefn>
<Name>id</Name>
<ElementPath>id</ElementPath>
<Type>Integer</Type>
</PropertyDefn>
<PropertyDefn>
<Name>id2</Name>
<ElementPath>id2</ElementPath>
<Type>Integer</Type>
</PropertyDefn>
</GMLFeatureClass>
</GMLFeatureClassList>
77 changes: 77 additions & 0 deletions python/plugins/processing/tests/testdata/expected/voronoi.gml
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8" ?>
<ogr:FeatureCollection
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=""
xmlns:ogr="http://ogr.maptools.org/"
xmlns:gml="http://www.opengis.net/gml">
<gml:boundedBy>
<gml:Box>
<gml:coord><gml:X>0</gml:X><gml:Y>-5</gml:Y></gml:coord>
<gml:coord><gml:X>8</gml:X><gml:Y>3</gml:Y></gml:coord>
</gml:Box>
</gml:boundedBy>

<gml:featureMember>
<ogr:voronoi fid="points.2">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>2.5,0.5 0,3 2.0,3.0 3.16666666666667,1.83333333333333 2.5,0.5</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:id>3</ogr:id>
<ogr:id2>0</ogr:id2>
</ogr:voronoi>
</gml:featureMember>
<gml:featureMember>
<ogr:voronoi fid="points.5">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>0,-5 0,-3 3.5,-3.0 4.64285714285714,-5.0 0,-5</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:id>6</ogr:id>
<ogr:id2>0</ogr:id2>
</ogr:voronoi>
</gml:featureMember>
<gml:featureMember>
<ogr:voronoi fid="points.4">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>3.5,-3.0 2.5,-1.0 2.5,0.5 3.16666666666667,1.83333333333333 3.83333333333333,2.16666666666667 5.7,0.3 3.5,-3.0</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:id>5</ogr:id>
<ogr:id2>1</ogr:id2>
</ogr:voronoi>
</gml:featureMember>
<gml:featureMember>
<ogr:voronoi fid="points.3">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>5.7,0.3 3.83333333333333,2.16666666666667 4.25,3.0 8,3 8,2 7.5,1.5 5.7,0.3</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:id>4</ogr:id>
<ogr:id2>2</ogr:id2>
</ogr:voronoi>
</gml:featureMember>
<gml:featureMember>
<ogr:voronoi fid="points.1">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>3.16666666666667,1.83333333333333 2.0,3.0 4.25,3.0 3.83333333333333,2.16666666666667 3.16666666666667,1.83333333333333</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:id>2</ogr:id>
<ogr:id2>1</ogr:id2>
</ogr:voronoi>
</gml:featureMember>
<gml:featureMember>
<ogr:voronoi fid="points.7">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>4.64285714285714,-5.0 3.5,-3.0 5.7,0.3 7.5,1.5 7.5,-5.0 4.64285714285714,-5.0</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:id>8</ogr:id>
<ogr:id2>0</ogr:id2>
</ogr:voronoi>
</gml:featureMember>
<gml:featureMember>
<ogr:voronoi fid="points.0">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>2.5,-1.0 0.0,0.25 0,3 2.5,0.5 2.5,-1.0</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:id>1</ogr:id>
<ogr:id2>2</ogr:id2>
</ogr:voronoi>
</gml:featureMember>
<gml:featureMember>
<ogr:voronoi fid="points.8">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>0,-3 0.0,0.25 2.5,-1.0 3.5,-3.0 0,-3</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:id>9</ogr:id>
<ogr:id2>0</ogr:id2>
</ogr:voronoi>
</gml:featureMember>
<gml:featureMember>
<ogr:voronoi fid="points.6">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>7.5,-5.0 7.5,1.5 8,2 8,-5 7.5,-5.0</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:id>7</ogr:id>
<ogr:id2>0</ogr:id2>
</ogr:voronoi>
</gml:featureMember>
</ogr:FeatureCollection>
@@ -0,0 +1,26 @@
<GMLFeatureClassList>
<GMLFeatureClass>
<Name>voronoi_buffer</Name>
<ElementPath>voronoi_buffer</ElementPath>
<!--POLYGON-->
<GeometryType>3</GeometryType>
<SRSName>EPSG:4326</SRSName>
<DatasetSpecificInfo>
<FeatureCount>9</FeatureCount>
<ExtentXMin>-0.80000</ExtentXMin>
<ExtentXMax>8.80000</ExtentXMax>
<ExtentYMin>-5.80000</ExtentYMin>
<ExtentYMax>3.80000</ExtentYMax>
</DatasetSpecificInfo>
<PropertyDefn>
<Name>id</Name>
<ElementPath>id</ElementPath>
<Type>Integer</Type>
</PropertyDefn>
<PropertyDefn>
<Name>id2</Name>
<ElementPath>id2</ElementPath>
<Type>Integer</Type>
</PropertyDefn>
</GMLFeatureClass>
</GMLFeatureClassList>
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8" ?>
<ogr:FeatureCollection
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=""
xmlns:ogr="http://ogr.maptools.org/"
xmlns:gml="http://www.opengis.net/gml">
<gml:boundedBy>
<gml:Box>
<gml:coord><gml:X>-0.8</gml:X><gml:Y>-5.8</gml:Y></gml:coord>
<gml:coord><gml:X>8.800000000000001</gml:X><gml:Y>3.800000000000001</gml:Y></gml:coord>
</gml:Box>
</gml:boundedBy>

<gml:featureMember>
<ogr:voronoi_buffer fid="points.2">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>2.5,0.5 -0.8,3.0 -0.8,3.8 0.703157894736841,3.8 3.16666666666667,1.83333333333333 2.5,0.5</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:id>3</ogr:id>
<ogr:id2>0</ogr:id2>
</ogr:voronoi_buffer>
</gml:featureMember>
<gml:featureMember>
<ogr:voronoi_buffer fid="points.5">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>-0.8,-5.8 -0.8,-3.0 3.5,-3.0 4.64285714285714,-5.8 -0.8,-5.8</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:id>6</ogr:id>
<ogr:id2>0</ogr:id2>
</ogr:voronoi_buffer>
</gml:featureMember>
<gml:featureMember>
<ogr:voronoi_buffer fid="points.4">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>3.5,-3.0 2.5,-1.0 2.5,0.5 3.16666666666667,1.83333333333333 3.83333333333333,2.16666666666667 5.7,0.3 3.5,-3.0</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:id>5</ogr:id>
<ogr:id2>1</ogr:id2>
</ogr:voronoi_buffer>
</gml:featureMember>
<gml:featureMember>
<ogr:voronoi_buffer fid="points.3">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>5.7,0.3 3.83333333333333,2.16666666666667 4.65,3.8 8.8,3.8 8.8,2.8 7.5,1.5 5.7,0.3</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:id>4</ogr:id>
<ogr:id2>2</ogr:id2>
</ogr:voronoi_buffer>
</gml:featureMember>
<gml:featureMember>
<ogr:voronoi_buffer fid="points.1">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>3.16666666666667,1.83333333333333 0.703157894736841,3.8 4.65,3.8 3.83333333333333,2.16666666666667 3.16666666666667,1.83333333333333</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:id>2</ogr:id>
<ogr:id2>1</ogr:id2>
</ogr:voronoi_buffer>
</gml:featureMember>
<gml:featureMember>
<ogr:voronoi_buffer fid="points.7">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>4.64285714285714,-5.8 3.5,-3.0 5.7,0.3 7.5,1.5 7.5,-5.8 4.64285714285714,-5.8</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:id>8</ogr:id>
<ogr:id2>0</ogr:id2>
</ogr:voronoi_buffer>
</gml:featureMember>
<gml:featureMember>
<ogr:voronoi_buffer fid="points.0">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>2.5,-1.0 -0.8,0.25 -0.8,3.0 2.5,0.5 2.5,-1.0</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:id>1</ogr:id>
<ogr:id2>2</ogr:id2>
</ogr:voronoi_buffer>
</gml:featureMember>
<gml:featureMember>
<ogr:voronoi_buffer fid="points.8">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>-0.8,-3.0 -0.8,0.25 2.5,-1.0 3.5,-3.0 -0.8,-3.0</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:id>9</ogr:id>
<ogr:id2>0</ogr:id2>
</ogr:voronoi_buffer>
</gml:featureMember>
<gml:featureMember>
<ogr:voronoi_buffer fid="points.6">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>7.5,-5.8 7.5,1.5 8.8,2.8 8.8,-5.8 7.5,-5.8</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:id>7</ogr:id>
<ogr:id2>0</ogr:id2>
</ogr:voronoi_buffer>
</gml:featureMember>
</ogr:FeatureCollection>
32 changes: 28 additions & 4 deletions python/plugins/processing/tests/testdata/qgis_algorithm_tests.yaml
Expand Up @@ -1776,7 +1776,7 @@ tests:
OUTPUT:
name: expected/grid_lines_overlay.gml
type: vector

- algorithm: qgis:creategridpolygon
name: Create grid (rectangle with overlay)
params:
Expand All @@ -1794,7 +1794,7 @@ tests:
compare:
geometry:
precision: 7

- algorithm: qgis:creategridpolygon
name: Create grid (diamond with overlay)
params:
Expand All @@ -1812,7 +1812,7 @@ tests:
compare:
geometry:
precision: 7

- algorithm: qgis:creategridpolygon
name: Create grid (hexagon with overlay)
params:
Expand All @@ -1830,7 +1830,7 @@ tests:
compare:
geometry:
precision: 7

- algorithm: qgis:deleteholes
name: Delete holes (no min)
params:
Expand Down Expand Up @@ -2312,3 +2312,27 @@ tests:
OUTPUT:
name: expected/polygonize.gml
type: vector

- algorithm: qgis:voronoipolygons
name: Standard voronoi
params:
BUFFER: 0.0
INPUT:
name: points.gml
type: vector
results:
OUTPUT:
name: expected/voronoi.gml
type: vector

- algorithm: qgis:voronoipolygons
name: Vornoi with buffer region
params:
BUFFER: 10.0
INPUT:
name: points.gml
type: vector
results:
OUTPUT:
name: expected/voronoi_buffer.gml
type: vector

0 comments on commit 74c65c8

Please sign in to comment.