Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make colormap an independent dependency #252

Merged
merged 5 commits into from
Mar 5, 2021
Merged

Conversation

vincentsarago
Copy link
Member

@vincentsarago vincentsarago commented Mar 2, 2021

closes #251

This PR tries to simplify how we can register colormaps

from rio_tiler.colormap import cmap

# register new cmap if you want 
# cmap = cmap.register({"above": custom_colormap.above_cmap})

# define a enums with the available cmaps
ColorMapNames = Enum(  # type: ignore
    "ColorMapNames", [(a, a) for a in sorted(cmap.list())]
)

# create a cmap dependency
def ColorMapParams(
    color_map: ColorMapNames = Query(None, description="Colormap name",)
) -> Optional[Dict]:
    """Colormap Dependency."""
    if color_map:
        return cmap.get(color_map.value)
    return None


tiler = TilerFactory(colormap_dependency=ColorMapParams)

To Do

  • write doc

@vincentsarago vincentsarago merged commit f5f56d4 into master Mar 5, 2021
@vincentsarago vincentsarago deleted the colorMapDeps branch March 5, 2021 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

make colormap an independent dependency
2 participants