Skip to content

Commit

Permalink
Test for multipoint Delaunay triangulation
Browse files Browse the repository at this point in the history
  • Loading branch information
p0cisk authored and m-kuhn committed Oct 19, 2016
1 parent 41fafd6 commit 3af2303
Show file tree
Hide file tree
Showing 4 changed files with 155 additions and 3 deletions.
4 changes: 2 additions & 2 deletions python/plugins/processing/algs/qgis/Delaunay.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def processAlgorithm(self, progress):
features = vector.features(layer)
total = 100.0 / len(features)
for current, inFeat in enumerate(features):
geom = inFeat.geometry()
geom = QgsGeometry(inFeat.geometry())
if geom.isMultipart():
points = geom.asMultiPoint()
else:
Expand Down Expand Up @@ -118,7 +118,7 @@ def processAlgorithm(self, progress):
fid, n = ptDict[ids[index]]
request = QgsFeatureRequest().setFilterFid(fid)
inFeat = next(layer.getFeatures(request))
geom = inFeat.geometry()
geom = QgsGeometry(inFeat.geometry())
if geom.isMultipart():
point = QgsPoint(geom.asMultiPoint()[n])
else:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?xml version="1.0" encoding="utf-8" ?>
<ogr:FeatureCollection
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ogr.maptools.org/ multipoint_delauney.xsd"
xmlns:ogr="http://ogr.maptools.org/"
xmlns:gml="http://www.opengis.net/gml">
<gml:boundedBy>
<gml:Box>
<gml:coord><gml:X>0</gml:X><gml:Y>-5</gml:Y></gml:coord>
<gml:coord><gml:X>8</gml:X><gml:Y>3</gml:Y></gml:coord>
</gml:Box>
</gml:boundedBy>

<gml:featureMember>
<ogr:multipoint_delauney fid="multipoint_delauney.0">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>7,-1 8,-1 0,-5 7,-1</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:POINTA>8.000000000000000</ogr:POINTA>
<ogr:POINTB>7.000000000000000</ogr:POINTB>
<ogr:POINTC>6.000000000000000</ogr:POINTC>
</ogr:multipoint_delauney>
</gml:featureMember>
<gml:featureMember>
<ogr:multipoint_delauney fid="multipoint_delauney.1">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>0,-5 4,1 7,-1 0,-5</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:POINTA>6.000000000000000</ogr:POINTA>
<ogr:POINTB>5.000000000000000</ogr:POINTB>
<ogr:POINTC>8.000000000000000</ogr:POINTC>
</ogr:multipoint_delauney>
</gml:featureMember>
<gml:featureMember>
<ogr:multipoint_delauney fid="multipoint_delauney.2">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>0,-1 4,1 0,-5 0,-1</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:POINTA>9.000000000000000</ogr:POINTA>
<ogr:POINTB>5.000000000000000</ogr:POINTB>
<ogr:POINTC>6.000000000000000</ogr:POINTC>
</ogr:multipoint_delauney>
</gml:featureMember>
<gml:featureMember>
<ogr:multipoint_delauney fid="multipoint_delauney.3">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>1,1 0,-1 0,0 1,1</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:POINTA>1.000000000000000</ogr:POINTA>
<ogr:POINTB>9.000000000000000</ogr:POINTB>
<ogr:POINTC>0.000000000000000</ogr:POINTC>
</ogr:multipoint_delauney>
</gml:featureMember>
<gml:featureMember>
<ogr:multipoint_delauney fid="multipoint_delauney.4">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>1,1 4,1 0,-1 1,1</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:POINTA>1.000000000000000</ogr:POINTA>
<ogr:POINTB>5.000000000000000</ogr:POINTB>
<ogr:POINTC>9.000000000000000</ogr:POINTC>
</ogr:multipoint_delauney>
</gml:featureMember>
<gml:featureMember>
<ogr:multipoint_delauney fid="multipoint_delauney.5">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>2,2 4,1 1,1 2,2</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:POINTA>2.000000000000000</ogr:POINTA>
<ogr:POINTB>5.000000000000000</ogr:POINTB>
<ogr:POINTC>1.000000000000000</ogr:POINTC>
</ogr:multipoint_delauney>
</gml:featureMember>
<gml:featureMember>
<ogr:multipoint_delauney fid="multipoint_delauney.6">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>5,2 7,-1 4,1 5,2</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:POINTA>4.000000000000000</ogr:POINTA>
<ogr:POINTB>8.000000000000000</ogr:POINTB>
<ogr:POINTC>5.000000000000000</ogr:POINTC>
</ogr:multipoint_delauney>
</gml:featureMember>
<gml:featureMember>
<ogr:multipoint_delauney fid="multipoint_delauney.7">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>3,3 4,1 2,2 3,3</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:POINTA>3.000000000000000</ogr:POINTA>
<ogr:POINTB>5.000000000000000</ogr:POINTB>
<ogr:POINTC>2.000000000000000</ogr:POINTC>
</ogr:multipoint_delauney>
</gml:featureMember>
<gml:featureMember>
<ogr:multipoint_delauney fid="multipoint_delauney.8">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>3,3 5,2 4,1 3,3</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:POINTA>3.000000000000000</ogr:POINTA>
<ogr:POINTB>4.000000000000000</ogr:POINTB>
<ogr:POINTC>5.000000000000000</ogr:POINTC>
</ogr:multipoint_delauney>
</gml:featureMember>
<gml:featureMember>
<ogr:multipoint_delauney fid="multipoint_delauney.9">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>5,2 8,-1 7,-1 5,2</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:POINTA>4.000000000000000</ogr:POINTA>
<ogr:POINTB>7.000000000000000</ogr:POINTB>
<ogr:POINTC>8.000000000000000</ogr:POINTC>
</ogr:multipoint_delauney>
</gml:featureMember>
</ogr:FeatureCollection>
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?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="multipoint_delauney" type="ogr:multipoint_delauney_Type" substitutionGroup="gml:_Feature"/>
<xs:complexType name="multipoint_delauney_Type">
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureType">
<xs:sequence>
<xs:element name="geometryProperty" type="gml:PolygonPropertyType" nillable="true" minOccurs="0" maxOccurs="1"/>
<xs:element name="POINTA" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:totalDigits value="25"/>
<xs:fractionDigits value="15"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="POINTB" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:totalDigits value="25"/>
<xs:fractionDigits value="15"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="POINTC" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:totalDigits value="25"/>
<xs:fractionDigits value="15"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>
Original file line number Diff line number Diff line change
Expand Up @@ -1112,4 +1112,15 @@ tests:
results:
OUTPUT:
name: expected/sum_line_length.gml
type: vector
type: vector

- algorithm: qgis:delaunaytriangulation
name: Delaunay triangulation (multipoint data)
params:
INPUT:
name: multipoints.gml
type: vector
results:
OUTPUT:
name: expected/multipoint_delaunay.gml
type: vector

0 comments on commit 3af2303

Please sign in to comment.