diff --git a/CHANGES.md b/CHANGES.md index 43dd4c96..fa93d35c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -12,6 +12,10 @@ Note: Minor version `0.X.0` update might break the API, It's recommended to pin - forward `catalog_dependency` in `OGCFeaturesFactory` and `OGCTilesFactory` when using `Endpoints` factory +### changed + +- changed `function_parameters_query` and `properties_filter_query` from dependencies to simple callabe + ## [0.4.2] - 2023-08-24 ### changed diff --git a/tipg/dependencies.py b/tipg/dependencies.py index 1cfc120f..a1f87c1d 100644 --- a/tipg/dependencies.py +++ b/tipg/dependencies.py @@ -15,7 +15,7 @@ from tipg.resources.enums import MediaType from tipg.settings import TMSSettings -from fastapi import Depends, HTTPException, Path, Query +from fastapi import HTTPException, Path, Query from starlette.requests import Request @@ -249,7 +249,7 @@ def properties_query( def properties_filter_query( request: Request, - collection: Annotated[Collection, Depends(CollectionParams)], + collection: Collection, ) -> List[Tuple[str, str]]: """Get properties to filter on excluding reserved keys.""" exclude = [ @@ -339,7 +339,7 @@ def TileParams( def function_parameters_query( # noqa: C901 request: Request, - collection: Annotated[Collection, Depends(CollectionParams)], + collection: Collection, ) -> Dict[str, str]: """Get parameters for function layers.""" function_parameters = {} diff --git a/tipg/factory.py b/tipg/factory.py index 255285f6..c7849cd3 100644 --- a/tipg/factory.py +++ b/tipg/factory.py @@ -4,17 +4,7 @@ import csv import json from dataclasses import dataclass, field -from typing import ( - Any, - Callable, - Dict, - Generator, - Iterable, - List, - Literal, - Optional, - Tuple, -) +from typing import Any, Callable, Dict, Generator, Iterable, List, Literal, Optional from urllib.parse import urlencode import jinja2 @@ -756,12 +746,6 @@ async def items( # noqa: C901 bbox_filter: Annotated[Optional[List[float]], Depends(bbox_query)], datetime_filter: Annotated[Optional[List[str]], Depends(datetime_query)], properties: Annotated[Optional[List[str]], Depends(properties_query)], - properties_filter: Annotated[ - List[Tuple[str, str]], Depends(properties_filter_query) - ], - function_parameters: Annotated[ - Dict[str, str], Depends(function_parameters_query) - ], cql_filter: Annotated[Optional[AstType], Depends(filter_query)], sortby: Annotated[Optional[str], Depends(sortby_query)], geom_column: Annotated[ @@ -824,8 +808,8 @@ async def items( # noqa: C901 ids_filter=ids_filter, bbox_filter=bbox_filter, datetime_filter=datetime_filter, - properties_filter=properties_filter, - function_parameters=function_parameters, + properties_filter=properties_filter_query(request, collection), + function_parameters=function_parameters_query(request, collection), cql_filter=cql_filter, sortby=sortby, properties=properties, @@ -1061,7 +1045,6 @@ async def item( ), ] = None, properties: Optional[List[str]] = Depends(properties_query), - function_parameters: Dict[str, str] = Depends(function_parameters_query), output_type: Annotated[ Optional[MediaType], Depends(ItemsOutputType) ] = None, @@ -1082,7 +1065,7 @@ async def item( simplify=simplify, ids_filter=[itemId], properties=properties, - function_parameters=function_parameters, + function_parameters=function_parameters_query(request, collection), geom=geom_column, dt=datetime_column, geom_as_wkt=geom_as_wkt, @@ -1571,12 +1554,6 @@ async def collection_get_tile( request: Request, collection: Annotated[Collection, Depends(self.collection_dependency)], tile: Annotated[Tile, Depends(TileParams)], - properties_filter: Annotated[ - List[Tuple[str, str]], Depends(properties_filter_query) - ], - function_parameters: Annotated[ - Dict[str, str], Depends(function_parameters_query) - ], tileMatrixSetId: Annotated[ Literal[tuple(self.supported_tms.list())], f"Identifier selecting one of the TileMatrixSetId supported (default: '{tms_settings.default_tms}')", @@ -1622,8 +1599,8 @@ async def collection_get_tile( ids_filter=ids_filter, bbox_filter=bbox_filter, datetime_filter=datetime_filter, - properties_filter=properties_filter, - function_parameters=function_parameters, + properties_filter=properties_filter_query(request, collection), + function_parameters=function_parameters_query(request, collection), cql_filter=cql_filter, sortby=sortby, properties=properties,