|
45 | 45 | from pycsw.core.pygeofilter_evaluate import to_filter
|
46 | 46 | from pycsw.core.util import bind_url, get_today_and_now, jsonify_links, load_custom_repo_mappings, wkt2geom
|
47 | 47 | from pycsw.ogc.api.oapi import gen_oapi
|
48 |
| -from pycsw.ogc.api.util import match_env_var, render_j2_template, to_json |
| 48 | +from pycsw.ogc.api.util import match_env_var, render_j2_template, to_json, merge_qs |
49 | 49 |
|
50 | 50 | LOGGER = logging.getLogger(__name__)
|
51 | 51 |
|
@@ -1000,20 +1000,61 @@ def record2json(record, url, collection, stac_item=False):
|
1000 | 1000 |
|
1001 | 1001 | if record.links:
|
1002 | 1002 | rdl = record_dict['links']
|
1003 |
| - |
1004 | 1003 | for link in jsonify_links(record.links):
|
1005 |
| - link2 = { |
1006 |
| - 'href': link['url'], |
1007 |
| - 'name': link['name'], |
| 1004 | + link2 = { |
| 1005 | + 'type': link['protocol'], |
1008 | 1006 | 'description': link['description'],
|
1009 |
| - 'type': link['protocol'] |
1010 |
| - } |
1011 |
| - if 'rel' in link: |
1012 |
| - link2['rel'] = link['rel'] |
1013 |
| - elif 'function' in link: |
1014 |
| - link2['rel'] = link['function'] |
1015 |
| - |
1016 |
| - rdl.append(link2) |
| 1007 | + 'title': link['name'], |
| 1008 | + 'href': link['url'] |
| 1009 | + } |
| 1010 | + if link['protocol']: |
| 1011 | + if 'OGC:WMS' in link['protocol'].upper(): |
| 1012 | + link2['rel'] = 'map' |
| 1013 | + link2['templated'] = 'true' |
| 1014 | + # assumes link['href'] includes '&layers=...', else link['name'] contains layername(s) |
| 1015 | + link2['href'] = merge_qs(link['url'], { |
| 1016 | + 'request': 'GetMap', 'service': 'WMS', |
| 1017 | + 'width': '{width}', 'height': '{height}', 'bbox': '{bbox}'}, { |
| 1018 | + 'version': '1.3.0', 'crs': 'epsg:4326', |
| 1019 | + 'layers': link['name'], 'format': 'image/png'}) |
| 1020 | + link2['variables'] = { |
| 1021 | + 'bbox': { |
| 1022 | + 'type': 'array', |
| 1023 | + 'items': {'type': 'number', 'format': 'double'}, |
| 1024 | + 'minItems': 4, 'maxItems': 4 |
| 1025 | + }, |
| 1026 | + 'width': {'type': 'number', 'format': 'integer'}, |
| 1027 | + 'height': {'type': 'number', 'format': 'integer'} |
| 1028 | + } |
| 1029 | + link2['type'] = 'image/png' |
| 1030 | + |
| 1031 | + elif 'OGC:WMTS' in link['protocol'].upper(): |
| 1032 | + link2['rel'] = 'map' |
| 1033 | + link2['templated'] = 'true' |
| 1034 | + link2['href'] = merge_qs(link['url'], { |
| 1035 | + 'service': 'WMTS', 'request': 'GetTile', 'version': '1.0.0', |
| 1036 | + 'TileMatrix': '{TileMatrix}', 'TileRow': '{TileRow}', 'TileCol': '{TileCol}'}, { |
| 1037 | + 'TileMatrixSet': 'default', 'Layer': link['name'], |
| 1038 | + 'Style': 'default', 'Format': 'image/png'}) |
| 1039 | + link2['variables'] = { |
| 1040 | + 'TileMatrix': {'type': 'number', 'format': 'integer'}, |
| 1041 | + 'TileRow': {'type': 'number', 'format': 'integer'}, |
| 1042 | + 'TileCol': {'type': 'number', 'format': 'integer'} |
| 1043 | + } |
| 1044 | + link2['type'] = 'image/png' |
| 1045 | + |
| 1046 | + #elif 'OSGEO:TMS' in link['protocol'].upper(): |
| 1047 | + #elif 'OGC:WFS' in link['protocol'].upper(): |
| 1048 | + #elif 'OGC:WMTS' in link['protocol'].upper(): |
| 1049 | + #elif 'OGC:CSW' in link['protocol'].upper(): |
| 1050 | + #elif 'OGC:WCS' in link['protocol'].upper(): |
| 1051 | + |
| 1052 | + elif 'rel' in link: |
| 1053 | + link2['rel'] = link['rel'] |
| 1054 | + elif 'function' in link: |
| 1055 | + link2['rel'] = link['function'] |
| 1056 | + |
| 1057 | + rdl.append(link2) |
1017 | 1058 |
|
1018 | 1059 | record_dict['links'].append({
|
1019 | 1060 | 'rel': 'collection',
|
|
0 commit comments