@geode/opengeodeweb-front 12.2.0-rc.1 → 12.2.0-rc.2
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/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/index.js +6 -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/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/project_crs.ts +197 -0
- 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/utils/crs.ts +17 -1
- 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/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/suites/crs.ts +228 -0
- package/tests/browser/suites/crs_harmonize.ts +96 -0
- package/tests/browser/suites/crs_shortlist.ts +37 -0
|
@@ -7,12 +7,22 @@ interface Props {
|
|
|
7
7
|
geodeObjectType: GeodeObjectType;
|
|
8
8
|
// Narrow containers: one "AUTHORITY:CODE" column and a truncated name
|
|
9
9
|
compact?: boolean;
|
|
10
|
+
// Shown as chips above the search, one row each, when they are in the list of this data type
|
|
11
|
+
favorites?: CRS[];
|
|
12
|
+
recent?: CRS[];
|
|
10
13
|
}
|
|
11
14
|
|
|
12
|
-
const { geodeObjectType, compact = false } = defineProps<Props>();
|
|
15
|
+
const { geodeObjectType, compact = false, favorites = [], recent = [] } = defineProps<Props>();
|
|
13
16
|
const selectedCrs = defineModel<CRS | undefined>();
|
|
17
|
+
const emit = defineEmits<{ "toggle-favorite": [crs: CRS] }>();
|
|
18
|
+
// The star column is only shown to a parent that keeps the favorites
|
|
19
|
+
const canToggleFavorite = getCurrentInstance()?.vnode.props?.onToggleFavorite !== undefined;
|
|
14
20
|
|
|
21
|
+
const DEFAULT_ITEMS_PER_PAGE = 10;
|
|
15
22
|
const search = ref<string>("");
|
|
23
|
+
const page = ref<number>(1);
|
|
24
|
+
const items_per_page = ref<number>(DEFAULT_ITEMS_PER_PAGE);
|
|
25
|
+
const sort_by = ref<{ key: string; order?: "asc" | "desc" }[]>([]);
|
|
16
26
|
const data_table_loading = ref<boolean>(false);
|
|
17
27
|
// Thousands of rows that are never mutated: no deep reactivity
|
|
18
28
|
const crs_list = shallowRef<CRS[]>([]);
|
|
@@ -29,6 +39,17 @@ function select_crs(crs: CRS): void {
|
|
|
29
39
|
selectedCrs.value = crs;
|
|
30
40
|
}
|
|
31
41
|
|
|
42
|
+
// A chip selects its CRS and shows its row: no search, default order, on the page of the row.
|
|
43
|
+
// The page is set once the table has seen the new search, which sends it back to the first page
|
|
44
|
+
async function show_crs(crs: CRS): Promise<void> {
|
|
45
|
+
select_crs(crs);
|
|
46
|
+
search.value = "";
|
|
47
|
+
sort_by.value = [];
|
|
48
|
+
await nextTick();
|
|
49
|
+
const index = crs_list.value.findIndex((listed_item) => crs_key(listed_item) === crs_key(crs));
|
|
50
|
+
page.value = Math.floor(index / items_per_page.value) + 1;
|
|
51
|
+
}
|
|
52
|
+
|
|
32
53
|
// Vuetify passes the click event first, then the clicked row
|
|
33
54
|
function on_row_click(_event: Event, { item }: { item: CRS }): void {
|
|
34
55
|
select_crs(item);
|
|
@@ -48,6 +69,17 @@ function row_props({ item }: { item: CRS }): Record<string, unknown> {
|
|
|
48
69
|
};
|
|
49
70
|
}
|
|
50
71
|
|
|
72
|
+
const listed_crs = computed(() => new Map(crs_list.value.map((crs) => [crs_key(crs), crs])));
|
|
73
|
+
const favorite_keys = computed(() => new Set(favorites.map((crs) => crs_key(crs))));
|
|
74
|
+
|
|
75
|
+
// The CRS of the list, not the given ones: a favorite of another data type is left out
|
|
76
|
+
function listed(shortlist: CRS[]): CRS[] {
|
|
77
|
+
return shortlist.flatMap((crs) => listed_crs.value.get(crs_key(crs)) ?? []);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const favorite_chips = computed(() => listed(favorites));
|
|
81
|
+
const recent_chips = computed(() => listed(recent));
|
|
82
|
+
|
|
51
83
|
async function get_crs_table(): Promise<void> {
|
|
52
84
|
toggle_loading();
|
|
53
85
|
crs_list.value = await crsStore.geographicList(geodeObjectType);
|
|
@@ -75,7 +107,15 @@ const compact_headers = [
|
|
|
75
107
|
// oxlint-disable-next-line no-magic-numbers -- the page sizes Vuetify offers by default, "All" aside
|
|
76
108
|
const items_per_page_options = [10, 25, 50, 100];
|
|
77
109
|
|
|
78
|
-
const
|
|
110
|
+
const favorite_header = { title: "", key: "favorite", sortable: false, width: 48 } as const;
|
|
111
|
+
|
|
112
|
+
const headers = computed(() => {
|
|
113
|
+
const base = compact ? compact_headers : full_headers;
|
|
114
|
+
if (!canToggleFavorite) {
|
|
115
|
+
return base;
|
|
116
|
+
}
|
|
117
|
+
return [favorite_header, ...base];
|
|
118
|
+
});
|
|
79
119
|
|
|
80
120
|
// Not awaited in setup: the table renders right away with its loader
|
|
81
121
|
onMounted(async () => {
|
|
@@ -84,6 +124,43 @@ onMounted(async () => {
|
|
|
84
124
|
</script>
|
|
85
125
|
|
|
86
126
|
<template>
|
|
127
|
+
<div
|
|
128
|
+
v-if="favorite_chips.length > 0"
|
|
129
|
+
data-testid="crsFavoriteRow"
|
|
130
|
+
class="d-flex flex-wrap align-center ga-2 mb-2"
|
|
131
|
+
>
|
|
132
|
+
<span class="shortlist-label text-caption text-medium-emphasis">Favorites</span>
|
|
133
|
+
<v-chip
|
|
134
|
+
v-for="crs in favorite_chips"
|
|
135
|
+
:key="`favorite-${crs_key(crs)}`"
|
|
136
|
+
data-testid="crsFavoriteChip"
|
|
137
|
+
prepend-icon="ph-fill ph-star"
|
|
138
|
+
size="small"
|
|
139
|
+
@click="show_crs(crs)"
|
|
140
|
+
>
|
|
141
|
+
{{ crs_key(crs) }}
|
|
142
|
+
<v-tooltip activator="parent" :text="crs.name" location="top" />
|
|
143
|
+
</v-chip>
|
|
144
|
+
</div>
|
|
145
|
+
<div
|
|
146
|
+
v-if="recent_chips.length > 0"
|
|
147
|
+
data-testid="crsRecentRow"
|
|
148
|
+
class="d-flex flex-wrap align-center ga-2 mb-2"
|
|
149
|
+
>
|
|
150
|
+
<span class="shortlist-label text-caption text-medium-emphasis">Recent</span>
|
|
151
|
+
<v-chip
|
|
152
|
+
v-for="crs in recent_chips"
|
|
153
|
+
:key="`recent-${crs_key(crs)}`"
|
|
154
|
+
data-testid="crsRecentChip"
|
|
155
|
+
prepend-icon="ph-clock-counter-clockwise"
|
|
156
|
+
size="small"
|
|
157
|
+
variant="outlined"
|
|
158
|
+
@click="show_crs(crs)"
|
|
159
|
+
>
|
|
160
|
+
{{ crs_key(crs) }}
|
|
161
|
+
<v-tooltip activator="parent" :text="crs.name" location="top" />
|
|
162
|
+
</v-chip>
|
|
163
|
+
</div>
|
|
87
164
|
<v-text-field
|
|
88
165
|
v-model="search"
|
|
89
166
|
data-testid="crsSearchInput"
|
|
@@ -94,7 +171,9 @@ onMounted(async () => {
|
|
|
94
171
|
hide-details
|
|
95
172
|
></v-text-field>
|
|
96
173
|
<v-data-table
|
|
97
|
-
:
|
|
174
|
+
v-model:page="page"
|
|
175
|
+
v-model:items-per-page="items_per_page"
|
|
176
|
+
v-model:sort-by="sort_by"
|
|
98
177
|
:items-per-page-options="items_per_page_options"
|
|
99
178
|
:headers="headers"
|
|
100
179
|
:items="crs_list"
|
|
@@ -108,6 +187,19 @@ onMounted(async () => {
|
|
|
108
187
|
loading-text="Loading... Please wait"
|
|
109
188
|
@click:row="on_row_click"
|
|
110
189
|
>
|
|
190
|
+
<template #[`item.favorite`]="{ item }">
|
|
191
|
+
<v-btn
|
|
192
|
+
data-testid="crsFavoriteToggle"
|
|
193
|
+
:icon="favorite_keys.has(crs_key(item)) ? 'ph-fill ph-star' : 'ph-star'"
|
|
194
|
+
:aria-label="
|
|
195
|
+
favorite_keys.has(crs_key(item)) ? 'Remove from favorites' : 'Add to favorites'
|
|
196
|
+
"
|
|
197
|
+
variant="text"
|
|
198
|
+
size="x-small"
|
|
199
|
+
@click.stop="emit('toggle-favorite', item)"
|
|
200
|
+
@keydown.enter.stop
|
|
201
|
+
/>
|
|
202
|
+
</template>
|
|
111
203
|
<template v-if="compact" #[`item.name`]="{ value }">
|
|
112
204
|
<v-tooltip :text="value" location="top">
|
|
113
205
|
<template #activator="{ props: tooltipProps }">
|
|
@@ -122,4 +214,9 @@ onMounted(async () => {
|
|
|
122
214
|
:deep(.crs-row) {
|
|
123
215
|
cursor: pointer;
|
|
124
216
|
}
|
|
217
|
+
|
|
218
|
+
/* One width for both labels: the chips of the two rows start at the same place */
|
|
219
|
+
.shortlist-label {
|
|
220
|
+
min-width: 64px;
|
|
221
|
+
}
|
|
125
222
|
</style>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
defineProps<{ active?: boolean }>();
|
|
3
|
+
|
|
4
|
+
const emit = defineEmits<{ click: [] }>();
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<template>
|
|
8
|
+
<v-tooltip :text="active ? 'Exit pick mode (Esc)' : 'Pick points from viewer'" location="bottom">
|
|
9
|
+
<template #activator="{ props }">
|
|
10
|
+
<v-btn
|
|
11
|
+
v-bind="props"
|
|
12
|
+
color="primary"
|
|
13
|
+
:variant="active ? 'flat' : 'tonal'"
|
|
14
|
+
size="small"
|
|
15
|
+
block
|
|
16
|
+
class="rounded-pill text-none font-weight-bold"
|
|
17
|
+
:class="{ 'pick-pulse': active }"
|
|
18
|
+
prepend-icon="ph-gps-fix"
|
|
19
|
+
data-testid="pickButton"
|
|
20
|
+
@click="emit('click')"
|
|
21
|
+
>
|
|
22
|
+
{{ active ? "Stop picking" : "Pick in viewer" }}
|
|
23
|
+
</v-btn>
|
|
24
|
+
</template>
|
|
25
|
+
</v-tooltip>
|
|
26
|
+
</template>
|
|
27
|
+
|
|
28
|
+
<style scoped>
|
|
29
|
+
@keyframes pulse-ring {
|
|
30
|
+
0% {
|
|
31
|
+
box-shadow: 0 0 0 0 rgba(var(--v-theme-primary), 0.7);
|
|
32
|
+
}
|
|
33
|
+
70% {
|
|
34
|
+
box-shadow: 0 0 0 8px rgba(var(--v-theme-primary), 0);
|
|
35
|
+
}
|
|
36
|
+
100% {
|
|
37
|
+
box-shadow: 0 0 0 0 rgba(var(--v-theme-primary), 0);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
.pick-pulse {
|
|
41
|
+
animation: pulse-ring 1.5s ease-out infinite;
|
|
42
|
+
}
|
|
43
|
+
</style>
|
|
@@ -0,0 +1,109 @@
|
|
|
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 GlassCard from "@ogw_front/components/GlassCard.vue";
|
|
5
|
+
import { formatCrs } from "@ogw_front/utils/crs";
|
|
6
|
+
import { useCrs } from "@ogw_front/composables/crs";
|
|
7
|
+
import { useCrsShortlist } from "@ogw_front/composables/crs_shortlist";
|
|
8
|
+
import { useCrsStore } from "@ogw_front/stores/crs";
|
|
9
|
+
import { useProjectCrs } from "@ogw_front/composables/project_crs";
|
|
10
|
+
|
|
11
|
+
// The geographic CRS list is the same for every data type
|
|
12
|
+
const LIST_TYPE = "PointSet3D";
|
|
13
|
+
|
|
14
|
+
const { show = false } = defineProps<{ show?: boolean }>();
|
|
15
|
+
const emit = defineEmits<{ "update:show": [value: boolean]; changed: [] }>();
|
|
16
|
+
|
|
17
|
+
const crsStore = useCrsStore();
|
|
18
|
+
const { changeProjectCrs } = useCrs();
|
|
19
|
+
const { adoptProjectCrs } = useProjectCrs();
|
|
20
|
+
const { favorites, recent, toggleFavorite, recordUse } = useCrsShortlist();
|
|
21
|
+
const selectedCrs = ref<CRS | undefined>(undefined);
|
|
22
|
+
const changing = ref(false);
|
|
23
|
+
|
|
24
|
+
watch(
|
|
25
|
+
() => show,
|
|
26
|
+
(value) => {
|
|
27
|
+
if (value) {
|
|
28
|
+
selectedCrs.value = undefined;
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
async function apply(): Promise<void> {
|
|
34
|
+
const crs = selectedCrs.value;
|
|
35
|
+
if (!crs || changing.value) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
changing.value = true;
|
|
39
|
+
try {
|
|
40
|
+
await changeProjectCrs(crs);
|
|
41
|
+
await adoptProjectCrs(crs);
|
|
42
|
+
recordUse(crs);
|
|
43
|
+
emit("changed");
|
|
44
|
+
emit("update:show", false);
|
|
45
|
+
} catch {
|
|
46
|
+
// The request feedback already shows the error: the dialog stays open to pick another CRS
|
|
47
|
+
} finally {
|
|
48
|
+
changing.value = false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
<template>
|
|
54
|
+
<v-dialog
|
|
55
|
+
:model-value="show"
|
|
56
|
+
scrollable
|
|
57
|
+
max-width="800"
|
|
58
|
+
@update:model-value="emit('update:show', $event)"
|
|
59
|
+
>
|
|
60
|
+
<GlassCard variant="panel" padding="pa-8" :width="800">
|
|
61
|
+
<v-card-title class="pb-2 text-h5 font-weight-bold d-flex align-center">
|
|
62
|
+
<v-icon icon="ph-globe-hemisphere-west" class="mr-3 text-h4" color="primary" />
|
|
63
|
+
Project CRS
|
|
64
|
+
</v-card-title>
|
|
65
|
+
<v-card-subtitle class="ma-0">
|
|
66
|
+
Current CRS:
|
|
67
|
+
<span data-testid="projectCrsCurrent">{{ formatCrs(crsStore.projectCrs) }}</span>
|
|
68
|
+
</v-card-subtitle>
|
|
69
|
+
<v-card-text class="pt-8 px-0">
|
|
70
|
+
<p class="text-medium-emphasis mb-4">
|
|
71
|
+
Every georeferenced data is converted to the new CRS.
|
|
72
|
+
</p>
|
|
73
|
+
<CrsSelector
|
|
74
|
+
v-model="selectedCrs"
|
|
75
|
+
:geode-object-type="LIST_TYPE"
|
|
76
|
+
:favorites="favorites"
|
|
77
|
+
:recent="recent"
|
|
78
|
+
@toggle-favorite="toggleFavorite"
|
|
79
|
+
/>
|
|
80
|
+
</v-card-text>
|
|
81
|
+
<v-card-actions class="px-0 pb-0 mt-4">
|
|
82
|
+
<v-btn
|
|
83
|
+
variant="text"
|
|
84
|
+
color="primary"
|
|
85
|
+
size="large"
|
|
86
|
+
class="text-none rounded-pill"
|
|
87
|
+
@click="emit('update:show', false)"
|
|
88
|
+
>
|
|
89
|
+
<v-icon start>ph-x-circle</v-icon>
|
|
90
|
+
Cancel
|
|
91
|
+
</v-btn>
|
|
92
|
+
<v-spacer />
|
|
93
|
+
<v-btn
|
|
94
|
+
color="accent"
|
|
95
|
+
size="large"
|
|
96
|
+
variant="flat"
|
|
97
|
+
data-testid="projectCrsApply"
|
|
98
|
+
:disabled="!selectedCrs || changing"
|
|
99
|
+
:loading="changing"
|
|
100
|
+
class="text-none rounded-pill font-weight-bold"
|
|
101
|
+
@click="apply"
|
|
102
|
+
>
|
|
103
|
+
<v-icon start>ph-arrows-left-right</v-icon>
|
|
104
|
+
Change project CRS
|
|
105
|
+
</v-btn>
|
|
106
|
+
</v-card-actions>
|
|
107
|
+
</GlassCard>
|
|
108
|
+
</v-dialog>
|
|
109
|
+
</template>
|
|
@@ -8,15 +8,18 @@ interface Props {
|
|
|
8
8
|
width?: number;
|
|
9
9
|
closeLabel?: string;
|
|
10
10
|
actionLabel?: string;
|
|
11
|
+
// The content brings its own title and close control
|
|
12
|
+
hideActions?: boolean;
|
|
11
13
|
clickOutside?: boolean;
|
|
12
14
|
escapeFunction?: () => void;
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
const {
|
|
16
|
-
title =
|
|
18
|
+
title = undefined,
|
|
17
19
|
width = DEFAULT_PANEL_WIDTH,
|
|
18
20
|
closeLabel = "Close",
|
|
19
21
|
actionLabel = undefined,
|
|
22
|
+
hideActions = false,
|
|
20
23
|
clickOutside = true,
|
|
21
24
|
escapeFunction = undefined,
|
|
22
25
|
} = defineProps<Props>();
|
|
@@ -54,7 +57,7 @@ function close(): void {
|
|
|
54
57
|
<slot />
|
|
55
58
|
</v-card-text>
|
|
56
59
|
|
|
57
|
-
<template #actions>
|
|
60
|
+
<template v-if="!hideActions" #actions>
|
|
58
61
|
<slot name="actions">
|
|
59
62
|
<v-card-actions class="justify-center pb-3 pt-0" style="gap: 8px">
|
|
60
63
|
<v-btn variant="text" size="small" class="text-caption text-none" @click="close">
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import CrsAlign from "@ogw_front/components/CrsAlign.vue";
|
|
3
|
+
import CrsDialogHost from "@ogw_front/components/CrsDialogHost.vue";
|
|
4
|
+
import ProjectCrs from "@ogw_front/components/ProjectCrs.vue";
|
|
5
|
+
import ToolPanel from "@ogw_front/components/ToolPanel.vue";
|
|
6
|
+
import { useCrsStore } from "@ogw_front/stores/crs";
|
|
7
|
+
|
|
8
|
+
// Wide enough for the X and Y of the 3 pairs of points
|
|
9
|
+
const CRS_ALIGN_PANEL_WIDTH = 380;
|
|
10
|
+
|
|
11
|
+
const crsStore = useCrsStore();
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<template>
|
|
15
|
+
<ProjectCrs />
|
|
16
|
+
<CrsDialogHost />
|
|
17
|
+
<!-- Points are picked in the viewer: a click there must not close the panel.
|
|
18
|
+
CrsAlign has its own title and close button -->
|
|
19
|
+
<ToolPanel
|
|
20
|
+
v-model="crsStore.showCrsAlign"
|
|
21
|
+
:width="CRS_ALIGN_PANEL_WIDTH"
|
|
22
|
+
:click-outside="false"
|
|
23
|
+
hide-actions
|
|
24
|
+
data-testid="crsAlignPanel"
|
|
25
|
+
:escape-function="crsStore.closeCrsAlign"
|
|
26
|
+
>
|
|
27
|
+
<CrsAlign />
|
|
28
|
+
</ToolPanel>
|
|
29
|
+
</template>
|
|
@@ -4,8 +4,8 @@ import {
|
|
|
4
4
|
useOverlappingPicker,
|
|
5
5
|
} from "@ogw_front/composables/use_overlapping_picker";
|
|
6
6
|
import BasemapAttribution from "@ogw_front/components/BasemapAttribution.vue";
|
|
7
|
+
import CrsOverlays from "@ogw_front/components/Viewer/CrsOverlays.vue";
|
|
7
8
|
import OverlappingObjectsPicker from "@ogw_front/components/Viewer/OverlappingObjectsPicker.vue";
|
|
8
|
-
import ProjectCrs from "@ogw_front/components/ProjectCrs.vue";
|
|
9
9
|
import ToolActiveChip from "@ogw_front/components/Viewer/ToolActiveChip.vue";
|
|
10
10
|
import type { TreeMenuPayload } from "@ogw_front/utils/treeview";
|
|
11
11
|
import ViewerContextMenu from "@ogw_front/components/Viewer/ContextMenu/ContextMenu.vue";
|
|
@@ -27,6 +27,7 @@ const { displayMenu, containerWidth, containerHeight } = defineProps<Props>();
|
|
|
27
27
|
const emit = defineEmits<{
|
|
28
28
|
"show-menu": [payload: TreeMenuPayload];
|
|
29
29
|
}>();
|
|
30
|
+
|
|
30
31
|
const menuStore = useMenuStore();
|
|
31
32
|
const viewerStore = useViewerStore();
|
|
32
33
|
const hybridViewerStore = useHybridViewerStore();
|
|
@@ -111,7 +112,7 @@ defineExpose({ get_viewer_id });
|
|
|
111
112
|
:container-height="containerHeight"
|
|
112
113
|
/>
|
|
113
114
|
|
|
114
|
-
<
|
|
115
|
+
<CrsOverlays />
|
|
115
116
|
|
|
116
117
|
<BasemapAttribution />
|
|
117
118
|
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { type DataItem, useDataStore } from "@ogw_front/stores/data";
|
|
2
|
+
import { formatCrsCode, sameCrs } from "@ogw_front/utils/crs";
|
|
3
|
+
import type { AssignResponse } from "@ogw_front/composables/crs_assign";
|
|
4
|
+
import type { CRS } from "@geode/opengeodeweb-back/schema_types";
|
|
5
|
+
import type { DataId } from "@geode/opengeodeweb-microservice/schema_types";
|
|
6
|
+
import back_schemas from "@geode/opengeodeweb-back/opengeodeweb_back_typed_schemas.js";
|
|
7
|
+
import { reloadObject } from "@ogw_front/utils/reload_object";
|
|
8
|
+
import { useBackStore } from "@ogw_front/stores/back";
|
|
9
|
+
import { useCrsStore } from "@ogw_front/stores/crs";
|
|
10
|
+
import { useFeedbackStore } from "@ogw_front/stores/feedback";
|
|
11
|
+
import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
|
|
12
|
+
|
|
13
|
+
interface CrsPoint {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
// Source points only: picked on the displayed data rather than typed
|
|
17
|
+
picked?: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface Alignment {
|
|
21
|
+
sourcePoints: CrsPoint[];
|
|
22
|
+
targetPoints: CrsPoint[];
|
|
23
|
+
// Data sharing the local frame of the aligned item: aligned in the same request
|
|
24
|
+
linkedItems?: Pick<DataItem, "data_id">[];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface UseCrsReturn {
|
|
28
|
+
assignCrs: (
|
|
29
|
+
item: Pick<DataItem, "data_id">,
|
|
30
|
+
crs: CRS,
|
|
31
|
+
options?: { linkedItems?: Pick<DataItem, "data_id">[]; onlyPlausible?: boolean },
|
|
32
|
+
) => Promise<AssignResponse>;
|
|
33
|
+
convertCrs: (
|
|
34
|
+
item: Pick<DataItem, "data_id">,
|
|
35
|
+
crs: CRS,
|
|
36
|
+
options?: { focus?: boolean; linkedItems?: Pick<DataItem, "data_id">[] },
|
|
37
|
+
) => Promise<void>;
|
|
38
|
+
alignCrs: (item: DataItem, crs: CRS, alignment: Alignment) => Promise<void>;
|
|
39
|
+
changeProjectCrs: (crs: CRS) => Promise<void>;
|
|
40
|
+
followProject: (
|
|
41
|
+
entries: { data_id: DataId; name: string; crs: CRS }[],
|
|
42
|
+
project?: CRS,
|
|
43
|
+
) => Promise<void>;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Converting or aligning rewrites the data coordinates: the viewer object is reloaded and the camera moved to it
|
|
47
|
+
async function refresh(
|
|
48
|
+
item: Pick<DataItem, "data_id">,
|
|
49
|
+
{ binary_light_viewable, crs }: { binary_light_viewable?: string; crs?: CRS },
|
|
50
|
+
focus = true,
|
|
51
|
+
): Promise<void> {
|
|
52
|
+
// The local actor is rebuilt from the stored light viewable: store the moved one first
|
|
53
|
+
const dataStore = useDataStore();
|
|
54
|
+
await dataStore.updateItem(item.data_id, { binary_light_viewable });
|
|
55
|
+
await reloadObject(item.data_id, { rebuildActor: true });
|
|
56
|
+
// Only then the CRS: a basemap built for the new CRS reads the data bounds from the actors,
|
|
57
|
+
// Which must no longer hold the previous coordinates
|
|
58
|
+
await dataStore.updateItem(item.data_id, { crs });
|
|
59
|
+
if (focus) {
|
|
60
|
+
await useHybridViewerStore().focusCameraOnObject(item.data_id);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Each reload rebuilds an actor: one after another, then the camera moves once on the item
|
|
65
|
+
async function refreshLinked(
|
|
66
|
+
linked: { id: string; binary_light_viewable?: string; crs?: CRS }[] | undefined,
|
|
67
|
+
): Promise<void> {
|
|
68
|
+
for (const entry of linked ?? []) {
|
|
69
|
+
// oxlint-disable-next-line no-await-in-loop
|
|
70
|
+
await refresh({ data_id: entry.id }, entry, false);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async function convertCrs(
|
|
75
|
+
item: Pick<DataItem, "data_id">,
|
|
76
|
+
crs: CRS,
|
|
77
|
+
{
|
|
78
|
+
focus = true,
|
|
79
|
+
linkedItems = [],
|
|
80
|
+
}: { focus?: boolean; linkedItems?: Pick<DataItem, "data_id">[] } = {},
|
|
81
|
+
): Promise<void> {
|
|
82
|
+
const linkedIds = linkedItems.map(({ data_id }) => data_id);
|
|
83
|
+
const response = await useBackStore().request({
|
|
84
|
+
schema: back_schemas.opengeodeweb_back.crs.convert_geographic,
|
|
85
|
+
params: { id: item.data_id, ...(linkedIds.length > 0 && { linked_ids: linkedIds }), ...crs },
|
|
86
|
+
});
|
|
87
|
+
await refreshLinked(response.linked);
|
|
88
|
+
await refresh(item, response, focus);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Assigning only relabels the coordinates: nothing to reload, the stored CRS follows the back.
|
|
92
|
+
// With onlyPlausible, data whose coordinates miss the CRS area are left as they are
|
|
93
|
+
async function assignCrs(
|
|
94
|
+
item: Pick<DataItem, "data_id">,
|
|
95
|
+
crs: CRS,
|
|
96
|
+
{
|
|
97
|
+
linkedItems = [],
|
|
98
|
+
onlyPlausible = false,
|
|
99
|
+
}: { linkedItems?: Pick<DataItem, "data_id">[]; onlyPlausible?: boolean } = {},
|
|
100
|
+
): Promise<AssignResponse> {
|
|
101
|
+
const linkedIds = linkedItems.map(({ data_id }) => data_id);
|
|
102
|
+
const response = await useBackStore().request({
|
|
103
|
+
schema: back_schemas.opengeodeweb_back.crs.assign_geographic,
|
|
104
|
+
params: {
|
|
105
|
+
id: item.data_id,
|
|
106
|
+
...(linkedIds.length > 0 && { linked_ids: linkedIds }),
|
|
107
|
+
...(onlyPlausible && { only_plausible: true }),
|
|
108
|
+
...crs,
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
for (const { id, crs: assigned } of [
|
|
112
|
+
{ id: item.data_id, ...response },
|
|
113
|
+
...(response.linked ?? []),
|
|
114
|
+
]) {
|
|
115
|
+
if (assigned !== undefined) {
|
|
116
|
+
// oxlint-disable-next-line no-await-in-loop
|
|
117
|
+
await useDataStore().updateItem(id, { crs: assigned });
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return response;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
async function alignCrs(
|
|
124
|
+
item: DataItem,
|
|
125
|
+
crs: CRS,
|
|
126
|
+
{ sourcePoints, targetPoints, linkedItems = [] }: Alignment,
|
|
127
|
+
): Promise<void> {
|
|
128
|
+
const linkedIds = linkedItems.map(({ data_id }) => data_id);
|
|
129
|
+
const response = await useBackStore().request({
|
|
130
|
+
schema: back_schemas.opengeodeweb_back.crs.align,
|
|
131
|
+
params: {
|
|
132
|
+
id: item.data_id,
|
|
133
|
+
source_points: sourcePoints,
|
|
134
|
+
target_points: targetPoints,
|
|
135
|
+
...(linkedIds.length > 0 && { linked_ids: linkedIds }),
|
|
136
|
+
...crs,
|
|
137
|
+
},
|
|
138
|
+
});
|
|
139
|
+
await refreshLinked(response.linked);
|
|
140
|
+
await refresh(item, response);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// One request moves every georeferenced data, from its own CRS: all or nothing.
|
|
144
|
+
// Data without CRS are assigned afterwards, by useProjectCrs().adoptProjectCrs.
|
|
145
|
+
// The project CRS only changes once the back accepted the conversion
|
|
146
|
+
async function changeProjectCrs(crs: CRS): Promise<void> {
|
|
147
|
+
const crsStore = useCrsStore();
|
|
148
|
+
const items = crsStore.crsItems;
|
|
149
|
+
const moved = items.filter((item) => item.crs !== undefined && !sameCrs(item.crs, crs));
|
|
150
|
+
const [first, ...linkedItems] = moved;
|
|
151
|
+
if (first !== undefined) {
|
|
152
|
+
await convertCrs(first, crs, { focus: false, linkedItems });
|
|
153
|
+
}
|
|
154
|
+
crsStore.setProjectCrs(crs);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Data placed in another CRS than the project are converted to it, in one request.
|
|
158
|
+
// The project may already have followed them: callers pass the project CRS taken before.
|
|
159
|
+
// A refused conversion keeps their CRS and the project one: the warning points to their dialog
|
|
160
|
+
async function followProject(
|
|
161
|
+
entries: { data_id: DataId; name: string; crs: CRS }[],
|
|
162
|
+
project: CRS | undefined = useCrsStore().projectCrs,
|
|
163
|
+
): Promise<void> {
|
|
164
|
+
const crsStore = useCrsStore();
|
|
165
|
+
if (project === undefined) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const moved = entries.filter((entry) => !sameCrs(entry.crs, project));
|
|
169
|
+
const [first, ...linkedItems] = moved;
|
|
170
|
+
if (first === undefined) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
try {
|
|
174
|
+
await convertCrs(first, project, { focus: false, linkedItems });
|
|
175
|
+
} catch {
|
|
176
|
+
crsStore.setProjectCrs(project);
|
|
177
|
+
const names = moved.map(({ name }) => name).join(", ");
|
|
178
|
+
const warning = `Cannot convert ${names} to ${formatCrsCode(project)}. Check its CRS (Assign) or georeference it.`;
|
|
179
|
+
if (moved.length === 1) {
|
|
180
|
+
useFeedbackStore().add_warning(warning, {
|
|
181
|
+
label: "Edit CRS",
|
|
182
|
+
onClick: (): void => {
|
|
183
|
+
crsStore.requestCrsEdit(first.data_id);
|
|
184
|
+
},
|
|
185
|
+
});
|
|
186
|
+
} else {
|
|
187
|
+
useFeedbackStore().add_warning(warning);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function useCrs(): UseCrsReturn {
|
|
193
|
+
return { assignCrs, convertCrs, alignCrs, changeProjectCrs, followProject };
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export type { Alignment, CrsPoint };
|
|
197
|
+
export { useCrs };
|