diff --git a/sample/layman.map/internal_url_thumbnail.json b/sample/layman.map/internal_url_thumbnail.json new file mode 100644 index 000000000..702adc99a --- /dev/null +++ b/sample/layman.map/internal_url_thumbnail.json @@ -0,0 +1,49 @@ +{ + "abstract": "World places and boundaries abstract", + "title": "World places and boundaries", + "extent": [ + "-35.0", + "-48.5", + "179", + "81.5" + ], + "projection": "epsg:3857", + "layers": [ + { + "metadata": {}, + "visibility": true, + "opacity": 1, + "title": "Staty", + "className": "HSLayers.Layer.WMS", + "singleTile": true, + "url": "http://localhost:8000/geoserver/test_sld_style_applied_in_map_thumbnail_workspace_wms/ows", + "params": { + "LAYERS": "test_sld_style_applied_in_map_thumbnail_layer", + "FORMAT": "image\/png" + } + }, + { + "metadata": {}, + "visibility": true, + "opacity": 1, + "title": "Defini\u010dn\u00ed body administrativn\u00edch celk\u016f", + "className": "HSLayers.Layer.WMS", + "singleTile": true, + "wmsMaxScale": 0, + "legends": [ + "https%3A%2F%2Fgeoportal.kraj-lbc.cz%2Fcgi-bin%2Fmapserv%3Fmap%3D%2Fdata%2Fgis%2FMapServer%2Fprojects%2Fwms%2Fatlas%2Fadministrativni_cleneni.map%26version%3D1.3.0%26service%3DWMS%26request%3DGetLegendGraphic%26sld_version%3D1.1.0%26layer%3Ddefinicni_body_administrativnich_celku%26format%3Dimage%2Fpng%26STYLE%3Ddefault" + ], + "maxResolution": null, + "minResolution": 0, + "url": "https%3A%2F%2Fgeoportal.kraj-lbc.cz%2Fcgi-bin%2Fmapserv%3Fmap%3D%2Fdata%2Fgis%2FMapServer%2Fprojects%2Fwms%2Fatlas%2Fadministrativni_cleneni.map%26", + "params": { + "LAYERS": "definicni_body_administrativnich_celku", + "INFO_FORMAT": "application\/vnd.ogc.gml", + "FORMAT": "image\/png", + "FROMCRS": "EPSG:3857", + "VERSION": "1.3.0" + }, + "dimensions": {} + } + ] +} \ No newline at end of file diff --git a/sample/style/test_sld_style_applied_in_map_thumbnail_map.png b/sample/style/test_sld_style_applied_in_map_thumbnail_map.png new file mode 100644 index 000000000..0945606e2 Binary files /dev/null and b/sample/style/test_sld_style_applied_in_map_thumbnail_map.png differ diff --git a/src/layman/map/filesystem/thumbnail_test.py b/src/layman/map/filesystem/thumbnail_test.py new file mode 100644 index 000000000..7ed971e43 --- /dev/null +++ b/src/layman/map/filesystem/thumbnail_test.py @@ -0,0 +1,40 @@ +import pytest +from layman import app +from . import thumbnail +from test import process_client, util + + +headers_sld = { + 'Accept': 'application/vnd.ogc.sld+xml', + 'Content-type': 'application/xml', +} + + +@pytest.mark.usefixtures('ensure_layman') +def test_sld_style_applied_in_map_thumbnail(): + workspace = 'test_sld_style_applied_in_map_thumbnail_workspace' + layer = 'test_sld_style_applied_in_map_thumbnail_layer' + map = 'test_sld_style_applied_in_map_thumbnail_map' + geojson_file = ['/code/tmp/naturalearth/110m/cultural/ne_110m_admin_0_countries.geojson'] + map_file = ['sample/layman.map/internal_url_thumbnail.json'] + style_file = 'sample/style/generic-blue.xml' + expected_file = 'sample/style/test_sld_style_applied_in_map_thumbnail_map.png' + + process_client.publish_layer(workspace, + layer, + file_paths=geojson_file, + style_file=style_file) + + process_client.publish_map(workspace, + map, + file_paths=map_file) + + with app.app_context(): + thumbnail_path = thumbnail.get_map_thumbnail_path(workspace, map) + + diffs = util.compare_images(expected_file, thumbnail_path) + + assert diffs < 1000 + + process_client.delete_map(workspace, map) + process_client.delete_layer(workspace, layer)