Skip to content

Commit

Permalink
Add test for single layer union
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed May 10, 2018
1 parent ef145af commit aa2b1e9
Show file tree
Hide file tree
Showing 4 changed files with 216 additions and 0 deletions.
19 changes: 19 additions & 0 deletions python/plugins/processing/tests/testdata/custom/overlay0.geojson
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"type": "FeatureCollection",
"name": "overlay0",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::3857" } },
"features": [
{ "type": "Feature", "properties": { "id_a": "A1" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 1.0, 1.0 ], [ 5.0, 1.0 ], [ 5.0, 5.0 ], [ 1.0, 5.0 ], [ 1.0, 1.0 ] ] ] } },
{ "type": "Feature", "properties": { "id_a": "A2" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 2.0, 2.0 ], [ 4.0, 2.0 ], [ 4.0, 4.0 ], [ 2.0, 4.0 ], [ 2.0, 2.0 ] ] ] } },
{ "type": "Feature", "properties": { "id_a": "A3" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 7.0, 2.0 ], [ 9.0, 2.0 ], [ 9.0, 4.0 ], [ 7.0, 4.0 ], [ 7.0, 2.0 ] ] ] } },
{ "type": "Feature", "properties": { "id_a": "A4" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 6.0, 1.0 ], [ 10.0, 1.0 ], [ 10.0, 5.0 ], [ 6.0, 5.0 ], [ 6.0, 1.0 ] ] ] } },
{ "type": "Feature", "properties": { "id_a": "A5" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 1.0, 6.0 ], [ 3.0, 6.0 ], [ 3.0, 10.0 ], [ 1.0, 10.0 ], [ 1.0, 6.0 ] ] ] } },
{ "type": "Feature", "properties": { "id_a": "A6" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 3.0, 6.0 ], [ 5.0, 6.0 ], [ 5.0, 10.0 ], [ 3.0, 10.0 ], [ 3.0, 6.0 ] ] ] } },
{ "type": "Feature", "properties": { "id_a": "A7" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 6.0, 6.0 ], [ 10.0, 6.0 ], [ 10.0, 10.0 ], [ 6.0, 10.0 ], [ 6.0, 6.0 ] ] ] } },
{ "type": "Feature", "properties": { "id_a": "A8" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 1.0, 11.0 ], [ 4.0, 11.0 ], [ 4.0, 14.0 ], [ 1.0, 14.0 ], [ 1.0, 11.0 ] ] ] } },
{ "type": "Feature", "properties": { "id_a": "A9" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 1.0, 13.0 ], [ 4.0, 13.0 ], [ 4.0, 16.0 ], [ 1.0, 16.0 ], [ 1.0, 13.0 ] ] ] } },
{ "type": "Feature", "properties": { "id_a": "A10" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 2.0, 12.0 ], [ 5.0, 12.0 ], [ 5.0, 15.0 ], [ 2.0, 15.0 ], [ 2.0, 12.0 ] ] ] } },
{ "type": "Feature", "properties": { "id_a": "A11" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 6.0, 11.0 ], [ 10.0, 11.0 ], [ 10.0, 12.0 ], [ 7.0, 12.0 ], [ 7.0, 15.0 ], [ 6.0, 15.0 ], [ 6.0, 11.0 ] ] ] } },
{ "type": "Feature", "properties": { "id_a": "A12" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 8.0, 13.0 ], [ 10.0, 13.0 ], [ 10.0, 15.0 ], [ 8.0, 15.0 ], [ 8.0, 13.0 ] ] ] } }
]
}
152 changes: 152 additions & 0 deletions python/plugins/processing/tests/testdata/expected/union0.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
<?xml version="1.0" encoding="utf-8" ?>
<ogr:FeatureCollection
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ogr.maptools.org/ union0.xsd"
xmlns:ogr="http://ogr.maptools.org/"
xmlns:gml="http://www.opengis.net/gml">
<gml:boundedBy>
<gml:Box>
<gml:coord><gml:X>1</gml:X><gml:Y>1</gml:Y></gml:coord>
<gml:coord><gml:X>10</gml:X><gml:Y>16</gml:Y></gml:coord>
</gml:Box>
</gml:boundedBy>

