5151from titiler .core .utils import render_image
5252from titiler .mosaic .models .responses import Point
5353
54+ MOSAIC_THREADS = int (os .getenv ("MOSAIC_CONCURRENCY" , MAX_THREADS ))
55+ MOSAIC_STRICT_ZOOM = str (os .getenv ("MOSAIC_STRICT_ZOOM" , False )).lower () in [
56+ "true" ,
57+ "yes" ,
58+ ]
59+
5460
5561def PixelSelectionParams (
5662 pixel_selection : Annotated [ # type: ignore
@@ -575,13 +581,6 @@ def tile(
575581 f"Invalid 'scale' parameter: { scale } . Scale HAVE TO be between 1 and 4" ,
576582 )
577583
578- threads = int (os .getenv ("MOSAIC_CONCURRENCY" , MAX_THREADS ))
579-
580- strict_zoom = str (os .getenv ("MOSAIC_STRICT_ZOOM" , False )).lower () in [
581- "true" ,
582- "yes" ,
583- ]
584-
585584 tms = self .supported_tms .get (tileMatrixSetId )
586585 with rasterio .Env (** env ):
587586 with self .backend (
@@ -592,7 +591,9 @@ def tile(
592591 ** backend_params .as_dict (),
593592 ) as src_dst :
594593
595- if strict_zoom and (z < src_dst .minzoom or z > src_dst .maxzoom ):
594+ if MOSAIC_STRICT_ZOOM and (
595+ z < src_dst .minzoom or z > src_dst .maxzoom
596+ ):
596597 raise HTTPException (
597598 400 ,
598599 f"Invalid ZOOM level { z } . Should be between { src_dst .minzoom } and { src_dst .maxzoom } " ,
@@ -604,7 +605,7 @@ def tile(
604605 z ,
605606 pixel_selection = pixel_selection ,
606607 tilesize = scale * 256 ,
607- threads = threads ,
608+ threads = MOSAIC_THREADS ,
608609 ** tile_params .as_dict (),
609610 ** layer_params .as_dict (),
610611 ** dataset_params .as_dict (),
@@ -779,10 +780,12 @@ def map_viewer(
779780 ):
780781 """Return TileJSON document for a dataset."""
781782 tilejson_url = self .url_for (
782- request , "tilejson" , tileMatrixSetId = tileMatrixSetId
783+ request ,
784+ "tilejson" ,
785+ tileMatrixSetId = tileMatrixSetId ,
783786 )
784787 if request .query_params ._list :
785- tilejson_url += f"?{ urlencode (request .query_params ._list )} "
788+ tilejson_url += f"?{ urlencode (request .query_params ._list , doseq = True )} "
786789
787790 tms = self .supported_tms .get (tileMatrixSetId )
788791 return self .templates .TemplateResponse (
@@ -966,8 +969,6 @@ def point(
966969 env = Depends (self .environment_dependency ),
967970 ):
968971 """Get Point value for a Mosaic."""
969- threads = int (os .getenv ("MOSAIC_CONCURRENCY" , MAX_THREADS ))
970-
971972 with rasterio .Env (** env ):
972973 with self .backend (
973974 src_path ,
@@ -979,7 +980,7 @@ def point(
979980 lon ,
980981 lat ,
981982 coord_crs = coord_crs or WGS84_CRS ,
982- threads = threads ,
983+ threads = MOSAIC_THREADS ,
983984 ** layer_params .as_dict (),
984985 ** dataset_params .as_dict (),
985986 )
0 commit comments