Module titiler.core.factory¶
TiTiler Router factories.
Variables¶
img_endpoint_params
templates
Classes¶
AlgorithmFactory¶
class AlgorithmFactory(
supported_algorithm: titiler.core.algorithm.Algorithms = Algorithms(data={'hillshade': <class 'titiler.core.algorithm.dem.HillShade'>, 'contours': <class 'titiler.core.algorithm.dem.Contours'>, 'normalizedIndex': <class 'titiler.core.algorithm.index.NormalizedIndex'>, 'terrarium': <class 'titiler.core.algorithm.dem.Terrarium'>, 'terrainrgb': <class 'titiler.core.algorithm.dem.TerrainRGB'>}),
router: fastapi.routing.APIRouter = <factory>
)
Algorithm endpoints Factory.
Class variables¶
supported_algorithm
BaseTilerFactory¶
class BaseTilerFactory(
reader: Type[rio_tiler.io.base.BaseReader],
router: fastapi.routing.APIRouter = <factory>,
path_dependency: Callable[..., Any] = <function DatasetPathParams at 0x7f682fd530d0>,
dataset_dependency: Type[titiler.core.dependencies.DefaultDependency] = <class 'titiler.core.dependencies.DatasetParams'>,
layer_dependency: Type[titiler.core.dependencies.DefaultDependency] = <class 'titiler.core.dependencies.BidxExprParams'>,
render_dependency: Type[titiler.core.dependencies.DefaultDependency] = <class 'titiler.core.dependencies.ImageRenderingParams'>,
colormap_dependency: Callable[..., Union[Dict[int, Tuple[int, int, int, int]], Sequence[Tuple[Tuple[Union[float, int], Union[float, int]], Tuple[int, int, int, int]]], NoneType]] = <function ColorMapParams at 0x7f68336ba4c0>,
process_dependency: Callable[..., Union[titiler.core.algorithm.base.BaseAlgorithm, NoneType]] = <function Algorithms.dependency.<locals>.post_process at 0x7f6833b01820>,
reader_dependency: Type[titiler.core.dependencies.DefaultDependency] = <class 'titiler.core.dependencies.DefaultDependency'>,
environment_dependency: Callable[..., Dict] = <function BaseTilerFactory.<lambda> at 0x7f6833b01790>,
supported_tms: morecantile.defaults.TileMatrixSets = TileMatrixSets(tms={'WorldCRS84Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/WorldCRS84Quad.json'), 'EuropeanETRS89_LAEAQuad': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/EuropeanETRS89_LAEAQuad.json'), 'WebMercatorQuad': <TileMatrixSet title='Google Maps Compatible for the World' identifier='WebMercatorQuad'>, 'WorldMercatorWGS84Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/WorldMercatorWGS84Quad.json'), 'UTM31WGS84Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/UTM31WGS84Quad.json'), 'WGS1984Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/WGS1984Quad.json'), 'NZTM2000Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/NZTM2000Quad.json'), 'UPSAntarcticWGS84Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/UPSAntarcticWGS84Quad.json'), 'NZTM2000': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/NZTM2000.json'), 'LINZAntarticaMapTilegrid': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/LINZAntarticaMapTilegrid.json'), 'CanadianNAD83_LCC': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/CanadianNAD83_LCC.json'), 'UPSArcticWGS84Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/UPSArcticWGS84Quad.json')}),
default_tms: str = 'WebMercatorQuad',
router_prefix: str = '',
optional_headers: List[titiler.core.resources.enums.OptionalHeader] = <factory>,
route_dependencies: List[Tuple[List[titiler.core.routing.EndpointScope], List[fastapi.params.Depends]]] = <factory>,
extensions: List[titiler.core.factory.FactoryExtension] = <factory>
)
BaseTiler Factory.
Abstract Base Class which defines most inputs used by dynamic tiler.
Attributes¶
Name | Type | Description | Default |
---|---|---|---|
reader | rio_tiler.io.base.BaseReader | A rio-tiler reader (e.g Reader). | None |
router | fastapi.APIRouter | Application router to register endpoints to. | None |
path_dependency | Callable | Endpoint dependency defining path to pass to the reader init. |
None |
dataset_dependency | titiler.core.dependencies.DefaultDependency | Endpoint dependency defining dataset overwriting options (e.g nodata). | None |
layer_dependency | titiler.core.dependencies.DefaultDependency | Endpoint dependency defining dataset indexes/bands/assets options. | None |
render_dependency | titiler.core.dependencies.DefaultDependency | Endpoint dependency defining image rendering options (e.g add_mask). | None |
colormap_dependency | Callable | Endpoint dependency defining ColorMap options (e.g colormap_name). | None |
process_dependency | titiler.core.dependencies.DefaultDependency | Endpoint dependency defining image post-processing options (e.g rescaling, color-formula). | None |
tms_dependency | Callable | Endpoint dependency defining TileMatrixSet to use. | None |
reader_dependency | titiler.core.dependencies.DefaultDependency | Endpoint dependency defining BaseReader options. | None |
environment_dependency | Callable | Endpoint dependency to define GDAL environment at runtime. | None |
router_prefix | str | prefix where the router will be mounted in the application. | None |
optional_headers | sequence of titiler.core.resources.enums.OptionalHeader | additional headers to return with the response. | None |
Descendants¶
- titiler.core.factory.TilerFactory
Class variables¶
dataset_dependency
default_tms
layer_dependency
reader_dependency
render_dependency
router_prefix
supported_tms
Methods¶
add_route_dependencies¶
def add_route_dependencies(
self,
*,
scopes: List[titiler.core.routing.EndpointScope],
dependencies=typing.List[fastapi.params.Depends]
)
Add dependencies to routes.
Allows a developer to add dependencies to a route after the route has been defined.
colormap_dependency¶
def colormap_dependency(
colormap_name: titiler.core.dependencies.ColorMapName = Query(None),
colormap: str = Query(None)
) -> Union[Dict[int, Tuple[int, int, int, int]], Sequence[Tuple[Tuple[Union[float, int], Union[float, int]], Tuple[int, int, int, int]]], NoneType]
Colormap Dependency.
environment_dependency¶
def environment_dependency(
)
path_dependency¶
def path_dependency(
url: str = Query(Ellipsis)
) -> str
Create dataset path from args
process_dependency¶
def process_dependency(
algorithm: Literal['hillshade', 'contours', 'normalizedIndex', 'terrarium', 'terrainrgb'] = Query(None),
algorithm_params: str = Query(None)
) -> Union[titiler.core.algorithm.base.BaseAlgorithm, NoneType]
Data Post-Processing options.
register_routes¶
def register_routes(
self
)
Register Tiler Routes.
url_for¶
def url_for(
self,
request: starlette.requests.Request,
name: str,
**path_params: Any
) -> str
Return full url (with prefix) for a specific endpoint.
FactoryExtension¶
class FactoryExtension(
)
Factory Extension.
Methods¶
register¶
def register(
self,
factory: 'BaseTilerFactory'
)
Register extension to the factory.
MultiBandTilerFactory¶
class MultiBandTilerFactory(
reader: Type[rio_tiler.io.base.MultiBandReader] = <class 'rio_tiler.io.rasterio.Reader'>,
router: fastapi.routing.APIRouter = <factory>,
path_dependency: Callable[..., Any] = <function DatasetPathParams at 0x7f682fd530d0>,
dataset_dependency: Type[titiler.core.dependencies.DefaultDependency] = <class 'titiler.core.dependencies.DatasetParams'>,
layer_dependency: Type[titiler.core.dependencies.DefaultDependency] = <class 'titiler.core.dependencies.BandsExprParams'>,
render_dependency: Type[titiler.core.dependencies.DefaultDependency] = <class 'titiler.core.dependencies.ImageRenderingParams'>,
colormap_dependency: Callable[..., Union[Dict[int, Tuple[int, int, int, int]], Sequence[Tuple[Tuple[Union[float, int], Union[float, int]], Tuple[int, int, int, int]]], NoneType]] = <function ColorMapParams at 0x7f68336ba4c0>,
process_dependency: Callable[..., Union[titiler.core.algorithm.base.BaseAlgorithm, NoneType]] = <function Algorithms.dependency.<locals>.post_process at 0x7f6833b01820>,
reader_dependency: Type[titiler.core.dependencies.DefaultDependency] = <class 'titiler.core.dependencies.DefaultDependency'>,
environment_dependency: Callable[..., Dict] = <function BaseTilerFactory.<lambda> at 0x7f6833b01790>,
supported_tms: morecantile.defaults.TileMatrixSets = TileMatrixSets(tms={'WorldCRS84Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/WorldCRS84Quad.json'), 'EuropeanETRS89_LAEAQuad': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/EuropeanETRS89_LAEAQuad.json'), 'WebMercatorQuad': <TileMatrixSet title='Google Maps Compatible for the World' identifier='WebMercatorQuad'>, 'WorldMercatorWGS84Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/WorldMercatorWGS84Quad.json'), 'UTM31WGS84Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/UTM31WGS84Quad.json'), 'WGS1984Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/WGS1984Quad.json'), 'NZTM2000Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/NZTM2000Quad.json'), 'UPSAntarcticWGS84Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/UPSAntarcticWGS84Quad.json'), 'NZTM2000': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/NZTM2000.json'), 'LINZAntarticaMapTilegrid': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/LINZAntarticaMapTilegrid.json'), 'CanadianNAD83_LCC': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/CanadianNAD83_LCC.json'), 'UPSArcticWGS84Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/UPSArcticWGS84Quad.json')}),
default_tms: str = 'WebMercatorQuad',
router_prefix: str = '',
optional_headers: List[titiler.core.resources.enums.OptionalHeader] = <factory>,
route_dependencies: List[Tuple[List[titiler.core.routing.EndpointScope], List[fastapi.params.Depends]]] = <factory>,
extensions: List[titiler.core.factory.FactoryExtension] = <factory>,
stats_dependency: Type[titiler.core.dependencies.DefaultDependency] = <class 'titiler.core.dependencies.StatisticsParams'>,
histogram_dependency: Type[titiler.core.dependencies.DefaultDependency] = <class 'titiler.core.dependencies.HistogramParams'>,
img_dependency: Type[titiler.core.dependencies.DefaultDependency] = <class 'titiler.core.dependencies.ImageParams'>,
add_preview: bool = True,
add_part: bool = True,
add_viewer: bool = True,
bands_dependency: Type[titiler.core.dependencies.DefaultDependency] = <class 'titiler.core.dependencies.BandsParams'>
)
Custom Tiler Factory for MultiBandReader classes.
Note:
To be able to use the rio_tiler.io.MultiBandReader we need to be able to pass a bands
argument to most of its methods. By using the BandsExprParams
for the layer_dependency
, the
.tile(), .point(), .preview() and the .part() methods will receive bands or expression arguments.
The rio_tiler.io.MultiBandReader `.info()` and `.metadata()` have `bands` as
a requirement arguments (https://github.com/cogeotiff/rio-tiler/blob/master/rio_tiler/io/base.py#L775).
This means we have to update the /info and /metadata endpoints in order to add the `bands` dependency.
For implementation example see https://github.com/developmentseed/titiler-pds
Ancestors (in MRO)¶
- titiler.core.factory.TilerFactory
- titiler.core.factory.BaseTilerFactory
Class variables¶
add_part
add_preview
add_viewer
bands_dependency
dataset_dependency
default_tms
histogram_dependency
img_dependency
layer_dependency
reader
reader_dependency
render_dependency
router_prefix
stats_dependency
supported_tms
Methods¶
add_route_dependencies¶
def add_route_dependencies(
self,
*,
scopes: List[titiler.core.routing.EndpointScope],
dependencies=typing.List[fastapi.params.Depends]
)
Add dependencies to routes.
Allows a developer to add dependencies to a route after the route has been defined.
bounds¶
def bounds(
self
)
Register /bounds endpoint.
colormap_dependency¶
def colormap_dependency(
colormap_name: titiler.core.dependencies.ColorMapName = Query(None),
colormap: str = Query(None)
) -> Union[Dict[int, Tuple[int, int, int, int]], Sequence[Tuple[Tuple[Union[float, int], Union[float, int]], Tuple[int, int, int, int]]], NoneType]
Colormap Dependency.
environment_dependency¶
def environment_dependency(
)
info¶
def info(
self
)
Register /info endpoint.
map_viewer¶
def map_viewer(
self
)
Register /map endpoint.
part¶
def part(
self
)
Register /crop endpoint.
path_dependency¶
def path_dependency(
url: str = Query(Ellipsis)
) -> str
Create dataset path from args
point¶
def point(
self
)
Register /point endpoints.
preview¶
def preview(
self
)
Register /preview endpoint.
process_dependency¶
def process_dependency(
algorithm: Literal['hillshade', 'contours', 'normalizedIndex', 'terrarium', 'terrainrgb'] = Query(None),
algorithm_params: str = Query(None)
) -> Union[titiler.core.algorithm.base.BaseAlgorithm, NoneType]
Data Post-Processing options.
register_routes¶
def register_routes(
self
)
This Method register routes to the router.
Because we wrap the endpoints in a class we cannot define the routes as methods (because of the self argument). The HACK is to define routes inside the class method and register them after the class initialization.
statistics¶
def statistics(
self
)
add statistics endpoints.
tile¶
def tile(
self
)
Register /tiles endpoint.
tilejson¶
def tilejson(
self
)
Register /tilejson.json endpoint.
url_for¶
def url_for(
self,
request: starlette.requests.Request,
name: str,
**path_params: Any
) -> str
Return full url (with prefix) for a specific endpoint.
wmts¶
def wmts(
self
)
Register /wmts endpoint.
MultiBaseTilerFactory¶
class MultiBaseTilerFactory(
reader: Type[rio_tiler.io.base.MultiBaseReader] = <class 'rio_tiler.io.rasterio.Reader'>,
router: fastapi.routing.APIRouter = <factory>,
path_dependency: Callable[..., Any] = <function DatasetPathParams at 0x7f682fd530d0>,
dataset_dependency: Type[titiler.core.dependencies.DefaultDependency] = <class 'titiler.core.dependencies.DatasetParams'>,
layer_dependency: Type[titiler.core.dependencies.DefaultDependency] = <class 'titiler.core.dependencies.AssetsBidxExprParams'>,
render_dependency: Type[titiler.core.dependencies.DefaultDependency] = <class 'titiler.core.dependencies.ImageRenderingParams'>,
colormap_dependency: Callable[..., Union[Dict[int, Tuple[int, int, int, int]], Sequence[Tuple[Tuple[Union[float, int], Union[float, int]], Tuple[int, int, int, int]]], NoneType]] = <function ColorMapParams at 0x7f68336ba4c0>,
process_dependency: Callable[..., Union[titiler.core.algorithm.base.BaseAlgorithm, NoneType]] = <function Algorithms.dependency.<locals>.post_process at 0x7f6833b01820>,
reader_dependency: Type[titiler.core.dependencies.DefaultDependency] = <class 'titiler.core.dependencies.DefaultDependency'>,
environment_dependency: Callable[..., Dict] = <function BaseTilerFactory.<lambda> at 0x7f6833b01790>,
supported_tms: morecantile.defaults.TileMatrixSets = TileMatrixSets(tms={'WorldCRS84Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/WorldCRS84Quad.json'), 'EuropeanETRS89_LAEAQuad': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/EuropeanETRS89_LAEAQuad.json'), 'WebMercatorQuad': <TileMatrixSet title='Google Maps Compatible for the World' identifier='WebMercatorQuad'>, 'WorldMercatorWGS84Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/WorldMercatorWGS84Quad.json'), 'UTM31WGS84Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/UTM31WGS84Quad.json'), 'WGS1984Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/WGS1984Quad.json'), 'NZTM2000Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/NZTM2000Quad.json'), 'UPSAntarcticWGS84Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/UPSAntarcticWGS84Quad.json'), 'NZTM2000': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/NZTM2000.json'), 'LINZAntarticaMapTilegrid': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/LINZAntarticaMapTilegrid.json'), 'CanadianNAD83_LCC': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/CanadianNAD83_LCC.json'), 'UPSArcticWGS84Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/UPSArcticWGS84Quad.json')}),
default_tms: str = 'WebMercatorQuad',
router_prefix: str = '',
optional_headers: List[titiler.core.resources.enums.OptionalHeader] = <factory>,
route_dependencies: List[Tuple[List[titiler.core.routing.EndpointScope], List[fastapi.params.Depends]]] = <factory>,
extensions: List[titiler.core.factory.FactoryExtension] = <factory>,
stats_dependency: Type[titiler.core.dependencies.DefaultDependency] = <class 'titiler.core.dependencies.StatisticsParams'>,
histogram_dependency: Type[titiler.core.dependencies.DefaultDependency] = <class 'titiler.core.dependencies.HistogramParams'>,
img_dependency: Type[titiler.core.dependencies.DefaultDependency] = <class 'titiler.core.dependencies.ImageParams'>,
add_preview: bool = True,
add_part: bool = True,
add_viewer: bool = True,
assets_dependency: Type[titiler.core.dependencies.DefaultDependency] = <class 'titiler.core.dependencies.AssetsParams'>
)
Custom Tiler Factory for MultiBaseReader classes.
Note:
To be able to use the rio_tiler.io.MultiBaseReader we need to be able to pass a assets
argument to most of its methods. By using the AssetsBidxExprParams
for the layer_dependency
, the
.tile(), .point(), .preview() and the .part() methods will receive assets, expression or indexes arguments.
The rio_tiler.io.MultiBaseReader `.info()` and `.metadata()` have `assets` as
a requirement arguments (https://github.com/cogeotiff/rio-tiler/blob/master/rio_tiler/io/base.py#L365).
This means we have to update the /info and /metadata endpoints in order to add the `assets` dependency.
Ancestors (in MRO)¶
- titiler.core.factory.TilerFactory
- titiler.core.factory.BaseTilerFactory
Class variables¶
add_part
add_preview
add_viewer
assets_dependency
dataset_dependency
default_tms
histogram_dependency
img_dependency
layer_dependency
reader
reader_dependency
render_dependency
router_prefix
stats_dependency
supported_tms
Methods¶
add_route_dependencies¶
def add_route_dependencies(
self,
*,
scopes: List[titiler.core.routing.EndpointScope],
dependencies=typing.List[fastapi.params.Depends]
)
Add dependencies to routes.
Allows a developer to add dependencies to a route after the route has been defined.
bounds¶
def bounds(
self
)
Register /bounds endpoint.
colormap_dependency¶
def colormap_dependency(
colormap_name: titiler.core.dependencies.ColorMapName = Query(None),
colormap: str = Query(None)
) -> Union[Dict[int, Tuple[int, int, int, int]], Sequence[Tuple[Tuple[Union[float, int], Union[float, int]], Tuple[int, int, int, int]]], NoneType]
Colormap Dependency.
environment_dependency¶
def environment_dependency(
)
info¶
def info(
self
)
Register /info endpoint.
map_viewer¶
def map_viewer(
self
)
Register /map endpoint.
part¶
def part(
self
)
Register /crop endpoint.
path_dependency¶
def path_dependency(
url: str = Query(Ellipsis)
) -> str
Create dataset path from args
point¶
def point(
self
)
Register /point endpoints.
preview¶
def preview(
self
)
Register /preview endpoint.
process_dependency¶
def process_dependency(
algorithm: Literal['hillshade', 'contours', 'normalizedIndex', 'terrarium', 'terrainrgb'] = Query(None),
algorithm_params: str = Query(None)
) -> Union[titiler.core.algorithm.base.BaseAlgorithm, NoneType]
Data Post-Processing options.
register_routes¶
def register_routes(
self
)
This Method register routes to the router.
Because we wrap the endpoints in a class we cannot define the routes as methods (because of the self argument). The HACK is to define routes inside the class method and register them after the class initialization.
statistics¶
def statistics(
self
)
Register /statistics endpoint.
tile¶
def tile(
self
)
Register /tiles endpoint.
tilejson¶
def tilejson(
self
)
Register /tilejson.json endpoint.
url_for¶
def url_for(
self,
request: starlette.requests.Request,
name: str,
**path_params: Any
) -> str
Return full url (with prefix) for a specific endpoint.
wmts¶
def wmts(
self
)
Register /wmts endpoint.
TMSFactory¶
class TMSFactory(
supported_tms: morecantile.defaults.TileMatrixSets = TileMatrixSets(tms={'WorldCRS84Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/WorldCRS84Quad.json'), 'EuropeanETRS89_LAEAQuad': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/EuropeanETRS89_LAEAQuad.json'), 'WebMercatorQuad': <TileMatrixSet title='Google Maps Compatible for the World' identifier='WebMercatorQuad'>, 'WorldMercatorWGS84Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/WorldMercatorWGS84Quad.json'), 'UTM31WGS84Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/UTM31WGS84Quad.json'), 'WGS1984Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/WGS1984Quad.json'), 'NZTM2000Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/NZTM2000Quad.json'), 'UPSAntarcticWGS84Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/UPSAntarcticWGS84Quad.json'), 'NZTM2000': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/NZTM2000.json'), 'LINZAntarticaMapTilegrid': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/LINZAntarticaMapTilegrid.json'), 'CanadianNAD83_LCC': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/CanadianNAD83_LCC.json'), 'UPSArcticWGS84Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/UPSArcticWGS84Quad.json')}),
router: fastapi.routing.APIRouter = <factory>,
router_prefix: str = ''
)
TileMatrixSet endpoints Factory.
Class variables¶
router_prefix
supported_tms
Methods¶
register_routes¶
def register_routes(
self
)
Register TMS endpoint routes.
url_for¶
def url_for(
self,
request: starlette.requests.Request,
name: str,
**path_params: Any
) -> str
Return full url (with prefix) for a specific endpoint.
TilerFactory¶
class TilerFactory(
reader: Type[rio_tiler.io.base.BaseReader] = <class 'rio_tiler.io.rasterio.Reader'>,
router: fastapi.routing.APIRouter = <factory>,
path_dependency: Callable[..., Any] = <function DatasetPathParams at 0x7f682fd530d0>,
dataset_dependency: Type[titiler.core.dependencies.DefaultDependency] = <class 'titiler.core.dependencies.DatasetParams'>,
layer_dependency: Type[titiler.core.dependencies.DefaultDependency] = <class 'titiler.core.dependencies.BidxExprParams'>,
render_dependency: Type[titiler.core.dependencies.DefaultDependency] = <class 'titiler.core.dependencies.ImageRenderingParams'>,
colormap_dependency: Callable[..., Union[Dict[int, Tuple[int, int, int, int]], Sequence[Tuple[Tuple[Union[float, int], Union[float, int]], Tuple[int, int, int, int]]], NoneType]] = <function ColorMapParams at 0x7f68336ba4c0>,
process_dependency: Callable[..., Union[titiler.core.algorithm.base.BaseAlgorithm, NoneType]] = <function Algorithms.dependency.<locals>.post_process at 0x7f6833b01820>,
reader_dependency: Type[titiler.core.dependencies.DefaultDependency] = <class 'titiler.core.dependencies.DefaultDependency'>,
environment_dependency: Callable[..., Dict] = <function BaseTilerFactory.<lambda> at 0x7f6833b01790>,
supported_tms: morecantile.defaults.TileMatrixSets = TileMatrixSets(tms={'WorldCRS84Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/WorldCRS84Quad.json'), 'EuropeanETRS89_LAEAQuad': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/EuropeanETRS89_LAEAQuad.json'), 'WebMercatorQuad': <TileMatrixSet title='Google Maps Compatible for the World' identifier='WebMercatorQuad'>, 'WorldMercatorWGS84Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/WorldMercatorWGS84Quad.json'), 'UTM31WGS84Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/UTM31WGS84Quad.json'), 'WGS1984Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/WGS1984Quad.json'), 'NZTM2000Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/NZTM2000Quad.json'), 'UPSAntarcticWGS84Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/UPSAntarcticWGS84Quad.json'), 'NZTM2000': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/NZTM2000.json'), 'LINZAntarticaMapTilegrid': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/LINZAntarticaMapTilegrid.json'), 'CanadianNAD83_LCC': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/CanadianNAD83_LCC.json'), 'UPSArcticWGS84Quad': PosixPath('/opt/hostedtoolcache/Python/3.8.16/x64/lib/python3.8/site-packages/morecantile/data/UPSArcticWGS84Quad.json')}),
default_tms: str = 'WebMercatorQuad',
router_prefix: str = '',
optional_headers: List[titiler.core.resources.enums.OptionalHeader] = <factory>,
route_dependencies: List[Tuple[List[titiler.core.routing.EndpointScope], List[fastapi.params.Depends]]] = <factory>,
extensions: List[titiler.core.factory.FactoryExtension] = <factory>,
stats_dependency: Type[titiler.core.dependencies.DefaultDependency] = <class 'titiler.core.dependencies.StatisticsParams'>,
histogram_dependency: Type[titiler.core.dependencies.DefaultDependency] = <class 'titiler.core.dependencies.HistogramParams'>,
img_dependency: Type[titiler.core.dependencies.DefaultDependency] = <class 'titiler.core.dependencies.ImageParams'>,
add_preview: bool = True,
add_part: bool = True,
add_viewer: bool = True
)
Tiler Factory.
Attributes¶
Name | Type | Description | Default |
---|---|---|---|
reader | rio_tiler.io.base.BaseReader | A rio-tiler reader. Defaults to rio_tiler.io.Reader . |
rio_tiler.io.Reader |
stats_dependency | titiler.core.dependencies.DefaultDependency | Endpoint dependency defining options for rio-tiler's statistics method. | None |
histogram_dependency | titiler.core.dependencies.DefaultDependency | Endpoint dependency defining options for numpy's histogram method. | None |
img_dependency | titiler.core.dependencies.DefaultDependency | Endpoint dependency defining options for rio-tiler's preview/crop method. | None |
add_preview | bool | add /preview endpoints. Defaults to True. |
True |
add_part | bool | add /crop endpoints. Defaults to True. |
True |
add_viewer | bool | add /map endpoints. Defaults to True. |
True |
Ancestors (in MRO)¶
- titiler.core.factory.BaseTilerFactory
Descendants¶
- titiler.core.factory.MultiBaseTilerFactory
- titiler.core.factory.MultiBandTilerFactory
Class variables¶
add_part
add_preview
add_viewer
dataset_dependency
default_tms
histogram_dependency
img_dependency
layer_dependency
reader
reader_dependency
render_dependency
router_prefix
stats_dependency
supported_tms
Methods¶
add_route_dependencies¶
def add_route_dependencies(
self,
*,
scopes: List[titiler.core.routing.EndpointScope],
dependencies=typing.List[fastapi.params.Depends]
)
Add dependencies to routes.
Allows a developer to add dependencies to a route after the route has been defined.
bounds¶
def bounds(
self
)
Register /bounds endpoint.
colormap_dependency¶
def colormap_dependency(
colormap_name: titiler.core.dependencies.ColorMapName = Query(None),
colormap: str = Query(None)
) -> Union[Dict[int, Tuple[int, int, int, int]], Sequence[Tuple[Tuple[Union[float, int], Union[float, int]], Tuple[int, int, int, int]]], NoneType]
Colormap Dependency.
environment_dependency¶
def environment_dependency(
)
info¶
def info(
self
)
Register /info endpoint.
map_viewer¶
def map_viewer(
self
)
Register /map endpoint.
part¶
def part(
self
)
Register /crop endpoint.
path_dependency¶
def path_dependency(
url: str = Query(Ellipsis)
) -> str
Create dataset path from args
point¶
def point(
self
)
Register /point endpoints.
preview¶
def preview(
self
)
Register /preview endpoint.
process_dependency¶
def process_dependency(
algorithm: Literal['hillshade', 'contours', 'normalizedIndex', 'terrarium', 'terrainrgb'] = Query(None),
algorithm_params: str = Query(None)
) -> Union[titiler.core.algorithm.base.BaseAlgorithm, NoneType]
Data Post-Processing options.
register_routes¶
def register_routes(
self
)
This Method register routes to the router.
Because we wrap the endpoints in a class we cannot define the routes as methods (because of the self argument). The HACK is to define routes inside the class method and register them after the class initialization.
statistics¶
def statistics(
self
)
add statistics endpoints.
tile¶
def tile(
self
)
Register /tiles endpoint.
tilejson¶
def tilejson(
self
)
Register /tilejson.json endpoint.
url_for¶
def url_for(
self,
request: starlette.requests.Request,
name: str,
**path_params: Any
) -> str
Return full url (with prefix) for a specific endpoint.
wmts¶
def wmts(
self
)
Register /wmts endpoint.