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

Addressing Requirements class 2 (Requirements Class Tileset) of the OGC API Tiles Standard #1497

Merged
merged 25 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
992796d
- refactored mvt classes to support all implemented metadata formats,…
doublebyte1 Dec 29, 2023
64689cd
- fixed formatting issues
doublebyte1 Dec 29, 2023
4f38b7c
Implementing basic tile metadata methods
PascalLike Jan 8, 2024
199ed39
Fixing yml models
PascalLike Jan 8, 2024
808cd19
Adding additional format
PascalLike Jan 8, 2024
8a7b77d
Fixing schema set on load
PascalLike Jan 9, 2024
c343374
Removing unused field from documentation
PascalLike Jan 9, 2024
ad8165b
- added support to TileMatrixSets endpoint
doublebyte1 Jan 12, 2024
de70c25
- added tiling-schemes link in the json representation of the landing…
doublebyte1 Jan 12, 2024
3d3fcf9
- added html pages for tilematrixset endpoints
doublebyte1 Jan 16, 2024
be25b0f
- Merge branch 'tileset-links' into tms
doublebyte1 Jan 16, 2024
d64fa2e
- advertise json and html representations of the tiling schemes in th…
doublebyte1 Jan 16, 2024
96b8228
- Use api definition of Well-known TileMatrixSets in the tiling-schem…
doublebyte1 Jan 16, 2024
efbb95a
- added tiling-scheme url on tiles metadata page, for es and tippecan…
doublebyte1 Jan 16, 2024
dae4d99
- fixed flak8 formatting errors
doublebyte1 Jan 16, 2024
7bbeebf
- updated number of links on the landing page, on the api test
doublebyte1 Jan 16, 2024
735fd72
- Manage tile matrix set id dinamically, on tilematrix set flask endp…
doublebyte1 Jan 21, 2024
17882a5
- renamed functions to lower case
doublebyte1 Jan 21, 2024
1feba2f
- renamed tilematrix set functions on flask
doublebyte1 Jan 21, 2024
53f67dd
- Use TtileMatrixSetId parameter in tilematrixset api function
doublebyte1 Jan 21, 2024
0d5b32d
- added support to TileMatrixSet endpoints on starlette
doublebyte1 Jan 21, 2024
0136c0e
- added test for tileMatrixSets api endpoint
doublebyte1 Jan 22, 2024
8bea035
- added test for the tilematrixset endpoint
doublebyte1 Jan 22, 2024
63dc864
Merge branch 'geopython:master' into tms
doublebyte1 Jan 30, 2024
5931e1a
- added routes for django
doublebyte1 Jan 30, 2024
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
135 changes: 133 additions & 2 deletions pygeoapi/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@
from pygeoapi.provider.base import (
ProviderGenericError, ProviderConnectionError, ProviderNotFoundError,
ProviderTypeError)
from pygeoapi.models.provider.base import TilesMetadataFormat
from pygeoapi.models.provider.base import (TilesMetadataFormat,
TileMatrixSetEnum)

from pygeoapi.models.cql import CQLModel
from pygeoapi.util import (dategetter, RequestedProcessExecutionMode,
Expand Down Expand Up @@ -751,6 +752,16 @@ def landing_page(self,
'type': FORMAT_TYPES[F_JSON],
'title': 'Jobs',
'href': f"{self.base_url}/jobs"
}, {
'rel': 'http://www.opengis.net/def/rel/ogc/1.0/tiling-schemes',
'type': FORMAT_TYPES[F_JSON],
'title': 'The list of supported tiling schemes (as JSON)',
'href': f"{self.base_url}/TileMatrixSets?f=json"
}, {
'rel': 'http://www.opengis.net/def/rel/ogc/1.0/tiling-schemes',
'type': FORMAT_TYPES[F_HTML],
'title': 'The list of supported tiling schemes (as HTML)',
'href': f"{self.base_url}/TileMatrixSets?f=html"
}]

