Skip to content

Commit

Permalink
Add tests for gridify
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Aug 5, 2017
1 parent 591de92 commit 0930e18
Show file tree
Hide file tree
Showing 5 changed files with 177 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<GMLFeatureClassList>
<GMLFeatureClass>
<Name>gridify_lines</Name>
<ElementPath>gridify_lines</ElementPath>
<!--LINESTRING-->
<GeometryType>2</GeometryType>
<SRSName>EPSG:4326</SRSName>
<DatasetSpecificInfo>
<FeatureCount>7</FeatureCount>
<ExtentXMin>2.00000</ExtentXMin>
<ExtentXMax>12.00000</ExtentXMax>
<ExtentYMin>-4.00000</ExtentYMin>
<ExtentYMax>4.00000</ExtentYMax>
</DatasetSpecificInfo>
</GMLFeatureClass>
</GMLFeatureClassList>
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?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>2</gml:X><gml:Y>-4</gml:Y></gml:coord>
<gml:coord><gml:X>12</gml:X><gml:Y>4</gml:Y></gml:coord>
</gml:Box>
</gml:boundedBy>

<gml:featureMember>
<ogr:gridify_lines fid="lines.0">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>6,2 8,2 8,4 12,4</gml:coordinates></gml:LineString></ogr:geometryProperty>
</ogr:gridify_lines>
</gml:featureMember>
<gml:featureMember>
<ogr:gridify_lines fid="lines.1">
</ogr:gridify_lines>
</gml:featureMember>
<gml:featureMember>
<ogr:gridify_lines fid="lines.2">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>2,0 2,2 4,2 4,4</gml:coordinates></gml:LineString></ogr:geometryProperty>
</ogr:gridify_lines>
</gml:featureMember>
<gml:featureMember>
<ogr:gridify_lines fid="lines.3">
</ogr:gridify_lines>
</gml:featureMember>
<gml:featureMember>
<ogr:gridify_lines fid="lines.4">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>8,-4 10,-4</gml:coordinates></gml:LineString></ogr:geometryProperty>
</ogr:gridify_lines>
</gml:featureMember>
<gml:featureMember>
<ogr:gridify_lines fid="lines.5">
<ogr:geometryProperty><gml:LineString srsName="EPSG:4326"><gml:coordinates>6,-4 10,0</gml:coordinates></gml:LineString></ogr:geometryProperty>
</ogr:gridify_lines>
</gml:featureMember>
<gml:featureMember>
<ogr:gridify_lines fid="lines.6">
</ogr:gridify_lines>
</gml:featureMember>
</ogr:FeatureCollection>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<GMLFeatureClassList>
<GMLFeatureClass>
<Name>gridify_polys</Name>
<ElementPath>gridify_polys</ElementPath>
<!--POLYGON-->
<GeometryType>3</GeometryType>
<SRSName>EPSG:4326</SRSName>
<DatasetSpecificInfo>
<FeatureCount>6</FeatureCount>
<ExtentXMin>0.00000</ExtentXMin>
<ExtentXMax>10.00000</ExtentXMax>
<ExtentYMin>-4.00000</ExtentYMin>
<ExtentYMax>6.00000</ExtentYMax>
</DatasetSpecificInfo>
<PropertyDefn>
<Name>name</Name>
<ElementPath>name</ElementPath>
<Type>String</Type>
<Width>5</Width>
</PropertyDefn>
<PropertyDefn>
<Name>intval</Name>
<ElementPath>intval</ElementPath>
<Type>Integer</Type>
</PropertyDefn>
<PropertyDefn>
<Name>floatval</Name>
<ElementPath>floatval</ElementPath>
<Type>Real</Type>
</PropertyDefn>
</GMLFeatureClass>
</GMLFeatureClassList>
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?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>-4</gml:Y></gml:coord>
<gml:coord><gml:X>10</gml:X><gml:Y>6</gml:Y></gml:coord>
</gml:Box>
</gml:boundedBy>

<gml:featureMember>
<ogr:gridify_polys fid="polys.0">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>0,0 0,4 4,4 4,2 2,2 2,0 0,0</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:name>aaaaa</ogr:name>
<ogr:intval>33</ogr:intval>
<ogr:floatval>44.123456</ogr:floatval>
</ogr:gridify_polys>
</gml:featureMember>
<gml:featureMember>
<ogr:gridify_polys fid="polys.1">
<ogr:name>Aaaaa</ogr:name>
<ogr:intval>-33</ogr:intval>
<ogr:floatval>0</ogr:floatval>
</ogr:gridify_polys>
</gml:featureMember>
<gml:featureMember>
<ogr:gridify_polys fid="polys.2">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>2,4 2,6 4,6 4,4 2,4</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:name>bbaaa</ogr:name>
<ogr:floatval>0.123</ogr:floatval>
</ogr:gridify_polys>
</gml:featureMember>
<gml:featureMember>
<ogr:gridify_polys fid="polys.3">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>6,0 10,0 10,-4 6,-4 6,0</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:name>ASDF</ogr:name>
<ogr:intval>0</ogr:intval>
</ogr:gridify_polys>
</gml:featureMember>
<gml:featureMember>
<ogr:gridify_polys fid="polys.4">
<ogr:intval>120</ogr:intval>
<ogr:floatval>-100291.43213</ogr:floatval>
</ogr:gridify_polys>
</gml:featureMember>
<gml:featureMember>
<ogr:gridify_polys fid="polys.5">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>4,2 6,0 6,-4 2,0 2,2 4,2</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:name>elim</ogr:name>
<ogr:intval>2</ogr:intval>
<ogr:floatval>3.33</ogr:floatval>
</ogr:gridify_polys>
</gml:featureMember>
</ogr:FeatureCollection>
26 changes: 26 additions & 0 deletions python/plugins/processing/tests/testdata/qgis_algorithm_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2158,6 +2158,32 @@ tests:
name: expected/lines_to_polygon.gml
type: vector

- algorithm: qgis:snappointstogrid
name: Gridify polys
params:
INPUT:
name: polys.gml
type: vector
HSPACING: 2
VSPACING: 2
results:
OUTPUT:
name: expected/gridify_polys.gml
type: vector

- algorithm: qgis:snappointstogrid
name: Gridify lines
params:
INPUT:
name: lines.gml
type: vector
HSPACING: 2
VSPACING: 2
results:
OUTPUT:
name: expected/gridify_lines.gml
type: vector

# - algorithm: qgis:joinattributestable
# name: join the attribute table by common field
# params:
Expand Down

0 comments on commit 0930e18

Please sign in to comment.