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

Layer freeze #2357

Merged
merged 5 commits into from
Oct 29, 2023
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
1 change: 0 additions & 1 deletion app/src/components/CenterPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<script>
// Utilities
import {
mapGetters,
mapState,
} from 'vuex';
import Map from '@/components/map/Map.vue';
Expand Down
2 changes: 1 addition & 1 deletion app/src/components/DataPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
indicatorObject
&& (appConfig.id === 'gtif' || !indicatorObject.features
|| dataObject || mergedConfigsData[0].customAreaIndicator)
" class="d-flex">
" class="d-flex ma-0">
<!--
<v-col v-if="appConfig.id === 'gtif'"
:cols="$vuetify.breakpoint.mdAndDown || !expanded ? 12 : 6"
Expand Down
22 changes: 22 additions & 0 deletions app/src/components/map/CustomAreaButtons.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,22 @@
</template>
<span>Cancel drawing</span>
</v-tooltip>
<v-tooltip
v-if="freezeLayerButtonVisible"
left
>
<template v-slot:activator="{ on }">
<v-btn
:color="$vuetify.theme.currentTheme.background"
class="pa-0 elevation-0"
v-on="on"
@click="freezeLayer()"
>
<v-icon>mdi-content-duplicate</v-icon>
</v-btn>
</template>
<span>Freeze layer for comparison</span>
</v-tooltip>
</div>
</template>

