Skip to content
Permalink
Browse files

Merge pull request #34750 from gacarrillor/remove_duplicate_nodes_in_…

…collections

Remove duplicate nodes from each part in a collection
  • Loading branch information
m-kuhn committed Mar 5, 2020
2 parents 23aa83c + e41930d commit 6548d6c17cb3ed8857befb64092ec1151c687da5
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8" ?>
<ogr:FeatureCollection
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ogr.maptools.org/ multi_polygons_with_duplicate_nodes_per_part.xsd"
xmlns:ogr="http://ogr.maptools.org/"
xmlns:gml="http://www.opengis.net/gml">
<gml:boundedBy>
<gml:Box>
<gml:coord><gml:X>968815.3943152929</gml:X><gml:Y>1025158.19515878</gml:Y><gml:Z>0</gml:Z></gml:coord>
<gml:coord><gml:X>968914.597029779</gml:X><gml:Y>1025230.1192821</gml:Y><gml:Z>0</gml:Z></gml:coord>
</gml:Box>
</gml:boundedBy>

<gml:featureMember>
<ogr:multi_polygons_with_duplicate_nodes_per_part fid="1">
<ogr:geometryProperty><gml:MultiPolygon srsName="EPSG:3116"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>968914.597029771,1025161.47936474,0 968911.522754316,1025158.19515878,0 968909.880651343,1025159.73229651,0 968908.238548368,1025161.26943424,0 968906.596445397,1025162.80657196,0 968904.954342425,1025164.34370969,0 968903.312239451,1025165.88084741,0 968901.670136476,1025167.41798513,0 968900.028033506,1025168.95512285,0 968898.385930536,1025170.49226056,0 968896.743827569,1025172.02939827,0 968895.101724596,1025173.56653599,0 968893.459621628,1025175.10367369,0 968891.817518649,1025176.6408114,0 968890.175415682,1025178.17794911,0 968888.533312703,1025179.71508681,0 968886.891209736,1025181.25222451,0 968885.249106765,1025182.7893622,0 968883.607003796,1025184.3264999,0 968881.964900828,1025185.86363759,0 968880.322797863,1025187.40077529,0 968878.68069489,1025188.93791297,0 968877.038591917,1025190.47505067,0 968875.396488946,1025192.01218835,0 968873.754385985,1025193.54932605,0 968872.112283011,1025195.08646373,0 968870.470180035,1025196.62360141,0 968868.828077071,1025198.16073909,0 968867.185974099,1025199.69787676,0 968865.543871132,1025201.23501443,0 968863.901768165,1025202.7721521,0 968862.259665201,1025204.30928977,0 968860.617562226,1025205.84642743,0 968858.975459257,1025207.3835651,0 968857.333356278,1025208.92070276,0 968855.691253323,1025210.45784042,0 968854.049150351,1025211.99497808,0 968852.407047385,1025213.53211573,0 968850.764944418,1025215.06925339,0 968849.122841457,1025216.60639104,0 968847.480738491,1025218.14352868,0 968845.838635518,1025219.68066633,0 968844.196532546,1025221.21780398,0 968842.554429589,1025222.75494163,0 968845.628704867,1025226.03914756,0 968847.270807833,1025224.50200992,0 968848.912910808,1025222.96487227,0 968850.555013783,1025221.42773462,0 968852.197116745,1025219.89059697,0 968853.839219726,1025218.35345932,0 968855.481322689,1025216.81632167,0 968857.123425662,1025215.27918402,0 968858.765528633,1025213.74204635,0 968860.407631607,1025212.2049087,0 968862.049734583,1025210.66777104,0 968863.691837564,1025209.13063337,0 968865.333940528,1025207.59349571,0 968866.976043502,1025206.05635805,0 968868.618146473,1025204.51922037,0 968870.260249449,1025202.98208271,0 968871.902352417,1025201.44494503,0 968873.544455392,1025199.90780736,0 968875.186558365,1025198.37066967,0 968876.828661348,1025196.833532,0 968878.470764315,1025195.29639432,0 968880.112867295,1025193.75925663,0 968881.754970269,1025192.22211893,0 968883.397073237,1025190.68498124,0 968885.039176219,1025189.14784355,0 968886.681279184,1025187.61070586,0 968888.323382159,1025186.07356817,0 968889.965485132,1025184.53643047,0 968891.607588104,1025182.99929276,0 968893.249691087,1025181.46215507,0 968894.891794066,1025179.92501736,0 968896.533897035,1025178.38787966,0 968898.176000014,1025176.85074195,0 968899.818102987,1025175.31360424,0 968901.460205966,1025173.77646653,0 968903.102308939,1025172.23932881,0 968904.744411915,1025170.7021911,0 968906.386514898,1025169.16505337,0 968908.028617876,1025167.62791565,0 968909.670720846,1025166.09077793,0 968911.312823825,1025164.5536402,0 968912.954926799,1025163.01650248,0 968914.597029779,1025161.47936475,0 968914.597029771,1025161.47936474,0</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>968820.215658792,1025210.62397739,0 968818.678521156,1025208.98187445,0 968815.394315293,1025212.05614973,0 968816.931452928,1025213.69825267,0 968818.468590571,1025215.3403556,0 968820.005728204,1025216.98245854,0 968821.542865847,1025218.62456147,0 968823.080003479,1025220.26666442,0 968824.617141122,1025221.90876736,0 968826.154278753,1025223.5508703,0 968827.691416396,1025225.19297325,0 968829.228554029,1025226.83507619,0 968830.765691671,1025228.47717914,0 968832.302829298,1025230.1192821,0 968835.587035208,1025227.04500683,0 968834.049897577,1025225.40290386,0 968832.512759924,1025223.76080092,0 968830.975622296,1025222.11869796,0 968829.438484644,1025220.47659502,0 968829.438484644,1025220.47659502,0 968827.90134701,1025218.83449207,0 968826.364209362,1025217.19238913,0 968824.827071723,1025215.55028619,0 968823.289934075,1025213.90818326,0 968821.75279644,1025212.26608031,0 968820.215658792,1025210.62397739,0</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>968843.585005633,1025218.29667523,0 968842.04786799,1025216.65457227,0 968842.04786799,1025216.65457227,0 968842.047867976,1025216.65457228,0 968840.51073033,1025215.01246932,0 968838.973592665,1025213.37036637,0 968837.436455022,1025211.72826342,0 968835.899317361,1025210.08616048,0 968834.36217971,1025208.44405754,0 968832.825042064,1025206.80195459,0 968829.540836186,1025209.8762299,0 968831.07797383,1025211.51833284,0 968832.615111479,1025213.16043579,0 968834.152249129,1025214.80253873,0 968835.689386773,1025216.44464168,0 968837.226524426,1025218.08674462,0 968838.763662072,1025219.72884758,0 968840.300799724,1025221.37095053,0 968843.585005633,1025218.29667523,0</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon></ogr:geometryProperty>
<ogr:gml_id>multi_polygons_duplicate_nodes_per_part.0</ogr:gml_id>
</ogr:multi_polygons_with_duplicate_nodes_per_part>
</gml:featureMember>
</ogr:FeatureCollection>
@@ -0,0 +1,29 @@
<?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="multi_polygons_with_duplicate_nodes_per_part" type="ogr:multi_polygons_with_duplicate_nodes_per_part_Type" substitutionGroup="gml:_Feature"/>
<xs:complexType name="multi_polygons_with_duplicate_nodes_per_part_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="gml_id" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8" ?>
<ogr:FeatureCollection
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ogr.maptools.org/ multi_polygons_without_duplicate_nodes.xsd"
xmlns:ogr="http://ogr.maptools.org/"
xmlns:gml="http://www.opengis.net/gml">
<gml:boundedBy>
<gml:Box>
<gml:coord><gml:X>968815.3943152929</gml:X><gml:Y>1025158.19515878</gml:Y><gml:Z>0</gml:Z></gml:coord>
<gml:coord><gml:X>968914.597029771</gml:X><gml:Y>1025230.1192821</gml:Y><gml:Z>0</gml:Z></gml:coord>
</gml:Box>
</gml:boundedBy>

