Skip to content

Commit

Permalink
[processing] test for union algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
ghtmtt authored and nyalldawson committed Nov 15, 2017
1 parent 2d188e9 commit c321700
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 0 deletions.
24 changes: 24 additions & 0 deletions python/plugins/processing/tests/testdata/custom/for_union.gml
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8" ?>
<ogr:FeatureCollection
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ogr.maptools.org/ for_union.xsd"
xmlns:ogr="http://ogr.maptools.org/"
xmlns:gml="http://www.opengis.net/gml">
<gml:boundedBy>
<gml:Box>
<gml:coord><gml:X>18.6909193535413</gml:X><gml:Y>45.7778586469115</gml:Y></gml:coord>
<gml:coord><gml:X>18.7047140186325</gml:X><gml:Y>45.8064427846727</gml:Y></gml:coord>
</gml:Box>
</gml:boundedBy>

<gml:featureMember>
<ogr:for_union fid="1">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>18.6931079302144,45.8064427846727 18.6909193535413,45.7990812085903 18.6939700967826,45.7943061322126 18.7047140186325,45.7953009397913 18.6931079302144,45.8064427846727</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
</ogr:for_union>
</gml:featureMember>
<gml:featureMember>
<ogr:for_union fid="2">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>18.6989441346761,45.790923786445 18.695694429919,45.7842254154151 18.6982809296236,45.7800472235846 18.6998063012443,45.7778586469115 18.7027907239804,45.7864139920883 18.7047140186325,45.7884699277509 18.6989441346761,45.790923786445</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
</ogr:for_union>
</gml:featureMember>
</ogr:FeatureCollection>
23 changes: 23 additions & 0 deletions python/plugins/processing/tests/testdata/custom/for_union.xsd
@@ -0,0 +1,23 @@
<?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="for_union" type="ogr:for_union_Type" substitutionGroup="gml:_Feature"/>
<xs:complexType name="for_union_Type">
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureType">
<xs:sequence>
<xs:element name="geometryProperty" type="gml:PolygonPropertyType" nillable="true" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>
46 changes: 46 additions & 0 deletions python/plugins/processing/tests/testdata/expected/union.gml
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8" ?>
<ogr:FeatureCollection
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ogr.maptools.org/ union.xsd"
xmlns:ogr="http://ogr.maptools.org/"
xmlns:gml="http://www.opengis.net/gml">
<gml:boundedBy>
<gml:Box>
<gml:coord><gml:X>18.67319311115957</gml:X><gml:Y>45.7778586469115</gml:Y></gml:coord>
<gml:coord><gml:X>18.7047140186325</gml:X><gml:Y>45.80786158698488</gml:Y></gml:coord>
</gml:Box>
</gml:boundedBy>

<gml:featureMember>
<ogr:union fid="polygon_mask.0">
<ogr:geometryProperty><gml:MultiPolygon srsName="EPSG:4326"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>18.6919679411186,45.8026082758958 18.6948297543933,45.8001757346123 18.694442232425,45.7962359279339 18.6931834255857,45.7955374436512 18.6909193535413,45.7990812085903 18.6919679411186,45.8026082758958</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon></ogr:geometryProperty>
</ogr:union>
</gml:featureMember>
<gml:featureMember>
<ogr:union fid="polygon_mask.0">
<ogr:geometryProperty><gml:MultiPolygon srsName="EPSG:4326"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>18.6744202640594,45.7984964727494 18.6832040953424,45.8078615869849 18.6896627948151,45.8045676502538 18.6919679411186,45.8026082758958 18.6909193535413,45.7990812085903 18.6931834255857,45.7955374436512 18.6838499652896,45.7903585114137 18.6759703519329,45.7902293374243 18.6731931111596,45.7899709894453 18.6744202640594,45.7984964727494</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon></ogr:geometryProperty>
</ogr:union>
</gml:featureMember>
<gml:featureMember>
<ogr:union fid="polygon_mask.1">
<ogr:geometryProperty><gml:MultiPolygon srsName="EPSG:4326"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>18.6977017543579,45.7883629617075 18.7009009318977,45.7856436607986 18.6997383659926,45.7811225711677 18.6979288821319,45.7806159156867 18.695694429919,45.7842254154151 18.6977017543579,45.7883629617075</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon></ogr:geometryProperty>
</ogr:union>
</gml:featureMember>
<gml:featureMember>
<ogr:union fid="polygon_mask.1">
<ogr:geometryProperty><gml:MultiPolygon srsName="EPSG:4326"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>18.6906961867308,45.7866124657195 18.694442232425,45.7911335553504 18.6977017543579,45.7883629617075 18.695694429919,45.7842254154151 18.6979288821319,45.7806159156867 18.6884356419153,45.777957808426 18.6804914415638,45.7798954182678 18.6800393326007,45.7833185289884 18.6906961867308,45.7866124657195</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon></ogr:geometryProperty>
</ogr:union>
</gml:featureMember>
<gml:featureMember>
<ogr:union fid="union.4">
<ogr:geometryProperty><gml:MultiPolygon srsName="EPSG:4326"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>18.6919679411186,45.8026082758958 18.6931079302144,45.8064427846727 18.7047140186325,45.7953009397913 18.6939700967826,45.7943061322126 18.6931834255857,45.7955374436512 18.694442232425,45.7962359279339 18.6948297543933,45.8001757346123 18.6919679411186,45.8026082758958</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon></ogr:geometryProperty>
<ogr:fid_2>1</ogr:fid_2>
</ogr:union>
</gml:featureMember>
<gml:featureMember>
<ogr:union fid="union.5">
<ogr:geometryProperty><gml:MultiPolygon srsName="EPSG:4326"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>18.6977017543579,45.7883629617075 18.6989441346761,45.790923786445 18.7047140186325,45.7884699277509 18.7027907239804,45.7864139920883 18.6998063012443,45.7778586469115 18.6982809296236,45.7800472235846 18.6979288821319,45.7806159156867 18.6997383659926,45.7811225711677 18.7009009318977,45.7856436607986 18.6977017543579,45.7883629617075</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon></ogr:geometryProperty>
<ogr:fid_2>2</ogr:fid_2>
</ogr:union>
</gml:featureMember>
</ogr:FeatureCollection>
30 changes: 30 additions & 0 deletions python/plugins/processing/tests/testdata/expected/union.xsd
@@ -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="union" type="ogr:union_Type" substitutionGroup="gml:_Feature"/>
<xs:complexType name="union_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="fid_2" 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>
13 changes: 13 additions & 0 deletions python/plugins/processing/tests/testdata/qgis_algorithm_tests.yaml
Expand Up @@ -4499,3 +4499,16 @@ tests:
__all__:
precision: 7

- algorithm: qgis:union
name: Union simple
params:
INPUT:
name: custom/polygon_mask.gml
type: vector
OVERLAY:
name: custom/for_union.gml
type: vector
results:
OUTPUT:
name: expected/union.gml
type: vector

0 comments on commit c321700

Please sign in to comment.