From 94b9312a2a053d1a3b45043673ff9b4c7eb7518d Mon Sep 17 00:00:00 2001 From: index-git Date: Tue, 24 Aug 2021 14:40:24 +0200 Subject: [PATCH] Enable to upload geojson with id attribute with non-unique values. Closes #380 --- CHANGELOG.md | 1 + sample/layman.layer/small_layer_with_id.geojson | 11 +++++++++++ src/layman/layer/db/__init__.py | 1 + tests/static_publications/__init__.py | 4 +++- 4 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 sample/layman.layer/small_layer_with_id.geojson diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ad91a921..b5798098a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -78,6 +78,7 @@ - `ground_sample_distance` used for raster data - Metadata property `scale_denominator` was removed. Its value is now accessible as subproperty of new [`spatial_resolution`](doc/metadata.md#spatial_resolution) metadata property. - [#418](https://github.com/LayerManager/layman/issues/418) Combination of none geometry type in layer file and any geometry type in qml file is from now allowed. +- [#380](https://github.com/LayerManager/layman/issues/380) Enable to upload geojson with "id" attribute with non-unique values. ## v1.13.2 2021-06-25 diff --git a/sample/layman.layer/small_layer_with_id.geojson b/sample/layman.layer/small_layer_with_id.geojson new file mode 100644 index 000000000..0003f0bea --- /dev/null +++ b/sample/layman.layer/small_layer_with_id.geojson @@ -0,0 +1,11 @@ +{ +"type": "FeatureCollection", +"name": "small_layer", +"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, +"features": [ +{ "type": "Feature", "properties": { "cartodb_id": 24, "id": 1 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 14.1149, 48.969585 ], [ 14.114936, 48.96959 ], [ 14.114867, 48.969513 ], [ 14.1149, 48.969585 ] ] ] ] } }, +{ "type": "Feature", "properties": { "cartodb_id": 165, "id": 1 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 14.114496, 48.966783 ], [ 14.114473, 48.966654 ], [ 14.114369, 48.966661 ], [ 14.114392, 48.966791 ], [ 14.114496, 48.966783 ] ] ] ] } }, +{ "type": "Feature", "properties": { "cartodb_id": 181, "id": 1 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 14.119754, 48.97045 ], [ 14.11929, 48.970293 ], [ 14.119146, 48.970276 ], [ 14.118926, 48.970299 ], [ 14.118698, 48.970322 ], [ 14.11838, 48.970346 ], [ 14.118229, 48.970323 ], [ 14.118331, 48.970612 ], [ 14.118714, 48.970511 ], [ 14.118825, 48.970489 ], [ 14.119085, 48.970414 ], [ 14.119341, 48.970397 ], [ 14.119895, 48.970517 ], [ 14.119754, 48.97045 ] ] ] ] } }, +{ "type": "Feature", "properties": { "cartodb_id": 573, "id": 1 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 14.125504, 48.964832 ], [ 14.125418, 48.964941 ], [ 14.126555, 48.966056 ], [ 14.126595, 48.966031 ], [ 14.126774, 48.965931 ], [ 14.126824, 48.965822 ], [ 14.126577, 48.965577 ], [ 14.126007, 48.965189 ], [ 14.125504, 48.964832 ] ] ] ] } } +] +} diff --git a/src/layman/layer/db/__init__.py b/src/layman/layer/db/__init__.py index 7242fc39b..cece0c57b 100644 --- a/src/layman/layer/db/__init__.py +++ b/src/layman/layer/db/__init__.py @@ -105,6 +105,7 @@ def import_layer_vector_file_async(username, layername, main_filepath, '-lco', f'SCHEMA={username}', # '-clipsrc', '-180', '-85.06', '180', '85.06', '-f', 'PostgreSQL', + '-unsetFid', f'PG:{pg_conn}', # 'PG:{} active_schema={}'.format(PG_CONN, username), ] diff --git a/tests/static_publications/__init__.py b/tests/static_publications/__init__.py index 87715ecf5..3f3597632 100644 --- a/tests/static_publications/__init__.py +++ b/tests/static_publications/__init__.py @@ -48,7 +48,9 @@ }, (OWNER, LAYER_TYPE, 'post_private_sld'): { DEFINITION: [ - {'headers': HEADERS[OWNER]}, + {'headers': HEADERS[OWNER], + 'file_paths': ['sample/layman.layer/small_layer_with_id.geojson'], + }, ], TEST_DATA: { 'bbox': (1571204.369948366, 6268896.225570714, 1572590.854206196, 6269876.33561699),