Skip to content

Commit 52b2a58

Browse files
committed
[processing] Fix invalid reprojection in join by location (summary)
1 parent 979debc commit 52b2a58

10 files changed

+1550
-5
lines changed

python/plugins/processing/algs/qgis/SpatialJoinSummary.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,6 @@ def addField(original, stat, type):
275275
features = source.getFeatures()
276276
total = 100.0 / source.featureCount() if source.featureCount() else 0
277277

278-
# bounding box transform
279-
bbox_transform = QgsCoordinateTransform(source.sourceCrs(), join_source.sourceCrs(), context.project())
280-
281278
for current, f in enumerate(features):
282279
if feedback.isCanceled():
283280
break
@@ -294,12 +291,11 @@ def addField(original, stat, type):
294291
sink.addFeature(f, QgsFeatureSink.FastInsert)
295292
continue
296293

297-
bbox = bbox_transform.transformBoundingBox(f.geometry().boundingBox())
298294
engine = None
299295

300296
values = []
301297

302-
request = QgsFeatureRequest().setFilterRect(bbox).setSubsetOfAttributes(join_field_indexes).setDestinationCrs(source.sourceCrs(), context.transformContext())
298+
request = QgsFeatureRequest().setFilterRect(f.geometry().boundingBox()).setSubsetOfAttributes(join_field_indexes).setDestinationCrs(source.sourceCrs(), context.transformContext())
303299
for test_feat in join_source.getFeatures(request):
304300
if feedback.isCanceled():
305301
break
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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/ line_3857.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>-170142.2790295565</gml:X><gml:Y>-601233.6051123593</gml:Y></gml:coord>
10+
<gml:coord><gml:X>1198122.331412013</gml:X><gml:Y>487793.1282708889</gml:Y></gml:coord>
11+
</gml:Box>
12+
</gml:boundedBy>
13+
14+
<gml:featureMember>
15+
<ogr:line_3857 fid="line_3857.0">
16+
<ogr:geometryProperty><gml:LineString srsName="EPSG:3857"><gml:coordinates>193303.008118985,455636.648094066 67700.5927073567,337822.202907407 40976.6745346706,33011.8416339877 -44539.8636179277,-303824.512095835 -170142.279029556,-309175.468327608</gml:coordinates></gml:LineString></ogr:geometryProperty>
17+
<ogr:val>5</ogr:val>
18+
</ogr:line_3857>
19+
</gml:featureMember>
20+
<gml:featureMember>
21+
<ogr:line_3857 fid="line_3857.1">
22+
<ogr:geometryProperty><gml:LineString srsName="EPSG:3857"><gml:coordinates>-63246.6063388065,487793.128270889 -33850.2963488532,142591.63526526</gml:coordinates></gml:LineString></ogr:geometryProperty>
23+
<ogr:val>4</ogr:val>
24+
</ogr:line_3857>
25+
</gml:featureMember>
26+
<gml:featureMember>
27+
<ogr:line_3857 fid="line_3857.2">
28+
<ogr:geometryProperty><gml:LineString srsName="EPSG:3857"><gml:coordinates>67700.5927073567,-368051.169570389 78390.1599764311,-23108.5844752597 300198.680809733,-47160.4899983067 628902.874333781,254888.031682493</gml:coordinates></gml:LineString></ogr:geometryProperty>
29+
<ogr:val>8</ogr:val>
30+
</ogr:line_3857>
31+
</gml:featureMember>
32+
<gml:featureMember>
33+
<ogr:line_3857 fid="line_3857.3">
34+
<ogr:geometryProperty><gml:LineString srsName="EPSG:3857"><gml:coordinates>733126.155207261,57063.981869392 1016399.68783774,54391.4880260408</gml:coordinates></gml:LineString></ogr:geometryProperty>
35+
<ogr:val>7</ogr:val>
36+
</ogr:line_3857>
37+
</gml:featureMember>
38+
<gml:featureMember>
39+
<ogr:line_3857 fid="line_3857.4">
40+
<ogr:geometryProperty><gml:LineString srsName="EPSG:3857"><gml:coordinates>992348.161482323,262911.813488384 1198122.33141201,-263698.89064191</gml:coordinates></gml:LineString></ogr:geometryProperty>
41+
<ogr:val>2</ogr:val>
42+
</ogr:line_3857>
43+
</gml:featureMember>
44+
<gml:featureMember>
45+
<ogr:line_3857 fid="line_3857.5">
46+
<ogr:geometryProperty><gml:LineString srsName="EPSG:3857"><gml:coordinates>882780.096974306,-601233.605112359 762522.465197217,-440351.072066794 1024416.86328955,-263698.89064191</gml:coordinates></gml:LineString></ogr:geometryProperty>
47+
<ogr:val>1</ogr:val>
48+
</ogr:line_3857>
49+
</gml:featureMember>
50+
</ogr:FeatureCollection>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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="line_3857" type="ogr:line_3857_Type" substitutionGroup="gml:_Feature"/>
14+
<xs:complexType name="line_3857_Type">
15+
<xs:complexContent>
16+
<xs:extension base="gml:AbstractFeatureType">
17+
<xs:sequence>
18+
<xs:element name="geometryProperty" type="gml:LineStringPropertyType" nillable="true" minOccurs="0" maxOccurs="1"/>
19+
<xs:element name="val" nillable="true" minOccurs="0" maxOccurs="1">
20+
<xs:simpleType>
21+
<xs:restriction base="xs:integer">
22+
<xs:totalDigits value="10"/>
23+
</xs:restriction>
24+
</xs:simpleType>
25+
</xs:element>
26+
</xs:sequence>
27+
</xs:extension>
28+
</xs:complexContent>
29+
</xs:complexType>
30+
</xs:schema>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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/ points_3857.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>-557305.2572745769</gml:Y></gml:coord>
10+
<gml:coord><gml:X>890555.9263461898</gml:X><gml:Y>334111.1714019597</gml:Y></gml:coord>
11+
</gml:Box>
12+
</gml:boundedBy>
13+
14+
<gml:featureMember>
15+
<ogr:points_3857 fid="points.0">
16+
<ogr:geometryProperty><gml:Point srsName="EPSG:3857"><gml:coordinates>111319.490793272,111325.142866385</gml:coordinates></gml:Point></ogr:geometryProperty>
17+
<ogr:id>1</ogr:id>
18+
<ogr:id2>2</ogr:id2>
19+
</ogr:points_3857>
20+
</gml:featureMember>
21+
<gml:featureMember>
22+
<ogr:points_3857 fid="points.1">
23+
<ogr:geometryProperty><gml:Point srsName="EPSG:3857"><gml:coordinates>333958.47237982,334111.17140196</gml:coordinates></gml:Point></ogr:geometryProperty>
24+
<ogr:id>2</ogr:id>
25+
<ogr:id2>1</ogr:id2>
26+
</ogr:points_3857>
27+
</gml:featureMember>
28+
<gml:featureMember>
29+
<ogr:points_3857 fid="points.2">
30+
<ogr:geometryProperty><gml:Point srsName="EPSG:3857"><gml:coordinates>222638.981586547,222684.208505545</gml:coordinates></gml:Point></ogr:geometryProperty>
31+
<ogr:id>3</ogr:id>
32+
<ogr:id2>0</ogr:id2>
33+
</ogr:points_3857>
34+
</gml:featureMember>
35+
<gml:featureMember>
36+
<ogr:points_3857 fid="points.3">
37+
<ogr:geometryProperty><gml:Point srsName="EPSG:3857"><gml:coordinates>556597.453966367,222684.208505545</gml:coordinates></gml:Point></ogr:geometryProperty>
38+
<ogr:id>4</ogr:id>
39+
<ogr:id2>2</ogr:id2>
40+
</ogr:points_3857>
41+
</gml:featureMember>
42+
<gml:featureMember>
43+
<ogr:points_3857 fid="points.4">
44+
<ogr:geometryProperty><gml:Point srsName="EPSG:3857"><gml:coordinates>445277.963173095,111325.142866385</gml:coordinates></gml:Point></ogr:geometryProperty>
45+
<ogr:id>5</ogr:id>
46+
<ogr:id2>1</ogr:id2>
47+
</ogr:points_3857>
48+
</gml:featureMember>
49+
<gml:featureMember>
50+
<ogr:points_3857 fid="points.5">
51+
<ogr:geometryProperty><gml:Point srsName="EPSG:3857"><gml:coordinates>0.0,-557305.257274577</gml:coordinates></gml:Point></ogr:geometryProperty>
52+
<ogr:id>6</ogr:id>
53+
<ogr:id2>0</ogr:id2>
54+
</ogr:points_3857>
55+
</gml:featureMember>
56+
<gml:featureMember>
57+
<ogr:points_3857 fid="points.6">
58+
<ogr:geometryProperty><gml:Point srsName="EPSG:3857"><gml:coordinates>890555.92634619,-111325.142866386</gml:coordinates></gml:Point></ogr:geometryProperty>
59+
<ogr:id>7</ogr:id>
60+
<ogr:id2>0</ogr:id2>
61+
</ogr:points_3857>
62+
</gml:featureMember>
63+
<gml:featureMember>
64+
<ogr:points_3857 fid="points.7">
65+
<ogr:geometryProperty><gml:Point srsName="EPSG:3857"><gml:coordinates>779236.435552915,-111325.142866386</gml:coordinates></gml:Point></ogr:geometryProperty>
66+
<ogr:id>8</ogr:id>
67+
<ogr:id2>0</ogr:id2>
68+
</ogr:points_3857>
69+
</gml:featureMember>
70+
<gml:featureMember>
71+
<ogr:points_3857 fid="points.8">
72+
<ogr:geometryProperty><gml:Point srsName="EPSG:3857"><gml:coordinates>0.0,-111325.142866386</gml:coordinates></gml:Point></ogr:geometryProperty>
73+
<ogr:id>9</ogr:id>
74+
<ogr:id2>0</ogr:id2>
75+
</ogr:points_3857>
76+
</gml:featureMember>
77+
</ogr:FeatureCollection>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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="points_3857" type="ogr:points_3857_Type" substitutionGroup="gml:_Feature"/>
14+
<xs:complexType name="points_3857_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:long">
22+
<xs:totalDigits value="10"/>
23+
</xs:restriction>
24+
</xs:simpleType>
25+
</xs:element>
26+
<xs:element name="id2" nillable="true" minOccurs="0" maxOccurs="1">
27+
<xs:simpleType>
28+
<xs:restriction base="xs:long">
29+
<xs:totalDigits value="10"/>
30+
</xs:restriction>
31+
</xs:simpleType>
32+
</xs:element>
33+
</xs:sequence>
34+
</xs:extension>
35+
</xs:complexContent>
36+
</xs:complexType>
37+
</xs:schema>

0 commit comments

Comments
 (0)