@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.
- package/.build/server/utils/microservices_process.js +1 -1
- package/.build/tests/browser/helpers/crs.js +136 -0
- package/.build/tests/browser/helpers/crs_flows.js +60 -0
- package/.build/tests/browser/helpers/crs_shortlist.js +13 -0
- package/.build/tests/browser/helpers/crs_test_data.js +40 -0
- package/.build/tests/browser/helpers/image.js +25 -0
- package/.build/tests/browser/suites/crs.js +142 -0
- package/.build/tests/browser/suites/crs_harmonize.js +63 -0
- package/.build/tests/browser/suites/crs_shortlist.js +31 -0
- package/.build/tests/browser/suites/image/raster_image.js +33 -0
- package/.build/tests/browser/suites/index.js +8 -0
- package/app/app.config.ts +4 -0
- package/app/components/CrsAlign.vue +207 -0
- package/app/components/CrsDialog.vue +400 -0
- package/app/components/CrsDialogHost.vue +66 -0
- package/app/components/CrsSelector.vue +100 -3
- package/app/components/PickButton.vue +43 -0
- package/app/components/ProjectCrsDialog.vue +109 -0
- package/app/components/ToolPanel.vue +5 -2
- package/app/components/Viewer/CrsOverlays.vue +29 -0
- package/app/components/Viewer/Image/ImageOptions.vue +67 -0
- package/app/components/Viewer/ObjectTree/Views/GlobalObjects.vue +3 -2
- package/app/components/Viewer/Ui.vue +3 -2
- package/app/composables/crs.ts +197 -0
- package/app/composables/crs_align.ts +206 -0
- package/app/composables/crs_assign.ts +102 -0
- package/app/composables/crs_link.ts +22 -0
- package/app/composables/crs_shortlist.ts +63 -0
- package/app/composables/hover_highlight.ts +6 -5
- package/app/composables/project_crs.ts +197 -0
- package/app/composables/use_overlapping_picker.ts +6 -1
- package/app/composables/user_setting.ts +140 -0
- package/app/stores/basemap.ts +19 -2
- package/app/stores/crs.ts +11 -106
- package/app/stores/crs_helpers/geographic_list.ts +44 -0
- package/app/stores/crs_helpers/project_crs.ts +60 -0
- package/app/stores/crs_helpers/requests.ts +60 -0
- package/app/stores/data_style.ts +12 -1
- package/app/stores/menu_helpers/image.ts +11 -0
- package/app/stores/menu_helpers/menus_data.ts +2 -0
- package/app/types/identifiers.ts +8 -0
- package/app/utils/crs.ts +17 -1
- package/app/utils/default_styles/images.ts +16 -0
- package/app/utils/default_styles/index.ts +3 -2
- package/app/utils/import_item.ts +87 -0
- package/app/utils/import_workflow.ts +36 -94
- package/app/utils/reload_object.ts +26 -0
- package/app/utils/threshold_sources.ts +5 -1
- package/internal/stores/data_style/image/index.ts +107 -0
- package/package.json +1 -1
- package/server/utils/microservices_process.ts +4 -1
- package/tests/browser/data/test_lambert93_no_crs.og_pts3d +0 -0
- package/tests/browser/data/test_utm31n.og_pts3d +0 -0
- package/tests/browser/helpers/crs.ts +250 -0
- package/tests/browser/helpers/crs_flows.ts +115 -0
- package/tests/browser/helpers/crs_shortlist.ts +27 -0
- package/tests/browser/helpers/crs_test_data.ts +34 -0
- package/tests/browser/helpers/image.ts +33 -0
- package/tests/browser/suites/crs.ts +228 -0
- package/tests/browser/suites/crs_harmonize.ts +96 -0
- package/tests/browser/suites/crs_shortlist.ts +37 -0
- package/tests/browser/suites/image/raster_image.ts +40 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// Local imports
|
|
2
|
+
import { type LegacyDataId, fromLegacyDataId } from "@ogw_front/utils/legacy_data_id";
|
|
3
|
+
import { type NewDataItem, useDataStore } from "@ogw_front/stores/data";
|
|
4
|
+
import { useDataStyleStore } from "@ogw_front/stores/data_style";
|
|
5
|
+
import { useFeedbackStore } from "@ogw_front/stores/feedback";
|
|
6
|
+
import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
|
|
7
|
+
import { useTreeviewStore } from "@ogw_front/stores/treeview";
|
|
8
|
+
|
|
9
|
+
// Steps that need the data stored first, and run only for the data the viewer shows
|
|
10
|
+
async function registerWhenViewable(item: NewDataItem, added: Promise<unknown>): Promise<unknown> {
|
|
11
|
+
const dataStore = useDataStore();
|
|
12
|
+
await added;
|
|
13
|
+
if (!(await dataStore.isItemViewable(item))) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
return dataStore.registerObject(item.data_id, item.name ?? item.data_id);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async function addToViewerWhenViewable(
|
|
20
|
+
item: NewDataItem,
|
|
21
|
+
added: Promise<unknown>,
|
|
22
|
+
): Promise<unknown> {
|
|
23
|
+
const dataStore = useDataStore();
|
|
24
|
+
await added;
|
|
25
|
+
if (!(await dataStore.isItemViewable(item))) {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
return useHybridViewerStore().addItem(item.data_id);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async function applyStyleWhenReady(item: NewDataItem, ready: Promise<unknown>): Promise<unknown> {
|
|
32
|
+
await ready;
|
|
33
|
+
if (!(await useDataStore().isItemViewable(item))) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
return useDataStyleStore().applyDefaultStyle(item.data_id);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// NewDataItem has mutable array fields (mesh_components, collection_components), so it can't
|
|
40
|
+
// Satisfy prefer-readonly-parameter-types deeply; left unfixed (same pattern as app/plugins/auto_store_register.ts).
|
|
41
|
+
async function importDataItem(item: NewDataItem): Promise<string> {
|
|
42
|
+
const dataStore = useDataStore();
|
|
43
|
+
const dataStyleStore = useDataStyleStore();
|
|
44
|
+
const treeviewStore = useTreeviewStore();
|
|
45
|
+
if (item.nb_vertices === 0) {
|
|
46
|
+
const feedbackStore = useFeedbackStore();
|
|
47
|
+
feedbackStore.add_warning(`"${item.geode_object_type}" with name "${item.name}" is empty`);
|
|
48
|
+
}
|
|
49
|
+
const addDataTask = dataStore.addItem(item);
|
|
50
|
+
const registerTask = registerWhenViewable(item, addDataTask);
|
|
51
|
+
let addDataComponentsTask: Promise<unknown> = Promise.resolve(undefined);
|
|
52
|
+
let addDataRelationsTask: Promise<unknown> = Promise.resolve(undefined);
|
|
53
|
+
if (item.viewer_object_type === "model") {
|
|
54
|
+
addDataComponentsTask = dataStore.addComponents(item);
|
|
55
|
+
addDataRelationsTask = dataStore.addComponentRelations(item);
|
|
56
|
+
}
|
|
57
|
+
treeviewStore.addItem(
|
|
58
|
+
item.geode_object_type,
|
|
59
|
+
item.name ?? item.data_id,
|
|
60
|
+
item.data_id,
|
|
61
|
+
item.geode_id,
|
|
62
|
+
item.viewer_object_type,
|
|
63
|
+
);
|
|
64
|
+
const addDataStyleTask = dataStyleStore.addDataStyle(item.data_id, item.geode_object_type);
|
|
65
|
+
const addViewerTask = addToViewerWhenViewable(item, addDataTask);
|
|
66
|
+
const applyStyleTask = applyStyleWhenReady(
|
|
67
|
+
item,
|
|
68
|
+
Promise.all([registerTask, addDataComponentsTask, addDataStyleTask]),
|
|
69
|
+
);
|
|
70
|
+
await Promise.all([
|
|
71
|
+
registerTask,
|
|
72
|
+
addDataTask,
|
|
73
|
+
addDataComponentsTask,
|
|
74
|
+
addDataRelationsTask,
|
|
75
|
+
addViewerTask,
|
|
76
|
+
applyStyleTask,
|
|
77
|
+
]);
|
|
78
|
+
return item.data_id;
|
|
79
|
+
}
|
|
80
|
+
// Every item comes through here: from the back-end, which still names its data id `id`, or from a project
|
|
81
|
+
async function importItem(imported: LegacyDataId<NewDataItem> | NewDataItem): Promise<string> {
|
|
82
|
+
const item = fromLegacyDataId(imported);
|
|
83
|
+
const dataId = await useTreeviewStore().untilLoaded(item.data_id, importDataItem(item));
|
|
84
|
+
return dataId;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export { importItem };
|
|
@@ -1,86 +1,26 @@
|
|
|
1
|
-
// oxlint-disable promise/prefer-await-to-then
|
|
2
1
|
// Third party imports
|
|
3
2
|
import back_schemas from "@geode/opengeodeweb-back/opengeodeweb_back_typed_schemas.js";
|
|
4
3
|
import { consola } from "consola";
|
|
5
4
|
|
|
6
5
|
// Local imports
|
|
7
|
-
import { type LegacyDataId, fromLegacyDataId } from "@ogw_front/utils/legacy_data_id";
|
|
8
6
|
import { type NewDataItem, useDataStore } from "@ogw_front/stores/data";
|
|
7
|
+
import type { CRS } from "@geode/opengeodeweb-back/schema_types";
|
|
9
8
|
import type { DataId } from "@geode/opengeodeweb-microservice/schema_types";
|
|
10
9
|
import type { GeodeObjectType } from "@geode/opengeodeweb-microservice/data_types";
|
|
11
10
|
import type { GeodeObjectTyped } from "@ogw_front/types/identifiers";
|
|
11
|
+
import type { LegacyDataId } from "@ogw_front/utils/legacy_data_id";
|
|
12
|
+
import { importItem } from "@ogw_front/utils/import_item";
|
|
13
|
+
import { reloadObject } from "@ogw_front/utils/reload_object";
|
|
12
14
|
import { useBackStore } from "@ogw_front/stores/back";
|
|
13
|
-
import {
|
|
14
|
-
import { useFeedbackStore } from "@ogw_front/stores/feedback";
|
|
15
|
+
import { useCrsStore } from "@ogw_front/stores/crs";
|
|
15
16
|
import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
|
|
17
|
+
import { useProjectCrs } from "@ogw_front/composables/project_crs";
|
|
16
18
|
import { useTreeviewStore } from "@ogw_front/stores/treeview";
|
|
17
19
|
|
|
18
20
|
interface FileToImport extends Readonly<GeodeObjectTyped> {
|
|
19
21
|
readonly filename: string;
|
|
20
22
|
}
|
|
21
23
|
|
|
22
|
-
// NewDataItem has mutable array fields (mesh_components, collection_components), so it can't
|
|
23
|
-
// Satisfy prefer-readonly-parameter-types deeply; left unfixed (same pattern as app/plugins/auto_store_register.ts).
|
|
24
|
-
async function importDataItem(item: NewDataItem): Promise<string> {
|
|
25
|
-
const dataStore = useDataStore();
|
|
26
|
-
const dataStyleStore = useDataStyleStore();
|
|
27
|
-
const hybridViewerStore = useHybridViewerStore();
|
|
28
|
-
const treeviewStore = useTreeviewStore();
|
|
29
|
-
if (item.nb_vertices === 0) {
|
|
30
|
-
const feedbackStore = useFeedbackStore();
|
|
31
|
-
feedbackStore.add_warning(`"${item.geode_object_type}" with name "${item.name}" is empty`);
|
|
32
|
-
}
|
|
33
|
-
const addDataTask = dataStore.addItem(item);
|
|
34
|
-
const registerTask = addDataTask.then(async () => {
|
|
35
|
-
if (!(await dataStore.isItemViewable(item))) {
|
|
36
|
-
return undefined;
|
|
37
|
-
}
|
|
38
|
-
return dataStore.registerObject(item.data_id, item.name ?? item.data_id);
|
|
39
|
-
});
|
|
40
|
-
let addDataComponentsTask: Promise<string | undefined> = Promise.resolve(undefined);
|
|
41
|
-
let addDataRelationsTask: Promise<string | undefined> = Promise.resolve(undefined);
|
|
42
|
-
if (item.viewer_object_type === "model") {
|
|
43
|
-
addDataComponentsTask = dataStore.addComponents(item);
|
|
44
|
-
addDataRelationsTask = dataStore.addComponentRelations(item);
|
|
45
|
-
}
|
|
46
|
-
treeviewStore.addItem(
|
|
47
|
-
item.geode_object_type,
|
|
48
|
-
item.name ?? item.data_id,
|
|
49
|
-
item.data_id,
|
|
50
|
-
item.geode_id,
|
|
51
|
-
item.viewer_object_type,
|
|
52
|
-
);
|
|
53
|
-
const addDataStyleTask = dataStyleStore.addDataStyle(item.data_id, item.geode_object_type);
|
|
54
|
-
const addViewerTask = addDataTask.then(async () => {
|
|
55
|
-
if (!(await dataStore.isItemViewable(item))) {
|
|
56
|
-
return undefined;
|
|
57
|
-
}
|
|
58
|
-
return hybridViewerStore.addItem(item.data_id);
|
|
59
|
-
});
|
|
60
|
-
const applyStyleTask = Promise.all([registerTask, addDataComponentsTask, addDataStyleTask]).then(
|
|
61
|
-
async () => {
|
|
62
|
-
if (await dataStore.isItemViewable(item)) {
|
|
63
|
-
return dataStyleStore.applyDefaultStyle(item.data_id);
|
|
64
|
-
}
|
|
65
|
-
return undefined;
|
|
66
|
-
},
|
|
67
|
-
);
|
|
68
|
-
await Promise.all([
|
|
69
|
-
registerTask,
|
|
70
|
-
addDataTask,
|
|
71
|
-
addDataComponentsTask,
|
|
72
|
-
addDataRelationsTask,
|
|
73
|
-
addViewerTask,
|
|
74
|
-
applyStyleTask,
|
|
75
|
-
]);
|
|
76
|
-
return item.data_id;
|
|
77
|
-
}
|
|
78
|
-
// Every item comes through here: from the back-end, which still names its data id `id`, or from a project
|
|
79
|
-
async function importItem(imported: LegacyDataId<NewDataItem> | NewDataItem): Promise<string> {
|
|
80
|
-
const item = fromLegacyDataId(imported);
|
|
81
|
-
const dataId = await useTreeviewStore().untilLoaded(item.data_id, importDataItem(item));
|
|
82
|
-
return dataId;
|
|
83
|
-
}
|
|
84
24
|
// A single file can hold several objects: every one of them is imported, ids are returned in the response order
|
|
85
25
|
async function importFile(filename: string, geode_object_type: GeodeObjectType): Promise<string[]> {
|
|
86
26
|
const backStore = useBackStore();
|
|
@@ -103,7 +43,7 @@ async function importFile(filename: string, geode_object_type: GeodeObjectType):
|
|
|
103
43
|
return dataIds;
|
|
104
44
|
}
|
|
105
45
|
|
|
106
|
-
async function
|
|
46
|
+
async function importFiles(files: readonly FileToImport[]): Promise<string[]> {
|
|
107
47
|
const hybridViewerStore = useHybridViewerStore();
|
|
108
48
|
// Files are imported concurrently and the viewer only frames the first actor to arrive, so the camera is reset once everything is loaded
|
|
109
49
|
const wasSceneEmpty = Object.keys(hybridViewerStore.hybridDb).length === 0;
|
|
@@ -148,6 +88,32 @@ async function importWorkflow(files: readonly FileToImport[]): Promise<string[]>
|
|
|
148
88
|
return results;
|
|
149
89
|
}
|
|
150
90
|
|
|
91
|
+
// A harmonization failure is only logged: the import outcome does not depend on it
|
|
92
|
+
async function harmonize(ids: string[], projectCrs: CRS | undefined): Promise<void> {
|
|
93
|
+
try {
|
|
94
|
+
await useProjectCrs().harmonizeImportedCrs(ids, projectCrs);
|
|
95
|
+
} catch (error) {
|
|
96
|
+
consola.error("CRS harmonization failed:", error);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// When a file fails, the workflow throws without returning the imported ids: they are found by difference.
|
|
101
|
+
// The project CRS is read before the import, as the project follows the data as they land.
|
|
102
|
+
async function importWorkflow(files: readonly FileToImport[]): Promise<string[]> {
|
|
103
|
+
const { projectCrs } = useCrsStore();
|
|
104
|
+
const existingItems = await useDataStore().allItems();
|
|
105
|
+
const existingIds = new Set(existingItems.map((item) => item.data_id));
|
|
106
|
+
try {
|
|
107
|
+
const ids = await importFiles(files);
|
|
108
|
+
return ids;
|
|
109
|
+
} finally {
|
|
110
|
+
const items = await useDataStore().allItems();
|
|
111
|
+
const importedIds = items.map((item) => item.data_id).filter((id) => !existingIds.has(id));
|
|
112
|
+
// Conversions can be long: the caller is not kept waiting, the snackbars report the outcome
|
|
113
|
+
void harmonize(importedIds, projectCrs);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
151
117
|
// NewDataItem has mutable array fields (mesh_components, collection_components), so a readonly array of it can't satisfy prefer-readonly-parameter-types deeply; left unfixed (same pattern as app/plugins/auto_store_register.ts).
|
|
152
118
|
async function importWorkflowFromSnapshot(
|
|
153
119
|
items: readonly (LegacyDataId<NewDataItem> | NewDataItem)[],
|
|
@@ -182,25 +148,6 @@ async function importWorkflowFromSnapshot(
|
|
|
182
148
|
return ids;
|
|
183
149
|
}
|
|
184
150
|
|
|
185
|
-
// Reloads the viewer object under the same id with its stored style, after the back rewrote its files.
|
|
186
|
-
async function reloadObject(
|
|
187
|
-
dataId: DataId,
|
|
188
|
-
{ rebuildActor = false }: { rebuildActor?: boolean } = {},
|
|
189
|
-
): Promise<void> {
|
|
190
|
-
const dataStore = useDataStore();
|
|
191
|
-
const dataStyleStore = useDataStyleStore();
|
|
192
|
-
const hybridViewerStore = useHybridViewerStore();
|
|
193
|
-
const item = await dataStore.item(dataId);
|
|
194
|
-
await dataStore.deregisterObject(dataId);
|
|
195
|
-
await dataStore.registerObject(dataId, item.name ?? dataId);
|
|
196
|
-
// Only when the geometry moved: the local actor is rebuilt from the stored light viewable
|
|
197
|
-
if (rebuildActor) {
|
|
198
|
-
await hybridViewerStore.addItem(dataId);
|
|
199
|
-
}
|
|
200
|
-
await dataStyleStore.applyDefaultStyle(dataId);
|
|
201
|
-
await hybridViewerStore.remoteRender();
|
|
202
|
-
}
|
|
203
|
-
|
|
204
151
|
// The time series only adds attributes to the model, so the viewer object is reloaded.
|
|
205
152
|
async function applyTimeSeriesWorkflow(filename: string, dataId: DataId): Promise<string> {
|
|
206
153
|
const backStore = useBackStore();
|
|
@@ -212,11 +159,6 @@ async function applyTimeSeriesWorkflow(filename: string, dataId: DataId): Promis
|
|
|
212
159
|
return dataId;
|
|
213
160
|
}
|
|
214
161
|
|
|
215
|
-
export {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
importWorkflowFromSnapshot,
|
|
219
|
-
importItem,
|
|
220
|
-
applyTimeSeriesWorkflow,
|
|
221
|
-
reloadObject,
|
|
222
|
-
};
|
|
162
|
+
export { importFile, importWorkflow, importWorkflowFromSnapshot, applyTimeSeriesWorkflow };
|
|
163
|
+
export { importItem } from "@ogw_front/utils/import_item";
|
|
164
|
+
export { reloadObject } from "@ogw_front/utils/reload_object";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Local imports
|
|
2
|
+
import type { DataId } from "@geode/opengeodeweb-microservice/schema_types";
|
|
3
|
+
import { useDataStore } from "@ogw_front/stores/data";
|
|
4
|
+
import { useDataStyleStore } from "@ogw_front/stores/data_style";
|
|
5
|
+
import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
|
|
6
|
+
|
|
7
|
+
// Reloads the viewer object under the same id with its stored style, after the back rewrote its files.
|
|
8
|
+
async function reloadObject(
|
|
9
|
+
dataId: DataId,
|
|
10
|
+
{ rebuildActor = false }: { rebuildActor?: boolean } = {},
|
|
11
|
+
): Promise<void> {
|
|
12
|
+
const dataStore = useDataStore();
|
|
13
|
+
const dataStyleStore = useDataStyleStore();
|
|
14
|
+
const hybridViewerStore = useHybridViewerStore();
|
|
15
|
+
const item = await dataStore.item(dataId);
|
|
16
|
+
await dataStore.deregisterObject(dataId);
|
|
17
|
+
await dataStore.registerObject(dataId, item.name ?? dataId);
|
|
18
|
+
// Only when the geometry moved: the local actor is rebuilt from the stored light viewable
|
|
19
|
+
if (rebuildActor) {
|
|
20
|
+
await hybridViewerStore.addItem(dataId);
|
|
21
|
+
}
|
|
22
|
+
await dataStyleStore.applyDefaultStyle(dataId);
|
|
23
|
+
await hybridViewerStore.remoteRender();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { reloadObject };
|
|
@@ -32,7 +32,11 @@ async function fetchSources(
|
|
|
32
32
|
dataId: DataId,
|
|
33
33
|
): Promise<AttributeSource[]> {
|
|
34
34
|
const item = await dataStore.item(dataId);
|
|
35
|
-
|
|
35
|
+
// An image shows its own colors: it has no attribute to threshold
|
|
36
|
+
if (item.viewer_object_type === "image") {
|
|
37
|
+
return [];
|
|
38
|
+
}
|
|
39
|
+
if (item.viewer_object_type === "mesh") {
|
|
36
40
|
return ["vertex", MESH_ELEMENT_KINDS[item.geode_object_type]]
|
|
37
41
|
.filter((kind): kind is string => kind !== undefined)
|
|
38
42
|
.map((kind) => attributeSource(kind, "", { id: dataId }));
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { Opacity, Visibility } from "@geode/opengeodeweb-viewer/schema_types";
|
|
2
|
+
import type { ImageId } from "@ogw_front/types/identifiers";
|
|
3
|
+
// Third party imports
|
|
4
|
+
import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_typed_schemas.js";
|
|
5
|
+
|
|
6
|
+
// Local imports
|
|
7
|
+
import { useDataStyleState } from "@ogw_internal/stores/data_style/state";
|
|
8
|
+
import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
|
|
9
|
+
import { useViewerStore } from "@ogw_front/stores/viewer";
|
|
10
|
+
import { whenDefined } from "@ogw_internal/stores/data_style/when_defined";
|
|
11
|
+
|
|
12
|
+
// Local constants
|
|
13
|
+
const imageSchemas = viewer_schemas.opengeodeweb_viewer.image;
|
|
14
|
+
|
|
15
|
+
interface ImageStyleStore {
|
|
16
|
+
imageVisibility: (imageId: ImageId) => Visibility | undefined;
|
|
17
|
+
setImageVisibility: (imageId: ImageId, visibility: Visibility) => Promise<unknown>;
|
|
18
|
+
imageOpacity: (imageId: ImageId) => Opacity | undefined;
|
|
19
|
+
setImageOpacity: (imageId: ImageId, opacity: Opacity) => Promise<unknown>;
|
|
20
|
+
applyImageStyle: (imageId: ImageId) => Promise<unknown[]>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// An image shows its own colors: only its visibility and its opacity are styled
|
|
24
|
+
// oxlint-disable-next-line max-lines-per-function
|
|
25
|
+
export function useImageStyle(): ImageStyleStore {
|
|
26
|
+
const hybridViewerStore = useHybridViewerStore();
|
|
27
|
+
const viewerStore = useViewerStore();
|
|
28
|
+
const dataStyleState = useDataStyleState();
|
|
29
|
+
|
|
30
|
+
function imageVisibility(imageId: ImageId): Visibility | undefined {
|
|
31
|
+
return dataStyleState.getStyle(imageId).visibility;
|
|
32
|
+
}
|
|
33
|
+
async function setImageVisibility(imageId: ImageId, visibility: Visibility): Promise<unknown> {
|
|
34
|
+
const params = { id: imageId, visibility };
|
|
35
|
+
const result = await viewerStore.request(
|
|
36
|
+
{
|
|
37
|
+
schema: imageSchemas.visibility,
|
|
38
|
+
params,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
response_function: async () => {
|
|
42
|
+
hybridViewerStore.setVisibility(imageId, visibility);
|
|
43
|
+
const mutatedId = await dataStyleState.mutateStyle(imageId, { visibility });
|
|
44
|
+
return mutatedId;
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
);
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function imageOpacity(imageId: ImageId): Opacity | undefined {
|
|
52
|
+
// oxlint-disable-next-line no-unsafe-type-assertion -- opacity shape is defined by the data style schema.
|
|
53
|
+
return dataStyleState.getStyle(imageId).opacity as Opacity | undefined;
|
|
54
|
+
}
|
|
55
|
+
async function setImageOpacity(imageId: ImageId, opacity: Opacity): Promise<unknown> {
|
|
56
|
+
const params = { id: imageId, opacity };
|
|
57
|
+
const result = await viewerStore.request(
|
|
58
|
+
{
|
|
59
|
+
schema: imageSchemas.opacity,
|
|
60
|
+
params,
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
response_function: async () => {
|
|
64
|
+
const mutatedId = await dataStyleState.mutateStyle(imageId, { opacity });
|
|
65
|
+
return mutatedId;
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
);
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async function applyImageStyle(imageId: ImageId): Promise<unknown[]> {
|
|
73
|
+
const style = dataStyleState.getStyle(imageId);
|
|
74
|
+
const promise_array: unknown[] = [];
|
|
75
|
+
for (const key of Object.keys(style)) {
|
|
76
|
+
if (key === "visibility") {
|
|
77
|
+
promise_array.push(
|
|
78
|
+
whenDefined(imageVisibility(imageId), async (visibility) => {
|
|
79
|
+
const applied = await setImageVisibility(imageId, visibility);
|
|
80
|
+
return applied;
|
|
81
|
+
}),
|
|
82
|
+
);
|
|
83
|
+
} else if (key === "opacity") {
|
|
84
|
+
promise_array.push(
|
|
85
|
+
whenDefined(imageOpacity(imageId), async (opacity) => {
|
|
86
|
+
const applied = await setImageOpacity(imageId, opacity);
|
|
87
|
+
return applied;
|
|
88
|
+
}),
|
|
89
|
+
);
|
|
90
|
+
} else if (key === "data_id") {
|
|
91
|
+
continue;
|
|
92
|
+
} else {
|
|
93
|
+
throw new Error(`Unknown image key: ${key}`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const results = await Promise.all(promise_array);
|
|
97
|
+
return results;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return {
|
|
101
|
+
imageVisibility,
|
|
102
|
+
setImageVisibility,
|
|
103
|
+
imageOpacity,
|
|
104
|
+
setImageOpacity,
|
|
105
|
+
applyImageStyle,
|
|
106
|
+
};
|
|
107
|
+
}
|
package/package.json
CHANGED
|
@@ -55,8 +55,11 @@ async function runScript(
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
// Windows reports a taken port as WinError 10048 ("only one usage of each socket address")
|
|
58
59
|
function isPortInUseError(error: unknown): boolean {
|
|
59
|
-
return /EADDRINUSE|address already in use|port already in use/iu.test(
|
|
60
|
+
return /EADDRINUSE|address already in use|port already in use|only one usage of each socket address/iu.test(
|
|
61
|
+
String(error),
|
|
62
|
+
);
|
|
60
63
|
}
|
|
61
64
|
|
|
62
65
|
function resolveUploadFolderPath(
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
// Third party imports
|
|
2
|
+
import { type Locator, type Page, expect } from "@playwright/test";
|
|
3
|
+
|
|
4
|
+
// Local imports
|
|
5
|
+
import { closeFeedbackSnackbar, moveMouseOutOfTheWay } from "./app_interaction";
|
|
6
|
+
import { expandGeodeObjectTypeInTree, getTreeRowByTextAndParent } from "./object_trees/common";
|
|
7
|
+
import { getMainObjectTree } from "./object_trees/main_object_tree";
|
|
8
|
+
import { waitForActionSettled } from "./wait_for_action_settled";
|
|
9
|
+
|
|
10
|
+
const TOOLTIP_TIMEOUT_MS = 2000;
|
|
11
|
+
const TOOLTIP_HOVER_ATTEMPTS = 3;
|
|
12
|
+
|
|
13
|
+
async function getDataTreeRow(
|
|
14
|
+
window: Page,
|
|
15
|
+
geodeObjectType: string,
|
|
16
|
+
dataName: string,
|
|
17
|
+
): Promise<Locator> {
|
|
18
|
+
const tree = getMainObjectTree(window);
|
|
19
|
+
await expandGeodeObjectTypeInTree(window, geodeObjectType, tree);
|
|
20
|
+
return getTreeRowByTextAndParent(window, geodeObjectType, dataName, tree);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// The tooltip opens on mouseenter: a hover landing while the tree re-renders misses it, so it is retried from
|
|
24
|
+
// Outside the row
|
|
25
|
+
async function hoverTreeRowTooltip(window: Page, row: Locator, target: Locator): Promise<void> {
|
|
26
|
+
// Each attempt waits for the previous hover: they must run one after another
|
|
27
|
+
// oxlint-disable no-await-in-loop
|
|
28
|
+
for (let attempt = 1; attempt <= TOOLTIP_HOVER_ATTEMPTS; attempt += 1) {
|
|
29
|
+
await moveMouseOutOfTheWay(window);
|
|
30
|
+
await row.getByTestId("treeItemLabel").first().hover();
|
|
31
|
+
const shown = await target
|
|
32
|
+
.waitFor({ state: "visible", timeout: TOOLTIP_TIMEOUT_MS })
|
|
33
|
+
.then(() => true)
|
|
34
|
+
.catch(() => false);
|
|
35
|
+
if (shown) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
// oxlint-enable no-await-in-loop
|
|
40
|
+
throw new Error(`The tree tooltip did not open after ${TOOLTIP_HOVER_ATTEMPTS} hovers`);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async function openCrsFromTree(
|
|
44
|
+
window: Page,
|
|
45
|
+
geodeObjectType: string,
|
|
46
|
+
dataName: string,
|
|
47
|
+
): Promise<void> {
|
|
48
|
+
const row = await getDataTreeRow(window, geodeObjectType, dataName);
|
|
49
|
+
const editButton = window.locator(".v-overlay--active").getByTestId("editCrsBtn");
|
|
50
|
+
await hoverTreeRowTooltip(window, row, editButton);
|
|
51
|
+
await editButton.click();
|
|
52
|
+
await waitForActionSettled(window);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// The tooltip of the tree row shows the crs of the data
|
|
56
|
+
async function expectTreeCrs(
|
|
57
|
+
window: Page,
|
|
58
|
+
geodeObjectType: string,
|
|
59
|
+
dataName: string,
|
|
60
|
+
expected: string,
|
|
61
|
+
): Promise<void> {
|
|
62
|
+
const row = await getDataTreeRow(window, geodeObjectType, dataName);
|
|
63
|
+
const crsValue = window.locator(".v-overlay--active").getByTestId("tooltipCrsValue");
|
|
64
|
+
await hoverTreeRowTooltip(window, row, crsValue);
|
|
65
|
+
await expect(crsValue).toContainText(expected);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async function openCrsFromInfoCard(
|
|
69
|
+
window: Page,
|
|
70
|
+
geodeObjectType: string,
|
|
71
|
+
dataName: string,
|
|
72
|
+
): Promise<void> {
|
|
73
|
+
const row = await getDataTreeRow(window, geodeObjectType, dataName);
|
|
74
|
+
await row.click({ button: "right" });
|
|
75
|
+
await waitForActionSettled(window);
|
|
76
|
+
await window.getByTestId("circularMenuCenterButton").click();
|
|
77
|
+
await window.getByTestId("infoEditCrsBtn").click();
|
|
78
|
+
await waitForActionSettled(window);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// The warning icon of the tree opens the crs dialog of the data
|
|
82
|
+
async function openCrsFromWarning(
|
|
83
|
+
window: Page,
|
|
84
|
+
geodeObjectType: string,
|
|
85
|
+
dataName: string,
|
|
86
|
+
): Promise<void> {
|
|
87
|
+
const row = await getDataTreeRow(window, geodeObjectType, dataName);
|
|
88
|
+
await row.getByTestId("crsMismatchIcon").click();
|
|
89
|
+
await waitForActionSettled(window);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
async function openCrsFromFeedback(window: Page, text: string): Promise<void> {
|
|
93
|
+
const snackbar = window.getByTestId("feedbackSnackbar").filter({ hasText: text });
|
|
94
|
+
await expect(snackbar).toBeVisible();
|
|
95
|
+
await snackbar.getByTestId("feedbackActionBtn").click();
|
|
96
|
+
await waitForActionSettled(window);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Selecting is its own step so the dialog state is captured before the action
|
|
100
|
+
async function selectCrs(window: Page, crsName: string): Promise<void> {
|
|
101
|
+
await window.getByTestId("crsSearchInput").locator("input").fill(crsName);
|
|
102
|
+
// A click on the row selects it: the list has no checkbox column
|
|
103
|
+
await window.locator("tbody tr").filter({ hasText: crsName }).first().click();
|
|
104
|
+
await waitForActionSettled(window);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async function confirmAssign(window: Page): Promise<void> {
|
|
108
|
+
await window.getByTestId("crsAssignButton").click();
|
|
109
|
+
await waitForActionSettled(window);
|
|
110
|
+
// The global feedback snackbar outlives the next step: close it so screenshots stay stable
|
|
111
|
+
await closeFeedbackSnackbar(window);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
async function expectCurrentCrs(window: Page, expected: string): Promise<void> {
|
|
115
|
+
await expect(window.getByTestId("crsCurrentValue")).toContainText(expected);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// A georeferenced data opens on convert
|
|
119
|
+
async function selectAssignMode(window: Page): Promise<void> {
|
|
120
|
+
await window.getByTestId("crsModeAssign").click();
|
|
121
|
+
await waitForActionSettled(window);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Without closing the feedback: the step checks the dialog or the warning it shows
|
|
125
|
+
async function clickAssign(window: Page): Promise<void> {
|
|
126
|
+
await window.getByTestId("crsAssignButton").click();
|
|
127
|
+
await waitForActionSettled(window);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// The snackbar leaves after 10s: a slow basemap build (external tile servers) can outlast it while the action
|
|
131
|
+
// Settles, so it is watched from before the action
|
|
132
|
+
const FEEDBACK_TIMEOUT_MS = 60_000;
|
|
133
|
+
|
|
134
|
+
async function expectFeedback(
|
|
135
|
+
window: Page,
|
|
136
|
+
text: string,
|
|
137
|
+
action: () => Promise<void>,
|
|
138
|
+
): Promise<void> {
|
|
139
|
+
const shown = window
|
|
140
|
+
.getByTestId("feedbackSnackbar")
|
|
141
|
+
.filter({ hasText: text })
|
|
142
|
+
// Several builds can fail with the same message (e.g. one per aligned data): any of them will do
|
|
143
|
+
.first()
|
|
144
|
+
.waitFor({ state: "visible", timeout: FEEDBACK_TIMEOUT_MS });
|
|
145
|
+
await Promise.all([shown, action()]);
|
|
146
|
+
await closeFeedbackSnackbar(window);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
async function selectConvertMode(window: Page): Promise<void> {
|
|
150
|
+
await window.getByTestId("crsModeConvert").click();
|
|
151
|
+
await waitForActionSettled(window);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
async function confirmConvert(window: Page): Promise<void> {
|
|
155
|
+
await window.getByTestId("crsConvertButton").click();
|
|
156
|
+
await waitForActionSettled(window);
|
|
157
|
+
await closeFeedbackSnackbar(window);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
async function startAlignment(window: Page): Promise<void> {
|
|
161
|
+
await window.getByTestId("crsModeAlign").click();
|
|
162
|
+
await window.getByTestId("crsStartAlignButton").click();
|
|
163
|
+
await waitForActionSettled(window);
|
|
164
|
+
// The mouse left on the button would open its tooltip over the panel
|
|
165
|
+
await moveMouseOutOfTheWay(window);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
async function fillAlignPoints(
|
|
169
|
+
window: Page,
|
|
170
|
+
prefix: "crsAlignSource" | "crsAlignTarget",
|
|
171
|
+
points: { x: number; y: number }[],
|
|
172
|
+
): Promise<void> {
|
|
173
|
+
// Fills share the keyboard focus: they must run one after another
|
|
174
|
+
// oxlint-disable no-await-in-loop
|
|
175
|
+
for (const [index, { x, y }] of points.entries()) {
|
|
176
|
+
const inputs = window.getByTestId(`${prefix}-${index}`).locator("input");
|
|
177
|
+
await inputs.nth(0).fill(String(x));
|
|
178
|
+
await inputs.nth(1).fill(String(y));
|
|
179
|
+
}
|
|
180
|
+
// oxlint-enable no-await-in-loop
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
async function selectAlignmentCrs(window: Page, crsName: string): Promise<void> {
|
|
184
|
+
const panel = window.getByTestId("crsAlignPanel");
|
|
185
|
+
await panel.getByTestId("crsSearchInput").locator("input").fill(crsName);
|
|
186
|
+
await panel.locator("tbody tr").filter({ hasText: crsName }).first().click();
|
|
187
|
+
await waitForActionSettled(window);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// "All data" or "This data only", in the crs dialog (crsScope) or the align panel (crsAlignScope)
|
|
191
|
+
async function selectScope(
|
|
192
|
+
window: Page,
|
|
193
|
+
scope: "all" | "one",
|
|
194
|
+
testId: "crsScope" | "crsAlignScope" = "crsScope",
|
|
195
|
+
): Promise<void> {
|
|
196
|
+
await window.getByTestId(`${testId}-${scope}`).locator("input").check();
|
|
197
|
+
await waitForActionSettled(window);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
async function expectCrsMismatch(
|
|
201
|
+
window: Page,
|
|
202
|
+
geodeObjectType: string,
|
|
203
|
+
dataName: string,
|
|
204
|
+
expected: boolean,
|
|
205
|
+
): Promise<void> {
|
|
206
|
+
const row = await getDataTreeRow(window, geodeObjectType, dataName);
|
|
207
|
+
// The icon only exists on a mismatched data
|
|
208
|
+
await expect(row.getByTestId("crsMismatchIcon")).toHaveCount(expected ? 1 : 0);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
async function openProjectCrs(window: Page): Promise<void> {
|
|
212
|
+
await window.getByTestId("projectCrs").click();
|
|
213
|
+
await waitForActionSettled(window);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
async function confirmProjectCrs(window: Page): Promise<void> {
|
|
217
|
+
await window.getByTestId("projectCrsApply").click();
|
|
218
|
+
await waitForActionSettled(window);
|
|
219
|
+
await closeFeedbackSnackbar(window);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
async function applyAlignment(window: Page): Promise<void> {
|
|
223
|
+
await window.getByTestId("crsAlignApplyButton").click();
|
|
224
|
+
await waitForActionSettled(window);
|
|
225
|
+
await closeFeedbackSnackbar(window);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export {
|
|
229
|
+
applyAlignment,
|
|
230
|
+
clickAssign,
|
|
231
|
+
confirmAssign,
|
|
232
|
+
confirmConvert,
|
|
233
|
+
confirmProjectCrs,
|
|
234
|
+
expectCrsMismatch,
|
|
235
|
+
expectCurrentCrs,
|
|
236
|
+
expectFeedback,
|
|
237
|
+
expectTreeCrs,
|
|
238
|
+
fillAlignPoints,
|
|
239
|
+
openCrsFromFeedback,
|
|
240
|
+
openCrsFromInfoCard,
|
|
241
|
+
openCrsFromTree,
|
|
242
|
+
openCrsFromWarning,
|
|
243
|
+
openProjectCrs,
|
|
244
|
+
selectAlignmentCrs,
|
|
245
|
+
selectAssignMode,
|
|
246
|
+
selectConvertMode,
|
|
247
|
+
selectCrs,
|
|
248
|
+
selectScope,
|
|
249
|
+
startAlignment,
|
|
250
|
+
};
|