@geode/opengeodeweb-front 12.2.0-rc.1 → 12.2.0-rc.3

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 (62) hide show
  1. package/.build/server/utils/microservices_process.js +1 -1
  2. package/.build/tests/browser/helpers/crs.js +136 -0
  3. package/.build/tests/browser/helpers/crs_flows.js +60 -0
  4. package/.build/tests/browser/helpers/crs_shortlist.js +13 -0
  5. package/.build/tests/browser/helpers/crs_test_data.js +40 -0
  6. package/.build/tests/browser/helpers/image.js +25 -0
  7. package/.build/tests/browser/suites/crs.js +142 -0
  8. package/.build/tests/browser/suites/crs_harmonize.js +63 -0
  9. package/.build/tests/browser/suites/crs_shortlist.js +31 -0
  10. package/.build/tests/browser/suites/image/raster_image.js +33 -0
  11. package/.build/tests/browser/suites/index.js +8 -0
  12. package/app/app.config.ts +4 -0
  13. package/app/components/CrsAlign.vue +207 -0
  14. package/app/components/CrsDialog.vue +400 -0
  15. package/app/components/CrsDialogHost.vue +66 -0
  16. package/app/components/CrsSelector.vue +100 -3
  17. package/app/components/PickButton.vue +43 -0
  18. package/app/components/ProjectCrsDialog.vue +109 -0
  19. package/app/components/ToolPanel.vue +5 -2
  20. package/app/components/Viewer/CrsOverlays.vue +29 -0
  21. package/app/components/Viewer/Image/ImageOptions.vue +67 -0
  22. package/app/components/Viewer/ObjectTree/Views/GlobalObjects.vue +3 -2
  23. package/app/components/Viewer/Ui.vue +3 -2
  24. package/app/composables/crs.ts +197 -0
  25. package/app/composables/crs_align.ts +206 -0
  26. package/app/composables/crs_assign.ts +102 -0
  27. package/app/composables/crs_link.ts +22 -0
  28. package/app/composables/crs_shortlist.ts +63 -0
  29. package/app/composables/hover_highlight.ts +6 -5
  30. package/app/composables/project_crs.ts +197 -0
  31. package/app/composables/use_overlapping_picker.ts +6 -1
  32. package/app/composables/user_setting.ts +140 -0
  33. package/app/stores/basemap.ts +19 -2
  34. package/app/stores/crs.ts +11 -106
  35. package/app/stores/crs_helpers/geographic_list.ts +44 -0
  36. package/app/stores/crs_helpers/project_crs.ts +60 -0
  37. package/app/stores/crs_helpers/requests.ts +60 -0
  38. package/app/stores/data_style.ts +12 -1
  39. package/app/stores/menu_helpers/image.ts +11 -0
  40. package/app/stores/menu_helpers/menus_data.ts +2 -0
  41. package/app/types/identifiers.ts +8 -0
  42. package/app/utils/crs.ts +17 -1
  43. package/app/utils/default_styles/images.ts +16 -0
  44. package/app/utils/default_styles/index.ts +3 -2
  45. package/app/utils/import_item.ts +87 -0
  46. package/app/utils/import_workflow.ts +36 -94
  47. package/app/utils/reload_object.ts +26 -0
  48. package/app/utils/threshold_sources.ts +5 -1
  49. package/internal/stores/data_style/image/index.ts +107 -0
  50. package/package.json +1 -1
  51. package/server/utils/microservices_process.ts +4 -1
  52. package/tests/browser/data/test_lambert93_no_crs.og_pts3d +0 -0
  53. package/tests/browser/data/test_utm31n.og_pts3d +0 -0
  54. package/tests/browser/helpers/crs.ts +250 -0
  55. package/tests/browser/helpers/crs_flows.ts +115 -0
  56. package/tests/browser/helpers/crs_shortlist.ts +27 -0
  57. package/tests/browser/helpers/crs_test_data.ts +34 -0
  58. package/tests/browser/helpers/image.ts +33 -0
  59. package/tests/browser/suites/crs.ts +228 -0
  60. package/tests/browser/suites/crs_harmonize.ts +96 -0
  61. package/tests/browser/suites/crs_shortlist.ts +37 -0
  62. package/tests/browser/suites/image/raster_image.ts +40 -0
