@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,207 @@
1
+ <script setup lang="ts">
2
+ import type { CRS } from "@geode/opengeodeweb-back/schema_types";
3
+ import CrsSelector from "@ogw_front/components/CrsSelector.vue";
4
+ import PickButton from "@ogw_front/components/PickButton.vue";
5
+ import { useCrs } from "@ogw_front/composables/crs";
6
+ import { useCrsAlign } from "@ogw_front/composables/crs_align";
7
+ import { useCrsLinkCandidates } from "@ogw_front/composables/crs_link";
8
+ import { useCrsShortlist } from "@ogw_front/composables/crs_shortlist";
9
+ import { useCrsStore } from "@ogw_front/stores/crs";
10
+ import { useFeedbackStore } from "@ogw_front/stores/feedback";
11
+ import { useLiveDataItem } from "@ogw_front/composables/live_data_item";
12
+
13
+ const feedbackStore = useFeedbackStore();
14
+ const { alignCrs, followProject } = useCrs();
15
+ const crsStore = useCrsStore();
16
+ const { favorites, recent, toggleFavorite, recordUse } = useCrsShortlist();
17
+ const {
18
+ sourcePoints,
19
+ targetPoints,
20
+ pickingActive,
21
+ togglePickMode,
22
+ reset,
23
+ isComplete,
24
+ toSourceCrsPoints,
25
+ toTargetCrsPoints,
26
+ editSourcePoint,
27
+ } = useCrsAlign();
28
+
29
+ const targetCrs = ref<CRS | undefined>(undefined);
30
+ const applying = ref(false);
31
+ // "All data": the data in the same CRS state, usually sharing the local frame of the item
32
+ const scope = ref<"all" | "one">("all");
33
+ const linkCandidates = useCrsLinkCandidates(() => crsStore.crsAlignItem);
34
+ // Read live by its id: the data may be deleted while it is being aligned
35
+ const liveItem = useLiveDataItem(() => crsStore.crsAlignItem?.data_id);
36
+
37
+ watch(
38
+ () => crsStore.crsAlignItem,
39
+ (crsAlignItem) => {
40
+ reset();
41
+ targetCrs.value = undefined;
42
+ // Data in local coordinates usually share a frame; data in a CRS are usually the whole project
43
+ scope.value = crsAlignItem?.crs === undefined ? "all" : "one";
44
+ },
45
+ { immediate: true },
46
+ );
47
+
48
+ function successMessage(count: number): string {
49
+ return count > 1 ? `Data georeferenced (${count} items)` : "Data georeferenced";
50
+ }
51
+
52
+ function close(): void {
53
+ reset();
54
+ crsStore.closeCrsAlign();
55
+ }
56
+
57
+ // The live query answers nothing once the data is deleted: nothing is left to align
58
+ watch(liveItem, (value) => {
59
+ if (value === undefined && crsStore.crsAlignItem !== undefined) {
60
+ close();
61
+ }
62
+ });
63
+
64
+ async function apply(): Promise<void> {
65
+ const item = crsStore.crsAlignItem;
66
+ if (!item || !targetCrs.value || !isComplete.value || applying.value) {
67
+ return;
68
+ }
69
+ applying.value = true;
70
+ try {
71
+ const linkedItems = scope.value === "all" ? linkCandidates.value : [];
72
+ const crs = targetCrs.value;
73
+ // Taken before: the project follows the aligned data as soon as they are stored
74
+ const { projectCrs } = crsStore;
75
+ await alignCrs(item, crs, {
76
+ sourcePoints: toSourceCrsPoints(),
77
+ targetPoints: toTargetCrsPoints(),
78
+ linkedItems,
79
+ });
80
+ feedbackStore.add_success(successMessage(1 + linkedItems.length));
81
+ recordUse(crs);
82
+ // Typed in the target CRS: the data then join the project CRS
83
+ await followProject(
84
+ [item, ...linkedItems].map(({ data_id, name }) => ({ data_id, name, crs })),
85
+ projectCrs,
86
+ );
87
+ close();
88
+ } finally {
89
+ applying.value = false;
90
+ }
91
+ }
92
+ </script>
93
+
94
+ <template>
95
+ <v-card flat color="transparent" class="d-flex flex-column h-100 w-100 pa-3">
96
+ <div class="d-flex align-center mb-2">
97
+ <v-icon start icon="ph-triangle" size="18" />
98
+ <!-- One line: a long data name is truncated, the full name is in the tooltip -->
99
+ <h2 class="text-subtitle-1 font-weight-bold mb-0 text-truncate" style="min-width: 0">
100
+ Georeference {{ crsStore.crsAlignItem?.name }}
101
+ <v-tooltip activator="parent" location="bottom">
102
+ Georeference {{ crsStore.crsAlignItem?.name }}
103
+ </v-tooltip>
104
+ </h2>
105
+ <v-spacer />
106
+ <v-btn icon size="x-small" variant="text" @click="close">
107
+ <v-icon size="16">ph-x</v-icon>
108
+ </v-btn>
109
+ </div>
110
+
111
+ <!-- In the floating panel: the points scroll rather than leave the viewer -->
112
+ <v-card-text class="px-0 flex-grow-1 overflow-y-auto" style="max-height: 60vh">
113
+ <!-- At the top: what gets aligned must stay visible without scrolling -->
114
+ <v-radio-group
115
+ v-model="scope"
116
+ inline
117
+ hide-details
118
+ density="compact"
119
+ class="mb-3"
120
+ data-testid="crsAlignScope"
121
+ >
122
+ <v-radio label="All data" value="all" data-testid="crsAlignScope-all" />
123
+ <v-radio label="This data only" value="one" data-testid="crsAlignScope-one" />
124
+ </v-radio-group>
125
+ <div class="text-caption font-weight-bold text-uppercase opacity-60 mb-1">
126
+ Source points (on data)
127
+ </div>
128
+ <v-row
129
+ v-for="(point, index) in sourcePoints"
130
+ :key="'source-' + index"
131
+ dense
132
+ :data-testid="'crsAlignSource-' + index"
133
+ >
134
+ <v-col v-for="coord in ['x', 'y'] as const" :key="coord" cols="6">
135
+ <v-text-field
136
+ :model-value="point[coord]"
137
+ @update:model-value="(value) => editSourcePoint(index, coord, value)"
138
+ inputmode="decimal"
139
+ variant="outlined"
140
+ color="primary"
141
+ density="compact"
142
+ bg-color="surface-light"
143
+ hide-details
144
+ :label="coord.toUpperCase()"
145
+ />
146
+ </v-col>
147
+ </v-row>
148
+ <!-- PickButton's root is a tooltip: spacing classes must sit on a wrapper -->
149
+ <div class="mt-3">
150
+ <PickButton :active="pickingActive" @click="togglePickMode" />
151
+ </div>
152
+
153
+ <div class="text-caption font-weight-bold text-uppercase opacity-60 mt-4 mb-1">
154
+ Target points
155
+ </div>
156
+ <v-row
157
+ v-for="(point, index) in targetPoints"
158
+ :key="'target-' + index"
159
+ dense
160
+ :data-testid="'crsAlignTarget-' + index"
161
+ >
162
+ <v-col v-for="coord in ['x', 'y']" :key="coord" cols="6">
163
+ <v-text-field
164
+ v-model="point[coord]"
165
+ inputmode="decimal"
166
+ variant="outlined"
167
+ color="primary"
168
+ density="compact"
169
+ bg-color="surface-light"
170
+ hide-details
171
+ :label="coord.toUpperCase()"
172
+ />
173
+ </v-col>
174
+ </v-row>
175
+
176
+ <div class="text-caption font-weight-bold text-uppercase opacity-60 mt-4 mb-1">
177
+ Target CRS
178
+ </div>
179
+ <CrsSelector
180
+ v-if="crsStore.crsAlignItem"
181
+ :key="crsStore.crsAlignItem.data_id"
182
+ v-model="targetCrs"
183
+ compact
184
+ :geode-object-type="crsStore.crsAlignItem.geode_object_type"
185
+ :favorites="favorites"
186
+ :recent="recent"
187
+ @toggle-favorite="toggleFavorite"
188
+ />
189
+ </v-card-text>
190
+
191
+ <v-card-actions class="px-0 pb-0">
192
+ <v-spacer />
193
+ <v-btn
194
+ color="accent"
195
+ variant="flat"
196
+ data-testid="crsAlignApplyButton"
197
+ :disabled="!isComplete || !targetCrs || applying"
198
+ :loading="applying"
199
+ class="text-none rounded-pill font-weight-bold"
200
+ @click="apply"
201
+ >
202
+ <v-icon start>ph-check-circle</v-icon>
203
+ Apply
204
+ </v-btn>
205
+ </v-card-actions>
206
+ </v-card>
207
+ </template>
@@ -0,0 +1,400 @@
1
+ <script setup lang="ts">
2
+ import {
3
+ type AssignResponse,
4
+ buildAssignedEntries,
5
+ plausibleEntries,
6
+ useImplausibleWarning,
7
+ useOpenCrsAlignment,
8
+ } from "@ogw_front/composables/crs_assign";
9
+ import { type CrsItem, useDataStore } from "@ogw_front/stores/data";
10
+ import { formatCrs, formatCrsCode } from "@ogw_front/utils/crs";
11
+ import type { CRS } from "@geode/opengeodeweb-back/schema_types";
12
+ import CrsSelector from "@ogw_front/components/CrsSelector.vue";
13
+ import GlassCard from "@ogw_front/components/GlassCard.vue";
14
+ import back_schemas from "@geode/opengeodeweb-back/opengeodeweb_back_typed_schemas.js";
15
+ import { useBackStore } from "@ogw_front/stores/back";
16
+ import { useCrs } from "@ogw_front/composables/crs";
17
+ import { useCrsLinkCandidates } from "@ogw_front/composables/crs_link";
18
+ import { useCrsShortlist } from "@ogw_front/composables/crs_shortlist";
19
+ import { useCrsStore } from "@ogw_front/stores/crs";
20
+ import { useFeedbackStore } from "@ogw_front/stores/feedback";
21
+ import { useLiveDataItem } from "@ogw_front/composables/live_data_item";
22
+
23
+ const { show = false, itemId = undefined } = defineProps<{
24
+ show?: boolean;
25
+ itemId?: string;
26
+ }>();
27
+
28
+ // Read live by its id: the stored CRS shown and the candidates follow the changes
29
+ const liveItem = useLiveDataItem(() => itemId);
30
+ // The live query starts with an empty placeholder: the item is ready once it is the asked one
31
+ const item = computed(() => (liveItem.value?.data_id === itemId ? liveItem.value : undefined));
32
+
33
+ const emit = defineEmits<{
34
+ "update:show": [value: boolean];
35
+ assigned: [];
36
+ converted: [];
37
+ }>();
38
+
39
+ const backStore = useBackStore();
40
+ const crsStore = useCrsStore();
41
+ const dataStore = useDataStore();
42
+ const currentCrs = ref("");
43
+ const selectedCrs = ref<CRS | undefined>(undefined);
44
+ const assigning = ref(false);
45
+ const loadingCurrentCrs = ref(false);
46
+ const { convertCrs, changeProjectCrs, followProject } = useCrs();
47
+ const { favorites, recent, toggleFavorite, recordUse } = useCrsShortlist();
48
+ const isGeographic = ref(false);
49
+ const crsKnown = ref(false);
50
+ const mode = ref<"assign" | "convert" | "align">("assign");
51
+ const converting = ref(false);
52
+ // "All data": the data in the same CRS state for assign, the whole project for convert
53
+ const scope = ref<"all" | "one">("one");
54
+ // Relabeling a georeferenced data whose coordinates do not fit is usually a missed convert
55
+ const assignMismatch = ref<string | undefined>(undefined);
56
+ const linkCandidates = useCrsLinkCandidates(() => item.value);
57
+
58
+ // A wrong CRS is the error of one data; a CRS change usually moves the whole project
59
+ watch(mode, (value) => {
60
+ scope.value = value === "assign" ? "one" : "all";
61
+ assignMismatch.value = undefined;
62
+ });
63
+
64
+ async function fetchCurrentCrs(): Promise<void> {
65
+ currentCrs.value = "";
66
+ selectedCrs.value = undefined;
67
+ scope.value = "one";
68
+ assignMismatch.value = undefined;
69
+ mode.value = "assign";
70
+ isGeographic.value = false;
71
+ crsKnown.value = false;
72
+ if (itemId === undefined) {
73
+ return;
74
+ }
75
+ const dataId = itemId;
76
+ loadingCurrentCrs.value = true;
77
+ try {
78
+ await backStore.request(
79
+ {
80
+ schema: back_schemas.opengeodeweb_back.crs.active,
81
+ params: { id: dataId },
82
+ },
83
+ {
84
+ // Without geographic info, the active CRS is OpenGeode's default local one ("points")
85
+ response_function: async ({ crs_info }) => {
86
+ isGeographic.value = crs_info !== undefined;
87
+ // Changing the CRS of a georeferenced data is reprojecting it
88
+ if (crs_info !== undefined) {
89
+ mode.value = "convert";
90
+ }
91
+ crsKnown.value = true;
92
+ currentCrs.value = crs_info
93
+ ? `${crs_info.authority}:${crs_info.code} — ${crs_info.name}`
94
+ : "None (local coordinates)";
95
+ // The file is the reference: refresh the stored CRS shown in the table and tree,
96
+ // Only when it differs, as each write refreshes every live view of the data
97
+ if (item.value !== undefined && formatCrs(item.value.crs) !== formatCrs(crs_info)) {
98
+ await dataStore.updateItem(dataId, { crs: crs_info });
99
+ }
100
+ },
101
+ },
102
+ );
103
+ } finally {
104
+ loadingCurrentCrs.value = false;
105
+ }
106
+ }
107
+
108
+ watch(
109
+ () => show && itemId,
110
+ async (value) => {
111
+ if (value) {
112
+ await fetchCurrentCrs();
113
+ }
114
+ },
115
+ { immediate: true },
116
+ );
117
+
118
+ const openAlignment = useOpenCrsAlignment();
119
+ const warnImplausible = useImplausibleWarning(openAlignment);
120
+
121
+ async function onAssigned(
122
+ assignedItem: Pick<CrsItem, "data_id" | "name">,
123
+ linked: CrsItem[],
124
+ response: AssignResponse,
125
+ { crs, guarded, projectCrs }: { crs: CRS; guarded: boolean; projectCrs: CRS | undefined },
126
+ ): Promise<void> {
127
+ if (response.unsupported === true) {
128
+ // Only the data with points can be georeferenced, not grids
129
+ useFeedbackStore().add_warning(`${assignedItem.name} cannot hold a CRS`);
130
+ emit("update:show", false);
131
+ return;
132
+ }
133
+ const entries = buildAssignedEntries(assignedItem, linked, response);
134
+ // A data left out by the check keeps its CRS: nothing to store
135
+ for (const entry of entries.filter((assigned) => assigned.crs !== undefined)) {
136
+ // oxlint-disable-next-line no-await-in-loop
137
+ await dataStore.updateItem(entry.data_id, { crs: entry.crs });
138
+ }
139
+ // The plausible data join the project CRS; the others keep it and get the warning
140
+ await followProject(plausibleEntries(entries), projectCrs);
141
+ if (guarded && response.crs === undefined) {
142
+ // The user chooses between converting and relabeling anyway
143
+ assignMismatch.value = formatCrsCode(crs);
144
+ return;
145
+ }
146
+ recordUse(crs);
147
+ emit("assigned");
148
+ emit("update:show", false);
149
+ warnImplausible(
150
+ entries.filter((entry) => entry.implausible === true && entry.crs !== undefined),
151
+ response.crs,
152
+ itemId,
153
+ );
154
+ }
155
+
156
+ // Data already in a CRS are relabeled only when their coordinates fit it, unless confirmed
157
+ async function handleAssign(anyway = false): Promise<void> {
158
+ const assignedItem = item.value;
159
+ // Taken before: the user may pick another CRS while the request runs
160
+ const crs = selectedCrs.value;
161
+ if (!assignedItem || !crs || assigning.value) {
162
+ return;
163
+ }
164
+ const linked = scope.value === "all" ? linkCandidates.value : [];
165
+ const linkedDataIds = linked.map((linkedItem) => linkedItem.data_id);
166
+ const guarded = isGeographic.value && !anyway;
167
+ // Taken before: the project follows the assigned data as soon as they are stored
168
+ const { projectCrs } = crsStore;
169
+ assignMismatch.value = undefined;
170
+ assigning.value = true;
171
+ try {
172
+ await backStore.request(
173
+ {
174
+ schema: back_schemas.opengeodeweb_back.crs.assign_geographic,
175
+ params: {
176
+ id: assignedItem.data_id,
177
+ ...(linkedDataIds.length > 0 && { linked_ids: linkedDataIds }),
178
+ ...(guarded && { only_plausible: true }),
179
+ ...crs,
180
+ },
181
+ },
182
+ {
183
+ response_function: async (response: AssignResponse) => {
184
+ await onAssigned(assignedItem, linked, response, {
185
+ crs,
186
+ guarded,
187
+ projectCrs,
188
+ });
189
+ },
190
+ },
191
+ );
192
+ } finally {
193
+ assigning.value = false;
194
+ }
195
+ }
196
+
197
+ function convertInstead(): void {
198
+ mode.value = "convert";
199
+ }
200
+
201
+ async function handleConvert(): Promise<void> {
202
+ const crs = selectedCrs.value;
203
+ if (!item.value || !crs || converting.value) {
204
+ return;
205
+ }
206
+ converting.value = true;
207
+ try {
208
+ if (scope.value === "all") {
209
+ await changeProjectCrs(crs);
210
+ } else {
211
+ await convertCrs(item.value, crs);
212
+ }
213
+ recordUse(crs);
214
+ emit("converted");
215
+ emit("update:show", false);
216
+ } finally {
217
+ converting.value = false;
218
+ }
219
+ }
220
+
221
+ async function startAlignment(): Promise<void> {
222
+ if (!item.value) {
223
+ return;
224
+ }
225
+ emit("update:show", false);
226
+ await openAlignment(item.value);
227
+ }
228
+ </script>
229
+
230
+ <template>
231
+ <v-dialog
232
+ :model-value="show"
233
+ scrollable
234
+ @update:model-value="emit('update:show', $event)"
235
+ max-width="800"
236
+ >
237
+ <GlassCard variant="panel" padding="pa-8" :width="800">
238
+ <v-card-title class="pb-2 text-h5 font-weight-bold d-flex align-center">
239
+ <v-icon icon="ph-globe-hemisphere-west" class="mr-3 text-h4" color="primary"></v-icon>
240
+ Coordinate Reference System
241
+ </v-card-title>
242
+
243
+ <v-card-subtitle class="ma-0">
244
+ Current CRS:
245
+ <v-progress-circular
246
+ v-if="loadingCurrentCrs"
247
+ data-testid="crsCurrentLoading"
248
+ indeterminate
249
+ size="16"
250
+ width="2"
251
+ />
252
+ <span v-else data-testid="crsCurrentValue">{{ currentCrs }}</span>
253
+ </v-card-subtitle>
254
+
255
+ <!-- flex-shrink-0: the scrollable dialog card would otherwise squash the toggle to 0 height -->
256
+ <div class="mt-4 flex-shrink-0">
257
+ <v-btn-toggle v-model="mode" mandatory density="compact" color="primary">
258
+ <v-btn value="assign" data-testid="crsModeAssign" class="text-none">Assign</v-btn>
259
+ <v-btn
260
+ v-if="crsKnown && isGeographic"
261
+ value="convert"
262
+ data-testid="crsModeConvert"
263
+ class="text-none"
264
+ >
265
+ Convert
266
+ </v-btn>
267
+ <!-- Re-aligning restarts from the original coordinates -->
268
+ <v-btn v-if="crsKnown" value="align" data-testid="crsModeAlign" class="text-none">
269
+ Georeference
270
+ </v-btn>
271
+ </v-btn-toggle>
272
+ </div>
273
+ <!-- Next to the mode: what gets assigned or converted stays visible without scrolling -->
274
+ <v-radio-group
275
+ v-if="item && mode !== 'align'"
276
+ v-model="scope"
277
+ inline
278
+ hide-details
279
+ density="compact"
280
+ class="mt-4 flex-shrink-0"
281
+ data-testid="crsScope"
282
+ >
283
+ <v-radio label="All data" value="all" data-testid="crsScope-all" />
284
+ <v-radio label="This data only" value="one" data-testid="crsScope-one" />
285
+ </v-radio-group>
286
+ <p
287
+ v-if="mode !== 'align'"
288
+ class="text-caption text-medium-emphasis mt-2 mb-0"
289
+ data-testid="crsModeHint"
290
+ >
291
+ {{
292
+ mode === "assign"
293
+ ? "The coordinates are already in this CRS: fix a wrong or missing CRS."
294
+ : "Reproject the coordinates to this CRS."
295
+ }}
296
+ </p>
297
+ <v-alert
298
+ v-if="assignMismatch"
299
+ type="warning"
300
+ variant="tonal"
301
+ density="compact"
302
+ class="mt-4 flex-shrink-0"
303
+ data-testid="crsAssignMismatch"
304
+ >
305
+ These coordinates do not fit {{ assignMismatch }}. Did you mean Convert?
306
+ <div class="d-flex justify-end ga-2 mt-2">
307
+ <v-btn
308
+ size="small"
309
+ variant="text"
310
+ class="text-none"
311
+ data-testid="crsConvertInstead"
312
+ @click="convertInstead"
313
+ >
314
+ Convert instead
315
+ </v-btn>
316
+ <v-btn
317
+ size="small"
318
+ variant="text"
319
+ class="text-none"
320
+ data-testid="crsAssignAnyway"
321
+ @click="handleAssign(true)"
322
+ >
323
+ Assign anyway
324
+ </v-btn>
325
+ </div>
326
+ </v-alert>
327
+
328
+ <v-card-text class="pt-8 px-0">
329
+ <CrsSelector
330
+ v-if="item && mode !== 'align'"
331
+ :key="item.data_id"
332
+ v-model="selectedCrs"
333
+ :geode-object-type="item.geode_object_type"
334
+ :favorites="favorites"
335
+ :recent="recent"
336
+ @toggle-favorite="toggleFavorite"
337
+ />
338
+ <div v-if="mode === 'align'">
339
+ <p class="mb-4">
340
+ Pick 3 points on the data and type their real coordinates in the target CRS.
341
+ </p>
342
+ <v-btn
343
+ color="accent"
344
+ variant="flat"
345
+ data-testid="crsStartAlignButton"
346
+ class="text-none rounded-pill"
347
+ @click="startAlignment"
348
+ >
349
+ <v-icon start>ph-triangle</v-icon>
350
+ Start georeferencing
351
+ </v-btn>
352
+ </div>
353
+ </v-card-text>
354
+
355
+ <v-card-actions class="px-0 pb-0 mt-4">
356
+ <v-btn
357
+ variant="text"
358
+ color="primary"
359
+ size="large"
360
+ @click="emit('update:show', false)"
361
+ class="text-none rounded-pill"
362
+ >
363
+ <v-icon start>ph-x-circle</v-icon>
364
+ Cancel
365
+ </v-btn>
366
+
367
+ <v-spacer />
368
+
369
+ <v-btn
370
+ v-if="mode === 'assign'"
371
+ color="accent"
372
+ size="large"
373
+ variant="flat"
374
+ data-testid="crsAssignButton"
375
+ :disabled="!selectedCrs || assigning"
376
+ :loading="assigning"
377
+ @click="handleAssign()"
378
+ class="text-none rounded-pill font-weight-bold"
379
+ >
380
+ <v-icon start>ph-check-circle</v-icon>
381
+ Assign
382
+ </v-btn>
383
+ <v-btn
384
+ v-if="mode === 'convert'"
385
+ color="accent"
386
+ size="large"
387
+ variant="flat"
388
+ data-testid="crsConvertButton"
389
+ :disabled="!selectedCrs || converting"
390
+ :loading="converting"
391
+ @click="handleConvert"
392
+ class="text-none rounded-pill font-weight-bold"
393
+ >
394
+ <v-icon start>ph-arrows-left-right</v-icon>
395
+ Convert
396
+ </v-btn>
397
+ </v-card-actions>
398
+ </GlassCard>
399
+ </v-dialog>
400
+ </template>
@@ -0,0 +1,66 @@
1
+ <script setup lang="ts">
2
+ import CrsDialog from "@ogw_front/components/CrsDialog.vue";
3
+ import ProjectCrsDialog from "@ogw_front/components/ProjectCrsDialog.vue";
4
+ import { useCrsStore } from "@ogw_front/stores/crs";
5
+ import { useDataStore } from "@ogw_front/stores/data";
6
+ import { useFeedbackStore } from "@ogw_front/stores/feedback";
7
+
8
+ const crsStore = useCrsStore();
9
+ const dataStore = useDataStore();
10
+ const feedbackStore = useFeedbackStore();
11
+ const show = ref(false);
12
+ const itemId = ref<string | undefined>(undefined);
13
+
14
+ // The app hosts the CRS dialog: the shared tree and info card may offer CRS edits
15
+ crsStore.enableCrsEdit();
16
+
17
+ watch(
18
+ () => crsStore.crsEditRequest,
19
+ async (dataId) => {
20
+ if (dataId === undefined) {
21
+ return;
22
+ }
23
+ try {
24
+ await dataStore.item(dataId);
25
+ } catch {
26
+ // The data was deleted since the edit was offered (e.g. by a snackbar)
27
+ crsStore.clearCrsEditRequest();
28
+ return;
29
+ }
30
+ itemId.value = dataId;
31
+ show.value = true;
32
+ },
33
+ // A request made on a page without a host opens once a host mounts
34
+ { immediate: true },
35
+ );
36
+
37
+ function updateShow(value: boolean): void {
38
+ show.value = value;
39
+ if (!value) {
40
+ crsStore.clearCrsEditRequest();
41
+ }
42
+ }
43
+
44
+ function updateProjectShow(value: boolean): void {
45
+ if (!value) {
46
+ crsStore.clearProjectCrsEditRequest();
47
+ }
48
+ }
49
+ </script>
50
+
51
+ <template>
52
+ <div>
53
+ <CrsDialog
54
+ :show="show"
55
+ :item-id="itemId"
56
+ @update:show="updateShow"
57
+ @assigned="feedbackStore.add_success('CRS assigned')"
58
+ @converted="feedbackStore.add_success('CRS converted')"
59
+ />
60
+ <ProjectCrsDialog
61
+ :show="crsStore.projectCrsEditRequest"
62
+ @update:show="updateProjectShow"
63
+ @changed="feedbackStore.add_success('Project CRS changed')"
64
+ />
65
+ </div>
66
+ </template>