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

Legend updates #23

Merged
merged 8 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions client/src/components/Coloring/ColorSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,17 @@ export default defineComponent({
&& layer.default_style.layers[props.layerType] !== true
) {
(layer.default_style.layers[props.layerType] as VectorLayerDisplayConfig).color = '#888888';
(layer.default_style.layers[props.layerType] as VectorLayerDisplayConfig).legend = false;
}
}
} else {
const { layer } = getVectorLayerDisplayConfig(props.layerId, props.layerType);
if (layer?.default_style?.layers && layer.default_style.layers[props.layerType]) {
if (
layer.default_style.layers[props.layerType] !== false
&& layer.default_style.layers[props.layerType] !== true
) {
(layer.default_style.layers[props.layerType] as VectorLayerDisplayConfig).legend = true;
}
}
}
Expand Down
1 change: 0 additions & 1 deletion client/src/components/DataSelection/Datasets.vue
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ export default defineComponent({
return {
datasets: filteredDatasets,
layersByDataset: MapStore.mapLayersByDataset,
selectedLayers: MapStore.selectedMapLayers,
toggleLayerSelection,
loadDataset,
updateNetCDFLayer,
Expand Down
21 changes: 18 additions & 3 deletions client/src/components/DataSelection/NetCDFDataConfigurator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ export default defineComponent({
const data = getVariableInformation(variable);
if (data) {
if (data.geospatial === 'longitude360') {
if (data.attributes.units === 'degrees_east') {
return [-1 * convert360Longitude(data.max), -1 * convert360Longitude(data.min)];
}
return [convert360Longitude(data.min), convert360Longitude(data.max)];
}
return [data.min, data.max];
Expand All @@ -106,7 +109,11 @@ export default defineComponent({
const dataX = getVariableInformation(newLayerX.value);
let xRange = [dataX.min, dataX.max];
if (dataX.geospatial === 'longitude360') {
xRange = [convert360Longitude(dataX.min), convert360Longitude(dataX.max)];
if (dataX.attributes.units === 'degrees_east') {
xRange = [-1 * convert360Longitude(dataX.max), -1 * convert360Longitude(dataX.min)];
} else {
xRange = [convert360Longitude(dataX.min), convert360Longitude(dataX.max)];
}
}
const dataY = getVariableInformation(newLayerY.value);
const yRange = [dataY.min, dataY.max];
Expand Down Expand Up @@ -142,7 +149,11 @@ export default defineComponent({
const dataX = getVariableInformation(newLayerX.value);
let xRange = [dataX.min, dataX.max];
if (dataX.geospatial === 'longitude360') {
xRange = [convert360Longitude(dataX.min), convert360Longitude(dataX.max)];
if (dataX.attributes.units === 'degrees_east') {
xRange = [-1 * convert360Longitude(dataX.max), -1 * convert360Longitude(dataX.min)];
} else {
xRange = [convert360Longitude(dataX.min), convert360Longitude(dataX.max)];
}
}
const dataY = getVariableInformation(newLayerY.value);

Expand All @@ -168,7 +179,11 @@ export default defineComponent({
xLayerRange.value = [data.min, data.max];
xLayerRangeStep.value = (data.max - data.min) / (data.steps || 1);
if (data.geospatial === 'longitude360') {
xLayerRange.value = [convert360Longitude(data.min), convert360Longitude(data.max)];
if (data.attributes.units === 'degrees_east') {
xLayerRange.value = [-1 * convert360Longitude(data.max), -1 * convert360Longitude(data.min)];
} else {
xLayerRange.value = [convert360Longitude(data.min), convert360Longitude(data.max)];
}
xLayerRangeStep.value = (xLayerRange.value[1] - xLayerRange.value[0]) / (data.steps || 1);
}
});
Expand Down
162 changes: 125 additions & 37 deletions client/src/components/LayerTypeConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,12 @@ export default defineComponent({
return enabled;
});

type LayerActionItems = 'enabled' | 'selectable' | 'hoverable' | 'opacity' | 'zoomMinMax' | 'selectColor' | 'defaultSize' | 'color' | 'text' | 'heatmapControls';
type LayerActionItems = 'enabled' | 'selectable' | 'hoverable' | 'opacity' | 'zoomMinMax' | 'selectColor' | 'defaultSize' | 'legend' | 'color' | 'text' | 'heatmapControls';
const layerActionItemsMap: Record<LayerActionItems, AnnotationTypes[]> = {
enabled: ['line', 'fill', 'circle', 'fill-extrusion', 'text', 'heatmap'],
selectable: ['line', 'fill', 'circle', 'fill-extrusion'],
hoverable: ['line', 'fill', 'circle', 'fill-extrusion'],
legend: ['line', 'fill', 'circle', 'fill-extrusion', 'heatmap'],
opacity: ['line', 'fill', 'circle', 'fill-extrusion', 'text', 'heatmap'],
zoomMinMax: ['line', 'fill', 'circle', 'fill-extrusion', 'text', 'heatmap'],
selectColor: ['line', 'fill', 'circle', 'fill-extrusion'],
Expand All @@ -70,7 +71,7 @@ export default defineComponent({

const actionItemVisible = computed(() => {
const enabledItems = new Set<LayerActionItems>();
const itemList: LayerActionItems[] = ['enabled', 'selectable', 'hoverable', 'opacity', 'zoomMinMax', 'selectColor', 'defaultSize', 'color', 'text', 'heatmapControls'];
const itemList: LayerActionItems[] = ['enabled', 'selectable', 'hoverable', 'legend', 'opacity', 'zoomMinMax', 'selectColor', 'defaultSize', 'color', 'text', 'heatmapControls'];
itemList.forEach((key) => {
if (layerActionItemsMap[key].includes(props.layerType)) {
enabledItems.add(key);
Expand Down Expand Up @@ -98,6 +99,9 @@ export default defineComponent({
if (field === 'hoverable') {
displayConfig.hoverable = val;
}
if (field === 'legend') {
displayConfig.legend = val;
}
if (field === 'opacity') {
if (val) {
displayConfig.opacity = 0.75;
Expand Down Expand Up @@ -232,13 +236,48 @@ export default defineComponent({
const foundColorIndex = found.default_style.savedColors.findIndex((item) => item.name === name);
if (foundColorIndex !== -1) {
currentLayerType.value.color = found.default_style.savedColors[foundColorIndex].color;
if (typeof (currentLayerType.value.color) !== 'string' && currentLayerType.value.color?.type) {
updateLayerTypeField('legend', true);
} else {
updateLayerTypeField('legend', true);
}
updateLayer(found);
}
colorSaveChooser.value = false;
colorDisplayDialog.value = true;
}
}
};

// Static color setting:
const getLayerConfigColor = () => {
const found = MapStore.selectedVectorMapLayers.value.find((item: VectorMapLayer) => item.id === props.layerId);
if (found?.default_style?.layers) {
const layerTypeVal = found?.default_style?.layers[props.layerType];
if (layerTypeVal !== false && layerTypeVal !== true) {
if (layerTypeVal.color === undefined) {
layerTypeVal.color = '#00FF00';
}
return layerTypeVal.color;
}
}
return '#00FF00';
};
const baseColorConfig = computed(() => getLayerConfigColor());

const updateStaticColor = (color: string) => {
const { layer } = getVectorLayerDisplayConfig(props.layerId, props.layerType);
if (layer?.default_style?.layers && layer.default_style.layers[props.layerType]) {
if (
layer.default_style.layers[props.layerType] !== false
&& layer.default_style.layers[props.layerType] !== true
) {
(layer.default_style.layers[props.layerType] as VectorLayerDisplayConfig).color = color;
updateLayer(layer);
}
}
};

return {
currentLayerType,
colorPickerVisible,
Expand All @@ -259,6 +298,8 @@ export default defineComponent({
updateOpacity,
updateZoom,
actionItemVisible,
baseColorConfig,
updateStaticColor,
};
},
});
Expand Down Expand Up @@ -294,6 +335,43 @@ export default defineComponent({
<span class="pl-2">Enabled</span>
</v-col>
</v-row>
<v-row
v-if="actionItemVisible.has('opacity')"
dense
align="center"
justify="center"
>
<v-col cols="2">
<v-tooltip text="Opacity">
<template #activator="{ props }">
<v-icon
class="pl-3"
v-bind="props"
>
mdi-square-opacity
</v-icon>
</template>
</v-tooltip>
</v-col>
<v-col :cols="!valueDisplayCheckbox('opacity') ? '' : 3">
<v-icon @click="updateLayerTypeField('opacity', !valueDisplayCheckbox('opacity'))">
{{
valueDisplayCheckbox('opacity') ? 'mdi-checkbox-marked' : 'mdi-checkbox-blank-outline' }}
</v-icon>
<span v-if="!valueDisplayCheckbox('opacity')" class="pl-2">Opacity</span>
<span v-else class="pl-2" style="font-size:0.85em">{{ currentLayerType.opacity.toFixed(2) }}</span>
</v-col>
<v-col v-if="valueDisplayCheckbox('opacity') && currentLayerType && currentLayerType.opacity !== undefined">
<v-slider
density="compact"
class="opacity-slider"
min="0"
max="1.0"
:model-value="currentLayerType.opacity"
@update:model-value="updateOpacity($event)"
/>
</v-col>
</v-row>
<v-row
v-if="actionItemVisible.has('selectable')"
dense
Expand Down Expand Up @@ -345,7 +423,7 @@ export default defineComponent({
</template>
</v-tooltip>
</v-col>
<v-col cols="8">
<v-col>
<v-icon @click="updateLayerTypeField('selectColor', !valueDisplayCheckbox('selectColor'))">
{{
valueDisplayCheckbox('selectColor') ? 'mdi-checkbox-marked' : 'mdi-checkbox-blank-outline' }}
Expand Down Expand Up @@ -401,79 +479,68 @@ export default defineComponent({
</v-col>
</v-row>
<v-row
v-if="actionItemVisible.has('opacity')"
v-if="actionItemVisible.has('zoomMinMax')"
dense
align="center"
justify="center"
>
<v-col cols="2">
<v-tooltip text="Opacity">
<v-tooltip text="Zoom Min and Zoom max for displaying Feature Type">
<template #activator="{ props }">
<v-icon
class="pl-3"
v-bind="props"
>
mdi-square-opacity
mdi-magnify
</v-icon>
</template>
</v-tooltip>
</v-col>
<v-col :cols="!valueDisplayCheckbox('opacity') ? '' : 3">
<v-icon @click="updateLayerTypeField('opacity', !valueDisplayCheckbox('opacity'))">
<v-col>
<v-icon @click="updateLayerTypeField('zoom', !valueDisplayCheckbox('zoom'))">
{{
valueDisplayCheckbox('opacity') ? 'mdi-checkbox-marked' : 'mdi-checkbox-blank-outline' }}
valueDisplayCheckbox('zoom') ? 'mdi-checkbox-marked' : 'mdi-checkbox-blank-outline' }}
</v-icon>
<span v-if="!valueDisplayCheckbox('opacity')" class="pl-2">Opacity</span>
<span v-else class="pl-2" style="font-size:0.85em">{{ currentLayerType.opacity.toFixed(2) }}</span>
<span class="pl-2">Zoom Min/Max</span>
</v-col>
<v-col v-if="valueDisplayCheckbox('opacity') && currentLayerType && currentLayerType.opacity !== undefined">
<v-slider
<v-col v-if="valueDisplayCheckbox('zoom') && currentLayerType && currentLayerType.zoom !== undefined">
<v-range-slider
density="compact"
class="opacity-slider"
step="1"
height="1"
thumb-size="5"
thumb-label="always"
min="0"
max="1.0"
:model-value="currentLayerType.opacity"
@update:model-value="updateOpacity($event)"
max="24"
:model-value="[currentLayerType.zoom.min || 0, currentLayerType.zoom.max || 24]"
@update:model-value="updateZoom($event)"
/>
</v-col>
</v-row>
<v-row
v-if="actionItemVisible.has('zoomMinMax')"
v-if="actionItemVisible.has('legend')"
dense
align="center"
justify="center"
>
<v-col cols="2">
<v-tooltip text="Zoom Min and Zoom max for displaying Feature Type">
<v-tooltip text="Display Legend">
<template #activator="{ props }">
<v-icon
class="pl-3"
v-bind="props"
>
mdi-magnify
mdi-map-legend
</v-icon>
</template>
</v-tooltip>
</v-col>
<v-col>
<v-icon @click="updateLayerTypeField('zoom', !valueDisplayCheckbox('zoom'))">
<v-icon @click="updateLayerTypeField('legend', !valueDisplayCheckbox('legend'))">
{{
valueDisplayCheckbox('zoom') ? 'mdi-checkbox-marked' : 'mdi-checkbox-blank-outline' }}
valueDisplayCheckbox('legend') ? 'mdi-checkbox-marked' : 'mdi-checkbox-blank-outline' }}
</v-icon>
<span class="pl-2">Zoom Min/Max</span>
</v-col>
<v-col v-if="valueDisplayCheckbox('zoom') && currentLayerType && currentLayerType.zoom !== undefined">
<v-range-slider
density="compact"
step="1"
height="1"
thumb-size="5"
thumb-label="always"
min="0"
max="24"
:model-value="[currentLayerType.zoom.min || 0, currentLayerType.zoom.max || 24]"
@update:model-value="updateZoom($event)"
/>
<span class="pl-2">Legend</span>
</v-col>
</v-row>
<v-row
Expand Down Expand Up @@ -508,7 +575,28 @@ export default defineComponent({
</v-tooltip>
</v-col>
<v-col cols="6">
<span style="font-size: 0.75em"> {{ getColorType() }}</span>
<v-row dense>
<span style="font-size: 0.75em"> {{ getColorType() }}</span>
<span v-if="getColorType() === 'Static Color'" class="ml-2">
<v-menu
:close-on-content-click="false"
offset-y
>
<template #activator="{ props }">
<div
class="color-square"
:style="{ backgroundColor: baseColorConfig }"
v-bind="props"
/>
</template>
<v-color-picker
mode="hex"
:model-value="baseColorConfig"
@update:model-value="updateStaticColor($event)"
/>
</v-menu>
</span>
</v-row>
</v-col>
<v-col>
<v-tooltip text="Edit Color Display">
Expand Down
Loading