Skip to content

factory

titiler.core.factory

TiTiler Router factories.

AlgorithmFactory dataclass

Algorithm endpoints Factory.

BaseTilerFactory dataclass

BaseTiler Factory.

Abstract Base Class which defines most inputs used by dynamic tiler.

Attributes:

  • reader (BaseReader) –

    A rio-tiler reader (e.g Reader).

  • router (APIRouter) –

    Application router to register endpoints to.

  • path_dependency (Callable) –

    Endpoint dependency defining path to pass to the reader init.

  • dataset_dependency (DefaultDependency) –

    Endpoint dependency defining dataset overwriting options (e.g nodata).

  • layer_dependency (DefaultDependency) –

    Endpoint dependency defining dataset indexes/bands/assets options.

  • render_dependency (DefaultDependency) –

    Endpoint dependency defining image rendering options (e.g add_mask).

  • colormap_dependency (Callable) –

    Endpoint dependency defining ColorMap options (e.g colormap_name).

  • process_dependency (DefaultDependency) –

    Endpoint dependency defining image post-processing options (e.g rescaling, color-formula).

  • tms_dependency (Callable) –

    Endpoint dependency defining TileMatrixSet to use.

  • reader_dependency (DefaultDependency) –

    Endpoint dependency defining BaseReader options.

  • environment_dependency (Callable) –

    Endpoint dependency to define GDAL environment at runtime.

  • router_prefix (str) –

    prefix where the router will be mounted in the application.

  • optional_headers(sequence (of titiler.core.resources.enums.OptionalHeader) –

    additional headers to return with the response.

add_route_dependencies

add_route_dependencies(*, scopes: List[EndpointScope], dependencies=List[DependsFunc])

Add dependencies to routes.

Allows a developer to add dependencies to a route after the route has been defined.

register_routes abstractmethod

register_routes()

Register Tiler Routes.

url_for

url_for(request: Request, name: str, **path_params: Any) -> str

Return full url (with prefix) for a specific endpoint.

ColorMapFactory dataclass

Colormap endpoints Factory.

url_for

url_for(request: Request, name: str, **path_params: Any) -> str

Return full url (with prefix) for a specific endpoint.

FactoryExtension dataclass

Factory Extension.

register abstractmethod

register(factory: BaseTilerFactory)

Register extension to the factory.

MultiBandTilerFactory dataclass

Bases: TilerFactory

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 (github.com/cogeotiff/rio-tiler/blob/main/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 developmentseed/titiler-pds

info

info()

Register /info endpoint.

statistics

statistics()

add statistics endpoints.

MultiBaseTilerFactory dataclass

Bases: TilerFactory

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 (github.com/cogeotiff/rio-tiler/blob/main/rio_tiler/io/base.py#L365). This means we have to update the /info and /metadata endpoints in order to add the assets dependency.

info

info()

Register /info endpoint.

statistics

statistics()

Register /statistics endpoint.

TMSFactory dataclass

TileMatrixSet endpoints Factory.

register_routes

register_routes()

Register TMS endpoint routes.

url_for

url_for(request: Request, name: str, **path_params: Any) -> str

Return full url (with prefix) for a specific endpoint.

TilerFactory dataclass

Bases: BaseTilerFactory

Tiler Factory.

Attributes:

  • reader (BaseReader) –

    A rio-tiler reader. Defaults to rio_tiler.io.Reader.

  • stats_dependency (DefaultDependency) –

    Endpoint dependency defining options for rio-tiler's statistics method.

  • histogram_dependency (DefaultDependency) –

    Endpoint dependency defining options for numpy's histogram method.

  • img_preview_dependency (DefaultDependency) –

    Endpoint dependency defining options for rio-tiler's preview method.

  • img_part_dependency (DefaultDependency) –

    Endpoint dependency defining options for rio-tiler's part/feature methods.

  • add_preview (bool) –

    add /preview endpoints. Defaults to True.

  • add_part (bool) –

    add /bbox and /feature endpoints. Defaults to True.

  • add_viewer (bool) –

    add /map endpoints. Defaults to True.

bounds

bounds()

Register /bounds endpoint.

info

info()

Register /info endpoint.

map_viewer

map_viewer()

Register /map endpoint.

part

part()

Register /bbox and /feature endpoints.

point

point()

Register /point endpoints.

preview

preview()

Register /preview endpoint.

register_routes

register_routes()

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

statistics()

add statistics endpoints.

tile

tile()

Register /tiles endpoint.

tilejson

tilejson()

Register /tilejson.json endpoint.

wmts

wmts()

Register /wmts endpoint.