Skip to content

Commit e002660

Browse files
committed
Fix missing geometries/attributes in Extract by Location
1 parent 640a27b commit e002660

File tree

5 files changed

+50
-5
lines changed

5 files changed

+50
-5
lines changed

python/plugins/processing/gui/TestTools.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,10 @@ def createTest(text):
230230
else:
231231
params[param.name()] = float(token)
232232
elif isinstance(param, QgsProcessingParameterEnum):
233-
params[param.name()] = int(token)
233+
if isinstance(token, list):
234+
params[param.name()] = [int(t) for t in token]
235+
else:
236+
params[param.name()] = int(token)
234237
elif token:
235238
if token[0] == '"':
236239
token = token[1:]

python/plugins/processing/tests/testdata/expected/extract_by_location_intersection.gfs

+16
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,21 @@
1212
<ExtentYMin>-3.00000</ExtentYMin>
1313
<ExtentYMax>3.00000</ExtentYMax>
1414
</DatasetSpecificInfo>
15+
<PropertyDefn>
16+
<Name>name</Name>
17+
<ElementPath>name</ElementPath>
18+
<Type>String</Type>
19+
<Width>5</Width>
20+
</PropertyDefn>
21+
<PropertyDefn>
22+
<Name>intval</Name>
23+
<ElementPath>intval</ElementPath>
24+
<Type>Integer</Type>
25+
</PropertyDefn>
26+
<PropertyDefn>
27+
<Name>floatval</Name>
28+
<ElementPath>floatval</ElementPath>
29+
<Type>Real</Type>
30+
</PropertyDefn>
1531
</GMLFeatureClass>
1632
</GMLFeatureClassList>

python/plugins/processing/tests/testdata/expected/extract_by_location_intersection.gml

+11-3
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,26 @@
1212
</gml:boundedBy>
1313

1414
<gml:featureMember>
15-
<ogr:extract_by_location_intersection fid="extract_by_location_intersection.0">
15+
<ogr:extract_by_location_intersection fid="polys.0">
1616
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><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></ogr:geometryProperty>
17+
<ogr:name>aaaaa</ogr:name>
18+
<ogr:intval>33</ogr:intval>
19+
<ogr:floatval>44.123456</ogr:floatval>
1720
</ogr:extract_by_location_intersection>
1821
</gml:featureMember>
1922
<gml:featureMember>
20-
<ogr:extract_by_location_intersection fid="extract_by_location_intersection.1">
23+
<ogr:extract_by_location_intersection fid="polys.5">
2124
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><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></ogr:geometryProperty>
25+
<ogr:name>elim</ogr:name>
26+
<ogr:intval>2</ogr:intval>
27+
<ogr:floatval>3.33</ogr:floatval>
2228
</ogr:extract_by_location_intersection>
2329
</gml:featureMember>
2430
<gml:featureMember>
25-
<ogr:extract_by_location_intersection fid="extract_by_location_intersection.2">
31+
<ogr:extract_by_location_intersection fid="polys.3">
2632
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><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></ogr:geometryProperty>
33+
<ogr:name>ASDF</ogr:name>
34+
<ogr:intval>0</ogr:intval>
2735
</ogr:extract_by_location_intersection>
2836
</gml:featureMember>
2937
</ogr:FeatureCollection>

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

+17
Original file line numberDiff line numberDiff line change
@@ -3006,6 +3006,23 @@ tests:
30063006
fields:
30073007
fid: skip
30083008

3009+
- algorithm: native:extractbylocation
3010+
name: Polygons containing points
3011+
params:
3012+
INPUT:
3013+
name: polys.gml
3014+
type: vector
3015+
INTERSECT:
3016+
name: custom/points.shp
3017+
type: vector
3018+
PREDICATE:
3019+
- 1
3020+
results:
3021+
OUTPUT:
3022+
name: expected/extract_by_location_contains.gml
3023+
type: vector
3024+
3025+
30093026
- algorithm: qgis:addfieldtoattributestable
30103027
name: add float field
30113028
params:

src/core/processing/qgsnativealgorithms.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1493,6 +1493,7 @@ void QgsLocationBasedAlgorithm::process( QgsFeatureSource *targetSource,
14931493

14941494
}
14951495

1496+
current += 1;
14961497
feedback->setProgress( current * step );
14971498
}
14981499

@@ -1594,7 +1595,7 @@ QVariantMap QgsExtractByLocationAlgorithm::processAlgorithm( const QVariantMap &
15941595
QgsFeature f = feature;
15951596
sink->addFeature( f, QgsFeatureSink::FastInsert );
15961597
};
1597-
process( input, intersectSource, selectedPredicates, addToSink, true, feedback );
1598+
process( input, intersectSource, selectedPredicates, addToSink, false, feedback );
15981599

15991600
QVariantMap results;
16001601
results.insert( QStringLiteral( "OUTPUT" ), dest );

0 commit comments

Comments
 (0)