diff --git a/CHANGELOG.md b/CHANGELOG.md index 0337ad703..da31dc9fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -73,7 +73,7 @@ - Fix [GET Workspace Layer](doc/rest.md#get-workspace-layer) documentation, where was incorrectly `style` item instead of `sld`. - [#167](https://github.com/LayerManager/layman/issues/167) New metadata property [`spatial_resolution`](doc/metadata.md#spatial_resolution) is available. It has one of two subproperties: - `scale_denominator` used for vector data - - `ground_sample_distance` used for raster data (not yet filled) + - `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. ## v1.13.2 diff --git a/doc/metadata.md b/doc/metadata.md index 57cced947..88e1be25b 100644 --- a/doc/metadata.md +++ b/doc/metadata.md @@ -244,7 +244,7 @@ Multiplicity: 1 Shape: Object with one of following keys: - *scale_denominator*: Integer. Scale denominator, used for vector data, guessed from distances between vertices of line and polygon features. -- *ground_sample_distance*: Object. Ground sample distance, used for raster data. +- *ground_sample_distance*: Object. Ground sample distance, used for raster data, read from normalized raster. Keys: - **value**: Float. Value of ground sample distance. - **uom**: String. Unit of measurement of ground sample distance. diff --git a/src/layman/layer/filesystem/gdal.py b/src/layman/layer/filesystem/gdal.py index ed3671b83..d0a03e5e8 100644 --- a/src/layman/layer/filesystem/gdal.py +++ b/src/layman/layer/filesystem/gdal.py @@ -289,3 +289,11 @@ def get_bbox(workspace, layer): miny = maxy + geo_transform[5] * data.RasterYSize result = (minx, miny, maxx, maxy) return result + + +def get_normalized_ground_sample_distance(workspace, layer): + filepath = get_normalized_raster_layer_main_filepath(workspace, layer) + pixel_size = get_pixel_size(filepath) + abs_pixel_size = [abs(size) for size in pixel_size] + distance_value = sum(abs_pixel_size) / len(abs_pixel_size) + return distance_value diff --git a/src/layman/layer/micka/csw.py b/src/layman/layer/micka/csw.py index 4d7a1f7cc..62f9bda7e 100644 --- a/src/layman/layer/micka/csw.py +++ b/src/layman/layer/micka/csw.py @@ -9,6 +9,7 @@ from layman.common.filesystem.uuid import get_publication_uuid_file from layman.common.micka import util as common_util from layman.common import language as common_language, empty_method, empty_method_returns_none, bbox as bbox_util +from layman.layer.filesystem import gdal from layman.layer.filesystem.uuid import get_layer_uuid from layman.layer import db from layman.layer.geoserver import wms @@ -150,8 +151,12 @@ def get_template_path_and_values(workspace, layername, http_method=None): } elif file_type == settings.FILE_TYPE_RASTER: languages = [] + distance_value = gdal.get_normalized_ground_sample_distance(workspace, layername) spatial_resolution = { - 'ground_sample_distance': None, + 'ground_sample_distance': { + 'value': distance_value, + 'uom': 'm', # EPSG:3857 + } } else: raise NotImplementedError(f"Unknown file type: {file_type}") diff --git a/test_tools/data/micka/rest_test_filled_raster_template.xml b/test_tools/data/micka/rest_test_filled_raster_template.xml new file mode 100644 index 000000000..bbf32e956 --- /dev/null +++ b/test_tools/data/micka/rest_test_filled_raster_template.xml @@ -0,0 +1,277 @@ + + + + m-81c0debe-b2ea-4829-9b16-581083b29907 + + + eng + + + dataset + + + + + + + + + + + + + + + + + + + + pointOfContact + + + + + 2007-05-25 + + + ISO 19115/INSPIRE_TG2/CZ4 + + + 2003/cor.1/2006 + + + + + + + EPSG:4326 + + + + + + + + + + + EPSG:3857 + + + + + + + + + + + EPSG:5514 + + + + + + + + + + + post_tif_rgba_4326 + + + + + 2019-12-07 + + + publication + + + + + + + post_tif_rgba_4326 + + + + + + + + + + + + + + + + + + + + + + + + + custodian + + + + + + + http://enjoychallenge.tech/rest/workspaces/test_workspace/layers/post_tif_rgba_4326/thumbnail + + + PNG + + + + + + + + + + GEMET - INSPIRE themes, version 1.0 + + + + + 2008-06-01 + + + publication + + + + + + + + + + + otherRestrictions + + + Bez omezení + + + + + + + otherRestrictions + + + Žádné podmínky neplatí + + + + + vector + + + + + 0.043745341126665845 + + + + + + utf8 + + + + + + + + 15.08622670719884 + + + 15.086453058544048 + + + 50.665636410141985 + + + 50.66575821142854 + + + + + + + + + + + + + + + http://localhost:8000/geoserver/test_workspace_wms/ows?SERVICE=WMS&REQUEST=GetCapabilities&VERSION=1.3.0&LAYERS=post_tif_rgba_4326 + + + OGC:WMS-1.3.0-http-get-capabilities + + + download + + + + + + + http://localhost:8000/geoserver/test_workspace/wfs?SERVICE=WFS&REQUEST=GetCapabilities&VERSION=2.0.0&LAYERS=post_tif_rgba_4326 + + + OGC:WFS-2.0.0-http-get-capabilities + + + download + + + + + + + http://enjoychallenge.tech/rest/workspaces/test_workspace/layers/post_tif_rgba_4326 + + + WWW:LINK-1.0-http--link + + + information + + + + + + + + + + + + + dataset + + + + + + + + + + + diff --git a/tests/static_publications/__init__.py b/tests/static_publications/__init__.py index 59197ec4c..d2eb7bd76 100644 --- a/tests/static_publications/__init__.py +++ b/tests/static_publications/__init__.py @@ -274,6 +274,10 @@ 'thumbnail': '/code/test_tools/data/thumbnail/raster_layer_tif_rgba_4326.png', 'file_type': settings.FILE_TYPE_RASTER, 'style_type': 'sld', + 'micka_xml': {'filled_template': 'test_tools/data/micka/rest_test_filled_raster_template.xml', + 'diff_lines': MICKA_XML_LAYER_DIFF_LINES, + 'diff_lines_len': 29, + }, }, }, (COMMON_WORKSPACE, LAYER_TYPE, 'post_tiff'): {