Skip to content

Commit d7562ee

Browse files
Bernhard Ströblm-kuhn
authored andcommitted
[processing] add test for eliminate algorithm
1 parent 1dd7da4 commit d7562ee

File tree

5 files changed

+244
-0
lines changed

5 files changed

+244
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<ogr:FeatureCollection
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://ogr.maptools.org/ eliminate_largest_area.xsd"
5+
xmlns:ogr="http://ogr.maptools.org/"
6+
xmlns:gml="http://www.opengis.net/gml">
7+
<gml:boundedBy>
8+
<gml:Box>
9+
<gml:coord><gml:X>-1</gml:X><gml:Y>-3</gml:Y></gml:coord>
10+
<gml:coord><gml:X>10</gml:X><gml:Y>6</gml:Y></gml:coord>
11+
</gml:Box>
12+
</gml:boundedBy>
13+
14+
<gml:featureMember>
15+
<ogr:eliminate_largest_area fid="polys.0">
16+
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>-1,-1 -1,3 3,3 3,2 6,1 6,-3 2,-1 -1,-1</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
17+
<ogr:name>aaaaa</ogr:name>
18+
<ogr:intval>33</ogr:intval>
19+
<ogr:floatval>44.123455999999997</ogr:floatval>
20+
</ogr:eliminate_largest_area>
21+
</gml:featureMember>
22+
<gml:featureMember>
23+
<ogr:eliminate_largest_area fid="polys.1">
24+
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>5,5 6,4 4,4 5,5</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
25+
<ogr:name>Aaaaa</ogr:name>
26+
<ogr:intval>-33</ogr:intval>
27+
<ogr:floatval>0.000000000000000</ogr:floatval>
28+
</ogr:eliminate_largest_area>
29+
</gml:featureMember>
30+
<gml:featureMember>
31+
<ogr:eliminate_largest_area fid="polys.2">
32+
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>2,5 2,6 3,6 3,5 2,5</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
33+
<ogr:name>bbaaa</ogr:name>
34+
<ogr:floatval>0.123000000000000</ogr:floatval>
35+
</ogr:eliminate_largest_area>
36+
</gml:featureMember>
37+
<gml:featureMember>
38+
<ogr:eliminate_largest_area fid="polys.3">
39+
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>6,1 10,1 10,-3 6,-3 6,1</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs><gml:innerBoundaryIs><gml:LinearRing><gml:coordinates>7,0 7,-2 9,-2 9,0 7,0</gml:coordinates></gml:LinearRing></gml:innerBoundaryIs></gml:Polygon></ogr:geometryProperty>
40+
<ogr:name>ASDF</ogr:name>
41+
<ogr:intval>0</ogr:intval>
42+
</ogr:eliminate_largest_area>
43+
</gml:featureMember>
44+
<gml:featureMember>
45+
<ogr:eliminate_largest_area fid="polys.4">
46+
<ogr:intval>120</ogr:intval>
47+
<ogr:floatval>-100291.432130000001052</ogr:floatval>
48+
</ogr:eliminate_largest_area>
49+
</gml:featureMember>
50+
</ogr:FeatureCollection>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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">
3+
<xs:import namespace="http://www.opengis.net/gml" schemaLocation="http://schemas.opengis.net/gml/2.1.2/feature.xsd"/>
4+
<xs:element name="FeatureCollection" type="ogr:FeatureCollectionType" substitutionGroup="gml:_FeatureCollection"/>
5+
<xs:complexType name="FeatureCollectionType">
6+
<xs:complexContent>
7+
<xs:extension base="gml:AbstractFeatureCollectionType">
8+
<xs:attribute name="lockId" type="xs:string" use="optional"/>
9+
<xs:attribute name="scope" type="xs:string" use="optional"/>
10+
</xs:extension>
11+
</xs:complexContent>
12+
</xs:complexType>
13+
<xs:element name="eliminate_largest_area" type="ogr:eliminate_largest_area_Type" substitutionGroup="gml:_Feature"/>
14+
<xs:complexType name="eliminate_largest_area_Type">
15+
<xs:complexContent>
16+
<xs:extension base="gml:AbstractFeatureType">
17+
<xs:sequence>
18+
<xs:element name="geometryProperty" type="gml:PolygonPropertyType" nillable="true" minOccurs="0" maxOccurs="1"/>
19+
<xs:element name="name" nillable="true" minOccurs="0" maxOccurs="1">
20+
<xs:simpleType>
21+
<xs:restriction base="xs:string">
22+
<xs:maxLength value="5"/>
23+
</xs:restriction>
24+
</xs:simpleType>
25+
</xs:element>
26+
<xs:element name="intval" nillable="true" minOccurs="0" maxOccurs="1">
27+
<xs:simpleType>
28+
<xs:restriction base="xs:integer">
29+
<xs:totalDigits value="10"/>
30+
</xs:restriction>
31+
</xs:simpleType>
32+
</xs:element>
33+
<xs:element name="floatval" nillable="true" minOccurs="0" maxOccurs="1">
34+
<xs:simpleType>
35+
<xs:restriction base="xs:decimal">
36+
<xs:totalDigits value="24"/>
37+
<xs:fractionDigits value="15"/>
38+
</xs:restriction>
39+
</xs:simpleType>
40+
</xs:element>
41+
</xs:sequence>
42+
</xs:extension>
43+
</xs:complexContent>
44+
</xs:complexType>
45+
</xs:schema>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<ogr:FeatureCollection
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://ogr.maptools.org/ eliminate_smallest_area.xsd"
5+
xmlns:ogr="http://ogr.maptools.org/"
6+
xmlns:gml="http://www.opengis.net/gml">
7+
<gml:boundedBy>
8+
<gml:Box>
9+
<gml:coord><gml:X>-1</gml:X><gml:Y>-3</gml:Y></gml:coord>
10+
<gml:coord><gml:X>10</gml:X><gml:Y>6</gml:Y></gml:coord>
11+
</gml:Box>
12+
</gml:boundedBy>
13+
14+
<gml:featureMember>
15+
<ogr:eliminate_smallest_area fid="polys.0">
16+
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>-1,-1 -1,3 3,3 3,2 2,2 2,-1 -1,-1</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
17+
<ogr:name>aaaaa</ogr:name>
18+
<ogr:intval>33</ogr:intval>
19+
<ogr:floatval>44.123455999999997</ogr:floatval>
20+
</ogr:eliminate_smallest_area>
21+
</gml:featureMember>
22+
<gml:featureMember>
23+
<ogr:eliminate_smallest_area fid="polys.1">
24+
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>5,5 6,4 4,4 5,5</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
25+
<ogr:name>Aaaaa</ogr:name>
26+
<ogr:intval>-33</ogr:intval>
27+
<ogr:floatval>0.000000000000000</ogr:floatval>
28+
</ogr:eliminate_smallest_area>
29+
</gml:featureMember>
30+
<gml:featureMember>
31+
<ogr:eliminate_smallest_area fid="polys.2">
32+
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>2,5 2,6 3,6 3,5 2,5</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
33+
<ogr:name>bbaaa</ogr:name>
34+
<ogr:floatval>0.123000000000000</ogr:floatval>
35+
</ogr:eliminate_smallest_area>
36+
</gml:featureMember>
37+
<gml:featureMember>
38+
<ogr:eliminate_smallest_area fid="polys.3">
39+
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>6,1 10,1 10,-3 6,-3 2,-1 2,2 3,2 6,1</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs><gml:innerBoundaryIs><gml:LinearRing><gml:coordinates>7,0 7,-2 9,-2 9,0 7,0</gml:coordinates></gml:LinearRing></gml:innerBoundaryIs></gml:Polygon></ogr:geometryProperty>
40+
<ogr:name>ASDF</ogr:name>
41+
<ogr:intval>0</ogr:intval>
42+
</ogr:eliminate_smallest_area>
43+
</gml:featureMember>
44+
<gml:featureMember>
45+
<ogr:eliminate_smallest_area fid="polys.4">
46+
<ogr:intval>120</ogr:intval>
47+
<ogr:floatval>-100291.432130000001052</ogr:floatval>
48+
</ogr:eliminate_smallest_area>
49+
</gml:featureMember>
50+
</ogr:FeatureCollection>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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">
3+
<xs:import namespace="http://www.opengis.net/gml" schemaLocation="http://schemas.opengis.net/gml/2.1.2/feature.xsd"/>
4+
<xs:element name="FeatureCollection" type="ogr:FeatureCollectionType" substitutionGroup="gml:_FeatureCollection"/>
5+
<xs:complexType name="FeatureCollectionType">
6+
<xs:complexContent>
7+
<xs:extension base="gml:AbstractFeatureCollectionType">
8+
<xs:attribute name="lockId" type="xs:string" use="optional"/>
9+
<xs:attribute name="scope" type="xs:string" use="optional"/>
10+
</xs:extension>
11+
</xs:complexContent>
12+
</xs:complexType>
13+
<xs:element name="eliminate_smallest_area" type="ogr:eliminate_smallest_area_Type" substitutionGroup="gml:_Feature"/>
14+
<xs:complexType name="eliminate_smallest_area_Type">
15+
<xs:complexContent>
16+
<xs:extension base="gml:AbstractFeatureType">
17+
<xs:sequence>
18+
<xs:element name="geometryProperty" type="gml:PolygonPropertyType" nillable="true" minOccurs="0" maxOccurs="1"/>
19+
<xs:element name="name" nillable="true" minOccurs="0" maxOccurs="1">
20+
<xs:simpleType>
21+
<xs:restriction base="xs:string">
22+
<xs:maxLength value="5"/>
23+
</xs:restriction>
24+
</xs:simpleType>
25+
</xs:element>
26+
<xs:element name="intval" nillable="true" minOccurs="0" maxOccurs="1">
27+
<xs:simpleType>
28+
<xs:restriction base="xs:integer">
29+
<xs:totalDigits value="10"/>
30+
</xs:restriction>
31+
</xs:simpleType>
32+
</xs:element>
33+
<xs:element name="floatval" nillable="true" minOccurs="0" maxOccurs="1">
34+
<xs:simpleType>
35+
<xs:restriction base="xs:decimal">
36+
<xs:totalDigits value="24"/>
37+
<xs:fractionDigits value="15"/>
38+
</xs:restriction>
39+
</xs:simpleType>
40+
</xs:element>
41+
</xs:sequence>
42+
</xs:extension>
43+
</xs:complexContent>
44+
</xs:complexType>
45+
</xs:schema>

