* Start a wip alignment * Adding CRS to tile_matrix_set_links * Refactor json structure tiles endpoint * Link section in tileset * Unit test Co-authored-by: Francesco Bartoli <francesco.bartoli@geobeyond.it>
This commit is contained in:
committed by
GitHub
parent
f34d94e2eb
commit
514b7b9e08
+31
-6
@@ -2286,12 +2286,8 @@ class API:
|
||||
500, headers, request.format, 'NoApplicableCode', msg)
|
||||
|
||||
tiles = {
|
||||
'title': dataset,
|
||||
'description': l10n.translate(
|
||||
self.config['resources'][dataset]['description'],
|
||||
SYSTEM_LOCALE),
|
||||
'links': [],
|
||||
'tileMatrixSetLinks': []
|
||||
'tilesets': []
|
||||
}
|
||||
|
||||
tiles['links'].append({
|
||||
@@ -2325,7 +2321,36 @@ class API:
|
||||
for service in tile_services['links']:
|
||||
tiles['links'].append(service)
|
||||
|
||||
tiles['tileMatrixSetLinks'] = p.get_tiling_schemes()
|
||||
tiling_schemes = p.get_tiling_schemes()
|
||||
|
||||
for matrix in tiling_schemes:
|
||||
tile_matrix = {
|
||||
'title': dataset,
|
||||
'tileMatrixSetURI': matrix['tileMatrixSetURI'],
|
||||
'crs': matrix['crs'],
|
||||
'dataType': 'vector',
|
||||
'links': []
|
||||
}
|
||||
tile_matrix['links'].append({
|
||||
'type': FORMAT_TYPES[F_JSON],
|
||||
'rel': request.get_linkrel(F_JSON),
|
||||
'title': '{} - {} - {}'.format(
|
||||
dataset, matrix['tileMatrixSet'], F_JSON),
|
||||
'href': '{}/{}/tiles/{}?f={}'.format(
|
||||
self.get_collections_url(), dataset,
|
||||
matrix['tileMatrixSet'], F_JSON)
|
||||
})
|
||||
tile_matrix['links'].append({
|
||||
'type': FORMAT_TYPES[F_HTML],
|
||||
'rel': request.get_linkrel(F_HTML),
|
||||
'title': '{} - {} - {}'.format(
|
||||
dataset, matrix['tileMatrixSet'], F_HTML),
|
||||
'href': '{}/{}/tiles/{}?f={}'.format(
|
||||
self.get_collections_url(), dataset,
|
||||
matrix['tileMatrixSet'], F_HTML)
|
||||
})
|
||||
tiles['tilesets'].append(tile_matrix)
|
||||
|
||||
metadata_format = p.options['metadata_format']
|
||||
|
||||
if request.format == F_HTML: # render
|
||||
|
||||
+28
-20
@@ -55,14 +55,15 @@ class MVTProvider(BaseTileProvider):
|
||||
"""
|
||||
|
||||
super().__init__(provider_def)
|
||||
|
||||
if is_url(self.data):
|
||||
url = urlparse(self.data)
|
||||
baseurl = '{}://{}'.format(url.scheme, url.netloc)
|
||||
param_type = '?f=mvt'
|
||||
layer = url.path.split('/{z}/{x}/{y}')[0]
|
||||
tilepath = '{}/tiles'.format(layer)
|
||||
servicepath = \
|
||||
'{}/tiles/{{{}}}/{{{}}}/{{{}}}/{{{}}}{}'.format(
|
||||
url.path.split('/{z}/{x}/{y}')[0],
|
||||
'{}/{{{}}}/{{{}}}/{{{}}}/{{{}}}{}'.format(
|
||||
tilepath,
|
||||
'tileMatrixSetId',
|
||||
'tileMatrix',
|
||||
'tileRow',
|
||||
@@ -105,16 +106,18 @@ class MVTProvider(BaseTileProvider):
|
||||
url = urlparse(self.data)
|
||||
return url.path.split("/{z}/{x}/{y}")[0][1:]
|
||||
else:
|
||||
return None
|
||||
return Path(self.data).name
|
||||
|
||||
def get_tiling_schemes(self):
|
||||
|
||||
tile_matrix_set_links_list = [{
|
||||
'tileMatrixSet': 'WorldCRS84Quad',
|
||||
'tileMatrixSetURI': 'http://schemas.opengis.net/tms/1.0/json/examples/WorldCRS84Quad.json' # noqa
|
||||
'tileMatrixSetURI': 'http://schemas.opengis.net/tms/1.0/json/examples/WorldCRS84Quad.json', # noqa
|
||||
'crs': 'http://www.opengis.net/def/crs/OGC/1.3/CRS84'
|
||||
}, {
|
||||
'tileMatrixSet': 'WebMercatorQuad',
|
||||
'tileMatrixSetURI': 'http://schemas.opengis.net/tms/1.0/json/examples/WebMercatorQuad.json' # noqa
|
||||
'tileMatrixSetURI': 'http://schemas.opengis.net/tms/1.0/json/examples/WebMercatorQuad.json', # noqa
|
||||
'crs': 'http://www.opengis.net/def/crs/EPSG/0/3857'
|
||||
}]
|
||||
tile_matrix_set_links = [
|
||||
item for item in tile_matrix_set_links_list if item[
|
||||
@@ -156,21 +159,26 @@ class MVTProvider(BaseTileProvider):
|
||||
self._service_metadata_url = urljoin(
|
||||
self.service_url.split('{tileMatrix}/{tileRow}/{tileCol}')[0],
|
||||
'metadata')
|
||||
|
||||
links = {
|
||||
'links': [{
|
||||
'type': self.mimetype,
|
||||
'rel': 'item',
|
||||
'title': 'This collection as Mapbox vector tiles',
|
||||
'href': self.service_url,
|
||||
'templated': True
|
||||
}, {
|
||||
'type': 'application/json',
|
||||
'rel': 'describedby',
|
||||
'title': 'Metadata for this collection in the TileJSON format',
|
||||
'href': '{}?f=json'.format(self.service_metadata_url),
|
||||
'templated': True
|
||||
}]
|
||||
'links': [
|
||||
{
|
||||
'type': 'application/json',
|
||||
'rel': 'self',
|
||||
'title': 'This collection as multi vector tilesets',
|
||||
'href': self.service_url,
|
||||
},
|
||||
{
|
||||
'type': self.mimetype,
|
||||
'rel': 'item',
|
||||
'title': 'This collection as multi vector tiles',
|
||||
'href': self.service_url,
|
||||
}, {
|
||||
'type': 'application/json',
|
||||
'rel': 'describedby',
|
||||
'title': 'Collection metadata in TileJSON format',
|
||||
'href': '{}?f=json'.format(self.service_metadata_url),
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
return links
|
||||
|
||||
+2
-1
@@ -1125,7 +1125,8 @@ def test_get_collection_tiles(config, api_):
|
||||
req, 'naturalearth/lakes')
|
||||
assert rsp_headers['Content-Language'] == 'en-US'
|
||||
content = json.loads(response)
|
||||
assert content['description'] == 'lakes of the world, public domain'
|
||||
assert len(content['links']) > 0
|
||||
assert len(content['tilesets']) > 0
|
||||
|
||||
|
||||
def test_describe_processes(config, api_):
|
||||
|
||||
Reference in New Issue
Block a user