factory
titiler.core.factory ¶
TiTiler Router factories.
AlgorithmFactory ¶
Bases: BaseFactory
Algorithm endpoints Factory.
BaseFactory ¶
Base Factory.
Abstract Base Class which defines most inputs used by dynamic tiler.
Attributes:
-
router(APIRouter) –Application router to register endpoints to.
-
router_prefix(str) –prefix where the router will be mounted in the application.
-
route_dependencies(list) –Additional routes dependencies to add after routes creations.
__attrs_post_init__ ¶
__attrs_post_init__()
Post Init: register route and configure specific options.
add_route_dependencies ¶
add_route_dependencies(*, scopes: List[EndpointScope], dependencies=List[Depends])
Add dependencies to routes.
Allows a developer to add dependencies to a route after the route has been defined.
add_telemetry ¶
add_telemetry()
Applies the factory_trace decorator to all registered API routes.
This method iterates through the router's routes and wraps the endpoint of each APIRoute to ensure consistent OpenTelemetry tracing.
ColorMapFactory ¶
Bases: BaseFactory
Colormap endpoints Factory.
FactoryExtension ¶
Factory Extension.
MultiBandTilerFactory ¶
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
MultiBaseTilerFactory ¶
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.
TMSFactory ¶
TilerFactory ¶
Bases: BaseFactory
Tiler Factory.
Attributes:
-
reader(BaseReader) –A rio-tiler reader. Defaults to
rio_tiler.io.Reader. -
reader_dependency(DefaultDependency) –Endpoint dependency defining BaseReader options.
-
path_dependency(Callable) –Endpoint dependency defining
pathto pass to the reader init. -
layer_dependency(DefaultDependency) –Endpoint dependency defining dataset indexes/bands/assets options.
-
dataset_dependency(DefaultDependency) –Endpoint dependency defining dataset overwriting options (e.g nodata).
-
tile_dependency(DefaultDependency) –Endpoint dependency defining tile options (e.g buffer, padding).
-
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.
-
process_dependency(DefaultDependency) –Endpoint dependency defining image post-processing options (e.g rescaling, color-formula).
-
rescale_dependency(Callable[..., Optional[RescaleType]]) – -
color_formula_dependency(Callable[..., Optional[str]]) – -
colormap_dependency(Callable) –Endpoint dependency defining ColorMap options (e.g colormap_name).
-
render_dependency(DefaultDependency) –Endpoint dependency defining image rendering options (e.g add_mask).
-
environment_dependency(Callable) –Endpoint dependency to define GDAL environment at runtime.
-
supported_tms(TileMatrixSets) –TileMatrixSets object holding the supported TileMatrixSets.
-
templates(Jinja2Templates) –Jinja2 templates.
-
add_preview(bool) –add
/previewendpoints. Defaults to True. -
add_part(bool) –add
/bboxand/featureendpoints. Defaults to True. -
add_viewer(bool) –add
/map.htmlendpoints. Defaults to True.
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.