@geode/opengeodeweb-front 10.44.0-rc.6 → 10.44.0-rc.8

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.
Files changed (59) hide show
  1. package/.build/server/utils/scripts.js +34 -23
  2. package/app/components/BasemapAttribution.vue +28 -0
  3. package/app/components/MissingFilesSelector.vue +30 -17
  4. package/app/components/ObjectSelector.vue +34 -23
  5. package/app/components/Viewer/Basemap/CropOptions.vue +50 -0
  6. package/app/components/Viewer/Basemap/OpacityOptions.vue +52 -0
  7. package/app/components/Viewer/ContextMenu/ContextMenu.vue +5 -1
  8. package/app/components/Viewer/ContextMenu/ContextMenuItem.vue +6 -2
  9. package/app/components/Viewer/ObjectTree/Views/GlobalObjects.vue +49 -10
  10. package/app/components/Viewer/Ui.vue +6 -0
  11. package/app/composables/overlapping_picker_menu.ts +43 -0
  12. package/app/composables/project_manager_helpers/reset.ts +3 -0
  13. package/app/composables/project_manager_helpers/restore.ts +22 -10
  14. package/app/composables/project_manager_helpers/types.ts +2 -0
  15. package/app/composables/use_overlapping_picker.ts +23 -37
  16. package/app/composables/viewer_context_menu.ts +10 -0
  17. package/app/composables/virtual_tree_flatten.ts +66 -43
  18. package/app/stores/app_helpers/extension.ts +90 -51
  19. package/app/stores/basemap.ts +52 -0
  20. package/app/stores/basemap_detail.ts +51 -0
  21. package/app/stores/basemap_helpers/builds.ts +158 -0
  22. package/app/stores/basemap_helpers/detail_layers.ts +72 -0
  23. package/app/stores/basemap_helpers/detail_map.ts +62 -0
  24. package/app/stores/basemap_helpers/detail_refresh.ts +134 -0
  25. package/app/stores/basemap_helpers/detail_view.ts +94 -0
  26. package/app/stores/basemap_helpers/extent.ts +40 -0
  27. package/app/stores/basemap_helpers/georeferenced.ts +50 -0
  28. package/app/stores/basemap_helpers/layers.ts +66 -0
  29. package/app/stores/basemap_helpers/settings.ts +87 -0
  30. package/app/stores/basemap_helpers/viewer.ts +114 -0
  31. package/app/stores/infra.ts +26 -21
  32. package/app/stores/menu_helpers/basemap.ts +10 -0
  33. package/app/stores/menu_helpers/menus_data.ts +2 -0
  34. package/app/utils/basemap_tree.ts +76 -0
  35. package/app/utils/color_picker.ts +18 -15
  36. package/app/utils/treeview.ts +12 -1
  37. package/app/utils/visible_map_area.ts +129 -0
  38. package/internal/database/database.ts +47 -32
  39. package/internal/stores/data_style/mesh/base_style.ts +74 -0
  40. package/internal/stores/data_style/mesh/index.ts +2 -57
  41. package/internal/stores/data_style/model/blocks/color.ts +58 -57
  42. package/internal/stores/data_style/model/blocks/polyhedron.ts +88 -44
  43. package/internal/stores/data_style/model/blocks/vertex.ts +88 -44
  44. package/internal/stores/data_style/model/color.ts +25 -26
  45. package/internal/stores/data_style/model/corners/index.ts +85 -78
  46. package/internal/stores/data_style/model/corners/vertex.ts +83 -39
  47. package/internal/stores/data_style/model/lines/color.ts +53 -40
  48. package/internal/stores/data_style/model/lines/edge.ts +88 -44
  49. package/internal/stores/data_style/model/lines/vertex.ts +88 -44
  50. package/internal/stores/data_style/model/surfaces/color.ts +68 -56
  51. package/internal/stores/data_style/model/surfaces/polygon.ts +80 -36
  52. package/internal/stores/data_style/model/surfaces/vertex.ts +80 -36
  53. package/internal/stores/data_style/model/visibility_dispatch.ts +49 -99
  54. package/internal/stores/hybrid_viewer/highlight.ts +70 -54
  55. package/internal/stores/hybrid_viewer/scene.ts +31 -25
  56. package/internal/stores/hybrid_viewer/vtk_types.ts +2 -1
  57. package/package.json +1 -1
  58. package/server/api/local/extensions/upload.put.ts +47 -20
  59. package/server/utils/scripts.ts +35 -30
@@ -25,31 +25,46 @@ const encoder = new TextEncoder();
25
25
  function byteLength(str) {
26
26
  return encoder.encode(str).byteLength;
27
27
  }