headers = request.get_response_headers(**self.api_headers)
Expand Down Expand Up @@ -858,6 +869,121 @@ def conformance(self,

return headers, HTTPStatus.OK, to_json(conformance, self.pretty_print)

@gzip
@pre_process
def tilematrixsets(self,
request: Union[APIRequest, Any]) -> Tuple[dict, int,
str]:
"""
Provide tileMatrixSets definition

:param request: A request object

:returns: tuple of headers, status code, content
"""

if not request.is_valid():
return self.get_format_exception(request)

headers = request.get_response_headers(**self.api_headers)

# Retrieve available TileMatrixSets
enums = [e.value for e in TileMatrixSetEnum]

tms = {"tileMatrixSets": []}

for e in enums:
tms['tileMatrixSets'].append({
"title": e.title,
"id": e.tileMatrixSet,
"uri": e.tileMatrixSetURI,
"links": [
{
"rel": "self",
"type": "text/html",
"title": f"The HTML representation of the {e.tileMatrixSet} tile matrix set", # noqa
"href": f"{self.base_url}/TileMatrixSets/{e.tileMatrixSet}?f=html" # noqa
},
{
"rel": "self",
"type": "application/json",
"title": f"The JSON representation of the {e.tileMatrixSet} tile matrix set", # noqa
"href": f"{self.base_url}/TileMatrixSets/{e.tileMatrixSet}?f=json" # noqa
}
]
})

tms['links'] = [{
"rel": "alternate",
"type": "text/html",
"title": "This document as HTML",
"href": f"{self.base_url}/tileMatrixSets?f=html"
}, {
"rel": "self",
"type": "application/json",
"title": "This document",
"href": f"{self.base_url}/tileMatrixSets?f=json"
}]

if request.format == F_HTML: # render
content = render_j2_template(self.tpl_config,
'tilematrixsets/index.html',
tms, request.locale)
return headers, HTTPStatus.OK, content

return headers, HTTPStatus.OK, to_json(tms, self.pretty_print)

@gzip
@pre_process
def tilematrixset(self,
request: Union[APIRequest, Any]) -> Tuple[dict,
int, str]:
"""
Provide tile matrix definition

:param request: A request object

:returns: tuple of headers, status code, content
"""

if not request.is_valid():
return self.get_format_exception(request)

headers = request.get_response_headers(**self.api_headers)

# Retrieve relevant TileMatrixSet
enums = [e.value for e in TileMatrixSetEnum]
enum = None

try:
for e in enums:
if request.path_info.__contains__(e.tileMatrixSet):
enum = e
if not enum:
raise ValueError('could not find this tilematrixset')
except ValueError as err:
return self.get_exception(
HTTPStatus.BAD_REQUEST, headers, request.format,
'InvalidParameterValue', str(err))

tms = {
"title": enum.tileMatrixSet,
"crs": enum.crs,
"id": enum.tileMatrixSet,
"uri": enum.tileMatrixSetURI,
"orderedAxes": enum.orderedAxes,
"wellKnownScaleSet": enum.wellKnownScaleSet,
"tileMatrices": enum.tileMatrices
}

if request.format == F_HTML: # render
content = render_j2_template(self.tpl_config,
'tilematrixsets/tilematrixset.html',
tms, request.locale)
return headers, HTTPStatus.OK, content

return headers, HTTPStatus.OK, to_json(tms, self.pretty_print)

@gzip
@pre_process
@jsonldify
Expand Down Expand Up @@ -2665,7 +2791,12 @@ def get_collection_tiles(self, request: Union[APIRequest, Any],
'dataType': 'vector',
'links': []
}
tile_matrix['links'].append(matrix.tileMatrixSetDefinition)
tile_matrix['links'].append({
'type': FORMAT_TYPES[F_JSON],
'rel': 'http://www.opengis.net/def/rel/ogc/1.0/tiling-scheme',
'title': f'{matrix.tileMatrixSet} TileMatrixSet definition (as {F_JSON})', # noqa
'href': f'{self.base_url}/TileMatrixSets/{matrix.tileMatrixSet}?f={F_JSON}' # noqa
})
tile_matrix['links'].append({
'type': FORMAT_TYPES[F_JSON],
'rel': request.get_linkrel(F_JSON),
Expand Down
30 changes: 30 additions & 0 deletions pygeoapi/flask_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,36 @@ def conformance():
return get_response(api_.conformance(request))


@BLUEPRINT.route('/TileMatrixSets/WorldCRS84Quad')
doublebyte1 marked this conversation as resolved.
Show resolved Hide resolved
def WorldCRS84Quad():
doublebyte1 marked this conversation as resolved.
Show resolved Hide resolved
"""
OGC API WorldCRS84Quad endpoint

:returns: HTTP response
"""
return get_response(api_.tilematrixset(request))


@BLUEPRINT.route('/TileMatrixSets/WebMercatorQuad')
def WebMercatorQuad():
"""
OGC API WebMercatorQuad endpoint

:returns: HTTP response
"""
return get_response(api_.tilematrixset(request))


@BLUEPRINT.route('/TileMatrixSets')
def TileMatrixSets():
doublebyte1 marked this conversation as resolved.
Show resolved Hide resolved
"""
OGC API TileMatrixSets endpoint

:returns: HTTP response
"""
return get_response(api_.tilematrixsets(request))


@BLUEPRINT.route('/collections')
@BLUEPRINT.route('/collections/<path:collection_id>')
def collections(collection_id=None):
Expand Down
Loading
Loading