Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

901 accept 3.x.x maps #933

Merged
merged 4 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
- requests to [WMS](doc/endpoints.md#web-map-service) and [WFS](doc/endpoints.md#web-feature-service) endpoints
- [#868](https://github.com/LayerManager/layman/issues/868) Responses to [GET Workspace Layer Metadata Comparison](doc/rest.md#get-workspace-layer-metadata-comparison) and [GET Workspace Map Metadata Comparison](doc/rest.md#get-workspace-map-metadata-comparison) do not respect [HTTP X-Forwarded headers](doc/client-proxy.md#x-forwarded-http-headers) of the request intentionally, in order to keep URLs in canonical form.
- [#868](https://github.com/LayerManager/layman/issues/868) Relations between map and [internal layers](doc/models.md#internal-map-layer) are updated in `map_layer` table when calling [POST Workspace Maps](doc/rest.md#post-workspace-maps), [PATCH Workspace Map](doc/rest.md#patch-workspace-map), [DELETE Workspace Map](doc/rest.md#delete-workspace-map), and [DELETE Workspace Maps](doc/rest.md#delete-workspace-maps).
- [#901](https://github.com/LayerManager/layman/issues/868) Endpoints [POST](doc/rest.md#post-workspace-maps) and [PATCH](doc/rest.md#patch-workspace-map) accept map compositions in version `3.x.x`.
- [#927](https://github.com/LayerManager/layman/issues/927) Send styles to GeoServer with [`raw`](https://docs.geoserver.org/2.21.x/en/user/rest/api/styles.html#raw) param set to `True`.
- [#880](https://github.com/LayerManager/layman/issues/880) Use Docker Compose v2 (`docker compose`) in Makefile without `compatibility` flag and remove `Makefile_docker-compose_v1` file. Docker containers are named according to Docker Compose v2 and may have different name after upgrade.
- [#765](https://github.com/LayerManager/layman/issues/765) Stop saving OAuth2 claims in filesystem, use prime DB schema only.
Expand Down
2 changes: 1 addition & 1 deletion doc/models.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

## Map
- Also referred to as **map composition**
- Map is [publication](#publication) defined by JSON valid against [map-composition schema](https://github.com/hslayers/map-compositions) version 2 used by [Hslayers-ng](https://github.com/hslayers/hslayers-ng)
- Map is [publication](#publication) defined by JSON valid against [map-composition schema](https://github.com/hslayers/map-compositions) version 2 or 3 used by [Hslayers-ng](https://github.com/hslayers/hslayers-ng)
- Map is collection of WMS layers and vector data
- Maps composed of WMS layers only are fully supported
- Each layer is either [internal](#internal-map-layer), or [external](#external-map-layer).
Expand Down
2 changes: 1 addition & 1 deletion doc/publish-map.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Two types of QGIS maps are considered:
## Maps composed from WMS layers
In QGIS, you need to implement following steps.

First, compose JSON valid against [map-composition schema](https://github.com/hslayers/map-compositions). For Layman, especially `describedBy`, `name`, `title`, `abstract`, `layers`, `projection`, and `extent attributes are important. Each layer must have `className` attribute equal to `HSLayers.Layer.WMS`.
First, compose JSON valid against [map-composition schema](https://github.com/hslayers/map-compositions). For Layman, especially `describedBy`, `name`, `title`, `abstract`, `layers`, `projection`, and `extent attributes are important. Each layer must have `className` attribute equal to `HSLayers.Layer.WMS` or `WMS`.

Then save the file to Layman using [POST Workspace Maps](rest.md#post-workspace-maps) endpoint. Well-known [requests](https://requests.readthedocs.io/en/latest/) module can be used for sending HTTP requests. See especially
- [More complicated POST requests](https://requests.readthedocs.io/en/latest/user/quickstart/#more-complicated-post-requests)
Expand Down
2 changes: 1 addition & 1 deletion doc/rest.md
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ Get list of published maps (map compositions).
Have the same request parameters and response structure and headers as [GET Maps](#get-maps).

### POST Workspace Maps
Publish new map composition. Accepts JSON valid against [map-composition schema](https://github.com/hslayers/map-compositions) version 2 used by [Hslayers-ng](https://github.com/hslayers/hslayers-ng). Exact version of schema is defined by `describedBy` key of JSON data file.
Publish new map composition. Accepts JSON valid against [map-composition schema](https://github.com/hslayers/map-compositions) version 2 or 3 used by [Hslayers-ng](https://github.com/hslayers/hslayers-ng). Exact version of schema is defined by `describedBy` key of JSON data file.

Processing chain consists of few steps:
- validate JSON file against schema defined by `describedBy` key
Expand Down
54 changes: 54 additions & 0 deletions sample/layman.map/full_3_0_0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"describedBy": "https://raw.githubusercontent.com/hslayers/map-compositions/3.0.0/schema.json",
"schema_version": "3.0.0",
"abstract": "Na tematick\u00e9 map\u011b p\u0159i p\u0159ibl\u00ed\u017een\u00ed jsou postupn\u011b zobrazovan\u00e9 administrativn\u00ed celky Libereck\u00e9ho kraje : okresy, OP\u00da, ORP a obce.",
"title": "Administrativn\u00ed \u010dlen\u011bn\u00ed Libereck\u00e9ho kraje",
"extent": [
14.62,
50.58,
15.42,
50.82
],
"nativeExtent": [
1627490.9553976597,
6547334.172794042,
1716546.5480322787,
6589515.35758913
],
"user": {
"email": "[email protected]",
"name": "Test User"
},
"groups": {
"guest": "r"
},
"scale": 1,
"projection": "epsg:3857",
"center": [
1672068,
6568819
],
"units": "m",
"layers": [
{
"metadata": {},
"visibility": false,
"opacity": 1,
"title": "Jednoduch\u00e1 podkladov\u00e1 mapa",
"className": "WMS",
"singleTile": true,
"maxResolution": null,
"minResolution": 0,
"url": "https://geoportal.kraj-lbc.cz/cgi-bin/mapserv?map=/data/gis/MapServer/projects/wms/atlas/puda.map&",
"params": {
"LAYERS": "podkladova_mapa",
"FORMAT": "image\/png",
"ABSTRACT": "Jednoduch\u00e1 podkladov\u00e1 mapa Libereck\u00e9ho kraje"
},
"ratio": 1.5
}
],
"current_base_layer": {
"title": "Topografick\u00e1 podkladov\u00e1 mapa (\u0161edo\u0161k\u00e1l\u00e1)"
}
}
8 changes: 4 additions & 4 deletions src/layman/map/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
MAPNAME_MAX_LENGTH = PUBLICATION_MAX_LENGTH
SCHEMA_URL_PATTERN = r'^https://raw.githubusercontent.com/hslayers/map-compositions/(([0-9]{1,}.[0-9]{1,}.[0-9]{1,})|([a-zA-Z]*?))/schema.json$'
_SCHEMA_CACHE_PATH = 'tmp'
_ACCEPTED_SCHEMA_MAJOR_VERSION = '2'
_ACCEPTED_SCHEMA_MAJOR_VERSION_LIST = ['2', '3']

FLASK_PROVIDERS_KEY = f'{__name__}:PROVIDERS'
FLASK_SOURCES_KEY = f'{__name__}:SOURCES'
Expand Down Expand Up @@ -172,11 +172,11 @@ def get_composition_schema(url):
'regular_expression': SCHEMA_URL_PATTERN,
})
version = url.split('/')[-2]
if version.split('.')[0] != _ACCEPTED_SCHEMA_MAJOR_VERSION:
if version.split('.')[0] not in _ACCEPTED_SCHEMA_MAJOR_VERSION_LIST:
raise LaymanError(2, {
'parameter': 'file',
'reason': 'Invalid schema version',
'expected': _ACCEPTED_SCHEMA_MAJOR_VERSION + '.x.x',
'expected': ' or '.join([v + '.x.x' for v in _ACCEPTED_SCHEMA_MAJOR_VERSION_LIST]),
})

schema_file_name = os.path.join(*url.split('/')[-1:])
Expand Down Expand Up @@ -214,7 +214,7 @@ def check_file(file):
raise LaymanError(2, {
'parameter': 'file',
'reason': 'Missing key `describedBy`',
'expected': 'JSON file according schema `https://github.com/hslayers/map-compositions`, version ' + _ACCEPTED_SCHEMA_MAJOR_VERSION,
'expected': 'JSON file according schema `https://github.com/hslayers/map-compositions`, version ' + ' or '.join(_ACCEPTED_SCHEMA_MAJOR_VERSION_LIST),
}) from exc

schema_json = get_composition_schema(schema_url)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"describedBy": "https://raw.githubusercontent.com/hslayers/map-compositions/2.0.0/schema.json",
"schema_version": "2.0.0",
"abstract": "World places and boundaries abstract",
"title": "World places and boundaries",
"extent": [
-35.0,
-48.5,
179,
81.5
],
"nativeExtent": [
-3896182.18,
-6190443.81,
19926188.85,
16579785.82
],
"projection": "epsg:3857",
"layers": [
{
"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": {}
},
{
"metadata": {},
"visibility": true,
"opacity": 1,
"title": "Hranice",
"className": "HSLayers.Layer.WMS",
"singleTile": true,
"url": "http://localhost:8000/some-client-proxy/geoserver/test_map_json_workspace_wms/ows",
"params": {
"LAYERS": "hranice",
"FORMAT": "image\/png"
}
},
{
"className": "OpenLayers.Layer.Vector",
"dimensions": {},
"legends": [
""
],
"maxResolution": null,
"metadata": {},
"minResolution": 0,
"name": "mista",
"opacity": 1,
"protocol": {
"format": "hs.format.WFS",
"url": "http://localhost:8000/some-other-client-proxy/geoserver/test_map_json_workspace/wfs"
},
"ratio": 1.5,
"singleTile": true,
"title": "Mista",
"visibility": false,
"wmsMaxScale": 0
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"describedBy": "https://raw.githubusercontent.com/hslayers/map-compositions/3.0.0/schema.json",
"schema_version": "2.0.0",
"abstract": "World places and boundaries abstract",
"title": "World places and boundaries",
"extent": [
-35.0,
-48.5,
179,
81.5
],
"nativeExtent": [
-3896182.18,
-6190443.81,
19926188.85,
16579785.82
],
"projection": "epsg:3857",
"layers": [
{
"metadata": {},
"visibility": true,
"opacity": 1,
"title": "Defini\u010dn\u00ed body administrativn\u00edch celk\u016f",
"className": "WMS",
"singleTile": true,
"wmsMaxScale": 0,
"legends": [
"https://geoportal.kraj-lbc.cz/cgi-bin/mapserv?map=/data/gis/MapServer/projects/wms/atlas/administrativni_cleneni.map&version=1.3.0&service=WMS&request=GetLegendGraphic&sld_version=1.1.0&layer=definicni_body_administrativnich_celku&format=image/png&STYLE=default"
],
"maxResolution": null,
"minResolution": 0,
"url": "https://geoportal.kraj-lbc.cz/cgi-bin/mapserv?map=/data/gis/MapServer/projects/wms/atlas/administrativni_cleneni.map&",
"params": {
"LAYERS": "definicni_body_administrativnich_celku",
"INFO_FORMAT": "application\/vnd.ogc.gml",
"FORMAT": "image\/png",
"FROMCRS": "EPSG:3857",
"VERSION": "1.3.0"
},
"dimensions": {}
},
{
"metadata": {},
"visibility": true,
"opacity": 1,
"title": "Hranice",
"className": "WMS",
"singleTile": true,
"url": "http://localhost:8000/some-client-proxy/geoserver/test_map_json_workspace_wms/ows",
"params": {
"LAYERS": "hranice",
"FORMAT": "image\/png"
}
},
{
"className": "Vector",
"dimensions": {},
"legends": [],
"maxResolution": null,
"metadata": {},
"minResolution": 0,
"name": "mista",
"opacity": 1,
"protocol": {
"format": "WFS",
"url": "http://localhost:8000/some-other-client-proxy/geoserver/test_map_json_workspace/wfs"
},
"ratio": 1.5,
"singleTile": true,
"title": "Mista",
"visibility": false,
"wmsMaxScale": 0
}
]
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{
"describedBy": "https://raw.githubusercontent.com/hslayers/map-compositions/2.0.0/schema.json",
"schema_version": "2.0.0",
"abstract": "World places and boundaries abstract",
"title": "map_v2_0_0_post",
"extent": [
-35.0,
-48.5,
179,
81.5
],
"nativeExtent": [
-3896182.18,
-6190443.81,
19926188.85,
16579785.82
],
"projection": "epsg:3857",
"layers": [
{
"metadata": {},
"visibility": true,
"opacity": 1,
"title": "Definiční body administrativních celků",
"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://geoportal.kraj-lbc.cz/cgi-bin/mapserv?map=/data/gis/MapServer/projects/wms/atlas/administrativni_cleneni.map&",
"params": {
"LAYERS": "definicni_body_administrativnich_celku",
"INFO_FORMAT": "application/vnd.ogc.gml",
"FORMAT": "image/png",
"FROMCRS": "EPSG:3857",
"VERSION": "1.3.0"
},
"dimensions": {}
},
{
"metadata": {},
"visibility": true,
"opacity": 1,
"title": "Hranice",
"className": "HSLayers.Layer.WMS",
"singleTile": true,
"url": "https://enjoychallenge.tech/new-client-proxy/geoserver/test_map_json_workspace_wms/ows",
"params": {
"LAYERS": "hranice",
"FORMAT": "image/png"
}
},
{
"className": "OpenLayers.Layer.Vector",
"dimensions": {},
"legends": [
""
],
"maxResolution": null,
"metadata": {},
"minResolution": 0,
"name": "mista",
"opacity": 1,
"protocol": {
"format": "hs.format.WFS",
"url": "https://enjoychallenge.tech/new-client-proxy/geoserver/test_map_json_workspace/wfs"
},
"ratio": 1.5,
"singleTile": true,
"title": "Mista",
"visibility": false,
"wmsMaxScale": 0
}
],
"name": "map_v2_0_0_post",
"user": {
"email": "",
"name": "test_map_json_workspace"
}
}
Loading