<gml:featureMember>
<ogr:union0 fid="union0.0">
<ogr:geometryProperty><gml:MultiPolygon srsName="EPSG:3857"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>2,2 2,4 4,4 4,2 2,2</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon></ogr:geometryProperty>
<ogr:id_a>A2</ogr:id_a>
</ogr:union0>
</gml:featureMember>
<gml:featureMember>
<ogr:union0 fid="union0.1">
<ogr:geometryProperty><gml:MultiPolygon srsName="EPSG:3857"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>2,2 2,4 4,4 4,2 2,2</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon></ogr:geometryProperty>
<ogr:id_a>A1</ogr:id_a>
</ogr:union0>
</gml:featureMember>
<gml:featureMember>
<ogr:union0 fid="union0.2">
<ogr:geometryProperty><gml:MultiPolygon srsName="EPSG:3857"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>1,1 1,5 5,5 5,1 1,1</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs><gml:innerBoundaryIs><gml:LinearRing><gml:coordinates>2,2 4,2 4,4 2,4 2,2</gml:coordinates></gml:LinearRing></gml:innerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon></ogr:geometryProperty>
<ogr:id_a>A1</ogr:id_a>
</ogr:union0>
</gml:featureMember>
<gml:featureMember>
<ogr:union0 fid="union0.3">
<ogr:geometryProperty><gml:MultiPolygon srsName="EPSG:3857"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>7,2 7,4 9,4 9,2 7,2</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon></ogr:geometryProperty>
<ogr:id_a>A4</ogr:id_a>
</ogr:union0>
</gml:featureMember>
<gml:featureMember>
<ogr:union0 fid="union0.4">
<ogr:geometryProperty><gml:MultiPolygon srsName="EPSG:3857"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>7,2 7,4 9,4 9,2 7,2</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon></ogr:geometryProperty>
<ogr:id_a>A3</ogr:id_a>
</ogr:union0>
</gml:featureMember>
<gml:featureMember>
<ogr:union0 fid="union0.5">
<ogr:geometryProperty><gml:MultiPolygon srsName="EPSG:3857"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>2,13 1,13 1,14 2,14 2,13</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon></ogr:geometryProperty>
<ogr:id_a>A9</ogr:id_a>
</ogr:union0>
</gml:featureMember>
<gml:featureMember>
<ogr:union0 fid="union0.6">
<ogr:geometryProperty><gml:MultiPolygon srsName="EPSG:3857"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>2,13 1,13 1,14 2,14 2,13</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon></ogr:geometryProperty>
<ogr:id_a>A8</ogr:id_a>
</ogr:union0>
</gml:featureMember>
<gml:featureMember>
<ogr:union0 fid="union0.7">
<ogr:geometryProperty><gml:MultiPolygon srsName="EPSG:3857"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>6,1 6,5 10,5 10,1 6,1</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs><gml:innerBoundaryIs><gml:LinearRing><gml:coordinates>7,2 9,2 9,4 7,4 7,2</gml:coordinates></gml:LinearRing></gml:innerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon></ogr:geometryProperty>
<ogr:id_a>A4</ogr:id_a>
</ogr:union0>
</gml:featureMember>
<gml:featureMember>
<ogr:union0 fid="union0.8">
<ogr:geometryProperty><gml:MultiPolygon srsName="EPSG:3857"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>4,12 2,12 2,13 4,13 4,12</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon></ogr:geometryProperty>
<ogr:id_a>A10</ogr:id_a>
</ogr:union0>
</gml:featureMember>
<gml:featureMember>
<ogr:union0 fid="union0.9">
<ogr:geometryProperty><gml:MultiPolygon srsName="EPSG:3857"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>4,12 2,12 2,13 4,13 4,12</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon></ogr:geometryProperty>
<ogr:id_a>A8</ogr:id_a>
</ogr:union0>
</gml:featureMember>
<gml:featureMember>
<ogr:union0 fid="union0.10">
<ogr:geometryProperty><gml:MultiPolygon srsName="EPSG:3857"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>1,6 3,6 3,10 1,10 1,6</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon></ogr:geometryProperty>
<ogr:id_a>A5</ogr:id_a>
</ogr:union0>
</gml:featureMember>
<gml:featureMember>
<ogr:union0 fid="union0.11">
<ogr:geometryProperty><gml:MultiPolygon srsName="EPSG:3857"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>2,13 2,14 4,14 4,13 2,13</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon></ogr:geometryProperty>
<ogr:id_a>A10</ogr:id_a>
</ogr:union0>
</gml:featureMember>
<gml:featureMember>
<ogr:union0 fid="union0.12">
<ogr:geometryProperty><gml:MultiPolygon srsName="EPSG:3857"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>2,13 2,14 4,14 4,13 2,13</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon></ogr:geometryProperty>
<ogr:id_a>A9</ogr:id_a>
</ogr:union0>
</gml:featureMember>
<gml:featureMember>
<ogr:union0 fid="union0.13">
<ogr:geometryProperty><gml:MultiPolygon srsName="EPSG:3857"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>2,13 2,14 4,14 4,13 2,13</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon></ogr:geometryProperty>
<ogr:id_a>A8</ogr:id_a>
</ogr:union0>
</gml:featureMember>
<gml:featureMember>
<ogr:union0 fid="union0.14">
<ogr:geometryProperty><gml:MultiPolygon srsName="EPSG:3857"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>3,6 5,6 5,10 3,10 3,6</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon></ogr:geometryProperty>
<ogr:id_a>A6</ogr:id_a>
</ogr:union0>
</gml:featureMember>
<gml:featureMember>
<ogr:union0 fid="union0.15">
<ogr:geometryProperty><gml:MultiPolygon srsName="EPSG:3857"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>2,14 2,15 4,15 4,14 2,14</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon></ogr:geometryProperty>
<ogr:id_a>A10</ogr:id_a>
</ogr:union0>
</gml:featureMember>
<gml:featureMember>
<ogr:union0 fid="union0.16">
<ogr:geometryProperty><gml:MultiPolygon srsName="EPSG:3857"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>2,14 2,15 4,15 4,14 2,14</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon></ogr:geometryProperty>
<ogr:id_a>A9</ogr:id_a>
</ogr:union0>
</gml:featureMember>
<gml:featureMember>
<ogr:union0 fid="union0.17">
<ogr:geometryProperty><gml:MultiPolygon srsName="EPSG:3857"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>6,6 10,6 10,10 6,10 6,6</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon></ogr:geometryProperty>
<ogr:id_a>A7</ogr:id_a>
</ogr:union0>
</gml:featureMember>
<gml:featureMember>
<ogr:union0 fid="union0.18">
<ogr:geometryProperty><gml:MultiPolygon srsName="EPSG:3857"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>4,12 4,11 1,11 1,13 2,13 2,12 4,12</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon></ogr:geometryProperty>
<ogr:id_a>A8</ogr:id_a>
</ogr:union0>
</gml:featureMember>
<gml:featureMember>
<ogr:union0 fid="union0.19">
<ogr:geometryProperty><gml:MultiPolygon srsName="EPSG:3857"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>1,14 1,16 4,16 4,15 2,15 2,14 1,14</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon></ogr:geometryProperty>
<ogr:id_a>A9</ogr:id_a>
</ogr:union0>
</gml:featureMember>
<gml:featureMember>
<ogr:union0 fid="union0.20">
<ogr:geometryProperty><gml:MultiPolygon srsName="EPSG:3857"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>4,15 5,15 5,12 4,12 4,13 4,14 4,15</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon></ogr:geometryProperty>
<ogr:id_a>A10</ogr:id_a>
</ogr:union0>
</gml:featureMember>
<gml:featureMember>
<ogr:union0 fid="union0.21">
<ogr:geometryProperty><gml:MultiPolygon srsName="EPSG:3857"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>6,11 10,11 10,12 7,12 7,15 6,15 6,11</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon></ogr:geometryProperty>
<ogr:id_a>A11</ogr:id_a>
</ogr:union0>
</gml:featureMember>
<gml:featureMember>
<ogr:union0 fid="union0.22">
<ogr:geometryProperty><gml:MultiPolygon srsName="EPSG:3857"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>8,13 10,13 10,15 8,15 8,13</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon></ogr:geometryProperty>
<ogr:id_a>A12</ogr:id_a>
</ogr:union0>
</gml:featureMember>
</ogr:FeatureCollection>
30 changes: 30 additions & 0 deletions python/plugins/processing/tests/testdata/expected/union0.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://ogr.maptools.org/" xmlns:ogr="http://ogr.maptools.org/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:gml="http://www.opengis.net/gml" elementFormDefault="qualified" version="1.0">
<xs:import namespace="http://www.opengis.net/gml" schemaLocation="http://schemas.opengis.net/gml/2.1.2/feature.xsd"/>
<xs:element name="FeatureCollection" type="ogr:FeatureCollectionType" substitutionGroup="gml:_FeatureCollection"/>
<xs:complexType name="FeatureCollectionType">
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureCollectionType">
<xs:attribute name="lockId" type="xs:string" use="optional"/>
<xs:attribute name="scope" type="xs:string" use="optional"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="union0" type="ogr:union0_Type" substitutionGroup="gml:_Feature"/>
<xs:complexType name="union0_Type">
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureType">
<xs:sequence>
<xs:element name="geometryProperty" type="gml:MultiPolygonPropertyType" nillable="true" minOccurs="0" maxOccurs="1"/>
<xs:element name="id_a" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="255"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>
15 changes: 15 additions & 0 deletions python/plugins/processing/tests/testdata/qgis_algorithm_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5330,6 +5330,21 @@ tests:
fields:
fid: skip

- algorithm: native:union
name: Test Union of single layer
params:
INPUT:
name: custom/overlay0.geojson
type: vector
results:
OUTPUT:
name: expected/union0.gml
type: vector
compare:
unordered: true
fields:
fid: skip

- algorithm: native:union
name: Test Union (basic)
params:
Expand Down

0 comments on commit aa2b1e9

Please sign in to comment.