@geode/opengeodeweb-front 10.44.0-rc.6 → 10.44.0-rc.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/components/BasemapAttribution.vue +28 -0
- package/app/components/Viewer/Basemap/CropOptions.vue +50 -0
- package/app/components/Viewer/Basemap/OpacityOptions.vue +52 -0
- package/app/components/Viewer/ContextMenu/ContextMenu.vue +5 -1
- package/app/components/Viewer/ContextMenu/ContextMenuItem.vue +6 -2
- package/app/components/Viewer/ObjectTree/Views/GlobalObjects.vue +49 -10
- package/app/components/Viewer/Ui.vue +6 -0
- package/app/composables/project_manager_helpers/reset.ts +3 -0
- package/app/composables/project_manager_helpers/restore.ts +3 -0
- package/app/composables/project_manager_helpers/types.ts +2 -0
- package/app/composables/viewer_context_menu.ts +10 -0
- package/app/stores/basemap.ts +52 -0
- package/app/stores/basemap_detail.ts +51 -0
- package/app/stores/basemap_helpers/builds.ts +158 -0
- package/app/stores/basemap_helpers/detail_layers.ts +72 -0
- package/app/stores/basemap_helpers/detail_map.ts +62 -0
- package/app/stores/basemap_helpers/detail_refresh.ts +134 -0
- package/app/stores/basemap_helpers/detail_view.ts +94 -0
- package/app/stores/basemap_helpers/extent.ts +40 -0
- package/app/stores/basemap_helpers/georeferenced.ts +50 -0
- package/app/stores/basemap_helpers/layers.ts +66 -0
- package/app/stores/basemap_helpers/settings.ts +87 -0
- package/app/stores/basemap_helpers/viewer.ts +114 -0
- package/app/stores/menu_helpers/basemap.ts +10 -0
- package/app/stores/menu_helpers/menus_data.ts +2 -0
- package/app/utils/basemap_tree.ts +76 -0
- package/app/utils/treeview.ts +12 -1
- package/app/utils/visible_map_area.ts +129 -0
- package/internal/stores/hybrid_viewer/vtk_types.ts +2 -1
- package/package.json +1 -1
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { useBasemapStore } from "@ogw_front/stores/basemap";
|
|
3
|
+
|
|
4
|
+
const basemapStore = useBasemapStore();
|
|
5
|
+
// A hidden basemap stays built: its attribution goes with its maps
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<template>
|
|
9
|
+
<span
|
|
10
|
+
v-if="basemapStore.attribution && basemapStore.maps.length > 0"
|
|
11
|
+
data-testid="basemapAttribution"
|
|
12
|
+
class="basemap-attribution text-caption text-medium-emphasis px-1"
|
|
13
|
+
>
|
|
14
|
+
{{ basemapStore.attribution }}
|
|
15
|
+
</span>
|
|
16
|
+
</template>
|
|
17
|
+
|
|
18
|
+
<style scoped>
|
|
19
|
+
.basemap-attribution {
|
|
20
|
+
position: absolute;
|
|
21
|
+
left: 8px;
|
|
22
|
+
bottom: 4px;
|
|
23
|
+
z-index: 1;
|
|
24
|
+
background: rgba(var(--v-theme-surface), 0.6);
|
|
25
|
+
border-radius: 4px;
|
|
26
|
+
pointer-events: none;
|
|
27
|
+
}
|
|
28
|
+
</style>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { MAP_STYLES, mapStyleOf } from "@ogw_front/utils/basemap_tree";
|
|
3
|
+
import ViewerContextMenuItem, {
|
|
4
|
+
type ItemProps,
|
|
5
|
+
} from "@ogw_front/components/Viewer/ContextMenu/ContextMenuItem.vue";
|
|
6
|
+
import { useBasemapStore } from "@ogw_front/stores/basemap";
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
itemProps: ItemProps & { index: number };
|
|
10
|
+
tooltip?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const { itemProps, tooltip = "Crop to data" } = defineProps<Props>();
|
|
14
|
+
const basemapStore = useBasemapStore();
|
|
15
|
+
// A map menu crops that map, the basemap category menu crops every map
|
|
16
|
+
const mapStyles = computed(() => {
|
|
17
|
+
const mapStyle = mapStyleOf(itemProps.id);
|
|
18
|
+
if (mapStyle === undefined) {
|
|
19
|
+
return MAP_STYLES;
|
|
20
|
+
}
|
|
21
|
+
return [mapStyle];
|
|
22
|
+
});
|
|
23
|
+
// Cropped: only the map draped on the top surfaces, without the flat map around
|
|
24
|
+
const cropped = computed(() => mapStyles.value.map((mapStyle) => basemapStore.crop[mapStyle]));
|
|
25
|
+
const indeterminate = computed(() => new Set(cropped.value).size > 1);
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<template>
|
|
29
|
+
<ViewerContextMenuItem
|
|
30
|
+
data-testid="basemapCropMenu"
|
|
31
|
+
:index="itemProps.index"
|
|
32
|
+
:itemProps="itemProps"
|
|
33
|
+
:tooltip="tooltip"
|
|
34
|
+
btnIcon="mdi-panorama-outline"
|
|
35
|
+
>
|
|
36
|
+
<template #options>
|
|
37
|
+
<v-switch
|
|
38
|
+
:model-value="!indeterminate && cropped.every(Boolean)"
|
|
39
|
+
:indeterminate="indeterminate"
|
|
40
|
+
label="Crop to data"
|
|
41
|
+
data-testid="basemapCrop"
|
|
42
|
+
density="compact"
|
|
43
|
+
color="primary"
|
|
44
|
+
hide-details
|
|
45
|
+
class="px-1"
|
|
46
|
+
@update:model-value="(value) => basemapStore.setCrop(Boolean(value), mapStyles)"
|
|
47
|
+
/>
|
|
48
|
+
</template>
|
|
49
|
+
</ViewerContextMenuItem>
|
|
50
|
+
</template>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import ViewerContextMenuItem, {
|
|
3
|
+
type ItemProps,
|
|
4
|
+
} from "@ogw_front/components/Viewer/ContextMenu/ContextMenuItem.vue";
|
|
5
|
+
import { mapStyleOf } from "@ogw_front/utils/basemap_tree";
|
|
6
|
+
import { useBasemapStore } from "@ogw_front/stores/basemap";
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
itemProps: ItemProps & { index: number };
|
|
10
|
+
tooltip?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const { itemProps, tooltip = "Opacity" } = defineProps<Props>();
|
|
14
|
+
const basemapStore = useBasemapStore();
|
|
15
|
+
const PERCENT = 100;
|
|
16
|
+
const mapStyle = computed(() => mapStyleOf(itemProps.id));
|
|
17
|
+
// The slider works in percent, the store in 0..1
|
|
18
|
+
const opacityPercent = computed({
|
|
19
|
+
get: () => Math.round((mapStyle.value ? basemapStore.opacities[mapStyle.value] : 1) * PERCENT),
|
|
20
|
+
set: (value: number) => {
|
|
21
|
+
if (mapStyle.value) {
|
|
22
|
+
void basemapStore.setOpacity(mapStyle.value, value / PERCENT);
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<template>
|
|
29
|
+
<ViewerContextMenuItem
|
|
30
|
+
data-testid="basemapOpacityMenu"
|
|
31
|
+
:index="itemProps.index"
|
|
32
|
+
:itemProps="itemProps"
|
|
33
|
+
:tooltip="tooltip"
|
|
34
|
+
btnIcon="mdi-circle-half-full"
|
|
35
|
+
>
|
|
36
|
+
<template #options>
|
|
37
|
+
<div class="d-flex align-center ga-2 px-1">
|
|
38
|
+
<v-slider
|
|
39
|
+
v-model="opacityPercent"
|
|
40
|
+
data-testid="basemapOpacity"
|
|
41
|
+
:min="10"
|
|
42
|
+
:max="100"
|
|
43
|
+
:step="5"
|
|
44
|
+
density="compact"
|
|
45
|
+
color="primary"
|
|
46
|
+
hide-details
|
|
47
|
+
/>
|
|
48
|
+
<span class="text-caption text-right" style="min-width: 4ch">{{ opacityPercent }}%</span>
|
|
49
|
+
</div>
|
|
50
|
+
</template>
|
|
51
|
+
</ViewerContextMenuItem>
|
|
52
|
+
</template>
|
|
@@ -196,7 +196,11 @@ function toggleShowName(): void {
|
|
|
196
196
|
@click="toggleShowName"
|
|
197
197
|
/>
|
|
198
198
|
|
|
199
|
-
<InfoCard
|
|
199
|
+
<InfoCard
|
|
200
|
+
v-if="meta_data.viewer_type !== 'basemap'"
|
|
201
|
+
v-model:show="showName"
|
|
202
|
+
:meta-data="meta_data"
|
|
203
|
+
/>
|
|
200
204
|
</div>
|
|
201
205
|
</div>
|
|
202
206
|
</v-menu>
|
|
@@ -27,10 +27,12 @@ interface Props {
|
|
|
27
27
|
index: number;
|
|
28
28
|
itemProps: ItemProps;
|
|
29
29
|
tooltip: string;
|
|
30
|
-
|
|
30
|
+
// An image, or an mdi icon name
|
|
31
|
+
btnImage?: string;
|
|
32
|
+
btnIcon?: string;
|
|
31
33
|
}
|
|
32
34
|
|
|
33
|
-
const { index, itemProps, tooltip, btnImage } = defineProps<Props>();
|
|
35
|
+
const { index, itemProps, tooltip, btnImage = "", btnIcon = "" } = defineProps<Props>();
|
|
34
36
|
|
|
35
37
|
const buttonCoords = computed(() => {
|
|
36
38
|
const angle = (index / itemProps.totalItems) * 2 * Math.PI;
|
|
@@ -155,7 +157,9 @@ export type { ItemProps };
|
|
|
155
157
|
elevation="2"
|
|
156
158
|
:style="computedItemStyles"
|
|
157
159
|
>
|
|
160
|
+
<v-icon v-if="btnIcon" :icon="btnIcon" size="28" />
|
|
158
161
|
<v-img
|
|
162
|
+
v-else
|
|
159
163
|
:src="btnImage"
|
|
160
164
|
height="28"
|
|
161
165
|
width="28"
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
// oxlint-disable max-dependencies
|
|
2
3
|
import {
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
type MapStyle,
|
|
5
|
+
basemapGroup,
|
|
6
|
+
isBasemapId,
|
|
7
|
+
mapId,
|
|
8
|
+
nextBasemapMaps,
|
|
9
|
+
} from "@ogw_front/utils/basemap_tree";
|
|
10
|
+
import { type TreeMenuPayload, compareSelections } from "@ogw_front/utils/treeview";
|
|
7
11
|
import CommonTreeView from "@ogw_front/components/Viewer/ObjectTree/Base/CommonTreeView.vue";
|
|
8
12
|
import type { DisplayItem } from "@ogw_front/composables/virtual_tree";
|
|
9
13
|
import ObjectTreeControls from "@ogw_front/components/Viewer/ObjectTree/Base/Controls.vue";
|
|
10
14
|
import ObjectTreeItemLabel from "@ogw_front/components/Viewer/ObjectTree/Base/ItemLabel.vue";
|
|
15
|
+
import { useBasemapStore } from "@ogw_front/stores/basemap";
|
|
11
16
|
import { useDataStore } from "@ogw_front/stores/data";
|
|
12
17
|
import { useDataStyleStore } from "@ogw_front/stores/data_style";
|
|
13
18
|
import { useHoverhighlight } from "@ogw_front/composables/hover_highlight";
|
|
@@ -19,10 +24,11 @@ const treeviewStore = useTreeviewStore();
|
|
|
19
24
|
const dataStore = useDataStore();
|
|
20
25
|
const dataStyleStore = useDataStyleStore();
|
|
21
26
|
const hybridViewerStore = useHybridViewerStore();
|
|
27
|
+
const basemapStore = useBasemapStore();
|
|
22
28
|
const { onHoverEnter, onHoverLeave } = useHoverhighlight();
|
|
23
29
|
|
|
24
30
|
interface Emits {
|
|
25
|
-
"show-menu": [payload:
|
|
31
|
+
"show-menu": [payload: TreeMenuPayload];
|
|
26
32
|
}
|
|
27
33
|
|
|
28
34
|
const emit = defineEmits<Emits>();
|
|
@@ -53,11 +59,40 @@ const {
|
|
|
53
59
|
applySearchFilter,
|
|
54
60
|
} = useTreeFilter(() => treeviewStore.items, { recursiveSort: true });
|
|
55
61
|
|
|
62
|
+
// The basemap category comes first, out of the data sort and filters
|
|
63
|
+
const displayedItems = computed(() => {
|
|
64
|
+
if (!basemapStore.available) {
|
|
65
|
+
return processedItems.value;
|
|
66
|
+
}
|
|
67
|
+
return [basemapGroup(), ...processedItems.value];
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// The basemap rows show the basemap state: they are never stored in the data selection
|
|
71
|
+
const basemapRows = computed<string[]>(() => basemapStore.maps.map((mapStyle) => mapId(mapStyle)));
|
|
72
|
+
|
|
73
|
+
async function showBasemap(maps: MapStyle[]): Promise<void> {
|
|
74
|
+
try {
|
|
75
|
+
await basemapStore.setMaps(maps);
|
|
76
|
+
} catch {
|
|
77
|
+
// Already reported by the request feedback
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Basemap rows are never filtered out by the search
|
|
56
82
|
function onUpdateSelection(val: string[]): void {
|
|
57
|
-
|
|
83
|
+
const { added, removed } = compareSelections(val, basemapRows.value);
|
|
84
|
+
const maps = nextBasemapMaps(basemapStore.maps, basemapStore.shown, added, removed);
|
|
85
|
+
if (maps.join(",") !== basemapStore.maps.join(",")) {
|
|
86
|
+
void showBasemap(maps);
|
|
87
|
+
}
|
|
88
|
+
const data = val.filter((id) => !isBasemapId(id));
|
|
89
|
+
treeviewStore.selection = applySearchFilter(data, treeviewStore.selection);
|
|
58
90
|
}
|
|
59
91
|
|
|
60
|
-
const visibleSelection = computed<string[]>(() =>
|
|
92
|
+
const visibleSelection = computed<string[]>(() => [
|
|
93
|
+
...applySearchFilter(treeviewStore.selection, []),
|
|
94
|
+
...basemapRows.value,
|
|
95
|
+
]);
|
|
61
96
|
|
|
62
97
|
watch(
|
|
63
98
|
() => treeviewStore.selection,
|
|
@@ -88,6 +123,10 @@ watch(
|
|
|
88
123
|
|
|
89
124
|
function showMenu(event: MouseEvent, item: TreeGroupItem): void {
|
|
90
125
|
const actualItem = item.raw || item;
|
|
126
|
+
if (isBasemapId(actualItem.id)) {
|
|
127
|
+
emit("show-menu", { event, itemId: actualItem.id, context_type: "basemap" });
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
91
130
|
if (!actualItem.children) {
|
|
92
131
|
emit("show-menu", { event, itemId: actualItem.id });
|
|
93
132
|
return;
|
|
@@ -155,7 +194,7 @@ function expandAll(): void {
|
|
|
155
194
|
}
|
|
156
195
|
}
|
|
157
196
|
}
|
|
158
|
-
traverse(
|
|
197
|
+
traverse(displayedItems.value);
|
|
159
198
|
opened.value = allIds;
|
|
160
199
|
}
|
|
161
200
|
</script>
|
|
@@ -177,7 +216,7 @@ function expandAll(): void {
|
|
|
177
216
|
:selected="visibleSelection"
|
|
178
217
|
v-model:opened="opened"
|
|
179
218
|
v-model:active="treeviewStore.activeItems"
|
|
180
|
-
:items="
|
|
219
|
+
:items="displayedItems"
|
|
181
220
|
:options="{
|
|
182
221
|
selection: { selectable: true },
|
|
183
222
|
search,
|
|
@@ -198,7 +237,7 @@ function expandAll(): void {
|
|
|
198
237
|
<ObjectTreeItemLabel
|
|
199
238
|
:item="item as unknown as DisplayItem"
|
|
200
239
|
:is-leaf="isLeaf"
|
|
201
|
-
:show-crs="isLeaf"
|
|
240
|
+
:show-crs="isLeaf && !isBasemapId(item.id as string)"
|
|
202
241
|
@contextmenu="showMenu($event, item as unknown as TreeGroupItem)"
|
|
203
242
|
/>
|
|
204
243
|
</template>
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
type ViewerIdResult,
|
|
4
4
|
useOverlappingPicker,
|
|
5
5
|
} from "@ogw_front/composables/use_overlapping_picker";
|
|
6
|
+
import BasemapAttribution from "@ogw_front/components/BasemapAttribution.vue";
|
|
6
7
|
import OverlappingObjectsPicker from "@ogw_front/components/Viewer/OverlappingObjectsPicker.vue";
|
|
7
8
|
import ProjectCrs from "@ogw_front/components/ProjectCrs.vue";
|
|
8
9
|
import ToolActiveChip from "@ogw_front/components/Viewer/ToolActiveChip.vue";
|
|
@@ -10,6 +11,7 @@ import type { TreeMenuPayload } from "@ogw_front/utils/treeview";
|
|
|
10
11
|
import ViewerContextMenu from "@ogw_front/components/Viewer/ContextMenu/ContextMenu.vue";
|
|
11
12
|
import ViewerObjectTreeLayout from "@ogw_front/components/Viewer/ObjectTree/Layout.vue";
|
|
12
13
|
import { getCurrentInstance } from "vue";
|
|
14
|
+
import { useBasemapDetailStore } from "@ogw_front/stores/basemap_detail";
|
|
13
15
|
import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
|
|
14
16
|
import { useMenuStore } from "@ogw_front/stores/menu";
|
|
15
17
|
import { useViewerStore } from "@ogw_front/stores/viewer";
|
|
@@ -28,6 +30,8 @@ const emit = defineEmits<{
|
|
|
28
30
|
const menuStore = useMenuStore();
|
|
29
31
|
const viewerStore = useViewerStore();
|
|
30
32
|
const hybridViewerStore = useHybridViewerStore();
|
|
33
|
+
// The sharper map of the visible area follows the camera of this viewer
|
|
34
|
+
useBasemapDetailStore();
|
|
31
35
|
|
|
32
36
|
const hoverHighlightLabel = computed(
|
|
33
37
|
() =>
|
|
@@ -109,6 +113,8 @@ defineExpose({ get_viewer_id });
|
|
|
109
113
|
|
|
110
114
|
<ProjectCrs />
|
|
111
115
|
|
|
116
|
+
<BasemapAttribution />
|
|
117
|
+
|
|
112
118
|
<OverlappingObjectsPicker
|
|
113
119
|
:display-intermediate="displayIntermediate"
|
|
114
120
|
:intermediate-items="intermediateItems"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_typed_schemas.js";
|
|
2
2
|
|
|
3
3
|
import { releaseViewerDatabase } from "@ogw_front/composables/project_manager_helpers/viewer_session";
|
|
4
|
+
import { useBasemapStore } from "@ogw_front/stores/basemap";
|
|
4
5
|
import { useCrsStore } from "@ogw_front/stores/crs";
|
|
5
6
|
import { useDataStore } from "@ogw_front/stores/data";
|
|
6
7
|
import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
|
|
@@ -14,6 +15,7 @@ async function resetProject(): Promise<void> {
|
|
|
14
15
|
const treeviewStore = useTreeviewStore();
|
|
15
16
|
const hybridViewerStore = useHybridViewerStore();
|
|
16
17
|
const crsStore = useCrsStore();
|
|
18
|
+
const basemapStore = useBasemapStore();
|
|
17
19
|
|
|
18
20
|
await viewerStore.ws_connect();
|
|
19
21
|
|
|
@@ -26,6 +28,7 @@ async function resetProject(): Promise<void> {
|
|
|
26
28
|
await dataStore.clear();
|
|
27
29
|
hybridViewerStore.clear();
|
|
28
30
|
crsStore.reset();
|
|
31
|
+
basemapStore.reset();
|
|
29
32
|
}
|
|
30
33
|
|
|
31
34
|
export { resetProject };
|
|
@@ -2,6 +2,7 @@ import type { ProjectSnapshot } from "@ogw_front/composables/project_manager_hel
|
|
|
2
2
|
import { importProjectToViewer } from "@ogw_front/composables/project_manager_helpers/viewer_session";
|
|
3
3
|
import { importWorkflowFromSnapshot } from "@ogw_front/utils/import_workflow";
|
|
4
4
|
import { oldestCrs } from "@ogw_front/utils/crs";
|
|
5
|
+
import { useBasemapStore } from "@ogw_front/stores/basemap";
|
|
5
6
|
import { useCrsStore } from "@ogw_front/stores/crs";
|
|
6
7
|
import { useDataStore } from "@ogw_front/stores/data";
|
|
7
8
|
import { useDataStyleStore } from "@ogw_front/stores/data_style";
|
|
@@ -28,6 +29,7 @@ async function restoreProject(snapshot: ProjectSnapshot): Promise<void> {
|
|
|
28
29
|
const dataStore = useDataStore();
|
|
29
30
|
const treeviewStore = useTreeviewStore();
|
|
30
31
|
const hybridViewerStore = useHybridViewerStore();
|
|
32
|
+
const basemapStore = useBasemapStore();
|
|
31
33
|
|
|
32
34
|
treeviewStore.isImporting = true;
|
|
33
35
|
|
|
@@ -42,6 +44,7 @@ async function restoreProject(snapshot: ProjectSnapshot): Promise<void> {
|
|
|
42
44
|
const items = snapshot.data?.items ?? [];
|
|
43
45
|
await importWorkflowFromSnapshot(items);
|
|
44
46
|
restoreCrs(snapshot);
|
|
47
|
+
await basemapStore.importStores(snapshot.basemap);
|
|
45
48
|
await hybridViewerStore.importStores(snapshot.hybridViewer);
|
|
46
49
|
if (snapshot.dataStyle !== undefined) {
|
|
47
50
|
await dataStyleStore.importStores(snapshot.dataStyle);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ModelComponentRelationRecord, NewDataItem } from "@ogw_front/stores/data";
|
|
2
|
+
import type { BasemapSnapshot } from "@ogw_front/stores/basemap";
|
|
2
3
|
import type { CRSList } from "@geode/opengeodeweb-back/opengeodeweb_back_typed_schemas.js";
|
|
3
4
|
import type { CameraSnapshot } from "@ogw_internal/stores/hybrid_viewer/camera";
|
|
4
5
|
import type { DataStyleSnapshot } from "@ogw_front/stores/data_style";
|
|
@@ -17,6 +18,7 @@ interface ProjectSnapshot {
|
|
|
17
18
|
hybridViewer?: CameraSnapshot;
|
|
18
19
|
dataStyle?: DataStyleSnapshot;
|
|
19
20
|
crs?: { projectCrs?: CRSList };
|
|
21
|
+
basemap?: BasemapSnapshot;
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
export type { ProjectSnapshot };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type MenuMetaData, useMenuStore } from "@ogw_front/stores/menu";
|
|
2
2
|
import type { Ref, ShallowRef } from "vue";
|
|
3
|
+
import { BASEMAP_GROUP_ID } from "@ogw_front/utils/basemap_tree";
|
|
3
4
|
import type { TreeMenuPayload } from "@ogw_front/utils/treeview";
|
|
4
5
|
import type { ViewerIdResult } from "@ogw_front/composables/use_overlapping_picker";
|
|
5
6
|
import { useDataStore } from "@ogw_front/stores/data";
|
|
@@ -18,6 +19,15 @@ async function treeMenuTarget(
|
|
|
18
19
|
dataStore: ReturnType<typeof useDataStore>,
|
|
19
20
|
payload: TreeMenuPayload,
|
|
20
21
|
): Promise<MenuTarget | undefined> {
|
|
22
|
+
if (payload.context_type === "basemap") {
|
|
23
|
+
return {
|
|
24
|
+
id: payload.itemId,
|
|
25
|
+
meta_data: {
|
|
26
|
+
viewer_type: "basemap",
|
|
27
|
+
geode_object_type: payload.itemId === BASEMAP_GROUP_ID ? "Basemap" : "Map",
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
21
31
|
if (payload.context_type === "geode_object_type") {
|
|
22
32
|
const [referenceId] = payload.targetIds;
|
|
23
33
|
if (referenceId === undefined) {
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { useBasemapBuilds } from "./basemap_helpers/builds.js";
|
|
2
|
+
import { useBasemapLayers } from "./basemap_helpers/layers.js";
|
|
3
|
+
import { useBasemapSettings } from "./basemap_helpers/settings.js";
|
|
4
|
+
import { useDebounceFn } from "@vueuse/core";
|
|
5
|
+
import { useGeoreferenced } from "./basemap_helpers/georeferenced.js";
|
|
6
|
+
|
|
7
|
+
const REBUILD_DELAY_MILLISECONDS = 500;
|
|
8
|
+
|
|
9
|
+
export const useBasemapStore = defineStore("basemap", () => {
|
|
10
|
+
const { available, georeferencedIds, dataBounds, dataKey } = useGeoreferenced();
|
|
11
|
+
const layers = useBasemapLayers(georeferencedIds);
|
|
12
|
+
const { shown, maps, opacities, crop, layersParams, applyLayers, applyBasemap } = layers;
|
|
13
|
+
const { basemapId, grid, attribution, rebuild, reset } = useBasemapBuilds(layers, dataBounds);
|
|
14
|
+
const settings = useBasemapSettings(layers, basemapId, rebuild);
|
|
15
|
+
const { setMaps, setOpacity, setCrop, exportStores, importStores } = settings;
|
|
16
|
+
|
|
17
|
+
const scheduleRebuild = useDebounceFn(() => {
|
|
18
|
+
void rebuild();
|
|
19
|
+
}, REBUILD_DELAY_MILLISECONDS);
|
|
20
|
+
// Rebuilt when the georeferenced data or their extent change: data added, removed, converted,
|
|
21
|
+
// Aligned, or displayed after a project import
|
|
22
|
+
watch(dataKey, () => {
|
|
23
|
+
// A hidden basemap would be out of date once shown again: the rebuild removes it
|
|
24
|
+
if (maps.value.length > 0 || basemapId.value !== undefined) {
|
|
25
|
+
void scheduleRebuild();
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
maps,
|
|
31
|
+
shown,
|
|
32
|
+
opacities,
|
|
33
|
+
crop,
|
|
34
|
+
basemapId,
|
|
35
|
+
grid,
|
|
36
|
+
attribution,
|
|
37
|
+
available,
|
|
38
|
+
setMaps,
|
|
39
|
+
setOpacity,
|
|
40
|
+
setCrop,
|
|
41
|
+
rebuild,
|
|
42
|
+
reset,
|
|
43
|
+
layersParams,
|
|
44
|
+
applyLayers,
|
|
45
|
+
applyBasemap,
|
|
46
|
+
exportStores,
|
|
47
|
+
importStores,
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
export type { BasemapSnapshot } from "./basemap_helpers/settings.js";
|
|
52
|
+
export type { MapStyle } from "@ogw_front/utils/basemap_tree";
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useBasemapStore } from "@ogw_front/stores/basemap";
|
|
2
|
+
import { useDetailLayers } from "./basemap_helpers/detail_layers.js";
|
|
3
|
+
import { useDetailMap } from "./basemap_helpers/detail_map.js";
|
|
4
|
+
import { useDetailRefresh } from "./basemap_helpers/detail_refresh.js";
|
|
5
|
+
import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
|
|
6
|
+
|
|
7
|
+
// When the camera rests, the visible area of the basemap at the zoom of the screen
|
|
8
|
+
export const useBasemapDetailStore = defineStore("basemapDetail", () => {
|
|
9
|
+
const basemapStore = useBasemapStore();
|
|
10
|
+
const hybridViewerStore = useHybridViewerStore();
|
|
11
|
+
const detail = useDetailMap();
|
|
12
|
+
const { detailId, newRefresh, forget, clear } = detail;
|
|
13
|
+
const layers = useDetailLayers(detail);
|
|
14
|
+
const { scheduleRefresh, onCameraChange } = useDetailRefresh(detail, layers);
|
|
15
|
+
|
|
16
|
+
watch(() => hybridViewerStore.camera_options, onCameraChange, { deep: true });
|
|
17
|
+
watch(
|
|
18
|
+
() => hybridViewerStore.is_moving,
|
|
19
|
+
(moving) => {
|
|
20
|
+
if (moving) {
|
|
21
|
+
// The result of a refresh started before the move is obsolete
|
|
22
|
+
newRefresh();
|
|
23
|
+
} else {
|
|
24
|
+
scheduleRefresh();
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
);
|
|
28
|
+
// A new base (data changed, maps rebuilt) drops the detail, then a new one is built for it
|
|
29
|
+
// Once the camera rests
|
|
30
|
+
watch(
|
|
31
|
+
() => basemapStore.basemapId,
|
|
32
|
+
async (id) => {
|
|
33
|
+
await clear();
|
|
34
|
+
if (id !== undefined) {
|
|
35
|
+
scheduleRefresh();
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
);
|
|
39
|
+
watch(() => JSON.stringify(basemapStore.layersParams()), layers.syncLayers);
|
|
40
|
+
// A detail dropped for a missing map, or built while the maps changed, is built again
|
|
41
|
+
watch(() => basemapStore.maps.join(","), scheduleRefresh);
|
|
42
|
+
|
|
43
|
+
// A new project: the viewer and the back are already cleared, nothing is requested
|
|
44
|
+
basemapStore.$onAction(({ name }) => {
|
|
45
|
+
if (name === "reset") {
|
|
46
|
+
forget();
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
return { detailId };
|
|
51
|
+
});
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { type MapStyle, sortedMaps } from "@ogw_front/utils/basemap_tree";
|
|
2
|
+
import back_schemas, {
|
|
3
|
+
type BasemapBuildResponse,
|
|
4
|
+
type CRSList,
|
|
5
|
+
} from "@geode/opengeodeweb-back/opengeodeweb_back_typed_schemas.js";
|
|
6
|
+
import { ignoreError, useBasemapViewer } from "./viewer.js";
|
|
7
|
+
import type { BasemapLayers } from "./layers.js";
|
|
8
|
+
import type { Extent } from "./extent.js";
|
|
9
|
+
import type { Ref } from "vue";
|
|
10
|
+
import { useBackStore } from "@ogw_front/stores/back";
|
|
11
|
+
import { useCrsStore } from "@ogw_front/stores/crs";
|
|
12
|
+
import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
|
|
13
|
+
|
|
14
|
+
// The grid of the basemap shown, and the height it lies at
|
|
15
|
+
interface BasemapGrid extends Pick<BasemapBuildResponse, "bounds" | "columns" | "zoom"> {
|
|
16
|
+
z: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface BasemapBuilds {
|
|
20
|
+
basemapId: Ref<string | undefined>;
|
|
21
|
+
grid: Ref<BasemapGrid | undefined>;
|
|
22
|
+
attribution: Ref<string | undefined>;
|
|
23
|
+
rebuild: () => Promise<void>;
|
|
24
|
+
reset: () => void;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const BASEMAP_NAME = "basemap";
|
|
28
|
+
|
|
29
|
+
// The basemap downloaded for the visible maps around the data, one build replacing the other
|
|
30
|
+
// oxlint-disable max-lines-per-function, max-statements
|
|
31
|
+
function useBasemapBuilds(
|
|
32
|
+
layers: BasemapLayers,
|
|
33
|
+
dataBounds: () => Extent | undefined,
|
|
34
|
+
): BasemapBuilds {
|
|
35
|
+
const { maps, hidden, built, layersParams, applyLayers, applyBasemap } = layers;
|
|
36
|
+
const backStore = useBackStore();
|
|
37
|
+
const crsStore = useCrsStore();
|
|
38
|
+
const hybridViewerStore = useHybridViewerStore();
|
|
39
|
+
const { discardMap } = useBasemapViewer();
|
|
40
|
+
const basemapId = ref<string | undefined>(undefined);
|
|
41
|
+
// The detail store compares its resolution with the screen
|
|
42
|
+
const grid = ref<BasemapGrid | undefined>(undefined);
|
|
43
|
+
const attribution = ref<string | undefined>(undefined);
|
|
44
|
+
// Each build gets a number: a build finishing after a newer one started is discarded
|
|
45
|
+
let lastBuild = 0;
|
|
46
|
+
// Builds up to this number belong to a project the viewer and the back already cleared
|
|
47
|
+
let lastBuildOfPreviousProject = 0;
|
|
48
|
+
// The maps of the basemap shown: a build that fails or is superseded gives them back
|
|
49
|
+
let shownMaps: MapStyle[] = [];
|
|
50
|
+
|
|
51
|
+
// A build of a previous project: the viewer and the back already cleared it
|
|
52
|
+
async function discardBuild(build: number, id: string, registered: boolean): Promise<void> {
|
|
53
|
+
if (build > lastBuildOfPreviousProject) {
|
|
54
|
+
await discardMap(id, registered);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function forget(): void {
|
|
59
|
+
basemapId.value = undefined;
|
|
60
|
+
grid.value = undefined;
|
|
61
|
+
built.value = [];
|
|
62
|
+
shownMaps = [];
|
|
63
|
+
attribution.value = undefined;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async function clear(): Promise<void> {
|
|
67
|
+
const id = basemapId.value;
|
|
68
|
+
forget();
|
|
69
|
+
if (id === undefined) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
await discardMap(id, true);
|
|
73
|
+
await hybridViewerStore.remoteRender();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async function display(build: number, extent: Extent, crs: CRSList): Promise<void> {
|
|
77
|
+
const response = await backStore.request({
|
|
78
|
+
schema: back_schemas.opengeodeweb_back.basemap.build,
|
|
79
|
+
params: { maps: [...maps.value], crs, ...extent },
|
|
80
|
+
});
|
|
81
|
+
if (build !== lastBuild) {
|
|
82
|
+
// A newer build started: this result is obsolete
|
|
83
|
+
await discardBuild(build, response.id, false);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const previousId = basemapId.value;
|
|
87
|
+
// The layers are computed from the maps just built
|
|
88
|
+
const builtMaps = sortedMaps(response.maps.map(({ map }) => map));
|
|
89
|
+
built.value = builtMaps;
|
|
90
|
+
// Only while this build still owns the built maps: a newer build may have set its own
|
|
91
|
+
function giveBackMaps(): void {
|
|
92
|
+
if (built.value === builtMaps) {
|
|
93
|
+
built.value = shownMaps;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
let sentLayers = "";
|
|
97
|
+
try {
|
|
98
|
+
sentLayers = await applyBasemap(response, BASEMAP_NAME);
|
|
99
|
+
} catch (error) {
|
|
100
|
+
giveBackMaps();
|
|
101
|
+
// The new mesh must not stay registered without anyone tracking it
|
|
102
|
+
await discardBuild(build, response.id, true);
|
|
103
|
+
throw error;
|
|
104
|
+
}
|
|
105
|
+
if (build !== lastBuild) {
|
|
106
|
+
giveBackMaps();
|
|
107
|
+
// Superseded while applying: the new basemap must not stay displayed
|
|
108
|
+
await discardBuild(build, response.id, true);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
basemapId.value = response.id;
|
|
112
|
+
shownMaps = builtMaps;
|
|
113
|
+
const { bounds, zoom, columns } = response;
|
|
114
|
+
grid.value = { bounds, zoom, columns, z: extent.z };
|
|
115
|
+
attribution.value = response.attribution;
|
|
116
|
+
if (previousId !== undefined) {
|
|
117
|
+
await discardBuild(build, previousId, true);
|
|
118
|
+
}
|
|
119
|
+
// The states changed while the basemap was built: the viewer still has the old ones
|
|
120
|
+
if (JSON.stringify(layersParams()) !== sentLayers) {
|
|
121
|
+
await applyLayers(response.id);
|
|
122
|
+
}
|
|
123
|
+
// Always render: the first build has no previous basemap whose removal would render
|
|
124
|
+
await hybridViewerStore.remoteRender();
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
async function rebuild(): Promise<void> {
|
|
128
|
+
lastBuild += 1;
|
|
129
|
+
const build = lastBuild;
|
|
130
|
+
const extent = dataBounds();
|
|
131
|
+
const crs = crsStore.projectCrs;
|
|
132
|
+
if (maps.value.length === 0 || crs === undefined || extent === undefined) {
|
|
133
|
+
await clear();
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
try {
|
|
137
|
+
await display(build, extent, crs);
|
|
138
|
+
} catch {
|
|
139
|
+
// The request feedback already shows the error: data changes must not repeat it forever
|
|
140
|
+
if (build === lastBuild) {
|
|
141
|
+
hidden.value = true;
|
|
142
|
+
await clear().catch(ignoreError);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// A new project: the viewer and the back were cleared, so nothing is requested
|
|
148
|
+
function reset(): void {
|
|
149
|
+
lastBuild += 1;
|
|
150
|
+
lastBuildOfPreviousProject = lastBuild;
|
|
151
|
+
forget();
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return { basemapId, grid, attribution, rebuild, reset };
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export type { BasemapGrid };
|
|
158
|
+
export { useBasemapBuilds };
|