python/plugins/processing/tests/testdata/qgis_algorithm_tests.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,57 @@ tests:
133133
name: expected/autoincrement_field.gml
134134
type: vector
135135

136+
137+
# Eliminate sliver polygons
138+
# case 1: merge with largest area
139+
- algorithm: qgis:eliminatesliverpolygons
140+
name: Eliminate sliver polygons largest area
141+
params:
142+
ATTRIBUTE: '"fid"'
143+
COMPARISON: '0'
144+
COMPARISONVALUE: '"polys.5"'
145+
INPUT:
146+
name: polys.shp
147+
type: vector
148+
KEEPSELECTION: 'False'
149+
MODE: '0'
150+
results:
151+
OUTPUT:
152+
name: expected/eliminate_largest_area.gml
153+
type: vector
154+
155+
# case 2: merge with smallest area
156+
- algorithm: qgis:eliminatesliverpolygons
157+
name: Eliminate sliver polygons smallest area
158+
params:
159+
ATTRIBUTE: '"fid"'
160+
COMPARISON: '0'
161+
COMPARISONVALUE: '"polys.5"'
162+
INPUT:
163+
name: polys.shp
164+
type: vector
165+
KEEPSELECTION: 'False'
166+
MODE: '1'
167+
results:
168+
OUTPUT:
169+
name: expected/eliminate_smallest_area.gml
170+
type: vector
171+
172+
# case 3: merge with longest common boundary
173+
- algorithm: qgis:eliminatesliverpolygons
174+
name: Eliminate sliver polygons largest area
175+
params:
176+
ATTRIBUTE: '"fid"'
177+
COMPARISON: '0'
178+
COMPARISONVALUE: '"polys.5"'
179+
INPUT:
180+
name: polys.shp
181+
type: vector
182+
KEEPSELECTION: 'False'
183+
MODE: '2'
184+
results:
185+
OUTPUT:
186+
name: expected/eliminate_largest_area.gml
187+
type: vector
188+
189+

0 commit comments

Comments
 (0)