Skip to content

Commit 0a4a19f

Browse files
committed
adding suggestions
1 parent 7a5b754 commit 0a4a19f

File tree

4 files changed

+14
-20
lines changed

4 files changed

+14
-20
lines changed

packages/base/src/dialogs/symbology/colorRamps.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IColorRampDefinition } from '@/src/types';
1+
import { ColorRampName, IColorRampDefinition } from '@/src/types';
22

33
export const COLOR_RAMP_DEFINITIONS = {
44
'rainbow-soft': { type: 'Cyclic' },
@@ -57,3 +57,10 @@ export const COLOR_RAMP_DEFINITIONS = {
5757
diff: { type: 'Divergent', criticalValue: 0.5 },
5858
tarn: { type: 'Divergent', criticalValue: 0.5 },
5959
} as const satisfies { [key: string]: IColorRampDefinition };
60+
61+
export const COLOR_RAMP_DEFAULTS: Partial<Record<ColorRampName, number>> = {
62+
hsv: 11,
63+
picnic: 11,
64+
'rainbow-soft': 11,
65+
cubehelix: 16,
66+
};

packages/base/src/dialogs/symbology/components/color_ramp/ColorRampControls.tsx

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,12 @@ import { IDict } from '@jupytergis/schema';
2121
import { Button } from '@jupyterlab/ui-components';
2222
import React, { useEffect, useState } from 'react';
2323

24-
import { COLOR_RAMP_DEFINITIONS } from '@/src/dialogs/symbology/colorRamps';
25-
import { LoadingIcon } from '@/src/shared/components/loading';
2624
import {
25+
COLOR_RAMP_DEFINITIONS,
2726
COLOR_RAMP_DEFAULTS,
28-
ColorRampName,
29-
ClassificationMode,
30-
} from '@/src/types';
27+
} from '@/src/dialogs/symbology/colorRamps';
28+
import { LoadingIcon } from '@/src/shared/components/loading';
29+
import { ColorRampName, ClassificationMode } from '@/src/types';
3130
import ColorRampSelector from './ColorRampSelector';
3231
import { ColorRampValueControls } from './ColorRampValueControls';
3332
import ModeSelectRow from './ModeSelectRow';
@@ -43,7 +42,6 @@ interface IColorRampControlsProps {
4342
setIsLoading: (isLoading: boolean) => void,
4443
minValue: number,
4544
maxValue: number,
46-
criticalValue?: number,
4745
) => void;
4846
showModeRow: boolean;
4947
showRampSelector: boolean;
@@ -143,13 +141,8 @@ const ColorRampControls: React.FC<IColorRampControlsProps> = ({
143141
// Typeguard: This should never happen
144142
return;
145143
}
146-
const scaledCritical =
147-
rampDef.type === 'Divergent' &&
148-
minValue !== undefined &&
149-
maxValue !== undefined
150-
? minValue + rampDef.criticalValue * (maxValue - minValue)
151-
: undefined;
152144

145+
// update shared model symbology state from component state
153146
useEffect(() => {
154147
if (renderType === 'Heatmap') {
155148
return;
@@ -247,7 +240,6 @@ const ColorRampControls: React.FC<IColorRampControlsProps> = ({
247240
setIsLoading,
248241
minValue,
249242
maxValue,
250-
scaledCritical,
251243
);
252244
}}
253245
>

packages/base/src/dialogs/symbology/hooks/useGetSingleBandInfo.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ const useGetSingleBandInfo = (
7171

7272
if (dataMin === undefined || dataMax === undefined) {
7373
// 2. Try smallest overview if available
74+
// A consequence of this method is that we will almost never find the **true** minimum and maximum for the whole raster, as overviews are aggregate data, averaging groups of grid cells to calculate lower-resolution grid cells. However, calculating the minimum and maximum from the entire dataset may be prohibitively expensive on CPU and memory!
7475
const overviewCount = await tiff.getImageCount();
7576
const targetImage =
7677
overviewCount > 1 ? await tiff.getImage(overviewCount - 1) : image;

packages/base/src/types.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,6 @@ export interface IColorMap {
8080

8181
export type ColorRampName = keyof typeof COLOR_RAMP_DEFINITIONS;
8282

83-
export const COLOR_RAMP_DEFAULTS: Partial<Record<ColorRampName, number>> = {
84-
hsv: 11,
85-
picnic: 11,
86-
'rainbow-soft': 11,
87-
cubehelix: 16,
88-
};
8983
const classificationModes = [
9084
'quantile',
9185
'equal interval',

0 commit comments

Comments
 (0)