Skip to content

Commit 63565ee

Browse files
committed
abundance feature layer
1 parent 397b6de commit 63565ee

File tree

3 files changed

+67
-7
lines changed

3 files changed

+67
-7
lines changed

app/hooks/map/index.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,7 @@ export function usePUGridLayer({
613613
puExcludedValue,
614614
puAvailableValue,
615615
features = [],
616+
selectedFeatures = [],
616617
preHighlightFeatures = [],
617618
postHighlightFeatures = [],
618619
runId,
@@ -629,6 +630,7 @@ export function usePUGridLayer({
629630
'lock-available': LockAvailableSettings = {},
630631
frequency: FrequencySettings = {},
631632
solution: SolutionSettings = {},
633+
...restLayerSettings
632634
} = settings;
633635

634636
const { opacity: PUgridOpacity = 1, visibility: PUgridVisibility = true } = PUgridSettings;
@@ -765,6 +767,55 @@ export function usePUGridLayer({
765767
],
766768
},
767769
},
770+
// features abundance
771+
...selectedFeatures.map((featureId) => {
772+
const {
773+
visibility = true,
774+
opacity = 1,
775+
amountRange = { min: 50000, max: 1000000 },
776+
} = restLayerSettings[featureId] || {};
777+
778+
return {
779+
type: 'fill',
780+
'source-layer': 'layer0',
781+
layout: {
782+
visibility: getLayerVisibility(visibility),
783+
},
784+
filter: ['all', ['in', featureId, ['get', 'featureList']]],
785+
paint: {
786+
'fill-outline-color': 'yellow',
787+
'fill-color': [
788+
'let',
789+
'ammount',
790+
[
791+
'to-number',
792+
[
793+
'let',
794+
'idx',
795+
['index-of', featureId, ['get', 'featureList']],
796+
[
797+
'slice',
798+
['get', 'featureList'],
799+
['+', ['index-of', ':', ['get', 'featureList'], ['var', 'idx']], 1],
800+
['index-of', ';', ['get', 'featureList'], ['var', 'idx']],
801+
],
802+
],
803+
],
804+
[
805+
'interpolate',
806+
['linear'],
807+
['var', 'ammount'],
808+
amountRange.min,
809+
'white', // ! use COLORS.abundance.default instead when is available
810+
amountRange.max,
811+
'green',
812+
// color, // ! enable the color variable when we receive it
813+
],
814+
],
815+
'fill-opacity': opacity,
816+
},
817+
};
818+
}),
768819
]
769820
: []),
770821

app/hooks/map/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ export interface UsePUGridLayer {
122122
puExcludedValue?: string[];
123123
puAvailableValue?: string[];
124124
runId?: number;
125-
features?: string[];
125+
features?: Feature['id'][];
126+
selectedFeatures?: Feature['id'][];
126127
preHighlightFeatures?: Array<string>;
127128
postHighlightFeatures?: Array<string>;
128129
cost?: {

app/layout/scenarios/edit/map/component.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,15 @@ export const ScenariosEditMap = (): JSX.Element => {
197197
return 'cost';
198198
}
199199

200-
if (tab === TABS['scenario-gap-analysis']) {
201-
return 'features';
202-
}
203-
204-
if ([TABS['scenario-advanced-settings'], TABS['scenario-blm-calibration']].includes(tab)) {
200+
if (
201+
[
202+
TABS['scenario-features'],
203+
TABS['scenario-gap-analysis'],
204+
TABS['scenario-features-targets-spf'],
205+
TABS['scenario-advanced-settings'],
206+
TABS['scenario-blm-calibration'],
207+
].includes(tab)
208+
) {
205209
return 'protection,features';
206210
}
207211

@@ -386,7 +390,10 @@ export const ScenariosEditMap = (): JSX.Element => {
386390
puIncludedValue: [...puIncludedValue, ...puTmpIncludedValue],
387391
puExcludedValue: [...puExcludedValue, ...puTmpExcludedValue],
388392
puAvailableValue: [...puAvailableValue, ...puTmpAvailableValue],
389-
features: featuresIds,
393+
features: [TABS['scenario-features'], TABS['scenario-features-targets-spf']].includes(tab)
394+
? []
395+
: featuresIds,
396+
selectedFeatures,
390397
preHighlightFeatures,
391398
postHighlightFeatures: postHighlightedFeaturesIds,
392399
cost: costSurfaceRangeData,
@@ -402,6 +409,7 @@ export const ScenariosEditMap = (): JSX.Element => {
402409
'lock-available': layerSettings['lock-available'],
403410
frequency: layerSettings.frequency,
404411
solution: layerSettings.solution,
412+
...layerSettings,
405413
},
406414
},
407415
});

0 commit comments

Comments
 (0)