@@ -0,0 +1,140 @@
1
+ import type { Ref, ShallowRef } from "vue";
2
+ import { useLocalStorage } from "@vueuse/core";
3
+ import type { z } from "zod";
4
+
5
+ interface DesktopSettingsAPI {
6
+ app_settings: unknown;
7
+ app_settings_write: (settings: Record<string, unknown>) => Promise<unknown>;
8
+ }
9
+
10
+ // A setting of the user (theme, favorite CRS...), declared once next to the feature that uses it.
11
+ // Its value is replaced, never changed in place: `favorites.value = [...favorites.value, entry]`
12
+ interface UserSettingDefinition<Value> {
13
+ // Its key in the desktop settings.json
14
+ key: string;
15
+ // Checks the stored value on read, strictly: an invalid one gives the fallback. A setting whose type
16
+ // Changes takes a new key: the old value is left as is, never converted
17
+ schema: z.ZodType<Value>;
18
+ // A JSON value: copied for each use, compared when the setting is declared again
19
+ fallback: Value;
20
+ // Its key in the browser local storage
21
+ browserKey: string;
22
+ // The value shared by every caller on the desktop, with the settings API it is saved through
23
+ desktop?: { api: DesktopSettingsAPI; setting: ShallowRef<Value> };
24
+ }
25
+
26
+ // The browser key and fallback of each declared setting, as JSON
27
+ const declared = new Map<string, string>();
28
+
29
+ // Declares a setting, at module level. Declaring it again the same way (hot reload, tests) is fine;
30
+ // Declaring it differently is an error: two features would overwrite each other's value.
31
+ function defineUserSetting<Value>(options: {
32
+ key: string;
33
+ schema: z.ZodType<Value>;
34
+ fallback: Value;
35
+ browserKey?: string;
36
+ }): UserSettingDefinition<Value> {
37
+ const definition: UserSettingDefinition<Value> = {
38
+ ...options,
39
+ browserKey: options.browserKey ?? `ogw-${options.key}`,
40
+ };
41
+ const signature = JSON.stringify([definition.browserKey, definition.fallback]);
42
+ const existing = declared.get(definition.key);
43
+ if (existing !== undefined && existing !== signature) {
44
+ throw new Error(`User setting "${definition.key}" is already defined differently`);
45
+ }
46
+ declared.set(definition.key, signature);
47
+ return definition;
48
+ }
49
+
50
+ function hasDesktopSettingsAPI(
51
+ value: typeof globalThis,
52
+ ): value is typeof globalThis & { electronAPI: DesktopSettingsAPI } {
53
+ return (
54
+ "electronAPI" in value &&
55
+ typeof value.electronAPI === "object" &&
56
+ value.electronAPI !== null &&
57
+ "app_settings" in value.electronAPI &&
58
+ "app_settings_write" in value.electronAPI
59
+ );
60
+ }
61
+
62
+ // The stored value when the setting's schema accepts it, a copy of the fallback otherwise
63
+ function validated<Value>(definition: UserSettingDefinition<Value>, value: unknown): Value {
64
+ const result = definition.schema.safeParse(value);
65
+ if (result.success) {
66
+ return result.data;
67
+ }
68
+ return structuredClone(definition.fallback);
69
+ }
70
+
71
+ // Every value is stored as JSON. A value that is not JSON is a string stored raw by a previous version
72
+ // (the Vease color theme was stored as `dark`)
73
+ function parseStored(raw: string): unknown {
74
+ try {
75
+ return JSON.parse(raw);
76
+ } catch {
77
+ return raw;
78
+ }
79
+ }
80
+
81
+ function browserSetting<Value>(definition: UserSettingDefinition<Value>): Ref<Value> {
82
+ return useLocalStorage<Value>(definition.browserKey, structuredClone(definition.fallback), {
83
+ shallow: true,
84
+ serializer: {
85
+ read: (raw: string): Value => validated(definition, parseStored(raw)),
86
+ write: (value: Value): string => JSON.stringify(value),
87
+ },
88
+ });
89
+ }
90
+
91
+ // A copy without Vue proxies: toRaw only unwraps the outer one, not the elements a filter or a spread returns
92
+ function toPlain(value: unknown): unknown {
93
+ const raw: unknown = toRaw(value);
94
+ if (Array.isArray(raw)) {
95
+ return raw.map((item: unknown) => toPlain(item));
96
+ }
97
+ if (typeof raw === "object" && raw !== null) {
98
+ return Object.fromEntries(
99
+ Object.entries(raw).map(([entryKey, entryValue]) => [entryKey, toPlain(entryValue)]),
100
+ );
101
+ }
102
+ return raw;
103
+ }
104
+
105
+ function desktopSetting<Value>(
106
+ api: DesktopSettingsAPI,
107
+ definition: UserSettingDefinition<Value>,
108
+ ): Ref<Value> {
109
+ if (definition.desktop?.api === api) {
110
+ return definition.desktop.setting;
111
+ }
112
+ let saved: unknown = undefined;
113
+ if (typeof api.app_settings === "object" && api.app_settings !== null) {
114
+ saved = Reflect.get(api.app_settings, definition.key);
115
+ }
116
+ const setting = shallowRef(validated(definition, saved));
117
+ // Detached: the first caller's unmount must not stop the saving
118
+ effectScope(true).run(() => {
119
+ watch(setting, (value) => {
120
+ // Electron cannot send the Vue proxies a new value may hold, at any depth
121
+ void api.app_settings_write({ [definition.key]: toPlain(value) });
122
+ });
123
+ });
124
+ definition.desktop = { api, setting };
125
+ return setting;
126
+ }
127
+
128
+ // The value of a setting, shared by every caller. The desktop app clears its browser storage on every launch:
129
+ // There the settings live in its settings.json, read before the page renders and written on every change.
130
+ // The browser keeps them in its local storage.
131
+ function useUserSetting<Value>(definition: UserSettingDefinition<Value>): Ref<Value> {
132
+ const globalScope = globalThis;
133
+ if (!hasDesktopSettingsAPI(globalScope)) {
134
+ return browserSetting(definition);
135
+ }
136
+ return desktopSetting(globalScope.electronAPI, definition);
137
+ }
138
+
139
+ export type { UserSettingDefinition };
140
+ export { defineUserSetting, useUserSetting };
@@ -6,11 +6,28 @@ import { useGeoreferenced } from "./basemap_helpers/georeferenced.js";
6
6
 
