diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f973aa72..036b3c74b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ - Undocumented authentication module `layman.authn.url_path.py` that was unused for a long time, was removed. - Python setting [`PG_NON_USER_SCHEMAS`](src/layman_settings.py) is now more explicit about forbidden schema names. - [#73](https://github.com/jirik/layman/issues/73) Layman users are automatically created on GeoServer (either at start up of Layman or when reserved) with separate role and workspace. Username is the same as in Layman, name of role is `"USER_"+username`, name of workspace is the same as username. Read and write permissions for workspace are set according to Layman's authorization (as of now read-everyone-write-everyone or read-everyone-write-owner). +- [#83](https://github.com/jirik/layman/issues/89) All layers are created as `GEOMETRY` type, so any other type can be added (for example polygons can be added to points). ## v1.5.0 2020-06-18 diff --git a/src/layman/layer/db/__init__.py b/src/layman/layer/db/__init__.py index 902d4833d..e03e9c0d6 100644 --- a/src/layman/layer/db/__init__.py +++ b/src/layman/layer/db/__init__.py @@ -106,6 +106,7 @@ def import_layer_vector_file_async(username, layername, main_filepath, 'ogr2ogr', '-t_srs', 'EPSG:3857', '-nln', layername, + '-nlt', 'GEOMETRY', '--config', 'OGR_ENABLE_PARTIAL_REPROJECTION', 'TRUE', '-lco', f'SCHEMA={username}', # '-clipsrc', '-180', '-85.06', '180', '85.06', @@ -119,7 +120,6 @@ def import_layer_vector_file_async(username, layername, main_filepath, ]) if os.path.splitext(main_filepath)[1] == '.shp': bash_args.extend([ - '-nlt', 'PROMOTE_TO_MULTI', '-lco', 'PRECISION=NO', ]) bash_args.extend([ diff --git a/src/layman/layer/rest_test.py b/src/layman/layer/rest_test.py index 6a8ba793c..48323b579 100644 --- a/src/layman/layer/rest_test.py +++ b/src/layman/layer/rest_test.py @@ -1128,3 +1128,118 @@ def test_get_layers_testuser2(client): uuid.check_redis_consistency(expected_publ_num_by_type={ f'{LAYER_TYPE}': num_layers_before_test + 2 }) + + +@pytest.mark.usefixtures('app_context') +def test_layer_with_different_geometry(client): + username = 'testgeometryuser1' + layername = 'layer_with_different_geometry' + rest_path = url_for('rest_layers.post', username=username) + file_paths = [ + 'tmp/naturalearth/110m/cultural/ne_110m_populated_places.geojson', + ] + for fp in file_paths: + assert os.path.isfile(fp) + files = [] + try: + files = [(open(fp, 'rb'), os.path.basename(fp)) for fp in file_paths] + rv = client.post(rest_path, data={ + 'file': files, + 'name': layername + }) + assert rv.status_code == 200 + finally: + for fp in files: + fp[0].close() + + wait_till_ready(username, layername) + + url_path_ows = urljoin(urljoin(settings.LAYMAN_GS_URL, username), 'ows?service=WFS&request=Transaction') + url_path_wfs = urljoin(urljoin(settings.LAYMAN_GS_URL, username), 'wfs?request=Transaction') + + headers_wfs = { + 'Accept': 'text/xml', + 'Content-type': 'text/xml', + } + + data_xml = ''' + + + + + + 1.27108004304E7 2548415.5977 + + + + +''' + + r = requests.post(url_path_ows, + data=data_xml, + headers=headers_wfs, + auth=settings.LAYMAN_GS_AUTH + ) + r.raise_for_status() + + r = requests.post(url_path_wfs, + data=data_xml, + headers=headers_wfs, + auth=settings.LAYMAN_GS_AUTH + ) + assert r.status_code == 200, f"HTTP Error {r.status_code}\n{r.text}" + + data_xml2 = ''' + + + + + + + + 3722077.1689 5775850.1007 3751406.9331 5815606.0102 3830548.3984 5781176.5357 + 3866350.4899 5774848.8358 3880796.9478 5743277.797 3897591.3679 5738418.6547 + + + + + + + +''' + + r = requests.post(url_path_ows, + data=data_xml2, + headers=headers_wfs, + auth=settings.LAYMAN_GS_AUTH + ) + assert r.status_code == 200, f"HTTP Error {r.status_code}\n{r.text}" + + r = requests.post(url_path_wfs, + data=data_xml2, + headers=headers_wfs, + auth=settings.LAYMAN_GS_AUTH + ) + assert r.status_code == 200, f"HTTP Error {r.status_code}\n{r.text}"