diff --git a/src/rok4/layer.py b/src/rok4/layer.py index c6c21ed..6901645 100644 --- a/src/rok4/layer.py +++ b/src/rok4/layer.py @@ -115,7 +115,7 @@ def from_parameters(cls, pyramids: List[Dict[str, str]], name: str, **kwargs) -> name (str): layer's technical name **title (str): Layer's title (will be equal to name if not provided) **abstract (str): Layer's abstract (will be equal to name if not provided) - **styles (List[str]): Styles identifier to authorized for the layer + **styles (List[str]): Styles identifier to authorize for the layer **resampling (str): Interpolation to use for resampling Raises: @@ -249,8 +249,8 @@ def serializable(self) -> Dict: "title": self.__title, "abstract": self.__abstract, "keywords": self.__keywords, - "wmts": {"authorized": True}, - "tms": {"authorized": True}, + "tms": {"enabled": True}, + "tiles": {"enabled": True}, "bbox": { "south": self.__geobbox[0], "west": self.__geobbox[1], @@ -270,16 +270,24 @@ def serializable(self) -> Dict: ) if self.type == PyramidType.RASTER: + serialization["wmts"] = { + "enabled": True + } serialization["wms"] = { - "authorized": True, - "crs": ["CRS:84", "IGNF:WGS84G", "EPSG:3857", "EPSG:4258", "EPSG:4326"], + "enabled": True, + "crs": ["CRS:84", "IGNF:WGS84G", "EPSG:3857", "EPSG:4326"], } - if self.__tms.srs.upper() not in serialization["wms"]["crs"]: - serialization["wms"]["crs"].append(self.__tms.srs.upper()) - serialization["styles"] = self.__styles serialization["resampling"] = self.__resampling + else: + serialization["wmts"] = { + "enabled": False + } + serialization["wms"] = { + "enabled": False + } + return serialization diff --git a/tests/test_layer.py b/tests/test_layer.py index a4df1b3..77975bc 100644 --- a/tests/test_layer.py +++ b/tests/test_layer.py @@ -42,7 +42,7 @@ def test_descriptor_ok(mocked_put_data_str, mocked_pyramid_class, mocked_get_dat layer.write_descriptor("s3://layers_backup/") mocked_put_data_str.assert_called_once_with( - '{"title": "SCAN1000", "abstract": "Diffusion de la donn\\u00e9e BDORTHO", "keywords": ["PM", "TIFF_JPG_UINT8"], "wmts": {"authorized": true}, "tms": {"authorized": true}, "bbox": {"south": 40.9798980696195, "west": -5.624999999999043, "north": 52.48278022207774, "east": 11.250000000000997}, "pyramids": [{"bottom_level": "10", "top_level": "10", "path": "s3://pyramids/SCAN1000.json"}], "wms": {"authorized": true, "crs": ["CRS:84", "IGNF:WGS84G", "EPSG:3857", "EPSG:4258", "EPSG:4326"]}, "styles": ["normal", "hypso"], "resampling": "linear"}', + '{"title": "SCAN1000", "abstract": "Diffusion de la donn\\u00e9e BDORTHO", "keywords": ["PM", "TIFF_JPG_UINT8"], "tms": {"enabled": true}, "tiles": {"enabled": true}, "bbox": {"south": 40.9798980696195, "west": -5.624999999999043, "north": 52.48278022207774, "east": 11.250000000000997}, "pyramids": [{"bottom_level": "10", "top_level": "10", "path": "s3://pyramids/SCAN1000.json"}], "wmts": {"enabled": true}, "wms": {"enabled": true, "crs": ["CRS:84", "IGNF:WGS84G", "EPSG:3857", "EPSG:4326"]}, "styles": ["normal", "hypso"], "resampling": "linear"}', "s3://layers_backup/SCAN1000.json", ) except Exception as exc: @@ -87,7 +87,7 @@ def test_parameters_vector_ok( assert layer.geobbox == (0, 0, 100, 100) layer.write_descriptor("file:///home/ign/layers/") mocked_put_data_str.assert_called_once_with( - '{"title": "title", "abstract": "abstract", "keywords": ["VECTOR", "layername"], "wmts": {"authorized": true}, "tms": {"authorized": true}, "bbox": {"south": 0, "west": 0, "north": 100, "east": 100}, "pyramids": [{"bottom_level": "10", "top_level": "10", "path": "file:///home/ign/pyramids/SCAN1000.json"}]}', + '{"title": "title", "abstract": "abstract", "keywords": ["VECTOR", "layername"], "tms": {"enabled": true}, "tiles": {"enabled": true}, "bbox": {"south": 0, "west": 0, "north": 100, "east": 100}, "pyramids": [{"bottom_level": "10", "top_level": "10", "path": "file:///home/ign/pyramids/SCAN1000.json"}], "wmts": {"enabled": false}, "wms": {"enabled": false}}', "file:///home/ign/layers/layername.json", ) @@ -135,7 +135,7 @@ def test_parameters_raster_ok( assert layer.geobbox == (0, 0, 100, 100) layer.write_descriptor("file:///home/ign/layers/") mocked_put_data_str.assert_called_once_with( - '{"title": "title", "abstract": "abstract", "keywords": ["RASTER", "layername"], "wmts": {"authorized": true}, "tms": {"authorized": true}, "bbox": {"south": 0, "west": 0, "north": 100, "east": 100}, "pyramids": [{"bottom_level": "10", "top_level": "10", "path": "file:///home/ign/pyramids/RGEALTI.json"}], "wms": {"authorized": true, "crs": ["CRS:84", "IGNF:WGS84G", "EPSG:3857", "EPSG:4258", "EPSG:4326"]}, "styles": ["normal"], "resampling": "nn"}', + '{"title": "title", "abstract": "abstract", "keywords": ["RASTER", "layername"], "tms": {"enabled": true}, "tiles": {"enabled": true}, "bbox": {"south": 0, "west": 0, "north": 100, "east": 100}, "pyramids": [{"bottom_level": "10", "top_level": "10", "path": "file:///home/ign/pyramids/RGEALTI.json"}], "wmts": {"enabled": true}, "wms": {"enabled": true, "crs": ["CRS:84", "IGNF:WGS84G", "EPSG:3857", "EPSG:4326"]}, "styles": ["normal"], "resampling": "nn"}', "file:///home/ign/layers/layername.json", )