Skip to content

Commit

Permalink
Fix missing geometries/attributes in Extract by Location
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Sep 10, 2017
1 parent 640a27b commit e002660
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 5 deletions.
5 changes: 4 additions & 1 deletion python/plugins/processing/gui/TestTools.py
Expand Up @@ -230,7 +230,10 @@ def createTest(text):
else:
params[param.name()] = float(token)
elif isinstance(param, QgsProcessingParameterEnum):
params[param.name()] = int(token)
if isinstance(token, list):
params[param.name()] = [int(t) for t in token]
else:
params[param.name()] = int(token)
elif token:
if token[0] == '"':
token = token[1:]
Expand Down
Expand Up @@ -12,5 +12,21 @@
<ExtentYMin>-3.00000</ExtentYMin>
<ExtentYMax>3.00000</ExtentYMax>
</DatasetSpecificInfo>
<PropertyDefn>
<Name>name</Name>
<ElementPath>name</ElementPath>
<Type>String</Type>
<Width>5</Width>
</PropertyDefn>
<PropertyDefn>
<Name>intval</Name>
<ElementPath>intval</ElementPath>
<Type>Integer</Type>
</PropertyDefn>
<PropertyDefn>
<Name>floatval</Name>
<ElementPath>floatval</ElementPath>
<Type>Real</Type>
</PropertyDefn>
</GMLFeatureClass>
</GMLFeatureClassList>
Expand Up @@ -12,18 +12,26 @@
</gml:boundedBy>

<gml:featureMember>
<ogr:extract_by_location_intersection fid="extract_by_location_intersection.0">
<ogr:extract_by_location_intersection fid="polys.0">
<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>
<ogr:name>aaaaa</ogr:name>
<ogr:intval>33</ogr:intval>
<ogr:floatval>44.123456</ogr:floatval>
</ogr:extract_by_location_intersection>
</gml:featureMember>
<gml:featureMember>
<ogr:extract_by_location_intersection fid="extract_by_location_intersection.1">
<ogr:extract_by_location_intersection fid="polys.5">
<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>
<ogr:name>elim</ogr:name>
<ogr:intval>2</ogr:intval>
<ogr:floatval>3.33</ogr:floatval>
</ogr:extract_by_location_intersection>
</gml:featureMember>
<gml:featureMember>
<ogr:extract_by_location_intersection fid="extract_by_location_intersection.2">
<ogr:extract_by_location_intersection fid="polys.3">
<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>
<ogr:name>ASDF</ogr:name>
<ogr:intval>0</ogr:intval>
</ogr:extract_by_location_intersection>
</gml:featureMember>
</ogr:FeatureCollection>
17 changes: 17 additions & 0 deletions python/plugins/processing/tests/testdata/qgis_algorithm_tests.yaml
Expand Up @@ -3006,6 +3006,23 @@ tests:
fields:
fid: skip

- algorithm: native:extractbylocation
name: Polygons containing points
params:
INPUT:
name: polys.gml
type: vector
INTERSECT:
name: custom/points.shp
type: vector
PREDICATE:
- 1
results:
OUTPUT:
name: expected/extract_by_location_contains.gml
type: vector


- algorithm: qgis:addfieldtoattributestable
name: add float field
params:
Expand Down
3 changes: 2 additions & 1 deletion src/core/processing/qgsnativealgorithms.cpp
Expand Up @@ -1493,6 +1493,7 @@ void QgsLocationBasedAlgorithm::process( QgsFeatureSource *targetSource,

}

current += 1;
feedback->setProgress( current * step );
}

Expand Down Expand Up @@ -1594,7 +1595,7 @@ QVariantMap QgsExtractByLocationAlgorithm::processAlgorithm( const QVariantMap &
QgsFeature f = feature;
sink->addFeature( f, QgsFeatureSink::FastInsert );
};
process( input, intersectSource, selectedPredicates, addToSink, true, feedback );
process( input, intersectSource, selectedPredicates, addToSink, false, feedback );

QVariantMap results;
results.insert( QStringLiteral( "OUTPUT" ), dest );
Expand Down

0 comments on commit e002660

Please sign in to comment.