Skip to content

Commit

Permalink
rename Enums for their singular forms (#261)
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentsarago authored Mar 5, 2021
1 parent ed9f205 commit b5bcb0f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
3 changes: 2 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

**breaking change**

* renamed `OptionalHeaders`, `MimeTypes` and `ImageDrivers` enums to the singular form. (https://github.com/developmentseed/titiler/pull/258)
* renamed `OptionalHeaders`, `MimeTypes` and `ImageDrivers` enums to the singular form (https://github.com/developmentseed/titiler/pull/258)
* renamed titiler.dependencies's Enums (`ColorMapName`, `ResamplingName` and `TileMatrixSetName`) to the singular form (https://github.com/developmentseed/titiler/pull/260)
* renamed `MimeType` to `MediaType` (https://github.com/developmentseed/titiler/pull/258)
* add `ColorMapParams` dependency to ease the creation of custom colormap dependency (https://github.com/developmentseed/titiler/pull/252)
* renamed `PathParams` to `DatasetPathParams` and also made it a simple callable (https://github.com/developmentseed/titiler/pull/260)
Expand Down
22 changes: 11 additions & 11 deletions titiler/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@
################################################################################
# DO NOT UPDATE
# Create ENUMS with all CMAP and TMS for documentation and validation.
ColorMapNames = Enum( # type: ignore
"ColorMapNames", [(a, a) for a in sorted(cmap.list())]
ColorMapName = Enum( # type: ignore
"ColorMapName", [(a, a) for a in sorted(cmap.list())]
)
ResamplingNames = Enum( # type: ignore
"ResamplingNames", [(r.name, r.name) for r in Resampling]
ResamplingName = Enum( # type: ignore
"ResamplingName", [(r.name, r.name) for r in Resampling]
)
WebMercatorTileMatrixSetName = Enum( # type: ignore
"WebMercatorTileMatrixSetName", [("WebMercatorQuad", "WebMercatorQuad")]
)
TileMatrixSetNames = Enum( # type: ignore
"TileMatrixSetNames", [(a, a) for a in sorted(tms.list())]
TileMatrixSetName = Enum( # type: ignore
"TileMatrixSetName", [(a, a) for a in sorted(tms.list())]
)


Expand All @@ -59,8 +59,8 @@ def WebMercatorTMSParams(


def TMSParams(
TileMatrixSetId: TileMatrixSetNames = Query(
TileMatrixSetNames.WebMercatorQuad, # type: ignore
TileMatrixSetId: TileMatrixSetName = Query(
TileMatrixSetName.WebMercatorQuad, # type: ignore
description="TileMatrixSet Name (default: 'WebMercatorQuad')",
)
) -> TileMatrixSet:
Expand All @@ -69,7 +69,7 @@ def TMSParams(


def ColorMapParams(
color_map: ColorMapNames = Query(None, description="Colormap name",)
color_map: ColorMapName = Query(None, description="Colormap name",)
) -> Optional[Dict]:
"""Colormap Dependency."""
if color_map:
Expand Down Expand Up @@ -302,8 +302,8 @@ class DatasetParams(DefaultDependency):
title="Apply internal Scale/Offset",
description="Apply internal Scale/Offset",
)
resampling_method: ResamplingNames = Query(
ResamplingNames.nearest, description="Resampling method." # type: ignore
resampling_method: ResamplingName = Query(
ResamplingName.nearest, description="Resampling method." # type: ignore
)

def __post_init__(self):
Expand Down
4 changes: 2 additions & 2 deletions titiler/endpoints/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
ImageParams,
MetadataParams,
RenderParams,
TileMatrixSetNames,
TileMatrixSetName,
TMSParams,
WebMercatorTMSParams,
)
Expand Down Expand Up @@ -1376,7 +1376,7 @@ class TMSFactory:
"""TileMatrixSet endpoints Factory."""

# Enum of supported TMS
supported_tms: Type[TileMatrixSetNames] = TileMatrixSetNames
supported_tms: Type[TileMatrixSetName] = TileMatrixSetName

# TileMatrixSet dependency
tms_dependency: Callable[..., TileMatrixSet] = TMSParams
Expand Down
4 changes: 2 additions & 2 deletions titiler/endpoints/tms.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""TMS Api."""

from ..dependencies import TileMatrixSetNames, TMSParams
from ..dependencies import TileMatrixSetName, TMSParams
from .factory import TMSFactory

tms = TMSFactory(supported_tms=TileMatrixSetNames, tms_dependency=TMSParams)
tms = TMSFactory(supported_tms=TileMatrixSetName, tms_dependency=TMSParams)
router = tms.router # noqa

0 comments on commit b5bcb0f

Please sign in to comment.