28
+ function truncateLine(lineOutput) {
29
+ const halfBuffer = MAX_ERROR_BUFFER_BYTES / 2;
30
+ return byteLength(lineOutput) > halfBuffer ? `${lineOutput.slice(0, halfBuffer)}…[truncated]` : lineOutput;
31
+ }
32
+ function trimOutputBuffer(output) {
33
+ let trimmed = output;
34
+ while (byteLength(trimmed) > MAX_ERROR_BUFFER_BYTES) {
35
+ const newline = trimmed.indexOf("\n");
36
+ if (newline === -1) return "";
37
+ trimmed = trimmed.slice(newline + 1);
38
+ }
39
+ return trimmed;
40
+ }
41
+ function createOutputRecorder() {
42
+ let recentOutput = "";
43
+ function record(lineOutput) {
44
+ recentOutput = trimOutputBuffer(`${recentOutput} ${truncateLine(lineOutput)}\n`);
45
+ }
46
+ function read() {
47
+ return recentOutput;
48
+ }
49
+ return {
50
+ record,
51
+ read
52
+ };
53
+ }
28
54
  async function waitForReady(child, expectedResponse, signal) {
29
55
  return new Promise((resolve, reject) => {
30
56
  const readlineStdout = readline.createInterface({ input: child.stdout });
31
57
  const readlineStderr = readline.createInterface({ input: child.stderr });
32
- let recentOutput = "";
33
- function recordOutput(lineOutput) {
34
- const safeLine = byteLength(lineOutput) > MAX_ERROR_BUFFER_BYTES / 2 ? `${lineOutput.slice(0, MAX_ERROR_BUFFER_BYTES / 2)}…[truncated]` : lineOutput;
35
- recentOutput = `${recentOutput} ${safeLine}\n`;
36
- while (byteLength(recentOutput) > MAX_ERROR_BUFFER_BYTES) {
37
- const newline = recentOutput.indexOf("\n");
38
- if (newline === -1) {
39
- recentOutput = "";
40
- break;
41
- }
42
- recentOutput = recentOutput.slice(newline + 1);
43
- }
44
- }
58
+ const recorder = createOutputRecorder();
45
59
  let onLine = void 0;
46
- let onErrLine = void 0;
47
60
  let onError = void 0;
48
61
  let onClose = void 0;
49
62
  let onAbort = void 0;
50
63
  function cleanup() {
51
- if (onLine) readlineStdout.removeListener("line", onLine);
52
- if (onErrLine) readlineStderr.removeListener("line", onErrLine);
64
+ if (onLine) {
65
+ readlineStdout.removeListener("line", onLine);
66
+ readlineStderr.removeListener("line", onLine);
67
+ }
53
68
  if (onError) child.removeListener("error", onError);
54
69
  if (onClose) child.removeListener("close", onClose);
55
70
  if (signal && onAbort) signal.removeEventListener("abort", onAbort);
@@ -69,14 +84,9 @@ async function waitForReady(child, expectedResponse, signal) {
69
84
  }
70
85
  onLine = (lineOutput) => {
71
86
  consola.info(`[${child.name}] ${lineOutput}`);
72
- recordOutput(lineOutput);
87
+ recorder.record(lineOutput);
73
88
  if (lineOutput.includes(expectedResponse)) becomeReady();
74
89
  };
75
- onErrLine = (line) => {
76
- consola.info(`[${child.name}] ${line}`);
77
- recordOutput(line);
78
- if (line.includes(expectedResponse)) becomeReady();
79
- };
80
90
  onError = (err) => {
81
91
  cleanup();
82
92
  reject(err);
@@ -84,6 +94,7 @@ async function waitForReady(child, expectedResponse, signal) {
84
94
  onClose = (code) => {
85
95
  consola.info(`[${child.name}] exited with code ${code}`);
86
96
  cleanup();
97
+ const recentOutput = recorder.read();
87
98
  reject(/* @__PURE__ */ new Error(`[${child.name}] exited with code ${code} before becoming ready.${recentOutput ? `\nRecent output:\n${recentOutput}` : ""}`));
88
99
  };
89
100
  onAbort = () => {
@@ -91,7 +102,7 @@ async function waitForReady(child, expectedResponse, signal) {
91
102
  reject(/* @__PURE__ */ new Error(`[${child.name}] timed out waiting for "${expectedResponse}"`));
92
103
  };
93
104
  readlineStdout.on("line", onLine);
94
- readlineStderr.on("line", onErrLine);
105
+ readlineStderr.on("line", onLine);
95
106
  child.once("error", onError);
96
107
  child.once("close", onClose);
97
108
  if (signal) signal.addEventListener("abort", onAbort, { once: true });
@@ -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>
@@ -94,29 +94,30 @@ function isCsvFile(filename: string): boolean {
94
94
  return filename.toLowerCase().endsWith(".csv") || filename.toLowerCase().endsWith(".csv.json");
95
95
  }
96
96
 
97
- async function missing_files(): Promise<void> {
98
- toggle_loading();
97
+ function reset_missing_state(): void {
99
98
  has_missing_files.value = false;
100
99
  mandatory_files.value = [];
101
100
  additional_files.value = [];
102
101
  missing_by_file.value = [];
102
+ }
103
+
104
+ function request_file_plan(filename: string): Promise<FilePlan> {
105
+ if (isCsvFile(filename)) {
106
+ return Promise.resolve({
107
+ has_missing_files: false,
108
+ mandatory_files: [],
109
+ additional_files: [],
110
+ });
111
+ }
103
112
  const backStore = useBackStore();
113
+ if (timeSeries) {
114
+ return backStore.request({ schema: time_series_schema, params: { filename } });
115
+ }
116
+ const params = { geode_object_type: geodeObjectTypes[filename] ?? "", filename };
117
+ return backStore.request({ schema, params });
118
+ }
104
119
 
105
- const promise_array = checked_filenames.value.map((filename): Promise<FilePlan> => {
106
- if (isCsvFile(filename)) {
107
- return Promise.resolve({
108
- has_missing_files: false,
109
- mandatory_files: [],
110
- additional_files: [],
111
- });
112
- }
113
- if (timeSeries) {
114
- return backStore.request({ schema: time_series_schema, params: { filename } });
115
- }
116
- const params = { geode_object_type: geodeObjectTypes[filename] ?? "", filename };
117
- return backStore.request({ schema, params });
118
- });
119
- const values = await Promise.all(promise_array);
120
+ function collect_file_plans(values: FilePlan[]): void {
120
121
  for (const [index, value] of values.entries()) {
121
122
  if (value.has_missing_files) {
122
123
  has_missing_files.value = true;
@@ -129,6 +130,9 @@ async function missing_files(): Promise<void> {
129
130
  mandatory_files.value = [...mandatory_files.value, ...value.mandatory_files];
130
131
  additional_files.value = [...additional_files.value, ...value.additional_files];
131
132
  }
133
+ }
134
+
135
+ function flag_unconfigured_csvs(): void {
132
136
  const unconfigured_csvs = files.filter((file) => isCsvFile(file.name) && !file.isConfigured);
133
137
  if (unconfigured_csvs.length > 0) {
134
138
  has_missing_files.value = true;
@@ -136,6 +140,15 @@ async function missing_files(): Promise<void> {
136
140
  accept.value = ".json";
137
141
  }
138
142
  }
143
+ }
144
+
145
+ async function missing_files(): Promise<void> {
146
+ toggle_loading();
147
+ reset_missing_state();
148
+
149
+ const values = await Promise.all(checked_filenames.value.map(request_file_plan));
150
+ collect_file_plans(values);
151
+ flag_unconfigured_csvs();
139
152
 
140
153
  if (!has_missing_files.value) {
141
154
  emit("update_values", { skipped_files: [] });
@@ -120,6 +120,37 @@ function showCommonGeodeObjects(
120
120
  return resolved.selectedGeodeObject;
121
121
  }
122
122
 
123
+ function toResolvedEntries(loadable: readonly FileAllowedObjects[]): [string, string][] {
124
+ return loadable.flatMap((file): [string, string][] => {
125
+ if (file.selectedGeodeObject === undefined) {
126
+ return [];
127
+ }
128
+ return [[file.filename, file.selectedGeodeObject]];
129
+ });
130
+ }
131
+
132
+ // Tries to settle the pending files without the per file panel. Returns true when it did
133
+ function resolveWithoutPanel(
134
+ pending: readonly FileAllowedObjects[],
135
+ allowedObjectsList: readonly AllowedObjectMap[],
136
+ ): boolean {
137
+ if (pending.length === 0) {
138
+ autoResolved.value = true;
139
+ emitGeodeObjectTypes(resolvedTypes.value);
140
+ return true;
141
+ }
142
+ const pendingAllowedObjects = pending.map(
143
+ (file) => allowedObjectsList[filenames.indexOf(file.filename)] ?? {},
144
+ );
145
+ // Pending files sharing a loadable type: one choice for all of them
146
+ const selected = showCommonGeodeObjects(pendingFilenames.value, pendingAllowedObjects);
147
+ if (Object.values(allowedGeodeObjects.value).some((object) => object.is_loadable > 0)) {
148
+ setGeodeObject(selected);
149
+ return true;
150
+ }
151
+ return false;
152
+ }
153
+
123
154
  // Each file gets its own type. Returns true when the per file panel is needed, i.e. the files cannot be handled by a single choice
124
155
  function resolvePerFile(allowedObjectsList: readonly AllowedObjectMap[]): boolean {
125
156
  const files = resolveAllowedObjectsPerFile(filenames, allowedObjectsList);
@@ -130,33 +161,13 @@ function resolvePerFile(allowedObjectsList: readonly AllowedObjectMap[]): boolea
130
161
  return false;
131
162
  }
132
163
  const pending = loadable.filter((file) => file.selectedGeodeObject === undefined);
133
- resolvedTypes.value = Object.fromEntries(
134
- loadable.flatMap((file) => {
135
- if (file.selectedGeodeObject === undefined) {
136
- return [];
137
- }
138
- return [[file.filename, file.selectedGeodeObject]];
139
- }),
140
- );
164
+ resolvedTypes.value = Object.fromEntries(toResolvedEntries(loadable));
141
165
  pendingFilenames.value = pending.map((file) => file.filename);
142
166
  skippedFiles.value = files
143
167
  .filter((file) => file.candidates.length === 0)
144
168
  .map((file) => file.filename);
145
- if (skippedFiles.value.length === 0) {
146
- if (pending.length === 0) {
147
- autoResolved.value = true;
148
- emitGeodeObjectTypes(resolvedTypes.value);
149
- return false;
150
- }
151
- const pendingAllowedObjects = pending.map(
152
- (file) => allowedObjectsList[filenames.indexOf(file.filename)] ?? {},
153
- );
154
- // Pending files sharing a loadable type: one choice for all of them
155
- const selected = showCommonGeodeObjects(pendingFilenames.value, pendingAllowedObjects);
156
- if (Object.values(allowedGeodeObjects.value).some((object) => object.is_loadable > 0)) {
157
- setGeodeObject(selected);
158
- return false;
159
- }
169
+ if (skippedFiles.value.length === 0 && resolveWithoutPanel(pending, allowedObjectsList)) {
170
+ return false;
160
171
  }
161
172
  pendingGroups.value = groupPendingFiles(pending);
162
173
  return true;
@@ -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 v-model:show="showName" :meta-data="meta_data" />
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
- btnImage: string;
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 DataMenuPayload,
4
- type GeodeObjectTypeMenuPayload,
5
- compareSelections,
6
- } from "@ogw_front/utils/treeview";
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: DataMenuPayload | GeodeObjectTypeMenuPayload];
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
- treeviewStore.selection = applySearchFilter(val, treeviewStore.selection);
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[]>(() => applySearchFilter(treeviewStore.selection, []));
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(treeviewStore.items);
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="processedItems"
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"
@@ -0,0 +1,43 @@
1
+ interface MenuPositionParams {
2
+ x: number;
3
+ y: number;
4
+ containerWidth: number;
5
+ containerHeight: number;
6
+ itemCount: number;
7
+ }
8
+
9
+ interface MenuPosition {
10
+ x: number;
11
+ y: number;
12
+ }
13
+
14
+ const MENU_WIDTH = 340;
15
+ const MENU_BASE_HEIGHT = 55;
16
+ const MENU_ITEM_HEIGHT = 48;
17
+ const CLAMP_MARGIN = 10;
18
+
19
+ function clampMenuY(yUI: number, containerHeight: number, menuHeight: number): number {
20
+ let clampedY = yUI;
21
+ if (yUI + menuHeight > containerHeight - CLAMP_MARGIN) {
22
+ clampedY = Math.max(yUI - menuHeight, CLAMP_MARGIN);
23
+ } else {
24
+ clampedY = Math.max(yUI, CLAMP_MARGIN);
25
+ }
26
+ return Math.min(Math.max(clampedY, CLAMP_MARGIN), containerHeight - menuHeight - CLAMP_MARGIN);
27
+ }
28
+
29
+ function computeMenuPosition({
30
+ x,
31
+ y,
32
+ containerWidth,
33
+ containerHeight,
34
+ itemCount,
35
+ }: MenuPositionParams): MenuPosition {
36
+ const menuHeight = MENU_BASE_HEIGHT + itemCount * MENU_ITEM_HEIGHT;
37
+ const clampedX = Math.min(Math.max(x, CLAMP_MARGIN), containerWidth - MENU_WIDTH - CLAMP_MARGIN);
38
+ const clampedY = clampMenuY(containerHeight - y, containerHeight, menuHeight);
39
+ return { x: clampedX, y: clampedY };
40
+ }
41
+
42
+ export { computeMenuPosition };
43
+ export type { MenuPosition, MenuPositionParams };
@@ -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 };