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

Add LAYERS URL parameter to wms_url/wfs_url metadata properties #306

Merged
merged 2 commits into from
Apr 7, 2021
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 @@ -11,6 +11,7 @@
### Changes
- [#257](https://github.com/jirik/layman/issues/257) Endpoints [GET Layers](doc/rest.md#get-layers) and [GET Maps](doc/rest.md#get-maps) can filter and reorder results according to new query parameters.
- [#257](https://github.com/jirik/layman/issues/257) Responses of [GET Layers](doc/rest.md#get-layers), [GET Workspace Layers](doc/rest.md#get-workspace-layer), [GET Workspace Layer](doc/rest.md#get-workspace-layer), [PATCH Workspace Layer](doc/rest.md#patch-workspace-layer), [GET Maps](doc/rest.md#get-maps), [GET Workspace Maps](doc/rest.md#get-workspace-map), [GET Workspace Map](doc/rest.md#get-workspace-map), and [PATCH Workspace Map](doc/rest.md#patch-workspace-map) contains new attribute `updated_at` with date and time of last PATCH/POST request to given publication.
- [#302](https://github.com/jirik/layman/issues/302) Metadata properties [wms_url](doc/metadata.md#wms_url) and [wfs_url](doc/metadata.md#wfs_url) contain new URL parameter `LAYERS` whose value is name of the layer. It's non-standard way how to store name of the layer at given WMS/WFS instance within metadata record.

## v1.11.0
2021-03-16
Expand Down
8 changes: 6 additions & 2 deletions doc/metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,23 +268,27 @@ XPath for Map: `/gmd:MD_Metadata/gmd:identificationInfo/srv:SV_ServiceIdentifica


### wfs_url
It contains standard SERVICE, REQUEST, and VERSION parameters and non-standard LAYERS parameter that holds name of the feature type at given WFS instance.

Multiplicity: 1

Shape: String

Example: `"http://localhost:8600/geoserver/workspace1/ows"`
Example: `"http://localhost:8600/geoserver/workspace1/ows?SERVICE=WFS&REQUEST=GetCapabilities&VERSION=2.0.0&LAYERS=layer"`

Synchronizable: yes

XPath for Layer: `/gmd:MD_Metadata/gmd:distributionInfo/gmd:MD_Distribution/gmd:transferOptions/gmd:MD_DigitalTransferOptions/gmd:onLine[gmd:CI_OnlineResource/gmd:protocol/gmx:Anchor/@xlink:href="https://services.cuzk.cz/registry/codelist/OnlineResourceProtocolValue/OGC:WFS-2.0.0-http-get-capabilities"]/gmd:CI_OnlineResource/gmd:linkage/gmd:URL/text()`


### wms_url
It contains standard SERVICE, REQUEST, and VERSION parameters and non-standard LAYERS parameter that holds name of the layer at given WMS instance.

Multiplicity: 1

Shape: String

Example: `"http://localhost:8600/geoserver/workspace1_wms/ows"`
Example: `"http://localhost:8600/geoserver/workspace1_wms/ows?SERVICE=WMS&REQUEST=GetCapabilities&VERSION=1.3.0&LAYERS=layer"`

Synchronizable: yes

Expand Down
5 changes: 4 additions & 1 deletion src/layman/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
IN_FLOWER_PROCESS = sys.argv and sys.argv[0].endswith('/flower/__main__.py')
IN_FLASK_PROCESS = sys.argv and (sys.argv[0].endswith('/flask') or sys.argv[0].endswith('/gunicorn'))
IN_UPGRADE_PROCESS = sys.argv and sys.argv[0].endswith('standalone_upgrade.py')
IN_UTIL_PROCESS = sys.argv and sys.argv[0].endswith('refresh-doc-metadata-xpath.py')
assert [
IN_CELERY_WORKER_PROCESS,
IN_PYTEST_PROCESS,
IN_FLOWER_PROCESS,
IN_FLASK_PROCESS,
IN_UPGRADE_PROCESS,
].count(True) == 1, f"IN_CELERY_WORKER_PROCESS={IN_CELERY_WORKER_PROCESS}, IN_PYTEST_PROCESS={IN_PYTEST_PROCESS}, IN_FLOWER_PROCESS={IN_FLOWER_PROCESS}, IN_FLASK_PROCESS={IN_FLASK_PROCESS}, IN_UPGRADE_PROCESS={IN_UPGRADE_PROCESS}"
IN_UTIL_PROCESS,
].count(True) == 1, f"IN_CELERY_WORKER_PROCESS={IN_CELERY_WORKER_PROCESS}, IN_PYTEST_PROCESS={IN_PYTEST_PROCESS}, IN_FLOWER_PROCESS={IN_FLOWER_PROCESS}, IN_FLASK_PROCESS={IN_FLASK_PROCESS}, IN_UPGRADE_PROCESS={IN_UPGRADE_PROCESS}, IN_UTIL_PROCESS={IN_UTIL_PROCESS}"

settings = importlib.import_module(os.environ['LAYMAN_SETTINGS_MODULE'])

Expand Down Expand Up @@ -54,6 +56,7 @@
logger.info(f"IN_FLOWER_PROCESS={IN_FLOWER_PROCESS}")
logger.info(f"IN_FLASK_PROCESS={IN_FLASK_PROCESS}")
logger.info(f"IN_UPGRADE_PROCESS={IN_UPGRADE_PROCESS}")
logger.info(f"IN_UTIL_PROCESS={IN_UTIL_PROCESS}")

# load UUIDs only once
LAYMAN_DEPS_ADJUSTED_KEY = f"{__name__}:LAYMAN_DEPS_ADJUSTED"
Expand Down
8 changes: 4 additions & 4 deletions src/layman/common/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ def extent_equals(a, b, limit=0.95):
},
'wms_url': {
'upper_mp': '1',
'equals_fn': lambda a, b: strip_capabilities_params(a) == strip_capabilities_params(b),
'equals_fn': lambda a, b: strip_capabilities_and_layers_params(a) == strip_capabilities_and_layers_params(b),
},
'wfs_url': {
'upper_mp': '1',
'equals_fn': lambda a, b: strip_capabilities_params(a) == strip_capabilities_params(b),
'equals_fn': lambda a, b: strip_capabilities_and_layers_params(a) == strip_capabilities_and_layers_params(b),
},
'layer_endpoint': {
'upper_mp': '1',
Expand Down Expand Up @@ -137,9 +137,9 @@ def prop_equals_strict(values, equals_fn=None):
return result


def strip_capabilities_params(url):
def strip_capabilities_and_layers_params(url):
from layman.layer.geoserver.wms import strip_params_from_url
return strip_params_from_url(url, ['SERVICE', 'REQUEST', 'VERSION'])
return strip_params_from_url(url, ['SERVICE', 'REQUEST', 'VERSION', 'LAYERS'])


def _is_extent_empty(e):
Expand Down
4 changes: 2 additions & 2 deletions src/layman/layer/micka/csw.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ def _get_property_values(
'graphic_url': url_for('rest_workspace_layer_thumbnail.get', username=workspace, layername=layername),
'extent': extent,

'wms_url': wms.add_capabilities_params_to_url(wms_url),
'wfs_url': wfs.add_capabilities_params_to_url(wfs_url),
'wms_url': f"{wms.add_capabilities_params_to_url(wms_url)}&LAYERS={layername}",
'wfs_url': f"{wfs.add_capabilities_params_to_url(wfs_url)}&LAYERS={layername}",
'layer_endpoint': url_for('rest_workspace_layer.get', username=workspace, layername=layername),
'scale_denominator': scale_denominator,
'language': languages,
Expand Down
4 changes: 2 additions & 2 deletions src/layman/layer/micka/util_test_filled_template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
<gmd:onLine>
<gmd:CI_OnlineResource>
<gmd:linkage>
<gmd:URL>http://www.env.cz/corine/data/download.zip?SERVICE=WMS&amp;REQUEST=GetCapabilities&amp;VERSION=1.3.0</gmd:URL>
<gmd:URL>http://www.env.cz/corine/data/download.zip?SERVICE=WMS&amp;REQUEST=GetCapabilities&amp;VERSION=1.3.0&amp;LAYERS=layer</gmd:URL>
</gmd:linkage>
<gmd:protocol>
<gmx:Anchor xlink:href="https://services.cuzk.cz/registry/codelist/OnlineResourceProtocolValue/OGC:WMS-1.3.0-http-get-capabilities">OGC:WMS-1.3.0-http-get-capabilities</gmx:Anchor>
Expand All @@ -230,7 +230,7 @@
<gmd:onLine>
<gmd:CI_OnlineResource>
<gmd:linkage>
<gmd:URL>http://www.env.cz/corine/data/download.zip?SERVICE=WFS&amp;REQUEST=GetCapabilities&amp;VERSION=2.0.0</gmd:URL>
<gmd:URL>http://www.env.cz/corine/data/download.zip?SERVICE=WFS&amp;REQUEST=GetCapabilities&amp;VERSION=2.0.0&amp;LAYERS=layer</gmd:URL>
</gmd:linkage>
<gmd:protocol>
<gmx:Anchor xlink:href="https://services.cuzk.cz/registry/codelist/OnlineResourceProtocolValue/OGC:WFS-2.0.0-http-get-capabilities">OGC:WFS-2.0.0-http-get-capabilities</gmx:Anchor>
Expand Down
4 changes: 2 additions & 2 deletions src/layman/layer/rest_test_filled_template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@
<gmd:onLine>
<gmd:CI_OnlineResource>
<gmd:linkage>
<gmd:URL>http://localhost:8000/geoserver/testuser1_wms/ows?SERVICE=WMS&amp;REQUEST=GetCapabilities&amp;VERSION=1.3.0</gmd:URL>
<gmd:URL>http://localhost:8000/geoserver/testuser1_wms/ows?SERVICE=WMS&amp;REQUEST=GetCapabilities&amp;VERSION=1.3.0&amp;LAYERS=ne_110m_admin_0_countries_shp</gmd:URL>
</gmd:linkage>
<gmd:protocol>
<gmx:Anchor xlink:href="https://services.cuzk.cz/registry/codelist/OnlineResourceProtocolValue/OGC:WMS-1.3.0-http-get-capabilities">OGC:WMS-1.3.0-http-get-capabilities</gmx:Anchor>
Expand All @@ -282,7 +282,7 @@
<gmd:onLine>
<gmd:CI_OnlineResource>
<gmd:linkage>
<gmd:URL>http://localhost:8000/geoserver/testuser1/wfs?SERVICE=WFS&amp;REQUEST=GetCapabilities&amp;VERSION=2.0.0</gmd:URL>
<gmd:URL>http://localhost:8000/geoserver/testuser1/wfs?SERVICE=WFS&amp;REQUEST=GetCapabilities&amp;VERSION=2.0.0&amp;LAYERS=ne_110m_admin_0_countries_shp</gmd:URL>
</gmd:linkage>
<gmd:protocol>
<gmx:Anchor xlink:href="https://services.cuzk.cz/registry/codelist/OnlineResourceProtocolValue/OGC:WFS-2.0.0-http-get-capabilities">OGC:WFS-2.0.0-http-get-capabilities</gmx:Anchor>
Expand Down