Skip to content

Commit

Permalink
Accept map json in version 3.x.x
Browse files Browse the repository at this point in the history
  • Loading branch information
index-git committed Sep 29, 2023
1 parent f2d7579 commit 1595a9f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,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) accepts 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
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
@@ -1,6 +1,6 @@
{
"describedBy": "https://raw.githubusercontent.com/hslayers/map-compositions/3.0.0/schema.json",
"schema_version": "3.0.0",
"describedBy": "https://raw.githubusercontent.com/hslayers/map-compositions/4.0.0/schema.json",
"schema_version": "4.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": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,19 +476,19 @@ class Key(Enum):
'http_code': 400,
'sync': True,
'code': 2,
'data': {'expected': 'JSON file according schema `https://github.com/hslayers/map-compositions`, version 2',
'data': {'expected': 'JSON file according schema `https://github.com/hslayers/map-compositions`, version 2 or 3',
'parameter': 'file',
'reason': 'Missing key `describedBy`'},
},
Key.MANDATORY_CASES: None,
Key.RUN_ONLY_CASES: frozenset([RestMethod.POST, WithChunksDomain.FALSE, CompressDomain.FALSE]),
Key.SPECIFIC_CASES: {},
},
'map_schema_3_0_0': {
'map_schema_4_0_0': {
Key.PUBLICATION_TYPE: process_client.MAP_TYPE,
Key.REST_ARGS: {
'file_paths': [
f'{DIRECTORY}/map_schema_3_0_0.json',
f'{DIRECTORY}/map_schema_4_0_0.json',
],
},
Key.EXCEPTION: LaymanError,
Expand All @@ -497,7 +497,7 @@ class Key(Enum):
'http_code': 400,
'sync': True,
'code': 2,
'data': {'expected': '2.x.x',
'data': {'expected': '2.x.x or 3.x.x',
'parameter': 'file',
'reason': 'Invalid schema version'},
},
Expand Down
8 changes: 5 additions & 3 deletions timgen/src/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,10 @@ const json_to_wms_layer = (layer_json, gs_public_url, gs_url, headers) => {


const json_to_layer = (layer_json, gs_public_url, gs_url, headers) => {
switch (layer_json.className) {
case "HSLayers.Layer.WMS":
const class_name_split = layer_json.className.split('.')
const class_name_last = class_name_split[class_name_split.length-1]
switch (class_name_last) {
case "WMS":
return json_to_wms_layer(layer_json, gs_public_url, gs_url, headers);
break;
// case 'OpenLayers.Layer.Vector':
Expand Down Expand Up @@ -296,4 +298,4 @@ export const map_to_canvas = (map) => {
export const log = (msg) => {
console.log(msg);
window['layman_logs'].push(msg);
}
}

0 comments on commit 1595a9f

Please sign in to comment.