Skip to content

Commit ba7fdde

Browse files
nyalldawsonalexbruy
authored andcommittedOct 11, 2016
[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
1 parent 5abeac1 commit ba7fdde

File tree

6 files changed

+220
-1
lines changed

6 files changed

+220
-1
lines changed
 

‎python/plugins/processing/gui/menus.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
analysisToolsMenu = vectorMenu + "/" + Processing.tr('&Analysis Tools')
2020
defaultMenuEntries.update({'qgis:distancematrix': analysisToolsMenu,
2121
'qgis:sumlinelengths': analysisToolsMenu,
22-
'qgis:pointsinpolygon': analysisToolsMenu,
22+
'qgis:countpointsinpolygon': analysisToolsMenu,
2323
'qgis:listuniquevalues': analysisToolsMenu,
2424
'qgis:basicstatisticsfornumericfields': analysisToolsMenu,
2525
'qgis:basicstatisticsfortextfields': analysisToolsMenu,
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<GMLFeatureClassList>
2+
<GMLFeatureClass>
3+
<Name>points_in_polys</Name>
4+
<ElementPath>points_in_polys</ElementPath>
5+
<GeometryType>3</GeometryType>
6+
<SRSName>EPSG:4326</SRSName>
7+
<DatasetSpecificInfo>
8+
<FeatureCount>6</FeatureCount>
9+
<ExtentXMin>-1.00000</ExtentXMin>
10+
<ExtentXMax>10.00000</ExtentXMax>
11+
<ExtentYMin>-3.00000</ExtentYMin>
12+
<ExtentYMax>6.00000</ExtentYMax>
13+
</DatasetSpecificInfo>
14+
<PropertyDefn>
15+
<Name>name</Name>
16+
<ElementPath>name</ElementPath>
17+
<Type>String</Type>
18+
<Width>5</Width>
19+
</PropertyDefn>
20+
<PropertyDefn>
21+
<Name>intval</Name>
22+
<ElementPath>intval</ElementPath>
23+
<Type>Integer</Type>
24+
</PropertyDefn>
25+
<PropertyDefn>
26+
<Name>floatval</Name>
27+
<ElementPath>floatval</ElementPath>
28+
<Type>Real</Type>
29+
</PropertyDefn>
30+
<PropertyDefn>
31+
<Name>NUMPOINTS</Name>
32+
<ElementPath>NUMPOINTS</ElementPath>
33+
<Type>Integer</Type>
34+
</PropertyDefn>
35+
</GMLFeatureClass>
36+
</GMLFeatureClassList>
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<ogr:FeatureCollection
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation=""
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>-1</gml:X><gml:Y>-3</gml:Y></gml:coord>
10+
<gml:coord><gml:X>10</gml:X><gml:Y>6</gml:Y></gml:coord>
11+
</gml:Box>
12+
</gml:boundedBy>
13+
14+
<gml:featureMember>
15+
<ogr:points_in_polys fid="polys.0">
16+
<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>
20+
<ogr:NUMPOINTS>4</ogr:NUMPOINTS>
21+
</ogr:points_in_polys>
22+
</gml:featureMember>
23+
<gml:featureMember>
24+
<ogr:points_in_polys fid="polys.1">
25+
<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>
26+
<ogr:name>Aaaaa</ogr:name>
27+
<ogr:intval>-33</ogr:intval>
28+
<ogr:floatval>0</ogr:floatval>
29+
<ogr:NUMPOINTS>1</ogr:NUMPOINTS>
30+
</ogr:points_in_polys>
31+
</gml:featureMember>
32+
<gml:featureMember>
33+
<ogr:points_in_polys fid="polys.2">
34+
<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>
35+
<ogr:name>bbaaa</ogr:name>
36+
<ogr:floatval>0.123</ogr:floatval>
37+
<ogr:NUMPOINTS>0</ogr:NUMPOINTS>
38+
</ogr:points_in_polys>
39+
</gml:featureMember>
40+
<gml:featureMember>
41+
<ogr:points_in_polys fid="polys.3">
42+
<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>
43+
<ogr:name>ASDF</ogr:name>
44+
<ogr:intval>0</ogr:intval>
45+
<ogr:NUMPOINTS>2</ogr:NUMPOINTS>
46+
</ogr:points_in_polys>
47+
</gml:featureMember>
48+
<gml:featureMember>
49+
<ogr:points_in_polys fid="polys.4">
50+
<ogr:intval>120</ogr:intval>
51+
<ogr:floatval>-100291.43213</ogr:floatval>
52+
<ogr:NUMPOINTS>0</ogr:NUMPOINTS>
53+
</ogr:points_in_polys>
54+
</gml:featureMember>
55+
<gml:featureMember>
56+
<ogr:points_in_polys fid="polys.5">
57+
<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>
58+
<ogr:name>elim</ogr:name>
59+
<ogr:intval>2</ogr:intval>
60+
<ogr:floatval>3.33</ogr:floatval>
61+
<ogr:NUMPOINTS>3</ogr:NUMPOINTS>
62+
</ogr:points_in_polys>
63+
</gml:featureMember>
64+
</ogr:FeatureCollection>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<GMLFeatureClassList>
2+
<GMLFeatureClass>
3+
<Name>points_in_polys</Name>
4+
<ElementPath>points_in_polys</ElementPath>
5+
<GeometryType>1</GeometryType>
6+
<SRSName>EPSG:4326</SRSName>
7+
<DatasetSpecificInfo>
8+
<FeatureCount>15</FeatureCount>
9+
<ExtentXMin>-0.13645</ExtentXMin>
10+
<ExtentXMax>7.79548</ExtentXMax>
11+
<ExtentYMin>-2.63675</ExtentYMin>
12+
<ExtentYMax>5.68735</ExtentYMax>
13+
</DatasetSpecificInfo>
14+
</GMLFeatureClass>
15+
</GMLFeatureClassList>
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<ogr:FeatureCollection
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation=""
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.1364457831325305</gml:X><gml:Y>-2.636746987951807</gml:Y></gml:coord>
10+
<gml:coord><gml:X>7.795481927710844</gml:X><gml:Y>5.687349397590362</gml:Y></gml:coord>
11+
</gml:Box>
12+
</gml:boundedBy>
13+
14+
<gml:featureMember>
15+
<ogr:points_in_polys fid="points_in_polys.0">
16+
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>1.078012048192771,2.499397590361446</gml:coordinates></gml:Point></ogr:geometryProperty>
17+
</ogr:points_in_polys>
18+
</gml:featureMember>
19+
<gml:featureMember>
20+
<ogr:points_in_polys fid="points_in_polys.1">
21+
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>0.154518072289156,2.499397590361446</gml:coordinates></gml:Point></ogr:geometryProperty>
22+
</ogr:points_in_polys>
23+
</gml:featureMember>
24+
<gml:featureMember>
25+
<ogr:points_in_polys fid="points_in_polys.2">
26+
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>-0.136445783132531,0.551204819277109</gml:coordinates></gml:Point></ogr:geometryProperty>
27+
</ogr:points_in_polys>
28+
</gml:featureMember>
29+
<gml:featureMember>
30+
<ogr:points_in_polys fid="points_in_polys.3">
31+
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>0.926204819277108,0.563855421686747</gml:coordinates></gml:Point></ogr:geometryProperty>
32+
</ogr:points_in_polys>
33+
</gml:featureMember>
34+
<gml:featureMember>
35+
<ogr:points_in_polys fid="points_in_polys.4">
36+
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>2.279819277108433,3.941566265060241</gml:coordinates></gml:Point></ogr:geometryProperty>
37+
</ogr:points_in_polys>
38+
</gml:featureMember>
39+
<gml:featureMember>
40+
<ogr:points_in_polys fid="points_in_polys.5">
41+
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>4.40512048192771,2.347590361445783</gml:coordinates></gml:Point></ogr:geometryProperty>
42+
</ogr:points_in_polys>
43+
</gml:featureMember>
44+
<gml:featureMember>
45+
<ogr:points_in_polys fid="points_in_polys.6">
46+
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>4.430421686746987,5.687349397590362</gml:coordinates></gml:Point></ogr:geometryProperty>
47+
</ogr:points_in_polys>
48+
</gml:featureMember>
49+
<gml:featureMember>
50+
<ogr:points_in_polys fid="points_in_polys.7">
51+
</ogr:points_in_polys>
52+
</gml:featureMember>
53+
<gml:featureMember>
54+
<ogr:points_in_polys fid="points_in_polys.8">
55+
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>5.379216867469879,0.18433734939759</gml:coordinates></gml:Point></ogr:geometryProperty>
56+
</ogr:points_in_polys>
57+
</gml:featureMember>
58+
<gml:featureMember>
59+
<ogr:points_in_polys fid="points_in_polys.9">
60+
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>4.253313253012048,-0.777108433734941</gml:coordinates></gml:Point></ogr:geometryProperty>
61+
</ogr:points_in_polys>
62+
</gml:featureMember>
63+
<gml:featureMember>
64+
<ogr:points_in_polys fid="points_in_polys.10">
65+
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>4.569578313253012,-1.257831325301205</gml:coordinates></gml:Point></ogr:geometryProperty>
66+
</ogr:points_in_polys>
67+
</gml:featureMember>
68+
<gml:featureMember>
69+
<ogr:points_in_polys fid="points_in_polys.11">
70+
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>7.744879518072288,-2.636746987951807</gml:coordinates></gml:Point></ogr:geometryProperty>
71+
</ogr:points_in_polys>
72+
</gml:featureMember>
73+
<gml:featureMember>
74+
<ogr:points_in_polys fid="points_in_polys.12">
75+
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>7.795481927710844,0.525903614457832</gml:coordinates></gml:Point></ogr:geometryProperty>
76+
</ogr:points_in_polys>
77+
</gml:featureMember>
78+
<gml:featureMember>
79+
<ogr:points_in_polys fid="points_in_polys.13">
80+
<ogr:geometryProperty><gml:Point srsName="EPSG:4326"><gml:coordinates>5.126204819277108,4.283132530120482</gml:coordinates></gml:Point></ogr:geometryProperty>
81+
</ogr:points_in_polys>
82+
</gml:featureMember>
83+
<gml:featureMember>
84+
<ogr:points_in_polys fid="points_in_polys.14">
85+
</ogr:points_in_polys>
86+
</gml:featureMember>
87+
</ogr:FeatureCollection>

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,3 +582,20 @@ tests:
582582
OUTPUT_LAYER:
583583
name: expected/point_on_line.gml
584584
type: vector
585+
586+
587+
588+
- algorithm: qgis:countpointsinpolygon
589+
name: Count points in polygon
590+
params:
591+
FIELD: NUMPOINTS
592+
POINTS:
593+
name: points_in_polys.gml
594+
type: vector
595+
POLYGONS:
596+
name: polys.gml
597+
type: vector
598+
results:
599+
OUTPUT:
600+
name: expected/points_in_polys.gml
601+
type: vector

0 commit comments

Comments
 (0)
Please sign in to comment.