<gml:featureMember>
<ogr:multi_polygons_without_duplicate_nodes fid="1">
<ogr:geometryProperty><gml:MultiPolygon srsName="EPSG:3116"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>968914.597029771,1025161.47936474,0 968911.522754316,1025158.19515878,0 968909.880651343,1025159.73229651,0 968908.238548368,1025161.26943424,0 968906.596445397,1025162.80657196,0 968904.954342425,1025164.34370969,0 968903.312239451,1025165.88084741,0 968901.670136476,1025167.41798513,0 968900.028033506,1025168.95512285,0 968898.385930536,1025170.49226056,0 968896.743827569,1025172.02939827,0 968895.101724596,1025173.56653599,0 968893.459621628,1025175.10367369,0 968891.817518649,1025176.6408114,0 968890.175415682,1025178.17794911,0 968888.533312703,1025179.71508681,0 968886.891209736,1025181.25222451,0 968885.249106765,1025182.7893622,0 968883.607003796,1025184.3264999,0 968881.964900828,1025185.86363759,0 968880.322797863,1025187.40077529,0 968878.68069489,1025188.93791297,0 968877.038591917,1025190.47505067,0 968875.396488946,1025192.01218835,0 968873.754385985,1025193.54932605,0 968872.112283011,1025195.08646373,0 968870.470180035,1025196.62360141,0 968868.828077071,1025198.16073909,0 968867.185974099,1025199.69787676,0 968865.543871132,1025201.23501443,0 968863.901768165,1025202.7721521,0 968862.259665201,1025204.30928977,0 968860.617562226,1025205.84642743,0 968858.975459257,1025207.3835651,0 968857.333356278,1025208.92070276,0 968855.691253323,1025210.45784042,0 968854.049150351,1025211.99497808,0 968852.407047385,1025213.53211573,0 968850.764944418,1025215.06925339,0 968849.122841457,1025216.60639104,0 968847.480738491,1025218.14352868,0 968845.838635518,1025219.68066633,0 968844.196532546,1025221.21780398,0 968842.554429589,1025222.75494163,0 968845.628704867,1025226.03914756,0 968847.270807833,1025224.50200992,0 968848.912910808,1025222.96487227,0 968850.555013783,1025221.42773462,0 968852.197116745,1025219.89059697,0 968853.839219726,1025218.35345932,0 968855.481322689,1025216.81632167,0 968857.123425662,1025215.27918402,0 968858.765528633,1025213.74204635,0 968860.407631607,1025212.2049087,0 968862.049734583,1025210.66777104,0 968863.691837564,1025209.13063337,0 968865.333940528,1025207.59349571,0 968866.976043502,1025206.05635805,0 968868.618146473,1025204.51922037,0 968870.260249449,1025202.98208271,0 968871.902352417,1025201.44494503,0 968873.544455392,1025199.90780736,0 968875.186558365,1025198.37066967,0 968876.828661348,1025196.833532,0 968878.470764315,1025195.29639432,0 968880.112867295,1025193.75925663,0 968881.754970269,1025192.22211893,0 968883.397073237,1025190.68498124,0 968885.039176219,1025189.14784355,0 968886.681279184,1025187.61070586,0 968888.323382159,1025186.07356817,0 968889.965485132,1025184.53643047,0 968891.607588104,1025182.99929276,0 968893.249691087,1025181.46215507,0 968894.891794066,1025179.92501736,0 968896.533897035,1025178.38787966,0 968898.176000014,1025176.85074195,0 968899.818102987,1025175.31360424,0 968901.460205966,1025173.77646653,0 968903.102308939,1025172.23932881,0 968904.744411915,1025170.7021911,0 968906.386514898,1025169.16505337,0 968908.028617876,1025167.62791565,0 968909.670720846,1025166.09077793,0 968911.312823825,1025164.5536402,0 968912.954926799,1025163.01650248,0 968914.597029771,1025161.47936474,0</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>968820.215658792,1025210.62397739,0 968818.678521156,1025208.98187445,0 968815.394315293,1025212.05614973,0 968816.931452928,1025213.69825267,0 968818.468590571,1025215.3403556,0 968820.005728204,1025216.98245854,0 968821.542865847,1025218.62456147,0 968823.080003479,1025220.26666442,0 968824.617141122,1025221.90876736,0 968826.154278753,1025223.5508703,0 968827.691416396,1025225.19297325,0 968829.228554029,1025226.83507619,0 968830.765691671,1025228.47717914,0 968832.302829298,1025230.1192821,0 968835.587035208,1025227.04500683,0 968834.049897577,1025225.40290386,0 968832.512759924,1025223.76080092,0 968830.975622296,1025222.11869796,0 968829.438484644,1025220.47659502,0 968827.90134701,1025218.83449207,0 968826.364209362,1025217.19238913,0 968824.827071723,1025215.55028619,0 968823.289934075,1025213.90818326,0 968821.75279644,1025212.26608031,0 968820.215658792,1025210.62397739,0</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>968843.585005633,1025218.29667523,0 968842.04786799,1025216.65457227,0 968840.51073033,1025215.01246932,0 968838.973592665,1025213.37036637,0 968837.436455022,1025211.72826342,0 968835.899317361,1025210.08616048,0 968834.36217971,1025208.44405754,0 968832.825042064,1025206.80195459,0 968829.540836186,1025209.8762299,0 968831.07797383,1025211.51833284,0 968832.615111479,1025213.16043579,0 968834.152249129,1025214.80253873,0 968835.689386773,1025216.44464168,0 968837.226524426,1025218.08674462,0 968838.763662072,1025219.72884758,0 968840.300799724,1025221.37095053,0 968843.585005633,1025218.29667523,0</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon></ogr:geometryProperty>
<ogr:gml_id>multi_polygons_duplicate_nodes_per_part.0</ogr:gml_id>
</ogr:multi_polygons_without_duplicate_nodes>
</gml:featureMember>
</ogr:FeatureCollection>
@@ -0,0 +1,29 @@
<?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="multi_polygons_without_duplicate_nodes" type="ogr:multi_polygons_without_duplicate_nodes_Type" substitutionGroup="gml:_Feature"/>
<xs:complexType name="multi_polygons_without_duplicate_nodes_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="gml_id" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>
@@ -41,6 +41,19 @@ tests:
name: expected/removed_duplicated_nodes_line.gml
type: vector

- algorithm: native:removeduplicatevertices
name: Remove duplicate vertices from all parts
params:
INPUT:
name: custom/multi_polygons_with_duplicate_nodes_per_part.gml
type: vector
TOLERANCE: 0.001
USE_Z_VALUE: false
results:
OUTPUT:
name: expected/multi_polygons_without_duplicate_nodes.gml
type: vector

- algorithm: qgis:keepnbiggestparts
name: Keep N biggest parts
params:
@@ -147,7 +147,7 @@ bool QgsGeometryCollection::removeDuplicateNodes( double epsilon, bool useZValue
bool result = false;
for ( QgsAbstractGeometry *geom : qgis::as_const( mGeometries ) )
{
result = result || geom->removeDuplicateNodes( epsilon, useZValues );
if ( geom->removeDuplicateNodes( epsilon, useZValues ) ) result = true;
}
return result;
}

0 comments on commit 6548d6c

Please sign in to comment.
You can’t perform that action at this time.