From 2abeea1128a56e325cb46a9be663cceff9192064 Mon Sep 17 00:00:00 2001 From: Matteo Ghetta Date: Mon, 19 Dec 2016 10:51:13 +0100 Subject: [PATCH] Convex Hull processing tests (#3876) Add two tests for convex hull --- .../testdata/custom/count_unique_points.gfs | 20 +++ .../testdata/custom/count_unique_points.gml | 169 ++++++++++++++++++ .../tests/testdata/custom/points_hull.gfs | 30 ++++ .../tests/testdata/custom/points_hull.gml | 86 +++++++++ .../expected/basic_statistics_float.html | 21 +++ .../expected/basic_statistics_int.html | 21 +++ .../tests/testdata/expected/convex_hull.gfs | 36 ++++ .../tests/testdata/expected/convex_hull.gml | 23 +++ .../testdata/expected/convex_hull_fields.gfs | 35 ++++ .../testdata/expected/convex_hull_fields.gml | 41 +++++ .../expected/count_unique_points.geojson | 13 ++ .../tests/testdata/qgis_algorithm_tests.yaml | 26 +++ 12 files changed, 521 insertions(+) create mode 100644 python/plugins/processing/tests/testdata/custom/count_unique_points.gfs create mode 100644 python/plugins/processing/tests/testdata/custom/count_unique_points.gml create mode 100644 python/plugins/processing/tests/testdata/custom/points_hull.gfs create mode 100644 python/plugins/processing/tests/testdata/custom/points_hull.gml create mode 100644 python/plugins/processing/tests/testdata/expected/basic_statistics_float.html create mode 100644 python/plugins/processing/tests/testdata/expected/basic_statistics_int.html create mode 100644 python/plugins/processing/tests/testdata/expected/convex_hull.gfs create mode 100644 python/plugins/processing/tests/testdata/expected/convex_hull.gml create mode 100644 python/plugins/processing/tests/testdata/expected/convex_hull_fields.gfs create mode 100644 python/plugins/processing/tests/testdata/expected/convex_hull_fields.gml create mode 100644 python/plugins/processing/tests/testdata/expected/count_unique_points.geojson diff --git a/python/plugins/processing/tests/testdata/custom/count_unique_points.gfs b/python/plugins/processing/tests/testdata/custom/count_unique_points.gfs new file mode 100644 index 00000000000..ed2efad88f2 --- /dev/null +++ b/python/plugins/processing/tests/testdata/custom/count_unique_points.gfs @@ -0,0 +1,20 @@ + + + count_unique_points + count_unique_points + 1 + EPSG:4326 + + 26 + -0.18351 + 9.58625 + -2.40588 + 5.73133 + + + unique + unique + Integer + + + diff --git a/python/plugins/processing/tests/testdata/custom/count_unique_points.gml b/python/plugins/processing/tests/testdata/custom/count_unique_points.gml new file mode 100644 index 00000000000..b304c697490 --- /dev/null +++ b/python/plugins/processing/tests/testdata/custom/count_unique_points.gml @@ -0,0 +1,169 @@ + + + + + -0.1835059209628658-2.405884426380911 + 9.5862510453464215.731328294905413 + + + + + + -0.183505920962866,2.287680278060103 + 10 + + + + + 1.372512812574644,1.496916659377106 + 10 + + + + + 0.607257697720131,-0.084610577988888 + 5 + + + + + 0.071579117321972,0.629627529208658 + 10 + + + + + 2.41836146954248,2.542765316344942 + 6 + + + + + 2.545903988684898,3.639630980969744 + + + + + 2.290818950400061,5.654802783419962 + 2 + + + + + 2.698955011655801,5.731328294905413 + 2 + + + + + 2.520395484856414,5.246666722164222 + 1 + + + + + 4.561075791135116,4.277343576681838 + 1 + + + + + 4.943703348562373,4.481411607309709 + 2 + + + + + 2.928531546112155,1.190814613435302 + 5 + + + + + 4.050905714565441,0.910221071321979 + 5 + + + + + 4.841669333248438,0.195982964124434 + 5 + + + + + 4.892686340905406,-1.206984746442174 + 3 + + + + + 3.821329180109087,-1.155967738785206 + 5 + + + + + 3.821329180109087,-0.390712623930693 + 2 + + + + + 3.260142095882444,0.042931941153531 + 5 + + + + + 2.954040049940638,-0.77334018135795 + 5 + + + + + 6.958875151012592,0.527593513894724 + 1 + + + + + 8.030232311808911,0.527593513894724 + 7 + + + + + 9.076080968776745,0.349033987095337 + 6 + + + + + 9.586251045346421,-1.58961230386943 + 5 + + + + + 8.336334357750715,-1.462069784727012 + 4 + + + + + 8.23430034243678,-2.405884426380911 + 3 + + + + + 6.831332631870172,-1.997748365125171 + 2 + + + diff --git a/python/plugins/processing/tests/testdata/custom/points_hull.gfs b/python/plugins/processing/tests/testdata/custom/points_hull.gfs new file mode 100644 index 00000000000..3b455b50f94 --- /dev/null +++ b/python/plugins/processing/tests/testdata/custom/points_hull.gfs @@ -0,0 +1,30 @@ + + + points_hull + points_hull + 1 + EPSG:4326 + + 9 + 0.00000 + 8.00000 + -5.00000 + 3.00000 + + + id + id + Integer + + + id2 + id2 + Integer + + + hull + hull + Integer + + + diff --git a/python/plugins/processing/tests/testdata/custom/points_hull.gml b/python/plugins/processing/tests/testdata/custom/points_hull.gml new file mode 100644 index 00000000000..917345ae58f --- /dev/null +++ b/python/plugins/processing/tests/testdata/custom/points_hull.gml @@ -0,0 +1,86 @@ + + + + + 0-5 + 83 + + + + + + 1,1 + 1 + 2 + 2 + + + + + 3,3 + 2 + 1 + 3 + + + + + 2,2 + 3 + 0 + 3 + + + + + 5,2 + 4 + 2 + 3 + + + + + 4,1 + 5 + 1 + 2 + + + + + 0,-5 + 6 + 0 + 1 + + + + + 8,-1 + 7 + 0 + 2 + + + + + 7,-1 + 8 + 0 + 1 + + + + + 0,-1 + 9 + 0 + 1 + + + diff --git a/python/plugins/processing/tests/testdata/expected/basic_statistics_float.html b/python/plugins/processing/tests/testdata/expected/basic_statistics_float.html new file mode 100644 index 00000000000..187f74074b4 --- /dev/null +++ b/python/plugins/processing/tests/testdata/expected/basic_statistics_float.html @@ -0,0 +1,21 @@ + + +

Analyzed layer: polys

+

Analyzed field: floatval

+

Count: 5

+

Unique values: 5

+

NULL (missing) values: 1

+

Minimum value: -100291.43213

+

Maximum value: 44.123456

+

Range: 100335.555586

+

Sum: -100243.855674

+

Mean value: -20048.7711348

+

Median value: 0.123

+

Standard deviation: 40121.333967334256

+

Coefficient of Variation: -2.001186691073198

+

Minority (rarest occurring value): -100291.43213

+

Majority (most frequently occurring value): -100291.43213

+

First quartile: 0.0

+

Third quartile: 3.33

+

Interquartile Range (IQR): 3.33

+ diff --git a/python/plugins/processing/tests/testdata/expected/basic_statistics_int.html b/python/plugins/processing/tests/testdata/expected/basic_statistics_int.html new file mode 100644 index 00000000000..60d98638b0e --- /dev/null +++ b/python/plugins/processing/tests/testdata/expected/basic_statistics_int.html @@ -0,0 +1,21 @@ + + +

Analyzed layer: polys

+

Analyzed field: intval

+

Count: 5

+

Unique values: 5

+

NULL (missing) values: 1

+

Minimum value: -33.0

+

Maximum value: 120.0

+

Range: 153.0

+

Sum: 122.0

+

Mean value: 24.4

+

Median value: 2.0

+

Standard deviation: 52.163588833591575

+

Coefficient of Variation: 2.137852001376704

+

Minority (rarest occurring value): -33.0

+

Majority (most frequently occurring value): -33.0

+

First quartile: 0.0

+

Third quartile: 33.0

+

Interquartile Range (IQR): 33.0

+ diff --git a/python/plugins/processing/tests/testdata/expected/convex_hull.gfs b/python/plugins/processing/tests/testdata/expected/convex_hull.gfs new file mode 100644 index 00000000000..98455e5ae2e --- /dev/null +++ b/python/plugins/processing/tests/testdata/expected/convex_hull.gfs @@ -0,0 +1,36 @@ + + + convex_hull + convex_hull + 3 + EPSG:4326 + + 1 + 0.00000 + 8.00000 + -5.00000 + 3.00000 + + + id + id + Integer + + + value + value + String + 3 + + + area + area + Real + + + perim + perim + Real + + + diff --git a/python/plugins/processing/tests/testdata/expected/convex_hull.gml b/python/plugins/processing/tests/testdata/expected/convex_hull.gml new file mode 100644 index 00000000000..601cc2d0dd5 --- /dev/null +++ b/python/plugins/processing/tests/testdata/expected/convex_hull.gml @@ -0,0 +1,23 @@ + + + + + 0-5 + 83 + + + + + + 0,-5 0,-1 1,1 3,3 5,2 8,-1 0,-5 + 0 + all + 34.500000 + 24.487476 + + + diff --git a/python/plugins/processing/tests/testdata/expected/convex_hull_fields.gfs b/python/plugins/processing/tests/testdata/expected/convex_hull_fields.gfs new file mode 100644 index 00000000000..c58766b29a6 --- /dev/null +++ b/python/plugins/processing/tests/testdata/expected/convex_hull_fields.gfs @@ -0,0 +1,35 @@ + + + convex_hull_fields + convex_hull_fields + 3 + EPSG:4326 + + 3 + 0.00000 + 8.00000 + -5.00000 + 3.00000 + + + id + id + Integer + + + value + value + Integer + + + area + area + Real + + + perim + perim + Real + + + diff --git a/python/plugins/processing/tests/testdata/expected/convex_hull_fields.gml b/python/plugins/processing/tests/testdata/expected/convex_hull_fields.gml new file mode 100644 index 00000000000..a908835fc56 --- /dev/null +++ b/python/plugins/processing/tests/testdata/expected/convex_hull_fields.gml @@ -0,0 +1,41 @@ + + + + + 0-5 + 83 + + + + + + 0,-5 0,-1 7,-1 0,-5 + 0 + 1 + 14.000000 + 19.062258 + + + + + 8,-1 1,1 4,1 8,-1 + 1 + 2 + 3.000000 + 14.752246 + + + + + 2,2 3,3 5,2 2,2 + 2 + 3 + 1.500000 + 6.650282 + + + diff --git a/python/plugins/processing/tests/testdata/expected/count_unique_points.geojson b/python/plugins/processing/tests/testdata/expected/count_unique_points.geojson new file mode 100644 index 00000000000..71013637878 --- /dev/null +++ b/python/plugins/processing/tests/testdata/expected/count_unique_points.geojson @@ -0,0 +1,13 @@ +{ +"type": "FeatureCollection", +"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, + +"features": [ +{ "type": "Feature", "properties": { "fid": "polys.0", "name": "aaaaa", "intval": 33, "floatval": 44.123456, "COUNT": 41 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -1.0, -1.0 ], [ -1.0, 3.0 ], [ 3.0, 3.0 ], [ 3.0, 2.0 ], [ 2.0, 2.0 ], [ 2.0, -1.0 ], [ -1.0, -1.0 ] ] ] } }, +{ "type": "Feature", "properties": { "fid": "polys.1", "name": "Aaaaa", "intval": -33, "floatval": 0.000000, "COUNT": 3 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 5.0, 5.0 ], [ 6.0, 4.0 ], [ 4.0, 4.0 ], [ 5.0, 5.0 ] ] ] } }, +{ "type": "Feature", "properties": { "fid": "polys.2", "name": "bbaaa", "intval": null, "floatval": 0.123000, "COUNT": 5 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 2.0, 5.0 ], [ 2.0, 6.0 ], [ 3.0, 6.0 ], [ 3.0, 5.0 ], [ 2.0, 5.0 ] ] ] } }, +{ "type": "Feature", "properties": { "fid": "polys.3", "name": "ASDF", "intval": 0, "floatval": null, "COUNT": 24 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 6.0, 1.0 ], [ 10.0, 1.0 ], [ 10.0, -3.0 ], [ 6.0, -3.0 ], [ 6.0, 1.0 ] ], [ [ 7.0, 0.0 ], [ 7.0, -2.0 ], [ 9.0, -2.0 ], [ 9.0, 0.0 ], [ 7.0, 0.0 ] ] ] } }, +{ "type": "Feature", "properties": { "fid": "polys.4", "name": null, "intval": 120, "floatval": -100291.432130, "COUNT": 0 }, "geometry": { "type": "Polygon", "coordinates": [ ] } }, +{ "type": "Feature", "properties": { "fid": "polys.5", "name": "elim", "intval": 2, "floatval": 3.330000, "COUNT": 35 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 3.0, 2.0 ], [ 6.0, 1.0 ], [ 6.0, -3.0 ], [ 2.0, -1.0 ], [ 2.0, 2.0 ], [ 3.0, 2.0 ] ] ] } } +] +} diff --git a/python/plugins/processing/tests/testdata/qgis_algorithm_tests.yaml b/python/plugins/processing/tests/testdata/qgis_algorithm_tests.yaml index e602489bac1..84a2f07e2e7 100644 --- a/python/plugins/processing/tests/testdata/qgis_algorithm_tests.yaml +++ b/python/plugins/processing/tests/testdata/qgis_algorithm_tests.yaml @@ -2015,6 +2015,32 @@ tests: name: expected/join_attribute_table.gml type: vector + - algorithm: qgis:convexhull + name: Simple convex hull + params: + INPUT: + name: custom/points_hull.gml + type: vector + METHOD: '0' + results: + OUTPUT: + name: expected/convex_hull.gml + type: vector + + - algorithm: qgis:convexhull + name: Convex hull based on field attribute + params: + FIELD: hull + INPUT: + name: custom/points_hull.gml + type: vector + METHOD: '1' + results: + OUTPUT: + name: expected/convex_hull_fields.gml + type: vector + + # These tests dissabled because algs require access to iface which # is not available in the test suite. #- algorithm: qgis:shortestpathpointtopoint