-
-
Notifications
You must be signed in to change notification settings - Fork 156
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
suggestion for implementing wms/wmts/wfs/... links in record.geojson #815
Draft
pvgenuchten
wants to merge
1
commit into
geopython:master
Choose a base branch
from
pvgenuchten:templated_links
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,7 @@ | |
from pycsw.core.pygeofilter_evaluate import to_filter | ||
from pycsw.core.util import bind_url, get_today_and_now, jsonify_links, load_custom_repo_mappings, wkt2geom | ||
from pycsw.ogc.api.oapi import gen_oapi | ||
from pycsw.ogc.api.util import match_env_var, render_j2_template, to_json | ||
from pycsw.ogc.api.util import match_env_var, render_j2_template, to_json, merge_qs | ||
|
||
LOGGER = logging.getLogger(__name__) | ||
|
||
|
@@ -1048,22 +1048,70 @@ def record2json(record, url, collection, stac_item=False): | |
|
||
if record.links: | ||
rdl = record_dict['links'] | ||
|
||
for link in jsonify_links(record.links): | ||
link2 = { | ||
'href': link['url'], | ||
'name': link['name'], | ||
link2 = { | ||
'type': link['protocol'], | ||
'description': link['description'], | ||
'type': link['protocol'] | ||
} | ||
if 'rel' in link: | ||
link2['rel'] = link['rel'] | ||
elif link['protocol'] == 'WWW:LINK-1.0-http--image-thumbnail': | ||
link2['rel'] = 'preview' | ||
elif 'function' in link: | ||
link2['rel'] = link['function'] | ||
|
||
rdl.append(link2) | ||
'title': link['name'], | ||
'href': link['url'] | ||
} | ||
if link['protocol']: | ||
if 'OGC:WMS' in link['protocol'].upper(): | ||
link2['rel'] = 'map' | ||
link2['templated'] = 'true' | ||
# assumes link['url'] includes '&layers=...', else link['name'] contains layername(s) | ||
link2['href'] = merge_qs(link['url'], { | ||
'request': 'GetMap', 'service': 'WMS', | ||
'width': '{width}', 'height': '{height}', 'bbox': '{bbox}'}, { | ||
'version': '1.3.0', 'crs': 'epsg:4326', | ||
'layers': link['name'], 'format': 'image/png'}) | ||
link2['variables'] = { | ||
'bbox': { | ||
'type': 'array', | ||
'items': {'type': 'number', 'format': 'double'}, | ||
'minItems': 4, 'maxItems': 4 | ||
}, | ||
'width': {'type': 'number', 'format': 'integer'}, | ||
'height': {'type': 'number', 'format': 'integer'} | ||
} | ||
link2['type'] = 'image/png' | ||
|
||
elif 'OGC:WMTS' in link['protocol'].upper(): | ||
link2['rel'] = 'map' | ||
link2['templated'] = 'true' | ||
link2['href'] = merge_qs(link['url'], { | ||
'service': 'WMTS', 'request': 'GetTile', 'version': '1.0.0', | ||
'TileMatrix': '{TileMatrix}', 'TileRow': '{TileRow}', 'TileCol': '{TileCol}'}, { | ||
'TileMatrixSet': 'default', 'Layer': link['name'], | ||
'Style': 'default', 'Format': 'image/png'}) | ||
link2['variables'] = { | ||
'TileMatrix': {'type': 'number', 'format': 'integer'}, | ||
'TileRow': {'type': 'number', 'format': 'integer'}, | ||
'TileCol': {'type': 'number', 'format': 'integer'} | ||
} | ||
link2['type'] = 'image/png' | ||
|
||
elif 'OGC:WFS' in link['protocol'].upper(): | ||
link2['rel'] = 'map' | ||
link2['templated'] = 'true' | ||
link2['href'] = merge_qs(link['url'], { | ||
'version': '2.0.0', 'request': 'GetFeature', 'service': 'WFS', 'count': '{count}'}, { | ||
'typenames': link['name'], 'srsName': 'urn:ogc:def:crs:EPSG::4326', | ||
'outputFormat':'application/gml+xml'}) | ||
link2['variables'] = { | ||
'count': {'type': 'number', 'format': 'integer'}} | ||
link2['type'] = 'application/gml+xml' | ||
|
||
#elif 'OSGEO:TMS' in link['protocol'].upper(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or better/also to use xyz (both not in catinterop yet, see OSGeo/Cat-Interop#42) |
||
#elif 'OGC:CSW' in link['protocol'].upper(): | ||
#elif 'OGC:WCS' in link['protocol'].upper(): | ||
|
||
elif 'rel' in link: | ||
link2['rel'] = link['rel'] | ||
elif 'function' in link: | ||
link2['rel'] = link['function'] | ||
|
||
rdl.append(link2) | ||
|
||
record_dict['links'].append({ | ||
'rel': 'collection', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alternative would be to use owslib.wms130.__build_getmap_request (but challenge to replace bbox array for
{bbox}
)