Skip to content

Commit

Permalink
Update fetch_colormaps shell script, further check "rest" colorMaps c…
Browse files Browse the repository at this point in the history
…ategory
  • Loading branch information
dzole0311 committed Sep 24, 2024
1 parent aad2ce5 commit 556eeec
Show file tree
Hide file tree
Showing 4 changed files with 27,630 additions and 128 deletions.
17 changes: 6 additions & 11 deletions app/scripts/components/common/map/layer-legend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
WidgetItemHGroup
} from '$styles/panel';
import { LayerLegendCategorical, LayerLegendGradient } from '$types/veda';
import { divergingColorMaps, sequentialColorMaps } from '$components/exploration/components/datasets/colorMaps';
import { divergingColorMaps, sequentialColorMaps, restColorMaps } from '$components/exploration/components/datasets/colorMaps';
import { DEFAULT_COLORMAP } from '$components/exploration/components/datasets/colormap-options';

interface LayerLegendCommonProps {
Expand Down Expand Up @@ -348,15 +348,9 @@ export const LayerGradientGraphic = (props: LayerLegendGradient) => {
};

export const LayerGradientColormapGraphic = (props: Omit<LayerLegendGradient, 'stops' | 'type'>) => {
const { colorMap, ...otherProps } = props;
let colormapResult;
const { colorMap = DEFAULT_COLORMAP, ...otherProps } = props;
const colormapResult = findColormapByName(colorMap);

if (colorMap) {
colormapResult = findColormapByName(colorMap);
}
if (!colorMap || !colormapResult) {
colormapResult = findColormapByName(DEFAULT_COLORMAP);
}
const { foundColorMap, isReversed } = colormapResult;
const stops = Object.values(foundColorMap)
.filter(value => Array.isArray(value) && value.length === 4)
Expand All @@ -374,10 +368,11 @@ export const LayerGradientColormapGraphic = (props: Omit<LayerLegendGradient, 's
export const findColormapByName = (name: string) => {
const isReversed = name.toLowerCase().endsWith('_r');
const baseName = isReversed ? name.slice(0, -2).toLowerCase() : name.toLowerCase();
const colormap = sequentialColorMaps[baseName] ?? divergingColorMaps[baseName];
const colormap = sequentialColorMaps[baseName] ?? divergingColorMaps[baseName] ?? restColorMaps[baseName];

if (!colormap) {
return null;
const defaultColormap = sequentialColorMaps[DEFAULT_COLORMAP.toLowerCase()] ?? divergingColorMaps[DEFAULT_COLORMAP.toLowerCase()];
return { foundColorMap: {...defaultColormap}, isReversed: false };
}

return { foundColorMap: {...colormap}, isReversed };
Expand Down
Loading

0 comments on commit 556eeec

Please sign in to comment.