Skip to content

Commit

Permalink
[processing] add test for gdal_polygonize
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Nov 12, 2016
1 parent 08231b8 commit 159fda6
Show file tree
Hide file tree
Showing 3 changed files with 184 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<GMLFeatureClassList>
<GMLFeatureClass>
<Name>polygonize</Name>
<ElementPath>polygonize</ElementPath>
<!--POLYGON-->
<GeometryType>3</GeometryType>
<SRSName>EPSG:23030</SRSName>
<DatasetSpecificInfo>
<FeatureCount>40</FeatureCount>
<ExtentXMin>270746.30402</ExtentXMin>
<ExtentXMax>270869.14438</ExtentXMax>
<ExtentYMin>4458929.13301</ExtentYMin>
<ExtentYMax>4459029.57452</ExtentYMax>
</DatasetSpecificInfo>
<PropertyDefn>
<Name>DN</Name>
<ElementPath>DN</ElementPath>
<Type>Integer</Type>
</PropertyDefn>
</GMLFeatureClass>
</GMLFeatureClassList>
134 changes: 134 additions & 0 deletions python/plugins/processing/tests/testdata/expected/gdal/polygonize.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
<?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>270746.3040214723</gml:X><gml:Y>4458929.133005033</gml:Y></gml:coord>
<gml:coord><gml:X>270869.1443783215</gml:X><gml:Y>4459029.574521748</gml:Y></gml:coord>
</gml:Box>
</gml:boundedBy>

<gml:featureMember>
<ogr:polygonize fid="polygonize.0">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:23030"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>270746.304021472,4459029.57452175 270766.777414281,4459029.57452175 270766.777414281,4459009.4862184 270746.304021472,4459009.4862184 270746.304021472,4459029.57452175</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:DN>826</ogr:DN>
</ogr:polygonize>
</gml:featureMember>
<gml:featureMember>
<ogr:polygonize fid="polygonize.1">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:23030"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>270766.777414281,4459029.57452175 270797.487503493,4459029.57452175 270797.487503493,4459009.4862184 270766.777414281,4459009.4862184 270766.777414281,4459029.57452175</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:DN>837</ogr:DN>
</ogr:polygonize>
</gml:featureMember>
<gml:featureMember>
<ogr:polygonize fid="polygonize.2">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:23030"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>270797.487503493,4459029.57452175 270817.960896301,4459029.57452175 270817.960896301,4459009.4862184 270797.487503493,4459009.4862184 270797.487503493,4459029.57452175</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:DN>845</ogr:DN>
</ogr:polygonize>
</gml:featureMember>
<gml:featureMember>
<ogr:polygonize fid="polygonize.3">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:23030"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>270817.960896301,4459029.57452175 270848.670985513,4459029.57452175 270848.670985513,4459009.4862184 270817.960896301,4459009.4862184 270817.960896301,4459029.57452175</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:DN>853</ogr:DN>
</ogr:polygonize>
</gml:featureMember>
<gml:featureMember>
<ogr:polygonize fid="polygonize.4">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:23030"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>270848.670985513,4459029.57452175 270869.144378322,4459029.57452175 270869.144378322,4459009.4862184 270848.670985513,4459009.4862184 270848.670985513,4459029.57452175</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:DN>861</ogr:DN>
</ogr:polygonize>
</gml:featureMember>
<gml:featureMember>
<ogr:polygonize fid="polygonize.5">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:23030"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>270746.304021472,4459009.4862184 270766.777414281,4459009.4862184 270766.777414281,4458979.35376339 270746.304021472,4458979.35376339 270746.304021472,4459009.4862184</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:DN>843</ogr:DN>
</ogr:polygonize>
</gml:featureMember>
<gml:featureMember>
<ogr:polygonize fid="polygonize.6">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:23030"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>270766.777414281,4459009.4862184 270797.487503493,4459009.4862184 270797.487503493,4458979.35376339 270766.777414281,4458979.35376339 270766.777414281,4459009.4862184</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:DN>851</ogr:DN>
</ogr:polygonize>
</gml:featureMember>
<gml:featureMember>
<ogr:polygonize fid="polygonize.7">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:23030"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>270797.487503493,4459009.4862184 270817.960896301,4459009.4862184 270817.960896301,4458979.35376339 270797.487503493,4458979.35376339 270797.487503493,4459009.4862184</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:DN>859</ogr:DN>
</ogr:polygonize>
</gml:featureMember>
<gml:featureMember>
<ogr:polygonize fid="polygonize.8">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:23030"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>270817.960896301,4459009.4862184 270848.670985513,4459009.4862184 270848.670985513,4458979.35376339 270817.960896301,4458979.35376339 270817.960896301,4459009.4862184</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:DN>866</ogr:DN>
</ogr:polygonize>
</gml:featureMember>
<gml:featureMember>
<ogr:polygonize fid="polygonize.9">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:23030"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>270848.670985513,4459009.4862184 270869.144378322,4459009.4862184 270869.144378322,4458979.35376339 270848.670985513,4458979.35376339 270848.670985513,4459009.4862184</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:DN>878</ogr:DN>
</ogr:polygonize>
</gml:featureMember>
<gml:featureMember>
<ogr:polygonize fid="polygonize.10">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:23030"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>270746.304021472,4458979.35376339 270766.777414281,4458979.35376339 270766.777414281,4458959.26546005 270746.304021472,4458959.26546005 270746.304021472,4458979.35376339</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:DN>859</ogr:DN>
</ogr:polygonize>
</gml:featureMember>
<gml:featureMember>
<ogr:polygonize fid="polygonize.11">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:23030"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>270766.777414281,4458979.35376339 270797.487503493,4458979.35376339 270797.487503493,4458959.26546005 270766.777414281,4458959.26546005 270766.777414281,4458979.35376339</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:DN>864</ogr:DN>
</ogr:polygonize>
</gml:featureMember>
<gml:featureMember>
<ogr:polygonize fid="polygonize.12">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:23030"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>270797.487503493,4458979.35376339 270817.960896301,4458979.35376339 270817.960896301,4458959.26546005 270797.487503493,4458959.26546005 270797.487503493,4458979.35376339</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:DN>872</ogr:DN>
</ogr:polygonize>
</gml:featureMember>
<gml:featureMember>
<ogr:polygonize fid="polygonize.13">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:23030"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>270817.960896301,4458979.35376339 270848.670985513,4458979.35376339 270848.670985513,4458959.26546005 270817.960896301,4458959.26546005 270817.960896301,4458979.35376339</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:DN>880</ogr:DN>
</ogr:polygonize>
</gml:featureMember>
<gml:featureMember>
<ogr:polygonize fid="polygonize.14">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:23030"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>270848.670985513,4458979.35376339 270869.144378322,4458979.35376339 270869.144378322,4458959.26546005 270848.670985513,4458959.26546005 270848.670985513,4458979.35376339</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:DN>890</ogr:DN>
</ogr:polygonize>
</gml:featureMember>
<gml:featureMember>
<ogr:polygonize fid="polygonize.15">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:23030"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>270746.304021472,4458959.26546005 270766.777414281,4458959.26546005 270766.777414281,4458929.13300503 270746.304021472,4458929.13300503 270746.304021472,4458959.26546005</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:DN>868</ogr:DN>
</ogr:polygonize>
</gml:featureMember>
<gml:featureMember>
<ogr:polygonize fid="polygonize.16">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:23030"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>270766.777414281,4458959.26546005 270797.487503493,4458959.26546005 270797.487503493,4458929.13300503 270766.777414281,4458929.13300503 270766.777414281,4458959.26546005</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:DN>873</ogr:DN>
</ogr:polygonize>
</gml:featureMember>
<gml:featureMember>
<ogr:polygonize fid="polygonize.17">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:23030"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>270797.487503493,4458959.26546005 270817.960896301,4458959.26546005 270817.960896301,4458929.13300503 270797.487503493,4458929.13300503 270797.487503493,4458959.26546005</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:DN>881</ogr:DN>
</ogr:polygonize>
</gml:featureMember>
<gml:featureMember>
<ogr:polygonize fid="polygonize.18">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:23030"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>270817.960896301,4458959.26546005 270848.670985513,4458959.26546005 270848.670985513,4458929.13300503 270817.960896301,4458929.13300503 270817.960896301,4458959.26546005</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:DN>890</ogr:DN>
</ogr:polygonize>
</gml:featureMember>
<gml:featureMember>
<ogr:polygonize fid="polygonize.19">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:23030"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>270848.670985513,4458959.26546005 270869.144378322,4458959.26546005 270869.144378322,4458929.13300503 270848.670985513,4458929.13300503 270848.670985513,4458959.26546005</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:DN>899</ogr:DN>
</ogr:polygonize>
</gml:featureMember>
</ogr:FeatureCollection>
46 changes: 29 additions & 17 deletions python/plugins/processing/tests/testdata/gdal_algorithm_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,6 @@ tests:
# hash: f1fedeb6782f9389cf43590d4c85ada9155ab61fef6dc285aaeb54d6
# type: rasterhash


