Skip to content

Commit d34c09b

Browse files
authoredOct 24, 2017
Merge pull request #5427 from alexbruy/processing-distance
[processing] keep column names in standard distance matrix (fix #17150)
2 parents 5261a9a + 04a8418 commit d34c09b

File tree

8 files changed

+1178
-13
lines changed

8 files changed

+1178
-13
lines changed
 

‎python/plugins/processing/algs/qgis/PointDistance.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
* *
1717
***************************************************************************
1818
"""
19-
from builtins import next
20-
from builtins import str
21-
from builtins import range
2219

2320
__author__ = 'Victor Olaya'
2421
__date__ = 'August 2012'
@@ -207,14 +204,15 @@ def linearMatrix(self, parameters, context, source, inField, target_source, targ
207204

208205
def regularMatrix(self, parameters, context, source, inField, target_source, targetField,
209206
nPoints, feedback):
210-
211-
index = QgsSpatialIndex(target_source.getFeatures(QgsFeatureRequest().setSubsetOfAttributes([]).setDestinationCrs(source.sourceCrs())), feedback)
212-
inIdx = source.fields().lookupField(inField)
213-
214207
distArea = QgsDistanceArea()
215208
distArea.setSourceCrs(source.sourceCrs())
216209
distArea.setEllipsoid(context.project().ellipsoid())
217210

211+
inIdx = source.fields().lookupField(inField)
212+
targetIdx = target_source.fields().lookupField(targetField)
213+
214+
index = QgsSpatialIndex(target_source.getFeatures(QgsFeatureRequest().setSubsetOfAttributes([]).setDestinationCrs(source.sourceCrs())), feedback)
215+
218216
first = True
219217
sink = None
220218
dest_id = None
@@ -225,27 +223,28 @@ def regularMatrix(self, parameters, context, source, inField, target_source, tar
225223
break
226224

227225
inGeom = inFeat.geometry()
228-
inID = str(inFeat.attributes()[inIdx])
229-
featList = index.nearestNeighbor(inGeom.asPoint(), nPoints)
230226
if first:
227+
featList = index.nearestNeighbor(inGeom.asPoint(), nPoints)
231228
first = False
232229
fields = QgsFields()
233230
input_id_field = source.fields()[inIdx]
234231
input_id_field.setName('ID')
235232
fields.append(input_id_field)
236-
for i in range(len(featList)):
237-
fields.append(QgsField('DIST_{0}'.format(i + 1), QVariant.Double))
233+
for f in target_source.getFeatures(QgsFeatureRequest().setFilterFids(featList).setSubsetOfAttributes([targetIdx]).setDestinationCrs(source.sourceCrs())):
234+
fields.append(QgsField(str(f[targetField]), QVariant.Double))
235+
238236
(sink, dest_id) = self.parameterAsSink(parameters, self.OUTPUT, context,
239237
fields, source.wkbType(), source.sourceCrs())
240238

241-
data = [inID]
239+
data = [inFeat[inField]]
242240
for target in target_source.getFeatures(QgsFeatureRequest().setSubsetOfAttributes([]).setFilterFids(featList).setDestinationCrs(source.sourceCrs())):
243241
if feedback.isCanceled():
244242
break
245243
outGeom = target.geometry()
246244
dist = distArea.measureLine(inGeom.asPoint(),
247245
outGeom.asPoint())
248-
data.append(float(dist))
246+
data.append(dist)
247+
249248
out_feature = QgsFeature()
250249
out_feature.setGeometry(inGeom)
251250
out_feature.setAttributes(data)

‎python/plugins/processing/tests/testdata/expected/linear_matrix.gml

Lines changed: 662 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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="linear_matrix" type="ogr:linear_matrix_Type" substitutionGroup="gml:_Feature"/>
14+
<xs:complexType name="linear_matrix_Type">
15+
<xs:complexContent>
16+
<xs:extension base="gml:AbstractFeatureType">
17+
<xs:sequence>
18+
<xs:element name="geometryProperty" type="gml:MultiPointPropertyType" nillable="true" minOccurs="0" maxOccurs="1"/>
19+
<xs:element name="InputID" nillable="true" minOccurs="0" maxOccurs="1">
20+
<xs:simpleType>
21+
<xs:restriction base="xs:string">
22+
<xs:maxLength value="255"/>
23+
</xs:restriction>
24+
</xs:simpleType>
25+
</xs:element>
26+
<xs:element name="TargetID" nillable="true" minOccurs="0" maxOccurs="1">
27+
<xs:simpleType>
28+
<xs:restriction base="xs:string">
29+
<xs:maxLength value="255"/>
30+
</xs:restriction>
31+
</xs:simpleType>
32+
</xs:element>
33+
<xs:element name="Distance" nillable="true" minOccurs="0" maxOccurs="1">
34+
<xs:simpleType>
35+
<xs:restriction base="xs:decimal">
36+
</xs:restriction>
37+
</xs:simpleType>
38+
</xs:element>
39+
</xs:sequence>
40+
</xs:extension>
41+
</xs:complexContent>
42+
</xs:complexType>
43+
</xs:schema>
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
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/ standard_matrix.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>0</gml:X><gml:Y>-5</gml:Y></gml:coord>
10+
<gml:coord><gml:X>8</gml:X><gml:Y>3</gml:Y></gml:coord>
11+
</gml:Box>
12+
</gml:boundedBy>
13+
14+
<gml:featureMember>
15+
<ogr:standard_matrix fid="standard_matrix.0">
16+
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>1,1</gml:coordinates></gml:Point></ogr:geometryProperty>
17+
<ogr:ID>points.0</ogr:ID>
18+
<ogr:points.7>6.32455532033676</ogr:points.7>
19+
<ogr:points.6>7.28010988928052</ogr:points.6>
20+
<ogr:points.5>6.08276253029822</ogr:points.5>
21+
<ogr:points.4>3</ogr:points.4>
22+
<ogr:points.8>2.23606797749979</ogr:points.8>
23+
<ogr:points.3>4.12310562561766</ogr:points.3>
24+
<ogr:points.2>1.4142135623731</ogr:points.2>
25+
<ogr:points.1>2.82842712474619</ogr:points.1>
26+
<ogr:points.0>0</ogr:points.0>
27+
</ogr:standard_matrix>
28+
</gml:featureMember>
29+
<gml:featureMember>
30+
<ogr:standard_matrix fid="standard_matrix.1">
31+
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>3,3</gml:coordinates></gml:Point></ogr:geometryProperty>
32+
<ogr:ID>points.1</ogr:ID>
33+
<ogr:points.7>5.65685424949238</ogr:points.7>
34+
<ogr:points.6>6.40312423743285</ogr:points.6>
35+
<ogr:points.5>8.54400374531753</ogr:points.5>
36+
<ogr:points.4>2.23606797749979</ogr:points.4>
37+
<ogr:points.8>5</ogr:points.8>
38+
<ogr:points.3>2.23606797749979</ogr:points.3>
39+
<ogr:points.2>1.4142135623731</ogr:points.2>
40+
<ogr:points.1>0</ogr:points.1>
41+
<ogr:points.0>2.82842712474619</ogr:points.0>
42+
</ogr:standard_matrix>
43+
</gml:featureMember>
44+
<gml:featureMember>
45+
<ogr:standard_matrix fid="standard_matrix.2">
46+
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>2,2</gml:coordinates></gml:Point></ogr:geometryProperty>
47+
<ogr:ID>points.2</ogr:ID>
48+
<ogr:points.7>5.8309518948453</ogr:points.7>
49+
<ogr:points.6>6.70820393249937</ogr:points.6>
50+
<ogr:points.5>7.28010988928052</ogr:points.5>
51+
<ogr:points.4>2.23606797749979</ogr:points.4>
52+
<ogr:points.8>3.60555127546399</ogr:points.8>
53+
<ogr:points.3>3</ogr:points.3>
54+
<ogr:points.2>0</ogr:points.2>
55+
<ogr:points.1>1.4142135623731</ogr:points.1>
56+
<ogr:points.0>1.4142135623731</ogr:points.0>
57+
</ogr:standard_matrix>
58+
</gml:featureMember>
59+
<gml:featureMember>
60+
<ogr:standard_matrix fid="standard_matrix.3">
61+
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>5,2</gml:coordinates></gml:Point></ogr:geometryProperty>
62+
<ogr:ID>points.3</ogr:ID>
63+
<ogr:points.7>3.60555127546399</ogr:points.7>
64+
<ogr:points.6>4.24264068711928</ogr:points.6>
65+
<ogr:points.5>8.60232526704263</ogr:points.5>
66+
<ogr:points.4>1.4142135623731</ogr:points.4>
67+
<ogr:points.8>5.8309518948453</ogr:points.8>
68+
<ogr:points.3>0</ogr:points.3>
69+
<ogr:points.2>3</ogr:points.2>
70+
<ogr:points.1>2.23606797749979</ogr:points.1>
71+
<ogr:points.0>4.12310562561766</ogr:points.0>
72+
</ogr:standard_matrix>
73+
</gml:featureMember>
74+
<gml:featureMember>
75+
<ogr:standard_matrix fid="standard_matrix.4">
76+
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>4,1</gml:coordinates></gml:Point></ogr:geometryProperty>
77+
<ogr:ID>points.4</ogr:ID>
78+
<ogr:points.7>3.60555127546399</ogr:points.7>
79+
<ogr:points.6>4.47213595499958</ogr:points.6>
80+
<ogr:points.5>7.21110255092798</ogr:points.5>
81+
<ogr:points.4>0</ogr:points.4>
82+
<ogr:points.8>4.47213595499958</ogr:points.8>
83+
<ogr:points.3>1.4142135623731</ogr:points.3>
84+
<ogr:points.2>2.23606797749979</ogr:points.2>
85+
<ogr:points.1>2.23606797749979</ogr:points.1>
86+
<ogr:points.0>3</ogr:points.0>
87+
</ogr:standard_matrix>
88+
</gml:featureMember>
89+
<gml:featureMember>
90+
<ogr:standard_matrix fid="standard_matrix.5">
91+
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>0,-5</gml:coordinates></gml:Point></ogr:geometryProperty>
92+
<ogr:ID>points.5</ogr:ID>
93+
<ogr:points.7>8.06225774829855</ogr:points.7>
94+
<ogr:points.6>8.94427190999916</ogr:points.6>
95+
<ogr:points.5>0</ogr:points.5>
96+
<ogr:points.4>7.21110255092798</ogr:points.4>
97+
<ogr:points.8>4</ogr:points.8>
98+
<ogr:points.3>8.60232526704263</ogr:points.3>
99+
<ogr:points.2>7.28010988928052</ogr:points.2>
100+
<ogr:points.1>8.54400374531753</ogr:points.1>
101+
<ogr:points.0>6.08276253029822</ogr:points.0>
102+
</ogr:standard_matrix>
103+
</gml:featureMember>
104+
<gml:featureMember>
105+
<ogr:standard_matrix fid="standard_matrix.6">
106+
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>8,-1</gml:coordinates></gml:Point></ogr:geometryProperty>
107+
<ogr:ID>points.6</ogr:ID>
108+
<ogr:points.7>1</ogr:points.7>
109+
<ogr:points.6>0</ogr:points.6>
110+
<ogr:points.5>8.94427190999916</ogr:points.5>
111+
<ogr:points.4>4.47213595499958</ogr:points.4>
112+
<ogr:points.8>8</ogr:points.8>
113+
<ogr:points.3>4.24264068711928</ogr:points.3>
114+
<ogr:points.2>6.70820393249937</ogr:points.2>
115+
<ogr:points.1>6.40312423743285</ogr:points.1>
116+
<ogr:points.0>7.28010988928052</ogr:points.0>
117+
</ogr:standard_matrix>
118+
</gml:featureMember>
119+
<gml:featureMember>
120+
<ogr:standard_matrix fid="standard_matrix.7">
121+
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>7,-1</gml:coordinates></gml:Point></ogr:geometryProperty>
122+
<ogr:ID>points.7</ogr:ID>
123+
<ogr:points.7>0</ogr:points.7>
124+
<ogr:points.6>1</ogr:points.6>
125+
<ogr:points.5>8.06225774829855</ogr:points.5>
126+
<ogr:points.4>3.60555127546399</ogr:points.4>
127+
<ogr:points.8>7</ogr:points.8>
128+
<ogr:points.3>3.60555127546399</ogr:points.3>
129+
<ogr:points.2>5.8309518948453</ogr:points.2>
130+
<ogr:points.1>5.65685424949238</ogr:points.1>
131+
<ogr:points.0>6.32455532033676</ogr:points.0>
132+
</ogr:standard_matrix>
133+
</gml:featureMember>
134+
<gml:featureMember>
135+
<ogr:standard_matrix fid="standard_matrix.8">
136+
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>0,-1</gml:coordinates></gml:Point></ogr:geometryProperty>
137+
<ogr:ID>points.8</ogr:ID>
138+
<ogr:points.7>7</ogr:points.7>
139+
<ogr:points.6>8</ogr:points.6>
140+
<ogr:points.5>4</ogr:points.5>
141+
<ogr:points.4>4.47213595499958</ogr:points.4>
142+
<ogr:points.8>0</ogr:points.8>
143+
<ogr:points.3>5.8309518948453</ogr:points.3>
144+
<ogr:points.2>3.60555127546399</ogr:points.2>
145+
<ogr:points.1>5</ogr:points.1>
146+
<ogr:points.0>2.23606797749979</ogr:points.0>
147+
</ogr:standard_matrix>
148+
</gml:featureMember>
149+
</ogr:FeatureCollection>
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
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="standard_matrix" type="ogr:standard_matrix_Type" substitutionGroup="gml:_Feature"/>
14+
<xs:complexType name="standard_matrix_Type">
15+
<xs:complexContent>
16+
<xs:extension base="gml:AbstractFeatureType">
17+
<xs:sequence>
18+
<xs:element name="geometryProperty" type="gml:PointPropertyType" nillable="true" minOccurs="0" maxOccurs="1"/>
19+
<xs:element name="ID" nillable="true" minOccurs="0" maxOccurs="1">
20+
<xs:simpleType>
21+
<xs:restriction base="xs:string">
22+
<xs:maxLength value="255"/>
23+
</xs:restriction>
24+
</xs:simpleType>
25+
</xs:element>
26+
<xs:element name="points.7" nillable="true" minOccurs="0" maxOccurs="1">
27+
<xs:simpleType>
28+
<xs:restriction base="xs:decimal">
29+
</xs:restriction>
30+
</xs:simpleType>
31+
</xs:element>
32+
<xs:element name="points.6" nillable="true" minOccurs="0" maxOccurs="1">
33+
<xs:simpleType>
34+
<xs:restriction base="xs:decimal">
35+
</xs:restriction>
36+
</xs:simpleType>
37+
</xs:element>
38+
<xs:element name="points.5" nillable="true" minOccurs="0" maxOccurs="1">
39+
<xs:simpleType>
40+
<xs:restriction base="xs:decimal">
41+
</xs:restriction>
42+
</xs:simpleType>
43+
</xs:element>
44+
<xs:element name="points.4" nillable="true" minOccurs="0" maxOccurs="1">
45+
<xs:simpleType>
46+
<xs:restriction base="xs:decimal">
47+
</xs:restriction>
48+
</xs:simpleType>
49+
</xs:element>
50+
<xs:element name="points.8" nillable="true" minOccurs="0" maxOccurs="1">
51+
<xs:simpleType>
52+
<xs:restriction base="xs:decimal">
53+
</xs:restriction>
54+
</xs:simpleType>
55+
</xs:element>
56+
<xs:element name="points.3" nillable="true" minOccurs="0" maxOccurs="1">
57+
<xs:simpleType>
58+
<xs:restriction base="xs:decimal">
59+
</xs:restriction>
60+
</xs:simpleType>
61+
</xs:element>
62+
<xs:element name="points.2" nillable="true" minOccurs="0" maxOccurs="1">
63+
<xs:simpleType>
64+
<xs:restriction base="xs:decimal">
65+
</xs:restriction>
66+
</xs:simpleType>
67+
</xs:element>
68+
<xs:element name="points.1" nillable="true" minOccurs="0" maxOccurs="1">
69+
<xs:simpleType>
70+
<xs:restriction base="xs:decimal">
71+
</xs:restriction>
72+
</xs:simpleType>
73+
</xs:element>
74+
<xs:element name="points.0" nillable="true" minOccurs="0" maxOccurs="1">
75+
<xs:simpleType>
76+
<xs:restriction base="xs:decimal">
77+
</xs:restriction>
78+
</xs:simpleType>
79+
</xs:element>
80+
</xs:sequence>
81+
</xs:extension>
82+
</xs:complexContent>
83+
</xs:complexType>
84+
</xs:schema>
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
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/ summary_matrix.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>0</gml:X><gml:Y>-5</gml:Y></gml:coord>
10+
<gml:coord><gml:X>8</gml:X><gml:Y>3</gml:Y></gml:coord>
11+
</gml:Box>
12+
</gml:boundedBy>
13+
14+
<gml:featureMember>
15+
<ogr:summary_matrix fid="summary_matrix.0">
16+
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>1,1</gml:coordinates></gml:Point></ogr:geometryProperty>
17+
<ogr:InputID>points.0</ogr:InputID>
18+
<ogr:MEAN>3.69880467001691</ogr:MEAN>
19+
<ogr:STDDEV>2.30626191337</ogr:STDDEV>
20+
<ogr:MIN>0</ogr:MIN>
21+
<ogr:MAX>7.28010988928052</ogr:MAX>
22+
</ogr:summary_matrix>
23+
</gml:featureMember>
24+
<gml:featureMember>
25+
<ogr:summary_matrix fid="summary_matrix.1">
26+
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>3,3</gml:coordinates></gml:Point></ogr:geometryProperty>
27+
<ogr:InputID>points.1</ogr:InputID>
28+
<ogr:MEAN>3.81319543048463</ogr:MEAN>
29+
<ogr:STDDEV>2.58491060409319</ogr:STDDEV>
30+
<ogr:MIN>0</ogr:MIN>
31+
<ogr:MAX>8.54400374531753</ogr:MAX>
32+
</ogr:summary_matrix>
33+
</gml:featureMember>
34+
<gml:featureMember>
35+
<ogr:summary_matrix fid="summary_matrix.2">
36+
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>2,2</gml:coordinates></gml:Point></ogr:geometryProperty>
37+
<ogr:InputID>points.2</ogr:InputID>
38+
<ogr:MEAN>3.49881245492613</ogr:MEAN>
39+
<ogr:STDDEV>2.42268910848357</ogr:STDDEV>
40+
<ogr:MIN>0</ogr:MIN>
41+
<ogr:MAX>7.28010988928052</ogr:MAX>
42+
</ogr:summary_matrix>
43+
</gml:featureMember>
44+
<gml:featureMember>
45+
<ogr:summary_matrix fid="summary_matrix.3">
46+
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>5,2</gml:coordinates></gml:Point></ogr:geometryProperty>
47+
<ogr:InputID>points.3</ogr:InputID>
48+
<ogr:MEAN>3.67276180999575</ogr:MEAN>
49+
<ogr:STDDEV>2.37106132315211</ogr:STDDEV>
50+
<ogr:MIN>0</ogr:MIN>
51+
<ogr:MAX>8.60232526704263</ogr:MAX>
52+
</ogr:summary_matrix>
53+
</gml:featureMember>
54+
<gml:featureMember>
55+
<ogr:summary_matrix fid="summary_matrix.4">
56+
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>4,1</gml:coordinates></gml:Point></ogr:geometryProperty>
57+
<ogr:InputID>points.4</ogr:InputID>
58+
<ogr:MEAN>3.18303058375153</ogr:MEAN>
59+
<ogr:STDDEV>1.96680357506854</ogr:STDDEV>
60+
<ogr:MIN>0</ogr:MIN>
61+
<ogr:MAX>7.21110255092798</ogr:MAX>
62+
</ogr:summary_matrix>
63+
</gml:featureMember>
64+
<gml:featureMember>
65+
<ogr:summary_matrix fid="summary_matrix.5">
66+
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>0,-5</gml:coordinates></gml:Point></ogr:geometryProperty>
67+
<ogr:InputID>points.5</ogr:InputID>
68+
<ogr:MEAN>6.52520373790717</ogr:MEAN>
69+
<ogr:STDDEV>2.72428269069167</ogr:STDDEV>
70+
<ogr:MIN>0</ogr:MIN>
71+
<ogr:MAX>8.94427190999916</ogr:MAX>
72+
</ogr:summary_matrix>
73+
</gml:featureMember>
74+
<gml:featureMember>
75+
<ogr:summary_matrix fid="summary_matrix.6">
76+
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>8,-1</gml:coordinates></gml:Point></ogr:geometryProperty>
77+
<ogr:InputID>points.6</ogr:InputID>
78+
<ogr:MEAN>5.22783184570342</ogr:MEAN>
79+
<ogr:STDDEV>2.90646726642964</ogr:STDDEV>
80+
<ogr:MIN>0</ogr:MIN>
81+
<ogr:MAX>8.94427190999916</ogr:MAX>
82+
</ogr:summary_matrix>
83+
</gml:featureMember>
84+
<gml:featureMember>
85+
<ogr:summary_matrix fid="summary_matrix.7">
86+
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>7,-1</gml:coordinates></gml:Point></ogr:geometryProperty>
87+
<ogr:InputID>points.7</ogr:InputID>
88+
<ogr:MEAN>4.565080195989</ogr:MEAN>
89+
<ogr:STDDEV>2.56991969692314</ogr:STDDEV>
90+
<ogr:MIN>0</ogr:MIN>
91+
<ogr:MAX>8.06225774829855</ogr:MAX>
92+
</ogr:summary_matrix>
93+
</gml:featureMember>
94+
<gml:featureMember>
95+
<ogr:summary_matrix fid="summary_matrix.8">
96+
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>0,-1</gml:coordinates></gml:Point></ogr:geometryProperty>
97+
<ogr:InputID>points.8</ogr:InputID>
98+
<ogr:MEAN>4.46052301142318</ogr:MEAN>
99+
<ogr:STDDEV>2.28360363804128</ogr:STDDEV>
100+
<ogr:MIN>0</ogr:MIN>
101+
<ogr:MAX>8</ogr:MAX>
102+
</ogr:summary_matrix>
103+
</gml:featureMember>
104+
</ogr:FeatureCollection>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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="summary_matrix" type="ogr:summary_matrix_Type" substitutionGroup="gml:_Feature"/>
14+
<xs:complexType name="summary_matrix_Type">
15+
<xs:complexContent>
16+
<xs:extension base="gml:AbstractFeatureType">
17+
<xs:sequence>
18+
<xs:element name="geometryProperty" type="gml:PointPropertyType" nillable="true" minOccurs="0" maxOccurs="1"/>
19+
<xs:element name="InputID" nillable="true" minOccurs="0" maxOccurs="1">
20+
<xs:simpleType>
21+
<xs:restriction base="xs:string">
22+
<xs:maxLength value="255"/>
23+
</xs:restriction>
24+
</xs:simpleType>
25+
</xs:element>
26+
<xs:element name="MEAN" nillable="true" minOccurs="0" maxOccurs="1">
27+
<xs:simpleType>
28+
<xs:restriction base="xs:decimal">
29+
</xs:restriction>
30+
</xs:simpleType>
31+
</xs:element>
32+
<xs:element name="STDDEV" nillable="true" minOccurs="0" maxOccurs="1">
33+
<xs:simpleType>
34+
<xs:restriction base="xs:decimal">
35+
</xs:restriction>
36+
</xs:simpleType>
37+
</xs:element>
38+
<xs:element name="MIN" nillable="true" minOccurs="0" maxOccurs="1">
39+
<xs:simpleType>
40+
<xs:restriction base="xs:decimal">
41+
</xs:restriction>
42+
</xs:simpleType>
43+
</xs:element>
44+
<xs:element name="MAX" nillable="true" minOccurs="0" maxOccurs="1">
45+
<xs:simpleType>
46+
<xs:restriction base="xs:decimal">
47+
</xs:restriction>
48+
</xs:simpleType>
49+
</xs:element>
50+
</xs:sequence>
51+
</xs:extension>
52+
</xs:complexContent>
53+
</xs:complexType>
54+
</xs:schema>

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

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4299,3 +4299,73 @@ tests:
42994299
OUTPUT:
43004300
name: expected/transect_multi_both_2_30.gml
43014301
type: vector
4302+
4303+
- algorithm: qgis:distancematrix
4304+
name: Linear (N*k x 3) distance matrix
4305+
params:
4306+
INPUT:
4307+
name: points.gml
4308+
type: vector
4309+
INPUT_FIELD: fid
4310+
MATRIX_TYPE: 0
4311+
NEAREST_POINTS: 0
4312+
TARGET:
4313+
name: points.gml
4314+
type: vector
4315+
TARGET_FIELD: fid
4316+
results:
4317+
OUTPUT:
4318+
pk:
4319+
- InputID
4320+
- TargetID
4321+
name: expected/linear_matrix.gml
4322+
type: vector
4323+
compare:
4324+
fields:
4325+
fid: skip
4326+
4327+
4328+
- algorithm: qgis:distancematrix
4329+
name: Standard (N x T) distance matrix
4330+
params:
4331+
INPUT:
4332+
name: points.gml
4333+
type: vector
4334+
INPUT_FIELD: fid
4335+
MATRIX_TYPE: 1
4336+
NEAREST_POINTS: 0
4337+
TARGET:
4338+
name: points.gml
4339+
type: vector
4340+
TARGET_FIELD: fid
4341+
results:
4342+
OUTPUT:
4343+
name: expected/standard_matrix.gml
4344+
type: vector
4345+
compare:
4346+
fields:
4347+
__all__:
4348+
precision: 7
4349+
4350+
- algorithm: qgis:distancematrix
4351+
name: Summary distance matrix (mean, std. dev., min, max)
4352+
params:
4353+
INPUT:
4354+
name: points.gml
4355+
type: vector
4356+
INPUT_FIELD: fid
4357+
MATRIX_TYPE: 2
4358+
NEAREST_POINTS: 0
4359+
TARGET:
4360+
name: points.gml
4361+
type: vector
4362+
TARGET_FIELD: fid
4363+
results:
4364+
OUTPUT:
4365+
name: expected/summary_matrix.gml
4366+
type: vector
4367+
compare:
4368+
fields:
4369+
__all__:
4370+
precision: 7
4371+

0 commit comments

Comments
 (0)
Please sign in to comment.