Expand Down Expand Up @@ -151,6 +167,9 @@ export default {
// enables chart generation
&& (this.drawnLayerVisible);
},
freezeLayerButtonVisible() {
return this.mergedConfigsData.length;
},
deleteButtonVisible() {
return this.drawnArea.area && this.drawToolsVisible;
},
Expand Down Expand Up @@ -214,6 +233,9 @@ export default {
},
},
methods: {
freezeLayer() {
this.$store.dispatch('indicators/freezeCurrentIndicator');
},
drawEnable(tool) {
const { map } = getMapInstance(this.mapId);
this.disableInteractions();
Expand Down
11 changes: 9 additions & 2 deletions app/src/components/map/FilterControls.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
dense
:min="filters[key].min"
:max="filters[key].max"
:step="(filters[key].max-filters[key].min)/100"
:step="filters[key].step || (filters[key].max-filters[key].min)/100"
@input="(evt) => throttledUpdate(evt, filters[key].id)"
>
<template v-slot:prepend>
Expand Down Expand Up @@ -215,7 +215,7 @@
dense
:min="filters[key].min"
:max="filters[key].max"
:step="(filters[key].max-filters[key].min)/100"
:step="filters[key].step || (filters[key].max-filters[key].min)/100"
@input="(evt) => throttledUpdate(evt, filters[key].id)"
>
<template v-slot:prepend>
Expand Down Expand Up @@ -416,6 +416,13 @@ export default {
}
return p;
});
if (this.indicatorCode === 'REP1') {
pars.push('height=200');
} else if (this.indicatorCode === 'REP1_1') {
pars.push('height=100');
} else if (this.indicatorCode === 'REP1_2') {
pars.push('height=50');
}
const id = this.$store.state.features.selectedFeatures[0].id_;
const aoi = `aoi=${id}&`;
const request = baseUrl + aoi + pars.join('&');
Expand Down
40 changes: 40 additions & 0 deletions app/src/components/map/Map.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@
@setMapTime="(time) => dataLayerTime = {value: time}"
@setTimeArray="handleSetTimeArray"
/>
<!-- additional special layer showing frozen indicator-->
<SpecialLayer
v-if="showFrozenLayer"
:mapId="mapId"
:mergedConfigs="mergedConfigsFrozenData"
:options="frozenLayerOptions"
/>
<div
class="d-flex justify-center fill-height"
style="position: absolute; bottom: 0; left: 0;
Expand Down Expand Up @@ -306,6 +313,10 @@ export default {
layerNameMapping() {
return this.baseConfig.layerNameMapping;
},
showFrozenLayer() {
return this.frozenIndicator && this.mergedConfigsFrozenData
&& this.mergedConfigsFrozenData.length;
},
showSpecialLayer() {
return this.mergedConfigsData.length && this.dataLayerName
&& this.indicatorHasMapData(this.indicator);
Expand Down Expand Up @@ -374,6 +385,9 @@ export default {
}
return indicator;
},
frozenIndicator() {
return this.$store.state.indicators.frozenIndicator;
},
featureObject() {
let featureObject = this.$store.state.features.selectedFeature?.indicatorObject;
if (this.currentFeatureObject) {
Expand Down Expand Up @@ -459,6 +473,26 @@ export default {
this.currentTimeIndex,
);
},
mergedConfigsFrozenData() {
const config = createConfigFromIndicator(
this.frozenIndicator,
-1,
);
let resultConfig = null;
// use only first "layer" entry
if (config.length > 0) {
[resultConfig] = config;
resultConfig.name = `${resultConfig.name} (Frozen copy)`;
resultConfig.id = `${resultConfig.id}_frozen`;
// bake in selected time by only passing one time to the frozen indicator
if ('usedTimes' in resultConfig && this.dataLayerTime) {
resultConfig.usedTimes.time = [
this.dataLayerTime.value,
];
}
}
return [resultConfig];
},
currentTimeIndex() {
return this.availableTimeEntries.findIndex((item) => item.name === this.dataLayerTime.name);
},
Expand All @@ -481,6 +515,12 @@ export default {
drawnArea: this.drawnArea,
};
},
frozenLayerOptions() {
return {
dataProp: 'frozenMapData',
frozenLayer: true,
};
},
availableTimeEntries() {
if (this.featureObject && this.featureData && this.featureData.time) {
// merge information from both
Expand Down
6 changes: 6 additions & 0 deletions app/src/components/map/SpecialLayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ export default {
if (this.compare) {
layer.set('name', `${layer.get('name')}_compare`);
}
if (options.frozenLayer) {
// exit early and do not bind any handlers
const dataGroup = map.getLayers().getArray().find((l) => l.get('id') === 'dataGroup');
dataGroup.getLayers().push(layer);
return;
}
// find first feature layer
if (config.features || config.tooltip) {
// initiate hover over functionality optionally for both featureLayer
Expand Down
12 changes: 2 additions & 10 deletions app/src/components/map/VectorTileStyleControl.vue
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
<template>
<v-container fluid>
<v-row align="center">
<v-row align="center"
v-if="queryParameters.items.length > 1">
<v-col cols="6">
<v-subheader>
Data properties
<info-dialog
v-if="select && select.dataInfo && queryParameters.items.length === 1"
:infoSource="select.dataInfo"
/>
<info-dialog
v-if="queryParameters.dataInfo"
:infoSource="queryParameters.dataInfo"
/>
</v-subheader>
</v-col>

<v-col cols="6">
<v-select
v-if="queryParameters.items.length > 1"
v-model="select"
:items="queryParameters.items"
item-text="description"
Expand Down
24 changes: 7 additions & 17 deletions app/src/components/map/WmsStyleControls.vue
Original file line number Diff line number Diff line change
@@ -1,23 +1,9 @@
<template>
<v-container fluid>
<v-row align="center">
<v-col cols="6">
<v-subheader>
Data properties
<info-dialog
v-if="select && select.dataInfo && wmsStyles.items.length === 1"
:infoSource="select.dataInfo"
/>
<info-dialog
v-if="wmsStyles.dataInfo"
:infoSource="wmsStyles.dataInfo"
/>
</v-subheader>
</v-col>

<v-row align="center"
v-if="wmsStyles.items.length > 1">
<v-col cols="6">
<v-select
v-if="wmsStyles.items.length > 1"
v-model="select"
:items="wmsStyles.items"
item-text="description"
Expand All @@ -27,7 +13,11 @@
return-object
single-line
@change="updateMap"
></v-select>
>
<template #append-outer v-if="select && select.dataInfo">
<info-dialog :infoSource="select.dataInfo"/>
</template>
</v-select>
</v-col>
</v-row>
</v-container>
Expand Down
Loading