- name: GDAL ogrinfo
algorithm: gdalogr:information
params:
INPUT:
name: lines.gml
type: vector
SUMMARY_ONLY: 'True'
results:
OUTPUT:
name: expected/gdal/vector_info.html
type: regex
rules:
- 'Extent: \(-1.000000, -3.000000\) - \(11.000000, 5.000000\)'
- 'Geometry: Line String'
- 'Feature Count: [6|7]' # On some platforms returns 6 instead of 7...

- algorithm: gdalorg:rasterinfo
name: GDAL gdalinfo
params:
Expand All @@ -60,3 +43,32 @@ tests:
- 'Origin = \(270736.067325068172067,4459029.574521748349071\)'
- 'Band 1 Block=16x14 Type=Float32, ColorInterp=Gray'
- ' NoData Value=-32768'

- algorithm: gdalogr:polygonize
name: GDAL polygonize
params:
FIELD: DN
INPUT:
name: raster.tif
type: raster
results:
OUTPUT:
name: expected/gdal/polygonize.gml
type: vector

- algorithm: gdalogr:information
name: GDAL ogrinfo
params:
INPUT:
name: lines.gml
type: vector
SUMMARY_ONLY: 'True'
results:
OUTPUT:
name: expected/gdal/vector_info.html
type: regex
rules:
- 'Extent: \(-1.000000, -3.000000\) - \(11.000000, 5.000000\)'
- 'Geometry: Line String'
- 'Feature Count: [6|7]' # On some platforms returns 6 instead of 7...

0 comments on commit 159fda6

Please sign in to comment.