Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[FEATURE] explode hstore algorithm (#8212)
  • Loading branch information
Gustry authored and nirvn committed Nov 9, 2018
1 parent df81e55 commit 6e16651
Show file tree
Hide file tree
Showing 11 changed files with 673 additions and 0 deletions.
49 changes: 49 additions & 0 deletions python/plugins/processing/tests/testdata/custom/hstore.gml
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8" ?>
<ogr:FeatureCollection
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ogr.maptools.org/ hstore.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>-3</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:hstore fid="polys.0">
<ogr:geometryProperty><gml:MultiPolygon srsName="EPSG:4326"><gml:polygonMember><gml:Polygon><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></gml:polygonMember></gml:MultiPolygon></ogr:geometryProperty>
<ogr:hstore>&quot;amenity&quot;=&gt;&quot;restaurant&quot;,&quot;barrier&quot;=&gt;&quot;wall&quot;,&quot;cuisine&quot;=&gt;&quot;chinese&quot;,&quot;internet_access&quot;=&gt;&quot;yes&quot;</ogr:hstore>
</ogr:hstore>
</gml:featureMember>
<gml:featureMember>
<ogr:hstore fid="polys.1">
<ogr:geometryProperty><gml:MultiPolygon srsName="EPSG:4326"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>5,5 6,4 4,4 5,5</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon></ogr:geometryProperty>
<ogr:hstore>&quot;amenity&quot;=&gt;&quot;fuel&quot;,&quot;building&quot;=&gt;&quot;roof&quot;,&quot;name&quot;=&gt;&quot;foo&quot;</ogr:hstore>
</ogr:hstore>
</gml:featureMember>
<gml:featureMember>
<ogr:hstore fid="polys.2">
<ogr:geometryProperty><gml:MultiPolygon srsName="EPSG:4326"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>2,5 2,6 3,6 3,5 2,5</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon></ogr:geometryProperty>
<ogr:hstore>&quot;building&quot;=&gt;&quot;yes&quot;</ogr:hstore>
</ogr:hstore>
</gml:featureMember>
<gml:featureMember>
<ogr:hstore fid="polys.3">
<ogr:geometryProperty><gml:MultiPolygon srsName="EPSG:4326"><gml:polygonMember><gml:Polygon><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></gml:polygonMember></gml:MultiPolygon></ogr:geometryProperty>
<ogr:hstore>&quot;amenity&quot;=&gt;&quot;restaurant&quot;,&quot;cuisine&quot;=&gt;&quot;burger&quot;,&quot;name&quot;=&gt;&quot;bar&quot;,&quot;operator&quot;=&gt;&quot;foo&quot;</ogr:hstore>
</ogr:hstore>
</gml:featureMember>
<gml:featureMember>
<ogr:hstore fid="polys.4">
<ogr:hstore>&quot;amenity&quot;=&gt;&quot;bank&quot;,&quot;atm&quot;=&gt;&quot;yes&quot;</ogr:hstore>
</ogr:hstore>
</gml:featureMember>
<gml:featureMember>
<ogr:hstore fid="polys.5">
<ogr:geometryProperty><gml:MultiPolygon srsName="EPSG:4326"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>3,2 6,1 6,-3 2,-1 2,2 3,2</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon></ogr:geometryProperty>
<ogr:hstore>&quot;stars&quot;=&gt;&quot;5&quot;,&quot;tourism&quot;=&gt;&quot;hotel&quot;</ogr:hstore>
</ogr:hstore>
</gml:featureMember>
</ogr:FeatureCollection>
30 changes: 30 additions & 0 deletions python/plugins/processing/tests/testdata/custom/hstore.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="hstore" type="ogr:hstore_Type" substitutionGroup="gml:_Feature"/>
<xs:complexType name="hstore_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="hstore" 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>
109 changes: 109 additions & 0 deletions python/plugins/processing/tests/testdata/expected/hstore_all_keys.gml
@@ -0,0 +1,109 @@
<?xml version="1.0" encoding="utf-8" ?>
<ogr:FeatureCollection
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ogr.maptools.org/ hstore_all_keys.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>-3</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:hstore_all_keys fid="polys.0">
<ogr:geometryProperty><gml:MultiPolygon srsName="EPSG:4326"><gml:polygonMember><gml:Polygon><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></gml:polygonMember></gml:MultiPolygon></ogr:geometryProperty>
<ogr:hstore>&quot;amenity&quot;=&gt;&quot;restaurant&quot;,&quot;barrier&quot;=&gt;&quot;wall&quot;,&quot;cuisine&quot;=&gt;&quot;chinese&quot;,&quot;internet_access&quot;=&gt;&quot;yes&quot;</ogr:hstore>
<ogr:tourism xsi:nil="true"/>
<ogr:stars xsi:nil="true"/>
<ogr:atm xsi:nil="true"/>
<ogr:operator xsi:nil="true"/>
<ogr:name xsi:nil="true"/>
<ogr:building xsi:nil="true"/>
<ogr:internet_access>yes</ogr:internet_access>
<ogr:cuisine>chinese</ogr:cuisine>
<ogr:barrier>wall</ogr:barrier>
<ogr:amenity>restaurant</ogr:amenity>
</ogr:hstore_all_keys>
</gml:featureMember>
<gml:featureMember>
<ogr:hstore_all_keys fid="polys.1">
<ogr:geometryProperty><gml:MultiPolygon srsName="EPSG:4326"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>5,5 6,4 4,4 5,5</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon></ogr:geometryProperty>
<ogr:hstore>&quot;amenity&quot;=&gt;&quot;fuel&quot;,&quot;building&quot;=&gt;&quot;roof&quot;,&quot;name&quot;=&gt;&quot;foo&quot;</ogr:hstore>
<ogr:tourism xsi:nil="true"/>
<ogr:stars xsi:nil="true"/>
<ogr:atm xsi:nil="true"/>
<ogr:operator xsi:nil="true"/>
<ogr:name>foo</ogr:name>
<ogr:building>roof</ogr:building>
<ogr:internet_access xsi:nil="true"/>
<ogr:cuisine xsi:nil="true"/>
<ogr:barrier xsi:nil="true"/>
<ogr:amenity>fuel</ogr:amenity>
</ogr:hstore_all_keys>
</gml:featureMember>
<gml:featureMember>
<ogr:hstore_all_keys fid="polys.2">
<ogr:geometryProperty><gml:MultiPolygon srsName="EPSG:4326"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>2,5 2,6 3,6 3,5 2,5</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon></ogr:geometryProperty>
<ogr:hstore>&quot;building&quot;=&gt;&quot;yes&quot;</ogr:hstore>
<ogr:tourism xsi:nil="true"/>
<ogr:stars xsi:nil="true"/>
<ogr:atm xsi:nil="true"/>
<ogr:operator xsi:nil="true"/>
<ogr:name xsi:nil="true"/>
<ogr:building>yes</ogr:building>
<ogr:internet_access xsi:nil="true"/>
<ogr:cuisine xsi:nil="true"/>
<ogr:barrier xsi:nil="true"/>
<ogr:amenity xsi:nil="true"/>
</ogr:hstore_all_keys>
</gml:featureMember>
<gml:featureMember>
<ogr:hstore_all_keys fid="polys.3">
<ogr:geometryProperty><gml:MultiPolygon srsName="EPSG:4326"><gml:polygonMember><gml:Polygon><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></gml:polygonMember></gml:MultiPolygon></ogr:geometryProperty>
<ogr:hstore>&quot;amenity&quot;=&gt;&quot;restaurant&quot;,&quot;cuisine&quot;=&gt;&quot;burger&quot;,&quot;name&quot;=&gt;&quot;bar&quot;,&quot;operator&quot;=&gt;&quot;foo&quot;</ogr:hstore>
<ogr:tourism xsi:nil="true"/>
<ogr:stars xsi:nil="true"/>
<ogr:atm xsi:nil="true"/>
<ogr:operator>foo</ogr:operator>
<ogr:name>bar</ogr:name>
<ogr:building xsi:nil="true"/>
<ogr:internet_access xsi:nil="true"/>
<ogr:cuisine>burger</ogr:cuisine>
<ogr:barrier xsi:nil="true"/>
<ogr:amenity>restaurant</ogr:amenity>
</ogr:hstore_all_keys>
</gml:featureMember>
<gml:featureMember>
<ogr:hstore_all_keys fid="polys.4">
<ogr:hstore>&quot;amenity&quot;=&gt;&quot;bank&quot;,&quot;atm&quot;=&gt;&quot;yes&quot;</ogr:hstore>
<ogr:tourism xsi:nil="true"/>
<ogr:stars xsi:nil="true"/>
<ogr:atm>yes</ogr:atm>
<ogr:operator xsi:nil="true"/>
<ogr:name xsi:nil="true"/>
<ogr:building xsi:nil="true"/>
<ogr:internet_access xsi:nil="true"/>
<ogr:cuisine xsi:nil="true"/>
<ogr:barrier xsi:nil="true"/>
<ogr:amenity>bank</ogr:amenity>
</ogr:hstore_all_keys>
</gml:featureMember>
<gml:featureMember>
<ogr:hstore_all_keys fid="polys.5">
<ogr:geometryProperty><gml:MultiPolygon srsName="EPSG:4326"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>3,2 6,1 6,-3 2,-1 2,2 3,2</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon></ogr:geometryProperty>
<ogr:hstore>&quot;stars&quot;=&gt;&quot;5&quot;,&quot;tourism&quot;=&gt;&quot;hotel&quot;</ogr:hstore>
<ogr:tourism>hotel</ogr:tourism>
<ogr:stars>5</ogr:stars>
<ogr:atm xsi:nil="true"/>
<ogr:operator xsi:nil="true"/>
<ogr:name xsi:nil="true"/>
<ogr:building xsi:nil="true"/>
<ogr:internet_access xsi:nil="true"/>
<ogr:cuisine xsi:nil="true"/>
<ogr:barrier xsi:nil="true"/>
<ogr:amenity xsi:nil="true"/>
</ogr:hstore_all_keys>
</gml:featureMember>
</ogr:FeatureCollection>
100 changes: 100 additions & 0 deletions python/plugins/processing/tests/testdata/expected/hstore_all_keys.xsd
@@ -0,0 +1,100 @@
<?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="hstore_all_keys" type="ogr:hstore_all_keys_Type" substitutionGroup="gml:_Feature"/>
<xs:complexType name="hstore_all_keys_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="hstore" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="255"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="tourism" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="255"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="stars" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="255"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="atm" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="255"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="operator" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="255"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="name" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="255"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="building" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="255"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="internet_access" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="255"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="cuisine" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="255"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="barrier" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="255"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="amenity" 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>

0 comments on commit 6e16651

Please sign in to comment.