7
7
  const REBUILD_DELAY_MILLISECONDS = 500;
8
8
 
9
+ // Apps opt in with `ogwFront.basemap` in their app.config.ts: without it, no map is built or offered
10
+ function readBasemapOption(appConfig: ReturnType<typeof useAppConfig>): boolean {
11
+ // The resolved type holds the layer's literal default (false): widen it to the config input type
12
+ const ogwFront: { basemap?: boolean } | undefined = appConfig.ogwFront;
13
+ return ogwFront?.basemap === true;
14
+ }
15
+
9
16
  export const useBasemapStore = defineStore("basemap", () => {
10
- const { available, georeferencedIds, dataBounds, dataKey } = useGeoreferenced();
17
+ const appConfig = useAppConfig();
18
+ const enabled = computed(() => readBasemapOption(appConfig));
19
+ const georeferenced = useGeoreferenced();
20
+ const { georeferencedIds, dataBounds, dataKey } = georeferenced;
21
+ const available = computed(() => enabled.value && georeferenced.available.value);
11
22
  const layers = useBasemapLayers(georeferencedIds);
12
23
  const { shown, maps, opacities, crop, layersParams, applyLayers, applyBasemap } = layers;
13
- const { basemapId, grid, attribution, rebuild, reset } = useBasemapBuilds(layers, dataBounds);
24
+ const builds = useBasemapBuilds(layers, dataBounds);
25
+ const { basemapId, grid, attribution, reset } = builds;
26
+ async function rebuild(): Promise<void> {
27
+ if (enabled.value) {
28
+ await builds.rebuild();
29
+ }
30
+ }
14
31
  const settings = useBasemapSettings(layers, basemapId, rebuild);
15
32
  const { setMaps, setOpacity, setCrop, exportStores, importStores } = settings;
16
33
 
package/app/stores/crs.ts CHANGED
@@ -1,110 +1,22 @@
1
- import { oldestCrs, sameCrs } from "@ogw_front/utils/crs";
2
1
  import type { CRS } from "@geode/opengeodeweb-back/schema_types";
3
- import type { DataId } from "@geode/opengeodeweb-microservice/schema_types";
4
- import type { GeodeObjectType } from "@geode/opengeodeweb-microservice/data_types";
5
- import back_schemas from "@geode/opengeodeweb-back/opengeodeweb_back_typed_schemas.js";
6
- import { useBackStore } from "@ogw_front/stores/back";
2
+ import { oldestCrs } from "@ogw_front/utils/crs";
3
+ import { useCrsRequests } from "./crs_helpers/requests.js";
7
4
  import { useDataStore } from "@ogw_front/stores/data";
5
+ import { useGeographicList } from "./crs_helpers/geographic_list.js";
6
+ import { useProjectCrsState } from "./crs_helpers/project_crs.js";
8
7
 
9
8
  // Session cache of the available CRS, the project CRS, and the channel the shared components use to ask the host app for a CRS edit
10
- // oxlint-disable-next-line max-lines-per-function, max-statements
11
9
  export const useCrsStore = defineStore("crs", () => {
12
- const backStore = useBackStore();
13
- // OpenGeode geosciences lists the same geographic CRS for 2D and 3D data: one list for all types
14
- let geographicListPromise: Promise<CRS[]> | undefined = undefined;
15
- const crsEditEnabled = ref(false);
16
- const crsEditRequest = ref<string | undefined>(undefined);
17
- const dataStore = useDataStore();
18
- const crsItems = dataStore.refCrsItems();
19
- const projectCrs = ref<CRS | undefined>(undefined);
20
- const projectCrsEditRequest = ref(false);
21
-
22
- // The project follows its data: once every georeferenced data is in one CRS, it is the project
23
- // CRS. Data already mixed before any project CRS: the oldest one is the reference
24
- watch(
25
- () => {
26
- const georeferenced = crsItems.value.filter((item) => item.crs !== undefined);
27
- const [first] = georeferenced;
28
- if (first === undefined) {
29
- return undefined;
30
- }
31
- if (georeferenced.every((item) => sameCrs(item.crs, first.crs))) {
32
- return first.crs;
33
- }
34
- return projectCrs.value ?? oldestCrs(georeferenced);
35
- },
36
- (reference) => {
37
- if (reference !== undefined && !sameCrs(reference, projectCrs.value)) {
38
- projectCrs.value = reference;
39
- }
40
- },
41
- { immediate: true },
42
- );
43
-
44
- // Data without CRS are listed too (value undefined): they could not follow the project
45
- const mismatchedCrs = computed(() => {
46
- const project = projectCrs.value;
47
- const mismatched = new Map<string, CRS | undefined>();
48
- for (const item of crsItems.value) {
49
- if (project !== undefined && !sameCrs(item.crs, project)) {
50
- mismatched.set(item.data_id, item.crs);
51
- }
52
- }
53
- return mismatched;
54
- });
55
-
56
- async function fetchGeographicList(geodeObjectType: GeodeObjectType): Promise<CRS[]> {
57
- try {
58
- const response = await backStore.request({
59
- schema: back_schemas.opengeodeweb_back.crs.geographic_list,
60
- params: { geode_object_type: geodeObjectType },
61
- });
62
- if (response?.crs_list !== undefined) {
63
- return response.crs_list;
64
- }
65
- } catch {
66
- // The back store already reports the error to the user
67
- }
68
- // A failed request is not cached: the next call retries
69
- geographicListPromise = undefined;
70
- return [];
71
- }
72
-
73
- async function geographicList(geodeObjectType: GeodeObjectType): Promise<CRS[]> {
74
- // The promise is cached, so dialogs opened together share a single request.
75
- // The back still checks each CRS against the list of the data dimension
76
- geographicListPromise ??= fetchGeographicList(geodeObjectType);
77
- const list = await geographicListPromise;
78
- return list;
79
- }
80
-
81
- function enableCrsEdit(): void {
82
- crsEditEnabled.value = true;
83
- }
84
-
85
- function requestCrsEdit(dataId: DataId): void {
86
- crsEditRequest.value = dataId;
87
- }
88
-
89
- function clearCrsEditRequest(): void {
90
- crsEditRequest.value = undefined;
91
- }
92
-
93
- function setProjectCrs(crs: CRS): void {
94
- projectCrs.value = crs;
95
- }
96
-
97
- function requestProjectCrsEdit(): void {
98
- projectCrsEditRequest.value = true;
99
- }
100
-
101
- function clearProjectCrsEditRequest(): void {
102
- projectCrsEditRequest.value = false;
103
- }
10
+ const crsItems = useDataStore().refCrsItems();
11
+ const { geographicList } = useGeographicList();
12
+ const { projectCrs, mismatchedCrs, setProjectCrs } = useProjectCrsState(crsItems);
13
+ // Edit and alignment requests, returned as they are
14
+ const requests = useCrsRequests();
104
15
 
105
16
  // A new project: its data set the project CRS again
106
17
  function reset(): void {
107
18
  projectCrs.value = undefined;
19
+ requests.closeCrsAlign();
108
20
  }
109
21
 
110
22
  function exportStores(): { projectCrs?: CRS } {
@@ -119,17 +31,10 @@ export const useCrsStore = defineStore("crs", () => {
119
31
  return {
120
32
  crsItems,
121
33
  geographicList,
122
- crsEditEnabled,
123
- enableCrsEdit,
124
- crsEditRequest,
125
- requestCrsEdit,
126
- clearCrsEditRequest,
127
34
  projectCrs,
128
35
  mismatchedCrs,
129
36
  setProjectCrs,
130
- projectCrsEditRequest,
131
- requestProjectCrsEdit,
132
- clearProjectCrsEditRequest,
37
+ ...requests,
133
38
  reset,
134
39
  exportStores,
135
40
  importStores,
@@ -0,0 +1,44 @@
1
+ import type { CRS } from "@geode/opengeodeweb-back/schema_types";
2
+ import type { GeodeObjectType } from "@geode/opengeodeweb-microservice/data_types";
3
+ import back_schemas from "@geode/opengeodeweb-back/opengeodeweb_back_typed_schemas.js";
4
+ import { useBackStore } from "@ogw_front/stores/back";
5
+
6
+ interface GeographicList {
7
+ geographicList: (geodeObjectType: GeodeObjectType) => Promise<CRS[]>;
8
+ }
9
+
10
+ // Session cache of the available CRS
11
+ function useGeographicList(): GeographicList {
12
+ const backStore = useBackStore();
13
+ // OpenGeode geosciences lists the same geographic CRS for 2D and 3D data: one list for all types
14
+ let geographicListPromise: Promise<CRS[]> | undefined = undefined;
15
+
16
+ async function fetchGeographicList(geodeObjectType: GeodeObjectType): Promise<CRS[]> {
17
+ try {
18
+ const response = await backStore.request({
19
+ schema: back_schemas.opengeodeweb_back.crs.geographic_list,
20
+ params: { geode_object_type: geodeObjectType },
21
+ });
22
+ if (response?.crs_list !== undefined) {
23
+ return response.crs_list;
24
+ }
25
+ } catch {
26
+ // The back store already reports the error to the user
27
+ }
28
+ // A failed request is not cached: the next call retries
29
+ geographicListPromise = undefined;
30
+ return [];
31
+ }
32
+
33
+ async function geographicList(geodeObjectType: GeodeObjectType): Promise<CRS[]> {
34
+ // The promise is cached, so dialogs opened together share a single request.
35
+ // The back still checks each CRS against the list of the data dimension
36
+ geographicListPromise ??= fetchGeographicList(geodeObjectType);
37
+ const list = await geographicListPromise;
38
+ return list;
39
+ }
40
+
41
+ return { geographicList };
42
+ }
43
+
44
+ export { useGeographicList };
@@ -0,0 +1,60 @@
1
+ import type { ComputedRef, Ref } from "vue";
2
+ import { oldestCrs, sameCrs } from "@ogw_front/utils/crs";
3
+ import type { CRS } from "@geode/opengeodeweb-back/schema_types";
4
+ import type { CrsItem } from "@ogw_front/stores/data";
5
+
6
+ interface ProjectCrsState {
7
+ projectCrs: Ref<CRS | undefined>;
8
+ mismatchedCrs: ComputedRef<Map<string, CRS | undefined>>;
9
+ setProjectCrs: (crs: CRS) => void;
10
+ }
11
+
12
+ // The CRS every data of the project should be in, given the data CRS
13
+ function referenceCrs(crsItems: CrsItem[], projectCrs: CRS | undefined): CRS | undefined {
14
+ const georeferenced = crsItems.filter((item) => item.crs !== undefined);
15
+ const [first] = georeferenced;
16
+ if (first === undefined) {
17
+ return undefined;
18
+ }
19
+ if (georeferenced.every((item) => sameCrs(item.crs, first.crs))) {
20
+ return first.crs;
21
+ }
22
+ return projectCrs ?? oldestCrs(georeferenced);
23
+ }
24
+
25
+ // The project CRS and the data out of it
26
+ function useProjectCrsState(crsItems: Ref<CrsItem[]>): ProjectCrsState {
27
+ const projectCrs = ref<CRS | undefined>(undefined);
28
+
29
+ // The project follows its data: once every georeferenced data is in one CRS, it is the project
30
+ // CRS. Data already mixed before any project CRS: the oldest one is the reference
31
+ watch(
32
+ () => referenceCrs(crsItems.value, projectCrs.value),
33
+ (reference) => {
34
+ if (reference !== undefined && !sameCrs(reference, projectCrs.value)) {
35
+ projectCrs.value = reference;
36
+ }
37
+ },
38
+ { immediate: true },
39
+ );
40
+
41
+ // Data without CRS are listed too (value undefined): they could not follow the project
42
+ const mismatchedCrs = computed(() => {
43
+ const project = projectCrs.value;
44
+ const mismatched = new Map<string, CRS | undefined>();
45
+ for (const item of crsItems.value) {
46
+ if (project !== undefined && !sameCrs(item.crs, project)) {
47
+ mismatched.set(item.data_id, item.crs);
48
+ }
49
+ }
50
+ return mismatched;
51
+ });
52
+
53
+ function setProjectCrs(crs: CRS): void {
54
+ projectCrs.value = crs;
55
+ }
56
+
57
+ return { projectCrs, mismatchedCrs, setProjectCrs };
58
+ }
59
+
60
+ export { useProjectCrsState };
@@ -0,0 +1,60 @@
1
+ import type { DataId } from "@geode/opengeodeweb-microservice/schema_types";
2
+ import type { DataItem } from "@ogw_front/stores/data";
3
+ import type { Ref } from "vue";
4
+
5
+ interface CrsRequests {
6
+ crsEditEnabled: Ref<boolean>;
7
+ enableCrsEdit: () => void;
8
+ crsEditRequest: Ref<string | undefined>;
9
+ requestCrsEdit: (dataId: DataId) => void;
10
+ clearCrsEditRequest: () => void;
11
+ projectCrsEditRequest: Ref<boolean>;
12
+ requestProjectCrsEdit: () => void;
13
+ clearProjectCrsEditRequest: () => void;
14
+ showCrsAlign: Ref<boolean>;
15
+ crsAlignItem: Ref<DataItem | undefined>;
16
+ openCrsAlign: (item: DataItem) => void;
17
+ closeCrsAlign: () => void;
18
+ }
19
+
20
+ // The channel the shared components use to ask the host app for a CRS edit or an alignment
21
+ function useCrsRequests(): CrsRequests {
22
+ const crsEditEnabled = ref(false);
23
+ const crsEditRequest = ref<string | undefined>(undefined);
24
+ const projectCrsEditRequest = ref(false);
25
+ const showCrsAlign = ref(false);
26
+ const crsAlignItem = ref<DataItem | undefined>(undefined);
27
+
28
+ return {
29
+ crsEditEnabled,
30
+ enableCrsEdit: (): void => {
31
+ crsEditEnabled.value = true;
32
+ },
33
+ crsEditRequest,
34
+ requestCrsEdit: (dataId: DataId): void => {
35
+ crsEditRequest.value = dataId;
36
+ },
37
+ clearCrsEditRequest: (): void => {
38
+ crsEditRequest.value = undefined;
39
+ },
40
+ projectCrsEditRequest,
41
+ requestProjectCrsEdit: (): void => {
42
+ projectCrsEditRequest.value = true;
43
+ },
44
+ clearProjectCrsEditRequest: (): void => {
45
+ projectCrsEditRequest.value = false;
46
+ },
47
+ showCrsAlign,
48
+ crsAlignItem,
49
+ openCrsAlign: (item: DataItem): void => {
50
+ crsAlignItem.value = item;
51
+ showCrsAlign.value = true;
52
+ },
53
+ closeCrsAlign: (): void => {
54
+ showCrsAlign.value = false;
55
+ crsAlignItem.value = undefined;
56
+ },
57
+ };
58
+ }
59
+
60
+ export { useCrsRequests };
@@ -14,6 +14,7 @@ import { getDefaultStyle } from "@ogw_front/utils/default_styles";
14
14
  import { useAttributeTimeStepStyle } from "@ogw_internal/stores/data_style/time_step";
15
15
  import { useDataStore } from "@ogw_front/stores/data";
16
16
  import { useDataStyleState } from "@ogw_internal/stores/data_style/state";
17
+ import { useImageStyle } from "@ogw_internal/stores/data_style/image/index";
17
18
  import { useMeshStyle } from "@ogw_internal/stores/data_style/mesh/index";
18
19
  import { useModelStyle } from "@ogw_internal/stores/data_style/model/index";
19
20
  import { useSceneStyle } from "@ogw_internal/stores/data_style/scene";
@@ -44,6 +45,7 @@ function isRecord(value: unknown): value is Record<string, unknown> {
44
45
  // oxlint-disable-next-line max-lines-per-function
45
46
  export const useDataStyleStore = defineStore("dataStyle", () => {
46
47
  const dataStyleState = useDataStyleState();
48
+ const imageStyleStore = useImageStyle();
47
49
  const meshStyleStore = useMeshStyle();
48
50
  const modelStyleStore = useModelStyle();
49
51
  const sceneStyleStore = useSceneStyle();
@@ -76,6 +78,9 @@ export const useDataStyleStore = defineStore("dataStyle", () => {
76
78
 
77
79
  const { viewer_object_type } = item;
78
80
 
81
+ if (viewer_object_type === "image") {
82
+ return imageStyleStore.setImageVisibility(dataId, visibility);
83
+ }
79
84
  if (viewer_object_type === "mesh") {
80
85
  return meshStyleStore.setMeshVisibility(dataId, visibility);
81
86
  }
@@ -93,6 +98,9 @@ export const useDataStyleStore = defineStore("dataStyle", () => {
93
98
 
94
99
  const { viewer_object_type } = item;
95
100
 
101
+ if (viewer_object_type === "image") {
102
+ return imageStyleStore.applyImageStyle(dataId);
103
+ }
96
104
  if (viewer_object_type === "mesh") {
97
105
  return meshStyleStore.applyMeshStyle(dataId);
98
106
  }
@@ -158,7 +166,9 @@ export const useDataStyleStore = defineStore("dataStyle", () => {
158
166
  return;
159
167
  }
160
168
  const viewerObjectType = meta.viewer_object_type;
161
- if (viewerObjectType === "mesh") {
169
+ if (viewerObjectType === "image") {
170
+ await imageStyleStore.applyImageStyle(dataId);
171
+ } else if (viewerObjectType === "mesh") {
162
172
  await meshStyleStore.applyMeshStyle(dataId);
163
173
  } else if (viewerObjectType === "model") {
164
174
  await modelStyleStore.applyModelStyle(dataId);
@@ -177,6 +187,7 @@ export const useDataStyleStore = defineStore("dataStyle", () => {
177
187
  applyAllStylesFromState,
178
188
  ...dataStyleState,
179
189
  ...attributeTimeStepStyle,
190
+ ...imageStyleStore,
180
191
  ...meshStyleStore,
181
192
  ...modelStyleStore,
182
193
  ...sceneStyleStore,
@@ -0,0 +1,11 @@
1
+ import ImageOptions from "@ogw_front/components/Viewer/Image/ImageOptions.vue";
2
+ import type { MenuItems } from "./types.js";
3
+
4
+ const Image_menu = [ImageOptions];
5
+
6
+ const imageMenus: Record<string, MenuItems> = {
7
+ RasterImage2D: Image_menu,
8
+ RasterImage3D: Image_menu,
9
+ };
10
+
11
+ export { imageMenus };
@@ -3,12 +3,14 @@ import type { MenuItems } from "./types.js";
3
3
  import { basemapMenus } from "./basemap.js";
4
4
  import { edgedCurveMenus } from "./mesh/edged_curve.js";
5
5
  import { gridMenus } from "./mesh/grid.js";
6
+ import { imageMenus } from "./image.js";
6
7
  import { pointSetMenus } from "./mesh/point_set.js";
7
8
  import { sceneMenus } from "./scene.js";
8
9
  import { solidMenus } from "./mesh/solid.js";
9
10
  import { surfaceMenus } from "./mesh/surface.js";
10
11
 
11
12
  const menusData: Record<string, Record<string, MenuItems>> = {
13
+ image: imageMenus,
12
14
  mesh: {
13
15
  ...edgedCurveMenus,
14
16
  ...gridMenus,
@@ -7,12 +7,18 @@ import type {
7
7
  // Id of a component of a model (a corner, a line, a surface or a block): its geode_id
8
8
  type ModelComponentId = GeodeId;
9
9
 
10
+ // The data of an image, the data an image style applies to
11
+ type ImageId = DataId;
12
+
10
13
  // The data of a mesh, the data a mesh style applies to
11
14
  type MeshId = DataId;
12
15
 
13
16
  // The data of a model, the data a model style or a model component applies to
14
17
  type ModelId = DataId;
15
18
 
19
+ // The viewer objects the viewer can highlight: images are not pickable
20
+ type HighlightableObjectType = Exclude<ViewerObjectType, "image">;
21
+
16
22
  // A corner of a model, by its id in the model
17
23
  type CornerId = ModelComponentId;
18
24
 
@@ -52,6 +58,8 @@ export type {
52
58
  DataIdentified,
53
59
  GeodeIdentified,
54
60
  GeodeObjectTyped,
61
+ HighlightableObjectType,
62
+ ImageId,
55
63
  LineId,
56
64
  MeshId,
57
65
  ModelComponentId,
package/app/utils/crs.ts CHANGED
@@ -1,6 +1,21 @@
1
1
  import type { CrsItem, NewDataItem } from "@ogw_front/stores/data";
2
2
  import type { CRS } from "@geode/opengeodeweb-back/schema_types";
3
3
  import type { LegacyDataId } from "@ogw_front/utils/legacy_data_id";
4
+ import { z } from "zod";
5
+
6
+ // Only what a CRS selector shows: the back may add other fields
7
+ interface CrsEntry {
8
+ authority: string;
9
+ code: string;
10
+ name: string;
11
+ }
12
+
13
+ // A stored CRS entry (favorites, history): unknown fields are dropped on read
14
+ const crsEntrySchema = z.object({
15
+ authority: z.string(),
16
+ code: z.string(),
17
+ name: z.string(),
18
+ });
4
19
 
5
20
  function formatCrs(crs: CRS | undefined): string {
6
21
  return crs ? `${crs.authority}:${crs.code} — ${crs.name}` : "None";
@@ -38,4 +53,5 @@ function oldestCrs(
38
53
  ?.crs;
39
54
  }
40
55
 
41
- export { formatCrs, formatCrsCode, oldestCrs, sameCrs, sameCrsState };
56
+ export type { CrsEntry };
57
+ export { crsEntrySchema, formatCrs, formatCrsCode, oldestCrs, sameCrs, sameCrsState };
@@ -0,0 +1,16 @@
1
+ import type { Opacity, Visibility } from "@geode/opengeodeweb-viewer/schema_types";
2
+
3
+ interface ImageStyle {
4
+ visibility: Visibility;
5
+ opacity: Opacity;
6
+ }
7
+
8
+ function imageDefaultStyle(): ImageStyle {
9
+ return {
10
+ visibility: true,
11
+ opacity: 1,
12
+ };
13
+ }
14
+
15
+ export { imageDefaultStyle };
16
+ export type { ImageStyle };
@@ -22,6 +22,7 @@ import {
22
22
  } from "./meshes";
23
23
  import type { ColorRGBA } from "@geode/opengeodeweb-viewer/schema_types";
24
24
  import type { SceneStyle } from "@ogw_internal/stores/data_style/types";
25
+ import { imageDefaultStyle } from "./images";
25
26
 
26
27
  function default_styles(): Record<string, unknown> {
27
28
  return {
@@ -40,8 +41,8 @@ function default_styles(): Record<string, unknown> {
40
41
  PolygonalSurface2D: surfaceDefaultStyle(),
41
42
  PolygonalSurface3D: surfaceDefaultStyle(),
42
43
  PolyhedralSolid3D: solidDefaultStyle(),
43
- RasterImage2D: {},
44
- RasterImage3D: {},
44
+ RasterImage2D: imageDefaultStyle(),
45
+ RasterImage3D: imageDefaultStyle(),
45
46
  RegularGrid2D: grid2dDefaultStyle(),
46
47
  RegularGrid3D: grid3dDefaultStyle(),
47
48
  Section: sectionDefaultStyle(),