titiler.core 2.0.4__tar.gz → 2.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {titiler_core-2.0.4 → titiler_core-2.1.0}/PKG-INFO +2 -1
- {titiler_core-2.0.4 → titiler_core-2.1.0}/pyproject.toml +2 -1
- {titiler_core-2.0.4 → titiler_core-2.1.0}/titiler/core/__init__.py +1 -1
- {titiler_core-2.0.4 → titiler_core-2.1.0}/titiler/core/algorithm/dem.py +2 -2
- {titiler_core-2.0.4 → titiler_core-2.1.0}/titiler/core/dependencies.py +31 -0
- {titiler_core-2.0.4 → titiler_core-2.1.0}/titiler/core/errors.py +14 -2
- {titiler_core-2.0.4 → titiler_core-2.1.0}/titiler/core/factory.py +31 -5
- {titiler_core-2.0.4 → titiler_core-2.1.0}/titiler/core/models/mapbox.py +10 -0
- {titiler_core-2.0.4 → titiler_core-2.1.0}/titiler/core/utils.py +4 -0
- {titiler_core-2.0.4 → titiler_core-2.1.0}/.gitignore +0 -0
- {titiler_core-2.0.4 → titiler_core-2.1.0}/LICENSE +0 -0
- {titiler_core-2.0.4 → titiler_core-2.1.0}/README.md +0 -0
- {titiler_core-2.0.4 → titiler_core-2.1.0}/titiler/core/algorithm/__init__.py +0 -0
- {titiler_core-2.0.4 → titiler_core-2.1.0}/titiler/core/algorithm/base.py +0 -0
- {titiler_core-2.0.4 → titiler_core-2.1.0}/titiler/core/algorithm/image.py +0 -0
- {titiler_core-2.0.4 → titiler_core-2.1.0}/titiler/core/algorithm/index.py +0 -0
- {titiler_core-2.0.4 → titiler_core-2.1.0}/titiler/core/algorithm/math.py +0 -0
- {titiler_core-2.0.4 → titiler_core-2.1.0}/titiler/core/algorithm/ops.py +0 -0
- {titiler_core-2.0.4 → titiler_core-2.1.0}/titiler/core/middleware.py +0 -0
- {titiler_core-2.0.4 → titiler_core-2.1.0}/titiler/core/models/OGC.py +0 -0
- {titiler_core-2.0.4 → titiler_core-2.1.0}/titiler/core/models/__init__.py +0 -0
- {titiler_core-2.0.4 → titiler_core-2.1.0}/titiler/core/models/common.py +0 -0
- {titiler_core-2.0.4 → titiler_core-2.1.0}/titiler/core/models/responses.py +0 -0
- {titiler_core-2.0.4 → titiler_core-2.1.0}/titiler/core/py.typed +0 -0
- {titiler_core-2.0.4 → titiler_core-2.1.0}/titiler/core/resources/__init__.py +0 -0
- {titiler_core-2.0.4 → titiler_core-2.1.0}/titiler/core/resources/enums.py +0 -0
- {titiler_core-2.0.4 → titiler_core-2.1.0}/titiler/core/resources/responses.py +0 -0
- {titiler_core-2.0.4 → titiler_core-2.1.0}/titiler/core/routing.py +0 -0
- {titiler_core-2.0.4 → titiler_core-2.1.0}/titiler/core/telemetry.py +0 -0
- {titiler_core-2.0.4 → titiler_core-2.1.0}/titiler/core/templates/algorithm.html +0 -0
- {titiler_core-2.0.4 → titiler_core-2.1.0}/titiler/core/templates/algorithms.html +0 -0
- {titiler_core-2.0.4 → titiler_core-2.1.0}/titiler/core/templates/base.html +0 -0
- {titiler_core-2.0.4 → titiler_core-2.1.0}/titiler/core/templates/colormap.html +0 -0
- {titiler_core-2.0.4 → titiler_core-2.1.0}/titiler/core/templates/colormaps.html +0 -0
- {titiler_core-2.0.4 → titiler_core-2.1.0}/titiler/core/templates/debug.html +0 -0
- {titiler_core-2.0.4 → titiler_core-2.1.0}/titiler/core/templates/footer.html +0 -0
- {titiler_core-2.0.4 → titiler_core-2.1.0}/titiler/core/templates/header.html +0 -0
- {titiler_core-2.0.4 → titiler_core-2.1.0}/titiler/core/templates/icons/clock.html +0 -0
- {titiler_core-2.0.4 → titiler_core-2.1.0}/titiler/core/templates/icons/license.html +0 -0
- {titiler_core-2.0.4 → titiler_core-2.1.0}/titiler/core/templates/icons/tag.html +0 -0
- {titiler_core-2.0.4 → titiler_core-2.1.0}/titiler/core/templates/map.html +0 -0
- {titiler_core-2.0.4 → titiler_core-2.1.0}/titiler/core/templates/tilematrixset.html +0 -0
- {titiler_core-2.0.4 → titiler_core-2.1.0}/titiler/core/templates/tilematrixsets.html +0 -0
- {titiler_core-2.0.4 → titiler_core-2.1.0}/titiler/core/templates/tileset.html +0 -0
- {titiler_core-2.0.4 → titiler_core-2.1.0}/titiler/core/templates/tilesets.html +0 -0
- {titiler_core-2.0.4 → titiler_core-2.1.0}/titiler/core/validation.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: titiler-core
|
|
3
|
-
Version: 2.0
|
|
3
|
+
Version: 2.1.0
|
|
4
4
|
Summary: A modern dynamic tile server built on top of FastAPI and Rasterio/GDAL.
|
|
5
5
|
Project-URL: Homepage, https://developmentseed.org/titiler/
|
|
6
6
|
Project-URL: Documentation, https://developmentseed.org/titiler/
|
|
@@ -30,6 +30,7 @@ Requires-Dist: pydantic~=2.0
|
|
|
30
30
|
Requires-Dist: rasterio
|
|
31
31
|
Requires-Dist: rio-tiler<10.0,>=9.0
|
|
32
32
|
Requires-Dist: simplejson
|
|
33
|
+
Requires-Dist: starlette>=1.0.1
|
|
33
34
|
Provides-Extra: telemetry
|
|
34
35
|
Requires-Dist: opentelemetry-api; extra == 'telemetry'
|
|
35
36
|
Requires-Dist: opentelemetry-exporter-otlp; extra == 'telemetry'
|
|
@@ -31,6 +31,7 @@ classifiers = [
|
|
|
31
31
|
dynamic = ["version"]
|
|
32
32
|
dependencies = [
|
|
33
33
|
"fastapi>=0.136.1",
|
|
34
|
+
"starlette>=1.0.1",
|
|
34
35
|
"geojson-pydantic>=1.1.2,<3.0",
|
|
35
36
|
"jinja2>=2.11.2,<4.0.0",
|
|
36
37
|
"numpy",
|
|
@@ -55,7 +56,7 @@ test = [
|
|
|
55
56
|
"pytest",
|
|
56
57
|
"pytest-cov",
|
|
57
58
|
"pytest-asyncio",
|
|
58
|
-
"
|
|
59
|
+
"httpx2",
|
|
59
60
|
]
|
|
60
61
|
|
|
61
62
|
[project.urls]
|
|
@@ -179,7 +179,7 @@ class Terrarium(BaseAlgorithm):
|
|
|
179
179
|
"""Encode DEM into RGB."""
|
|
180
180
|
data = numpy.clip(img.array[0] + 32768.0, 0.0, 65535.0)
|
|
181
181
|
if self.nodata_height is not None:
|
|
182
|
-
data[img.array.mask[0]] = numpy.clip( # type: ignore [
|
|
182
|
+
data[img.array.mask[0]] = numpy.clip( # type: ignore [call-overload]
|
|
183
183
|
self.nodata_height + 32768.0, 0.0, 65535.0
|
|
184
184
|
)
|
|
185
185
|
r = data / 256
|
|
@@ -239,7 +239,7 @@ class TerrainRGB(BaseAlgorithm):
|
|
|
239
239
|
raise ValueError(f"Data of {datarange} larger than 256 ** 3")
|
|
240
240
|
|
|
241
241
|
if self.nodata_height is not None:
|
|
242
|
-
data[img.array.mask[0]] = ( # type: ignore [
|
|
242
|
+
data[img.array.mask[0]] = ( # type: ignore [call-overload]
|
|
243
243
|
self.nodata_height - self.baseval
|
|
244
244
|
) / self.interval
|
|
245
245
|
|
|
@@ -8,6 +8,7 @@ from typing import Annotated, Any, Literal, cast
|
|
|
8
8
|
import numpy
|
|
9
9
|
from fastapi import HTTPException, Query
|
|
10
10
|
from pydantic import AfterValidator, BeforeValidator, Field
|
|
11
|
+
from pydantic.types import StringConstraints
|
|
11
12
|
from rasterio.crs import CRS
|
|
12
13
|
from rio_tiler.colormap import ColorMaps
|
|
13
14
|
from rio_tiler.colormap import cmap as default_cmap
|
|
@@ -643,3 +644,33 @@ def CoverScaleParams(
|
|
|
643
644
|
) -> int:
|
|
644
645
|
"""Cover Scale Parameter."""
|
|
645
646
|
return cover_scale or 10
|
|
647
|
+
|
|
648
|
+
|
|
649
|
+
ZoomsStr = Annotated[
|
|
650
|
+
str,
|
|
651
|
+
StringConstraints(pattern=r"^(\*|\w+)::\d+,\d+$"),
|
|
652
|
+
]
|
|
653
|
+
|
|
654
|
+
|
|
655
|
+
def ZoomsParams(
|
|
656
|
+
zooms: Annotated[
|
|
657
|
+
list[ZoomsStr] | None,
|
|
658
|
+
Query(
|
|
659
|
+
description="Overwrite TMS min/max zoom in form of`tileMatrixSetId::minzoom,maxzoom`",
|
|
660
|
+
openapi_examples={
|
|
661
|
+
"user-provided": {"value": None},
|
|
662
|
+
"Single": {"value": ["WebMercatorQuad::0,5"]},
|
|
663
|
+
"Multiples": {"value": ["WebMercatorQuad::0,5", "WorldCRS84Quad::0,1"]},
|
|
664
|
+
"All": {"value": ["*::0,5"]},
|
|
665
|
+
},
|
|
666
|
+
),
|
|
667
|
+
] = None,
|
|
668
|
+
) -> dict[str, tuple[int, int]]:
|
|
669
|
+
"""tileMatrixSets Zooms Parameter."""
|
|
670
|
+
if zooms:
|
|
671
|
+
return {
|
|
672
|
+
tms_id: tuple(map(int, zoom_range.split(",")[0:2])) # type: ignore
|
|
673
|
+
for tms_id, zoom_range in (zoom.split("::") for zoom in zooms)
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
return {}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"""Titiler error classes."""
|
|
2
2
|
|
|
3
|
+
import logging
|
|
3
4
|
from collections.abc import Callable
|
|
4
5
|
|
|
5
6
|
from fastapi import FastAPI
|
|
@@ -18,6 +19,8 @@ from starlette import status
|
|
|
18
19
|
from starlette.requests import Request
|
|
19
20
|
from starlette.responses import JSONResponse, Response
|
|
20
21
|
|
|
22
|
+
logger = logging.getLogger(__name__)
|
|
23
|
+
|
|
21
24
|
|
|
22
25
|
class TilerError(Exception):
|
|
23
26
|
"""Base exception class."""
|
|
@@ -48,7 +51,7 @@ DEFAULT_STATUS_CODES = {
|
|
|
48
51
|
}
|
|
49
52
|
|
|
50
53
|
|
|
51
|
-
def exception_handler_factory(status_code: int) -> Callable:
|
|
54
|
+
def exception_handler_factory(status_code: int, exc_class: type[Exception]) -> Callable:
|
|
52
55
|
"""
|
|
53
56
|
Create a FastAPI exception handler from a status code.
|
|
54
57
|
"""
|
|
@@ -57,6 +60,15 @@ def exception_handler_factory(status_code: int) -> Callable:
|
|
|
57
60
|
if status_code == status.HTTP_204_NO_CONTENT:
|
|
58
61
|
return Response(content=None, status_code=204)
|
|
59
62
|
|
|
63
|
+
# Only log concrete >=500 errors; the catch-all Exception/500 is
|
|
64
|
+
# already re-raised and logged by Starlette's ServerErrorMiddleware.
|
|
65
|
+
if status_code >= 500 and exc_class is not Exception:
|
|
66
|
+
logger.error(
|
|
67
|
+
"Exception mapped to HTTP %s response",
|
|
68
|
+
status_code,
|
|
69
|
+
exc_info=exc,
|
|
70
|
+
)
|
|
71
|
+
|
|
60
72
|
return JSONResponse(content={"detail": str(exc)}, status_code=status_code)
|
|
61
73
|
|
|
62
74
|
return handler
|
|
@@ -69,4 +81,4 @@ def add_exception_handlers(
|
|
|
69
81
|
Add exception handlers to the FastAPI app.
|
|
70
82
|
"""
|
|
71
83
|
for exc, code in status_codes.items():
|
|
72
|
-
app.add_exception_handler(exc, exception_handler_factory(code))
|
|
84
|
+
app.add_exception_handler(exc, exception_handler_factory(code, exc))
|
|
@@ -329,6 +329,10 @@ class TilerFactory(BaseFactory):
|
|
|
329
329
|
|
|
330
330
|
render_func: Callable[..., tuple[bytes, str]] = render_image
|
|
331
331
|
|
|
332
|
+
get_renders: Callable[[BaseReader], dict[str, dict[str, Any]]] = field(
|
|
333
|
+
default=lambda obj: {}
|
|
334
|
+
)
|
|
335
|
+
|
|
332
336
|
# Add/Remove some endpoints
|
|
333
337
|
add_preview: bool = True
|
|
334
338
|
add_part: bool = True
|
|
@@ -576,7 +580,7 @@ class TilerFactory(BaseFactory):
|
|
|
576
580
|
summary="Retrieve a list of available raster tilesets for the specified dataset.",
|
|
577
581
|
operation_id=f"{self.operation_prefix}getTileSetList",
|
|
578
582
|
)
|
|
579
|
-
|
|
583
|
+
def tileset_list(
|
|
580
584
|
request: Request,
|
|
581
585
|
src_path=Depends(self.path_dependency),
|
|
582
586
|
reader_params=Depends(self.reader_dependency),
|
|
@@ -697,7 +701,7 @@ class TilerFactory(BaseFactory):
|
|
|
697
701
|
summary="Retrieve the raster tileset metadata for the specified dataset and tiling scheme (tile matrix set).",
|
|
698
702
|
operation_id=f"{self.operation_prefix}getTileSet",
|
|
699
703
|
)
|
|
700
|
-
|
|
704
|
+
def tileset(
|
|
701
705
|
request: Request,
|
|
702
706
|
tileMatrixSetId: Annotated[
|
|
703
707
|
Literal[tuple(self.supported_tms.list())],
|
|
@@ -708,6 +712,14 @@ class TilerFactory(BaseFactory):
|
|
|
708
712
|
src_path=Depends(self.path_dependency),
|
|
709
713
|
reader_params=Depends(self.reader_dependency),
|
|
710
714
|
env=Depends(self.environment_dependency),
|
|
715
|
+
minzoom: Annotated[
|
|
716
|
+
int | None,
|
|
717
|
+
Query(description="Overwrite default minzoom."),
|
|
718
|
+
] = None,
|
|
719
|
+
maxzoom: Annotated[
|
|
720
|
+
int | None,
|
|
721
|
+
Query(description="Overwrite default maxzoom."),
|
|
722
|
+
] = None,
|
|
711
723
|
f: Annotated[
|
|
712
724
|
Literal["html", "json"] | None,
|
|
713
725
|
Query(
|
|
@@ -722,8 +734,8 @@ class TilerFactory(BaseFactory):
|
|
|
722
734
|
src_path, tms=tms, **reader_params.as_dict()
|
|
723
735
|
) as src_dst:
|
|
724
736
|
bounds = src_dst.get_geographic_bounds(tms.rasterio_geographic_crs)
|
|
725
|
-
minzoom = src_dst.minzoom
|
|
726
|
-
maxzoom = src_dst.maxzoom
|
|
737
|
+
minzoom = minzoom if minzoom is not None else src_dst.minzoom
|
|
738
|
+
maxzoom = maxzoom if maxzoom is not None else src_dst.maxzoom
|
|
727
739
|
|
|
728
740
|
collection_bbox = {
|
|
729
741
|
"lowerLeft": [bounds[0], bounds[1]],
|
|
@@ -1007,7 +1019,7 @@ class TilerFactory(BaseFactory):
|
|
|
1007
1019
|
with self.reader(
|
|
1008
1020
|
src_path, tms=tms, **reader_params.as_dict()
|
|
1009
1021
|
) as src_dst:
|
|
1010
|
-
|
|
1022
|
+
body = {
|
|
1011
1023
|
"bounds": src_dst.get_geographic_bounds(
|
|
1012
1024
|
tms.rasterio_geographic_crs
|
|
1013
1025
|
),
|
|
@@ -1017,6 +1029,16 @@ class TilerFactory(BaseFactory):
|
|
|
1017
1029
|
"attribution": os.environ.get("TITILER_DEFAULT_ATTRIBUTION"),
|
|
1018
1030
|
}
|
|
1019
1031
|
|
|
1032
|
+
# Custom TiTiler tilejson fields
|
|
1033
|
+
body["raster_layers"] = self.get_renders(src_dst)
|
|
1034
|
+
|
|
1035
|
+
info = src_dst.info()
|
|
1036
|
+
body["band_descriptions"] = getattr(info, "band_descriptions", None)
|
|
1037
|
+
body["data_type"] = getattr(info, "dtype", None)
|
|
1038
|
+
body["minmax"] = getattr(info, "minmax", None)
|
|
1039
|
+
|
|
1040
|
+
return body
|
|
1041
|
+
|
|
1020
1042
|
def map_viewer(self): # noqa: C901
|
|
1021
1043
|
"""Register /map.html endpoint."""
|
|
1022
1044
|
|
|
@@ -1464,6 +1486,10 @@ class MultiBaseTilerFactory(TilerFactory):
|
|
|
1464
1486
|
# Assets dependency
|
|
1465
1487
|
assets_dependency: type[DefaultDependency] = AssetsParams
|
|
1466
1488
|
|
|
1489
|
+
get_renders: Callable[[MultiBaseReader], dict[str, dict[str, Any]]] = field( # type: ignore
|
|
1490
|
+
default=lambda obj: {}
|
|
1491
|
+
)
|
|
1492
|
+
|
|
1467
1493
|
# Overwrite the `/info` endpoint to return the list of assets when no assets is passed.
|
|
1468
1494
|
def info(self):
|
|
1469
1495
|
"""Register /info endpoint."""
|
|
@@ -54,3 +54,13 @@ class TileJSON(BaseModel, extra="allow"):
|
|
|
54
54
|
self.minzoom,
|
|
55
55
|
)
|
|
56
56
|
return self
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class TiTilerJSON(TileJSON):
|
|
60
|
+
"""TiTiler custom TileJSON model."""
|
|
61
|
+
|
|
62
|
+
raster_layers: list[dict] | None = None
|
|
63
|
+
|
|
64
|
+
band_descriptions: list[tuple[str, str]] | None = None
|
|
65
|
+
dtype: str | None = None
|
|
66
|
+
minmax: list[tuple[float, float]] | None = None
|
|
@@ -477,6 +477,10 @@ def tms_limits(
|
|
|
477
477
|
else:
|
|
478
478
|
minzoom, maxzoom = tms.minzoom, tms.maxzoom
|
|
479
479
|
|
|
480
|
+
# Make sure to not overflow the TMS minzoom
|
|
481
|
+
# if minzoom < tms.minzoom, morecantile won't be able to compute the Matrix
|
|
482
|
+
minzoom = max(minzoom, tms.minzoom)
|
|
483
|
+
|
|
480
484
|
tilematrix_limits: list[TMSLimits] = []
|
|
481
485
|
for zoom in range(minzoom, maxzoom + 1):
|
|
482
486
|
matrix = tms.matrix(zoom)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|