Skip to content
Permalink
Browse files

[processing] Fix missing points in polygons menu item (fix #15670)

Also add a unit test

(cherry picked from commit d4323ad)

Conflicts:
	python/plugins/processing/tests/testdata/qgis_algorithm_tests.yaml
  • Loading branch information
nyalldawson authored and alexbruy committed Oct 11, 2016
1 parent 5abeac1 commit ba7fdded19760a5ee526cf7357be2b4a7e1b440c
@@ -19,7 +19,7 @@
analysisToolsMenu = vectorMenu + "/" + Processing.tr('&Analysis Tools')
defaultMenuEntries.update({'qgis:distancematrix': analysisToolsMenu,
'qgis:sumlinelengths': analysisToolsMenu,
'qgis:pointsinpolygon': analysisToolsMenu,
'qgis:countpointsinpolygon': analysisToolsMenu,
'qgis:listuniquevalues': analysisToolsMenu,
'qgis:basicstatisticsfornumericfields': analysisToolsMenu,
'qgis:basicstatisticsfortextfields': analysisToolsMenu,
@@ -0,0 +1,36 @@
<GMLFeatureClassList>
<GMLFeatureClass>
<Name>points_in_polys</Name>
<ElementPath>points_in_polys</ElementPath>
<GeometryType>3</GeometryType>
<SRSName>EPSG:4326</SRSName>
<DatasetSpecificInfo>
<FeatureCount>6</FeatureCount>
<ExtentXMin>-1.00000</ExtentXMin>
<ExtentXMax>10.00000</ExtentXMax>
<ExtentYMin>-3.00000</ExtentYMin>
<ExtentYMax>6.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>
<PropertyDefn>
<Name>NUMPOINTS</Name>
<ElementPath>NUMPOINTS</ElementPath>
<Type>Integer</Type>
</PropertyDefn>
</GMLFeatureClass>
</GMLFeatureClassList>
@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="utf-8" ?>
<ogr:FeatureCollection
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=""
xmlns:ogr="http://ogr.maptools.org/"
xmlns:gml="http://www.opengis.net/gml">
<gml:boundedBy>
<gml:Box>
<gml:coord><gml:X>-1</gml:X><gml:Y>-3</gml:Y></gml:coord>
<gml:coord><gml:X>10</gml:X><gml:Y>6</gml:Y></gml:coord>
</gml:Box>
</gml:boundedBy>

<gml:featureMember>
<ogr:points_in_polys 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:NUMPOINTS>4</ogr:NUMPOINTS>
</ogr:points_in_polys>
</gml:featureMember>
<gml:featureMember>
<ogr:points_in_polys fid="polys.1">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>5,5 6,4 4,4 5,5</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:name>Aaaaa</ogr:name>
<ogr:intval>-33</ogr:intval>
<ogr:floatval>0</ogr:floatval>
<ogr:NUMPOINTS>1</ogr:NUMPOINTS>
</ogr:points_in_polys>
</gml:featureMember>
<gml:featureMember>
<ogr:points_in_polys fid="polys.2">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>2,5 2,6 3,6 3,5 2,5</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:name>bbaaa</ogr:name>
<ogr:floatval>0.123</ogr:floatval>
<ogr:NUMPOINTS>0</ogr:NUMPOINTS>
</ogr:points_in_polys>
</gml:featureMember>
<gml:featureMember>
<ogr:points_in_polys 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:NUMPOINTS>2</ogr:NUMPOINTS>
</ogr:points_in_polys>
</gml:featureMember>
<gml:featureMember>
<ogr:points_in_polys fid="polys.4">
<ogr:intval>120</ogr:intval>
<ogr:floatval>-100291.43213</ogr:floatval>
<ogr:NUMPOINTS>0</ogr:NUMPOINTS>
</ogr:points_in_polys>
</gml:featureMember>
<gml:featureMember>
<ogr:points_in_polys 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:NUMPOINTS>3</ogr:NUMPOINTS>
</ogr:points_in_polys>
</gml:featureMember>
</ogr:FeatureCollection>
@@ -0,0 +1,15 @@
<GMLFeatureClassList>
<GMLFeatureClass>
<Name>points_in_polys</Name>
<ElementPath>points_in_polys</ElementPath>
<GeometryType>1</GeometryType>
<SRSName>EPSG:4326</SRSName>
<DatasetSpecificInfo>
<FeatureCount>15</FeatureCount>
<ExtentXMin>-0.13645</ExtentXMin>
<ExtentXMax>7.79548</ExtentXMax>
<ExtentYMin>-2.63675</ExtentYMin>
<ExtentYMax>5.68735</ExtentYMax>
</DatasetSpecificInfo>
</GMLFeatureClass>
</GMLFeatureClassList>
@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="utf-8" ?>
<ogr:FeatureCollection
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=""
xmlns:ogr="http://ogr.maptools.org/"
xmlns:gml="http://www.opengis.net/gml">
<gml:boundedBy>
<gml:Box>
<gml:coord><gml:X>-0.1364457831325305</gml:X><gml:Y>-2.636746987951807</gml:Y></gml:coord>
<gml:coord><gml:X>7.795481927710844</gml:X><gml:Y>5.687349397590362</gml:Y></gml:coord>
</gml:Box>
</gml:boundedBy>

<gml:featureMember>
<ogr:points_in_polys fid="points_in_polys.0">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>1.078012048192771,2.499397590361446</gml:coordinates></gml:Point></ogr:geometryProperty>
</ogr:points_in_polys>
</gml:featureMember>
<gml:featureMember>
<ogr:points_in_polys fid="points_in_polys.1">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>0.154518072289156,2.499397590361446</gml:coordinates></gml:Point></ogr:geometryProperty>
</ogr:points_in_polys>
</gml:featureMember>
<gml:featureMember>
<ogr:points_in_polys fid="points_in_polys.2">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>-0.136445783132531,0.551204819277109</gml:coordinates></gml:Point></ogr:geometryProperty>
</ogr:points_in_polys>
</gml:featureMember>
<gml:featureMember>
<ogr:points_in_polys fid="points_in_polys.3">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>0.926204819277108,0.563855421686747</gml:coordinates></gml:Point></ogr:geometryProperty>
</ogr:points_in_polys>
</gml:featureMember>
<gml:featureMember>
<ogr:points_in_polys fid="points_in_polys.4">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>2.279819277108433,3.941566265060241</gml:coordinates></gml:Point></ogr:geometryProperty>
</ogr:points_in_polys>
</gml:featureMember>
<gml:featureMember>
<ogr:points_in_polys fid="points_in_polys.5">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>4.40512048192771,2.347590361445783</gml:coordinates></gml:Point></ogr:geometryProperty>
</ogr:points_in_polys>
</gml:featureMember>
<gml:featureMember>
<ogr:points_in_polys fid="points_in_polys.6">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>4.430421686746987,5.687349397590362</gml:coordinates></gml:Point></ogr:geometryProperty>
</ogr:points_in_polys>
</gml:featureMember>
<gml:featureMember>
<ogr:points_in_polys fid="points_in_polys.7">
</ogr:points_in_polys>
</gml:featureMember>
<gml:featureMember>
<ogr:points_in_polys fid="points_in_polys.8">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>5.379216867469879,0.18433734939759</gml:coordinates></gml:Point></ogr:geometryProperty>
</ogr:points_in_polys>
</gml:featureMember>
<gml:featureMember>
<ogr:points_in_polys fid="points_in_polys.9">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>4.253313253012048,-0.777108433734941</gml:coordinates></gml:Point></ogr:geometryProperty>
</ogr:points_in_polys>
</gml:featureMember>
<gml:featureMember>
<ogr:points_in_polys fid="points_in_polys.10">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>4.569578313253012,-1.257831325301205</gml:coordinates></gml:Point></ogr:geometryProperty>
</ogr:points_in_polys>
</gml:featureMember>
<gml:featureMember>
<ogr:points_in_polys fid="points_in_polys.11">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>7.744879518072288,-2.636746987951807</gml:coordinates></gml:Point></ogr:geometryProperty>
</ogr:points_in_polys>
</gml:featureMember>
<gml:featureMember>
<ogr:points_in_polys fid="points_in_polys.12">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>7.795481927710844,0.525903614457832</gml:coordinates></gml:Point></ogr:geometryProperty>
</ogr:points_in_polys>
</gml:featureMember>
<gml:featureMember>
<ogr:points_in_polys fid="points_in_polys.13">
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>5.126204819277108,4.283132530120482</gml:coordinates></gml:Point></ogr:geometryProperty>
</ogr:points_in_polys>
</gml:featureMember>
<gml:featureMember>
<ogr:points_in_polys fid="points_in_polys.14">
</ogr:points_in_polys>
</gml:featureMember>
</ogr:FeatureCollection>
@@ -582,3 +582,20 @@ tests:
OUTPUT_LAYER:
name: expected/point_on_line.gml
type: vector



- algorithm: qgis:countpointsinpolygon
name: Count points in polygon
params:
FIELD: NUMPOINTS
POINTS:
name: points_in_polys.gml
type: vector
POLYGONS:
name: polys.gml
type: vector
results:
OUTPUT:
name: expected/points_in_polys.gml
type: vector

0 comments on commit ba7fdde

Please sign in to comment.
You can’t perform that action at this time.