Skip to content

Commit 984e299

Browse files
author
Tahira Ullah
committed
multiple geoms dissolve return none
1 parent 0869347 commit 984e299

File tree

3 files changed

+39
-8
lines changed

3 files changed

+39
-8
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"type": "FeatureCollection",
3+
"name": "collected",
4+
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
5+
"features": [
6+
{ "type": "Feature", "properties": { "id": null }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 9.267717755524947, 48.812788568504551 ], [ 9.274544337888633, 48.834874570269413 ], [ 9.300846758172247, 48.826642515066148 ], [ 9.28177248392077, 48.798533058274501 ], [ 9.267717755524947, 48.812788568504551 ] ] ], [ [ [ 9.301850667343377, 48.796324458098013 ], [ 9.286591247942196, 48.812387004836097 ], [ 9.291209230129395, 48.822626878381627 ], [ 9.321125723429077, 48.818209678028651 ], [ 9.301850667343377, 48.796324458098013 ] ] ] ] } }
7+
]
8+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "FeatureCollection",
3+
"name": "overlappingGeoms",
4+
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
5+
"features": [
6+
{ "type": "Feature", "properties": { "id": null }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 9.267717755524947, 48.812788568504551 ], [ 9.274544337888633, 48.834874570269413 ], [ 9.300846758172247, 48.826642515066148 ], [ 9.28177248392077, 48.798533058274501 ], [ 9.267717755524947, 48.812788568504551 ] ] ] ] } },
7+
{ "type": "Feature", "properties": { "id": null }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 9.301850667343377, 48.796324458098013 ], [ 9.286591247942196, 48.812387004836097 ], [ 9.291209230129395, 48.822626878381627 ], [ 9.321125723429077, 48.818209678028651 ], [ 9.301850667343377, 48.796324458098013 ] ] ] ] } }
8+
]
9+
}

mapswipe_workers/tests/unittests/test_validate_geometries.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,31 @@ class TestGeometryValidation(unittest.TestCase):
2020
def test_multiple_geom_validation(self):
2121
path = "fixtures/completeness/projectDraft.json"
2222
test_dir = os.path.dirname(os.path.abspath(__file__))
23-
project = create_project(path)
23+
# project = create_project(path)
2424
# prepare data that is expected
25-
path = os.path.join(test_dir, "fixtures/completeness/multiplePolygons.geojson")
25+
path = os.path.join(test_dir, "fixtures/completeness/overlappingGeoms.geojson")
2626
driver = ogr.GetDriverByName("GeoJSON")
2727
data_source = driver.Open(path, 0)
28-
wkt_geometries_expected = []
28+
29+
multipolygon_geometry = ogr.Geometry(ogr.wkbMultiPolygon)
2930
# Get the data layer
3031
layer = data_source.GetLayer()
32+
3133
for feature in layer:
3234
feat_geom = feature.GetGeometryRef()
33-
wkt_geometries_expected.append(feat_geom.ExportToWkt())
35+
wkt = feat_geom.ExportToWkt()
36+
geom_name = feat_geom.GetGeometryName()
37+
print(geom_name)
38+
multipolygon_geometry.AddGeometryDirectly(ogr.CreateGeometryFromWkt(wkt))
39+
40+
dissolved_geometry = multipolygon_geometry.UnionCascaded()
41+
print(dissolved_geometry)
3442

43+
# wkt_geometry_collection = geometry_collection.ExportToWkt()
44+
# print(wkt_geometry_collection)
3545
# results coming from the validate geometries function
36-
wkt = project.validate_geometries()
37-
self.assertCountEqual(wkt, wkt_geometries_expected)
3846

47+
"""
3948
def test_single_geom_validation(self):
4049
path = "fixtures/completeness/projectDraft_single.json"
4150
test_dir = os.path.dirname(os.path.abspath(__file__))
@@ -46,17 +55,22 @@ def test_single_geom_validation(self):
4655
driver = ogr.GetDriverByName("GeoJSON")
4756
datasource = driver.Open(path, 0)
4857
49-
wkt_geometries_expected = []
58+
59+
geometry_collection = ogr.Geometry(ogr.wkbGeometryCollection)
5060
# Get the data layer
5161
layer = datasource.GetLayer()
5262
for feature in layer:
5363
feat_geom = feature.GetGeometryRef()
54-
wkt_geometries_expected.append(feat_geom.ExportToWkt())
64+
geometry_collection.AddGeometry(feat_geom)
65+
66+
wkt_geometry_collection = geometry_collection.ExportToWkt()
67+
print(wkt_geometry_collection)
5568
5669
# results coming from the validate_geometries function
5770
wkt = project.validate_geometries()
5871
# Test that sequence first contains the same elements as second
5972
self.assertCountEqual(wkt, wkt_geometries_expected)
73+
"""
6074

6175

6276
if __name__ == "__main__":

0 commit comments

Comments
 (0)