Skip to content

Commit

Permalink
do not lower case ColorMap Names (#742)
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentsarago authored Oct 4, 2024
1 parent 02d69f6 commit a2302cb
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
26 changes: 26 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,45 @@
# Unreleased

* Enable dynamic definition of Asset **reader** in `MultiBaseReader` (https://github.com/cogeotiff/rio-tiler/pull/711/, https://github.com/cogeotiff/rio-tiler/pull/728)

* Adding `default_assets` for MultiBaseReader and STACReader (author @mccarthyryanc, https://github.com/cogeotiff/rio-tiler/pull/722)

* Adding `default_bands` for MultiBandReader (https://github.com/cogeotiff/rio-tiler/pull/722)

* Adding support for the STAC `Projection` extension to derive the `bounds`, `crs`, `minzoom` and `maxzoom` properties **breaking change**

* Refactor internal function and base classes for the `minzoom/maxzoom` calculation **breaking change**

* Adding `transform`, `height` and `width` attributes (outside init) for `SpatialMixin` class

* Moved `_dst_geom_in_tms_crs` from Reader to `SpatialMixin` class **breaking change**

* Removed use of rasterio's `is_tiled` method

* Enable **Alternate** asset's HREF for STAC by using `RIO_TILER_STAC_ALTERNATE_KEY` environment variable

* Adding support for GDAL VRT Connection string for STAC Assets

* Improve type hint definition

* make `ImageData.rescale` and `ImageData.apply_color_formula` to return `self`

* add support for `.json` colormap files

* do no `lowercase` colormap name in `ColorMaps.get` method **breaking change**

```python
from rio_tiler.colormap import cmap

# before
assert cmap.get("Viridis")

# now
assert cmap.get("Viridis")
>> InvalidColorMapName: Invalid colormap name: Viridis
```


# 6.7.0 (2024-09-05)

* raise `MissingCRS` or `InvalidGeographicBounds` errors when Xarray datasets have wrong geographic metadata
Expand Down
12 changes: 8 additions & 4 deletions rio_tiler/colormap.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def get(self, name: str) -> ColorMapType:
dict: colormap dictionary.
"""
cmap = self.data.get(name.lower(), None)
cmap = self.data.get(name, None)
if cmap is None:
raise InvalidColorMapName(f"Invalid colormap name: {name}")

Expand All @@ -308,7 +308,7 @@ def get(self, name: str) -> ColorMapType:
colormap = numpy.load(cmap)
assert colormap.shape == (256, 4)
assert colormap.dtype == numpy.uint8
return {idx: tuple(value) for idx, value in enumerate(colormap)}
cmap_data = {idx: tuple(value) for idx, value in enumerate(colormap)}

elif cmap.suffix == ".json":
with cmap.open() as f:
Expand All @@ -326,9 +326,13 @@ def get(self, name: str) -> ColorMapType:
for (inter, v) in cmap_data
]

return cmap_data
else:
raise ValueError(f"Not supported {cmap.suffix} extension for ColorMap")

raise ValueError(f"Not supported {cmap.suffix} extension for ColorMap")
# save the numpy array / dict / sequence in the data dict
# avoiding the need to re-load the data
self.data[name] = cmap_data
return cmap_data

return cmap

Expand Down

0 comments on commit a2302cb

Please sign in to comment.