@geode/opengeodeweb-front 10.43.2 → 10.44.0-rc.10

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 (254) hide show
  1. package/.build/server/utils/cleanup.js +7 -2
  2. package/.build/server/utils/microservices.js +9 -81
  3. package/.build/server/utils/microservices_process.js +85 -0
  4. package/.build/server/utils/scripts.js +34 -23
  5. package/.build/server/utils/typed_handler.js +5 -1
  6. package/.build/server/utils/ws_client.js +7 -2
  7. package/.build/shared/utils/fetch_raw.js +2 -2
  8. package/.build/shared/utils/parse_boolean.js +2 -1
  9. package/app/assets/geode_objects.ts +1 -0
  10. package/app/components/BasemapAttribution.vue +28 -0
  11. package/app/components/ClippingPlanes.vue +22 -78
  12. package/app/components/CrsSelector.vue +53 -46
  13. package/app/components/DragAndDrop.vue +16 -79
  14. package/app/components/FeedBack/Snackers.vue +27 -0
  15. package/app/components/FileSelector.vue +9 -6
  16. package/app/components/HybridViewerTooltip.vue +8 -2
  17. package/app/components/MissingFilesSelector.vue +40 -23
  18. package/app/components/ObjectSelector.vue +34 -20
  19. package/app/components/ProjectCrs.vue +37 -0
  20. package/app/components/Screenshot.vue +17 -59
  21. package/app/components/ThresholdCard.vue +205 -0
  22. package/app/components/ThresholdFilter.vue +81 -216
  23. package/app/components/ViewToolbar.vue +15 -231
  24. package/app/components/Viewer/Basemap/CropOptions.vue +50 -0
  25. package/app/components/Viewer/Basemap/OpacityOptions.vue +52 -0
  26. package/app/components/Viewer/ContextMenu/CircularItems.vue +1 -2
  27. package/app/components/Viewer/ContextMenu/ContextMenu.vue +11 -6
  28. package/app/components/Viewer/ContextMenu/ContextMenuItem.vue +10 -7
  29. package/app/components/Viewer/ContextMenu/InfoCard.vue +30 -0
  30. package/app/components/Viewer/EdgedCurve/SpecificEdgesColoring.vue +209 -0
  31. package/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue +3 -191
  32. package/app/components/Viewer/Generic/Mesh/CellsColoring.vue +221 -0
  33. package/app/components/Viewer/Generic/Mesh/CellsOptions.vue +3 -210
  34. package/app/components/Viewer/Generic/Mesh/EdgesColoring.vue +211 -0
  35. package/app/components/Viewer/Generic/Mesh/EdgesOptions.vue +3 -192
  36. package/app/components/Viewer/Generic/Mesh/PointsOptions.vue +13 -0
  37. package/app/components/Viewer/Generic/Mesh/PolygonsColoring.vue +227 -0
  38. package/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue +3 -215
  39. package/app/components/Viewer/Generic/Mesh/PolyhedraColoring.vue +221 -0
  40. package/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue +3 -203
  41. package/app/components/Viewer/Generic/Model/BlocksOptions.vue +14 -12
  42. package/app/components/Viewer/Generic/Model/ComponentPointsOptions.vue +2 -18
  43. package/app/components/Viewer/Generic/Model/CornerComponentOptions.vue +145 -0
  44. package/app/components/Viewer/Generic/Model/CornersOptions.vue +15 -294
  45. package/app/components/Viewer/Generic/Model/CornersTypeOptions.vue +173 -0
  46. package/app/components/Viewer/Generic/Model/LineComponentOptions.vue +218 -0
  47. package/app/components/Viewer/Generic/Model/LinesOptions.vue +15 -427
  48. package/app/components/Viewer/Generic/Model/LinesTypeOptions.vue +229 -0
  49. package/app/components/Viewer/Generic/Model/ModelCardTabs.vue +35 -0
  50. package/app/components/Viewer/Generic/Model/ModelEdgesCard.vue +34 -25
  51. package/app/components/Viewer/Generic/Model/ModelPointsCard.vue +34 -25
  52. package/app/components/Viewer/Generic/Model/ModelStyleCard.vue +17 -5
  53. package/app/components/Viewer/Generic/Model/SurfacesOptions.vue +16 -12
  54. package/app/components/Viewer/ObjectTree/Base/ComponentRelations.vue +4 -1
  55. package/app/components/Viewer/ObjectTree/Base/ItemLabel.vue +71 -1
  56. package/app/components/Viewer/ObjectTree/Views/GlobalObjects.vue +55 -10
  57. package/app/components/Viewer/Options/AttributeRangeSelector.vue +11 -4
  58. package/app/components/Viewer/Options/AttributeSelector.vue +40 -136
  59. package/app/components/Viewer/Options/ColorPicker.vue +4 -1
  60. package/app/components/Viewer/Options/ColoringTypeSelector.vue +48 -74
  61. package/app/components/Viewer/Options/ColormapQuickPicker.vue +13 -7
  62. package/app/components/Viewer/Options/NoDataColorInfo.vue +56 -0
  63. package/app/components/Viewer/Options/Sliders/Opacity.vue +22 -0
  64. package/app/components/Viewer/PointSet/SpecificPointsOptions.vue +13 -0
  65. package/app/components/Viewer/Scene/BackgroundOptions.vue +37 -0
  66. package/app/components/Viewer/Scene/OrientationWidgetOptions.vue +48 -0
  67. package/app/components/Viewer/Scene/TextOptions.vue +63 -0
  68. package/app/components/Viewer/Solid/SpecificPolyhedraColoring.vue +217 -0
  69. package/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue +4 -199
  70. package/app/components/Viewer/Surface/PolygonsColoring.vue +224 -0
  71. package/app/components/Viewer/Surface/PolygonsOptions.vue +3 -213
  72. package/app/components/Viewer/Ui.vue +9 -0
  73. package/app/components/csv-preview/CsvPreviewer.vue +4 -1
  74. package/app/composables/attribute_coloring_style.ts +8 -2
  75. package/app/composables/attribute_selector.ts +126 -0
  76. package/app/composables/batch_style_model.ts +34 -0
  77. package/app/composables/clipping_slices.ts +166 -0
  78. package/app/composables/global_attribute_style.ts +4 -3
  79. package/app/composables/hover_highlight.ts +19 -18
  80. package/app/composables/live_data_item.ts +39 -0
  81. package/app/composables/model_tabs.ts +86 -0
  82. package/app/composables/overlapping_picker_menu.ts +43 -0
  83. package/app/composables/project_manager.ts +5 -81
  84. package/app/composables/project_manager_helpers/reset.ts +34 -0
  85. package/app/composables/project_manager_helpers/restore.ts +67 -0
  86. package/app/composables/project_manager_helpers/types.ts +24 -0
  87. package/app/composables/project_manager_helpers/viewer_session.ts +25 -0
  88. package/app/composables/stepper_tree.ts +10 -2
  89. package/app/composables/tree_filter.ts +11 -2
  90. package/app/composables/tree_keyboard_nav.ts +4 -2
  91. package/app/composables/use_overlapping_picker.ts +30 -42
  92. package/app/composables/view_toolbar_options.ts +126 -0
  93. package/app/composables/view_toolbar_tool_options.ts +115 -0
  94. package/app/composables/view_toolbar_tools.ts +108 -0
  95. package/app/composables/viewer_context_menu.ts +19 -1
  96. package/app/composables/virtual_tree.ts +20 -131
  97. package/app/composables/virtual_tree_flatten.ts +109 -0
  98. package/app/composables/virtual_tree_types.ts +81 -0
  99. package/app/stores/app.ts +8 -55
  100. package/app/stores/app_helpers/extension.ts +90 -51
  101. package/app/stores/app_helpers/registry.ts +69 -0
  102. package/app/stores/basemap.ts +52 -0
  103. package/app/stores/basemap_detail.ts +51 -0
  104. package/app/stores/basemap_helpers/builds.ts +158 -0
  105. package/app/stores/basemap_helpers/detail_layers.ts +72 -0
  106. package/app/stores/basemap_helpers/detail_map.ts +62 -0
  107. package/app/stores/basemap_helpers/detail_refresh.ts +134 -0
  108. package/app/stores/basemap_helpers/detail_view.ts +94 -0
  109. package/app/stores/basemap_helpers/extent.ts +40 -0
  110. package/app/stores/basemap_helpers/georeferenced.ts +50 -0
  111. package/app/stores/basemap_helpers/layers.ts +66 -0
  112. package/app/stores/basemap_helpers/settings.ts +87 -0
  113. package/app/stores/basemap_helpers/viewer.ts +114 -0
  114. package/app/stores/crs.ts +136 -0
  115. package/app/stores/data.ts +24 -1
  116. package/app/stores/data_style.ts +8 -0
  117. package/app/stores/feedback.ts +12 -2
  118. package/app/stores/hybrid_viewer.ts +1 -1
  119. package/app/stores/infra.ts +26 -21
  120. package/app/stores/menu.ts +8 -124
  121. package/app/stores/menu_helpers/basemap.ts +10 -0
  122. package/app/stores/menu_helpers/menus_data.ts +27 -0
  123. package/app/stores/menu_helpers/mesh/edged_curve.ts +12 -0
  124. package/app/stores/menu_helpers/mesh/grid.ts +24 -0
  125. package/app/stores/menu_helpers/mesh/point_set.ts +11 -0
  126. package/app/stores/menu_helpers/mesh/solid.ts +29 -0
  127. package/app/stores/menu_helpers/mesh/surface.ts +22 -0
  128. package/app/stores/menu_helpers/model.ts +25 -0
  129. package/app/stores/menu_helpers/scene.ts +10 -0
  130. package/app/stores/menu_helpers/types.ts +5 -0
  131. package/app/stores/treeview.ts +17 -10
  132. package/app/stores/viewer.ts +17 -79
  133. package/app/stores/viewer_helpers/actions.ts +68 -0
  134. package/app/stores/viewer_helpers/request.ts +61 -0
  135. package/app/utils/basemap_tree.ts +76 -0
  136. package/app/utils/clipping_planes.ts +4 -131
  137. package/app/utils/clipping_planes_scene.ts +131 -0
  138. package/app/utils/color_picker.ts +18 -15
  139. package/app/utils/coloring_styles.ts +101 -0
  140. package/app/utils/crs.ts +38 -0
  141. package/app/utils/default_styles/constants.ts +10 -0
  142. package/app/utils/default_styles/index.ts +17 -1
  143. package/app/utils/default_styles/mesh_components.ts +168 -0
  144. package/app/utils/default_styles/meshes.ts +13 -153
  145. package/app/utils/default_styles/model_components.ts +170 -0
  146. package/app/utils/default_styles/models.ts +16 -153
  147. package/app/utils/drag_and_drop.ts +80 -0
  148. package/app/utils/extension.ts +1 -1
  149. package/app/utils/import_workflow.ts +26 -11
  150. package/app/utils/model_component_coloring.ts +46 -0
  151. package/app/utils/threshold.ts +33 -0
  152. package/app/utils/threshold_sources.ts +51 -0
  153. package/app/utils/treeview.ts +12 -1
  154. package/app/utils/upload_path.ts +15 -9
  155. package/app/utils/visible_map_area.ts +129 -0
  156. package/internal/database/base_database.ts +2 -0
  157. package/internal/database/database.ts +47 -29
  158. package/internal/database/tables/scene_style.ts +6 -0
  159. package/internal/stores/data_style/mesh/base_style.ts +74 -0
  160. package/internal/stores/data_style/mesh/cells/cell.ts +27 -150
  161. package/internal/stores/data_style/mesh/cells/cell_attribute.ts +74 -0
  162. package/internal/stores/data_style/mesh/cells/cell_config.ts +152 -0
  163. package/internal/stores/data_style/mesh/cells/color.ts +3 -1
  164. package/internal/stores/data_style/mesh/cells/index.ts +17 -1
  165. package/internal/stores/data_style/mesh/cells/opacity.ts +54 -0
  166. package/internal/stores/data_style/mesh/cells/vertex.ts +26 -157
  167. package/internal/stores/data_style/mesh/cells/vertex_attribute.ts +80 -0
  168. package/internal/stores/data_style/mesh/cells/vertex_config.ts +152 -0
  169. package/internal/stores/data_style/mesh/edges/color.ts +3 -1
  170. package/internal/stores/data_style/mesh/edges/edge.ts +27 -150
  171. package/internal/stores/data_style/mesh/edges/edge_attribute.ts +74 -0
  172. package/internal/stores/data_style/mesh/edges/edge_config.ts +152 -0
  173. package/internal/stores/data_style/mesh/edges/index.ts +17 -1
  174. package/internal/stores/data_style/mesh/edges/opacity.ts +54 -0
  175. package/internal/stores/data_style/mesh/edges/vertex.ts +26 -157
  176. package/internal/stores/data_style/mesh/edges/vertex_attribute.ts +80 -0
  177. package/internal/stores/data_style/mesh/edges/vertex_config.ts +152 -0
  178. package/internal/stores/data_style/mesh/index.ts +2 -57
  179. package/internal/stores/data_style/mesh/points/color.ts +3 -1
  180. package/internal/stores/data_style/mesh/points/index.ts +17 -1
  181. package/internal/stores/data_style/mesh/points/opacity.ts +54 -0
  182. package/internal/stores/data_style/mesh/points/vertex.ts +26 -157
  183. package/internal/stores/data_style/mesh/points/vertex_attribute.ts +80 -0
  184. package/internal/stores/data_style/mesh/points/vertex_config.ts +152 -0
  185. package/internal/stores/data_style/mesh/polygons/color.ts +3 -1
  186. package/internal/stores/data_style/mesh/polygons/index.ts +17 -1
  187. package/internal/stores/data_style/mesh/polygons/opacity.ts +54 -0
  188. package/internal/stores/data_style/mesh/polygons/polygon.ts +27 -152
  189. package/internal/stores/data_style/mesh/polygons/polygon_attribute.ts +80 -0
  190. package/internal/stores/data_style/mesh/polygons/polygon_config.ts +148 -0
  191. package/internal/stores/data_style/mesh/polygons/vertex.ts +26 -157
  192. package/internal/stores/data_style/mesh/polygons/vertex_attribute.ts +80 -0
  193. package/internal/stores/data_style/mesh/polygons/vertex_config.ts +152 -0
  194. package/internal/stores/data_style/mesh/polyhedra/color.ts +3 -1
  195. package/internal/stores/data_style/mesh/polyhedra/index.ts +17 -1
  196. package/internal/stores/data_style/mesh/polyhedra/opacity.ts +54 -0
  197. package/internal/stores/data_style/mesh/polyhedra/polyhedron.ts +27 -160
  198. package/internal/stores/data_style/mesh/polyhedra/polyhedron_attribute.ts +82 -0
  199. package/internal/stores/data_style/mesh/polyhedra/polyhedron_config.ts +157 -0
  200. package/internal/stores/data_style/mesh/polyhedra/vertex.ts +26 -157
  201. package/internal/stores/data_style/mesh/polyhedra/vertex_attribute.ts +80 -0
  202. package/internal/stores/data_style/mesh/polyhedra/vertex_config.ts +152 -0
  203. package/internal/stores/data_style/model/blocks/apply_coloring.ts +173 -0
  204. package/internal/stores/data_style/model/blocks/color.ts +58 -57
  205. package/internal/stores/data_style/model/blocks/coloring_groups.ts +18 -0
  206. package/internal/stores/data_style/model/blocks/index.ts +12 -140
  207. package/internal/stores/data_style/model/blocks/polyhedron.ts +102 -54
  208. package/internal/stores/data_style/model/blocks/vertex.ts +102 -54
  209. package/internal/stores/data_style/model/color.ts +25 -26
  210. package/internal/stores/data_style/model/common.ts +10 -119
  211. package/internal/stores/data_style/model/common_mutations.ts +184 -0
  212. package/internal/stores/data_style/model/corners/index.ts +85 -78
  213. package/internal/stores/data_style/model/corners/vertex.ts +97 -49
  214. package/internal/stores/data_style/model/lines/apply_coloring.ts +154 -0
  215. package/internal/stores/data_style/model/lines/color.ts +53 -40
  216. package/internal/stores/data_style/model/lines/coloring_groups.ts +18 -0
  217. package/internal/stores/data_style/model/lines/edge.ts +102 -54
  218. package/internal/stores/data_style/model/lines/index.ts +10 -134
  219. package/internal/stores/data_style/model/lines/vertex.ts +102 -54
  220. package/internal/stores/data_style/model/surfaces/apply_coloring.ts +186 -0
  221. package/internal/stores/data_style/model/surfaces/color.ts +68 -56
  222. package/internal/stores/data_style/model/surfaces/coloring_groups.ts +18 -0
  223. package/internal/stores/data_style/model/surfaces/index.ts +16 -160
  224. package/internal/stores/data_style/model/surfaces/polygon.ts +94 -46
  225. package/internal/stores/data_style/model/surfaces/vertex.ts +94 -46
  226. package/internal/stores/data_style/model/visibility.ts +3 -156
  227. package/internal/stores/data_style/model/visibility_dispatch.ts +110 -0
  228. package/internal/stores/data_style/scene.ts +118 -0
  229. package/internal/stores/data_style/state.ts +5 -181
  230. package/internal/stores/data_style/state_shared.ts +199 -0
  231. package/internal/stores/data_style/types.ts +24 -1
  232. package/internal/stores/hybrid_viewer/brightness.ts +8 -2
  233. package/internal/stores/hybrid_viewer/camera.ts +7 -161
  234. package/internal/stores/hybrid_viewer/camera_animation.ts +4 -3
  235. package/internal/stores/hybrid_viewer/camera_helpers.ts +120 -0
  236. package/internal/stores/hybrid_viewer/camera_orientation.ts +60 -0
  237. package/internal/stores/hybrid_viewer/filters.ts +54 -11
  238. package/internal/stores/hybrid_viewer/highlight.ts +80 -63
  239. package/internal/stores/hybrid_viewer/ruler.ts +4 -3
  240. package/internal/stores/hybrid_viewer/scene.ts +34 -26
  241. package/internal/stores/hybrid_viewer/vtk_types.ts +2 -1
  242. package/internal/utils/ws_client.ts +8 -1
  243. package/package.json +5 -5
  244. package/server/api/local/extensions/run.post.ts +6 -4
  245. package/server/api/local/extensions/upload.put.ts +47 -20
  246. package/server/utils/cleanup.ts +12 -2
  247. package/server/utils/microservices.ts +10 -102
  248. package/server/utils/microservices_process.ts +127 -0
  249. package/server/utils/scripts.ts +35 -30
  250. package/server/utils/typed_handler.ts +8 -1
  251. package/server/utils/ws_client.ts +15 -2
  252. package/shared/utils/fetch_raw.ts +2 -2
  253. package/shared/utils/parse_boolean.ts +4 -1
  254. package/app/components/Viewer/Options/OptionsSection.vue +0 -76
@@ -0,0 +1,50 @@
1
+ import { type Extent, boxesExtent } from "./extent.js";
2
+ import type { ComputedRef } from "vue";
3
+ import { sameCrs } from "@ogw_front/utils/crs";
4
+ import { useCrsStore } from "@ogw_front/stores/crs";
5
+ import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
6
+
7
+ interface Georeferenced {
8
+ // A map needs at least one data in the project CRS to lie under
9
+ available: ComputedRef<boolean>;
10
+ georeferencedIds: () => string[];
11
+ dataBounds: () => Extent | undefined;
12
+ // Changes with the project CRS, the georeferenced data or their extent
13
+ dataKey: () => string;
14
+ }
15
+
16
+ // Data without a CRS is still in local coordinates, and data in another CRS than the
17
+ // Project would be misplaced: only the data in the project CRS are under the basemap
18
+ function useGeoreferenced(): Georeferenced {
19
+ const crsStore = useCrsStore();
20
+ const hybridViewerStore = useHybridViewerStore();
21
+
22
+ function georeferencedIds(): string[] {
23
+ return crsStore.crsItems
24
+ .filter((item) => sameCrs(item.crs, crsStore.projectCrs))
25
+ .map((item) => item.id);
26
+ }
27
+
28
+ const available = computed(
29
+ () => crsStore.projectCrs !== undefined && georeferencedIds().length > 0,
30
+ );
31
+
32
+ function dataBounds(): Extent | undefined {
33
+ const georeferenced = new Set(georeferencedIds());
34
+ return boxesExtent(
35
+ Object.entries(hybridViewerStore.hybridDb)
36
+ .filter(([id]) => georeferenced.has(id))
37
+ .map(([, entry]) => entry.polydata.getBounds()),
38
+ );
39
+ }
40
+
41
+ function dataKey(): string {
42
+ const crs = crsStore.projectCrs;
43
+ const extentKey = JSON.stringify(dataBounds() ?? "none");
44
+ return `${crs?.authority}:${crs?.code}|${georeferencedIds().join(",")}|${extentKey}`;
45
+ }
46
+
47
+ return { available, georeferencedIds, dataBounds, dataKey };
48
+ }
49
+
50
+ export { useGeoreferenced };
@@ -0,0 +1,66 @@
1
+ import type { ComputedRef, Ref } from "vue";
2
+ import { type Layer, useBasemapViewer } from "./viewer.js";
3
+ import type { BasemapBuildResponse } from "@geode/opengeodeweb-back/opengeodeweb_back_typed_schemas.js";
4
+ import type { MapStyle } from "@ogw_front/utils/basemap_tree";
5
+ import { everyMap } from "./extent.js";
6
+
7
+ interface BasemapLayers {
8
+ // The last chosen maps: shown again when the basemap is shown again
9
+ shown: Ref<MapStyle[]>;
10
+ // Shown as soon as the project has a CRS, until the user hides it
11
+ hidden: Ref<boolean>;
12
+ // The visible maps, from the bottom one to the top one
13
+ maps: ComputedRef<MapStyle[]>;
14
+ opacities: Ref<Record<MapStyle, number>>;
15
+ // Cropped: only draped on the top surfaces, out of the flat map around
16
+ crop: Ref<Record<MapStyle, boolean>>;
17
+ // The maps downloaded in the current basemap: the others need a build
18
+ built: Ref<MapStyle[]>;
19
+ layersParams: () => Layer[];
20
+ applyLayers: (id: string) => Promise<void>;
21
+ // Returns the layers sent: the states changed meanwhile are sent again
22
+ applyBasemap: (
23
+ response: BasemapBuildResponse,
24
+ name: string,
25
+ detailOf?: string,
26
+ ) => Promise<string>;
27
+ }
28
+
29
+ // The state of each map, and how it reaches the viewer
30
+ function useBasemapLayers(georeferencedIds: () => string[]): BasemapLayers {
31
+ const { sendLayers, showMap } = useBasemapViewer();
32
+ const shown = ref<MapStyle[]>(["satellite"]);
33
+ const hidden = ref(false);
34
+ const maps = computed<MapStyle[]>(() => (hidden.value ? [] : shown.value));
35
+ const opacities = ref<Record<MapStyle, number>>(everyMap(1));
36
+ const crop = ref<Record<MapStyle, boolean>>(everyMap(false));
37
+ const built = ref<MapStyle[]>([]);
38
+
39
+ function layersParams(): Layer[] {
40
+ return built.value.map((map) => ({
41
+ map,
42
+ visible: maps.value.includes(map),
43
+ opacity: opacities.value[map],
44
+ crop: crop.value[map],
45
+ }));
46
+ }
47
+
48
+ async function applyLayers(id: string): Promise<void> {
49
+ await sendLayers(id, layersParams());
50
+ }
51
+
52
+ async function applyBasemap(
53
+ response: BasemapBuildResponse,
54
+ name: string,
55
+ detailOf?: string,
56
+ ): Promise<string> {
57
+ const layers = layersParams();
58
+ await showMap({ response, name, layers, dataIds: georeferencedIds() }, detailOf);
59
+ return JSON.stringify(layers);
60
+ }
61
+
62
+ return { shown, hidden, maps, opacities, crop, built, layersParams, applyLayers, applyBasemap };
63
+ }
64
+
65
+ export type { BasemapLayers };
66
+ export { useBasemapLayers };
@@ -0,0 +1,87 @@
1
+ import { type MapStyle, sortedMaps } from "@ogw_front/utils/basemap_tree";
2
+ import type { BasemapLayers } from "./layers.js";
3
+ import type { Ref } from "vue";
4
+ import { coalesced } from "./viewer.js";
5
+ import { everyMap } from "./extent.js";
6
+ import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
7
+
8
+ interface BasemapSnapshot {
9
+ maps?: MapStyle[];
10
+ opacities?: Partial<Record<MapStyle, number>>;
11
+ crop?: Partial<Record<MapStyle, boolean>>;
12
+ }
13
+
14
+ interface BasemapSettings {
15
+ setMaps: (newMaps: readonly MapStyle[]) => Promise<void>;
16
+ setOpacity: (mapStyle: MapStyle, value: number) => Promise<void>;
17
+ setCrop: (value: boolean, mapStyles: readonly MapStyle[]) => Promise<void>;
18
+ exportStores: () => Required<BasemapSnapshot>;
19
+ importStores: (snapshot: BasemapSnapshot | undefined) => Promise<void>;
20
+ }
21
+
22
+ // The choices of the user: a change already built only recomposes, the others rebuild
23
+ function useBasemapSettings(
24
+ layers: BasemapLayers,
25
+ basemapId: Ref<string | undefined>,
26
+ rebuild: () => Promise<void>,
27
+ ): BasemapSettings {
28
+ const hybridViewerStore = useHybridViewerStore();
29
+ const { shown, hidden, maps, opacities, crop, built, applyLayers } = layers;
30
+
31
+ const recompose = coalesced(async () => {
32
+ const id = basemapId.value;
33
+ if (id !== undefined) {
34
+ await applyLayers(id);
35
+ await hybridViewerStore.remoteRender();
36
+ }
37
+ });
38
+
39
+ // No map hides the basemap and keeps the last maps, to show them again. Hidden, the built
40
+ // Basemap stays with every layer invisible: shown again, it only recomposes
41
+ async function setMaps(newMaps: readonly MapStyle[]): Promise<void> {
42
+ if (newMaps.length === 0) {
43
+ hidden.value = true;
44
+ } else {
45
+ shown.value = sortedMaps(newMaps);
46
+ hidden.value = false;
47
+ }
48
+ const allBuilt = maps.value.every((mapStyle) => built.value.includes(mapStyle));
49
+ if (basemapId.value !== undefined && allBuilt) {
50
+ await recompose();
51
+ return;
52
+ }
53
+ await rebuild();
54
+ }
55
+
56
+ // No rebuild: each map keeps its opacity
57
+ async function setOpacity(mapStyle: MapStyle, value: number): Promise<void> {
58
+ opacities.value = { ...opacities.value, [mapStyle]: value };
59
+ await recompose();
60
+ }
61
+
62
+ // No rebuild
63
+ async function setCrop(value: boolean, mapStyles: readonly MapStyle[]): Promise<void> {
64
+ crop.value = {
65
+ ...crop.value,
66
+ ...Object.fromEntries(mapStyles.map((mapStyle) => [mapStyle, value])),
67
+ };
68
+ await recompose();
69
+ }
70
+
71
+ function exportStores(): Required<BasemapSnapshot> {
72
+ return { maps: maps.value, opacities: opacities.value, crop: crop.value };
73
+ }
74
+
75
+ // Called once the project data is imported. When the data is not displayed yet,
76
+ // The rebuild finds no bounds and the store rebuilds once it is displayed.
77
+ async function importStores(snapshot: BasemapSnapshot | undefined): Promise<void> {
78
+ opacities.value = { ...everyMap(1), ...snapshot?.opacities };
79
+ crop.value = { ...everyMap(false), ...snapshot?.crop };
80
+ await setMaps(sortedMaps(snapshot?.maps ?? ["satellite"]));
81
+ }
82
+
83
+ return { setMaps, setOpacity, setCrop, exportStores, importStores };
84
+ }
85
+
86
+ export type { BasemapSnapshot };
87
+ export { useBasemapSettings };
@@ -0,0 +1,114 @@
1
+ import back_schemas, {
2
+ type BasemapBuildResponse,
3
+ } from "@geode/opengeodeweb-back/opengeodeweb_back_typed_schemas.js";
4
+ import type { MapStyle } from "@ogw_front/utils/basemap_tree";
5
+ import { useBackStore } from "@ogw_front/stores/back";
6
+ import { useDataStore } from "@ogw_front/stores/data";
7
+ import { useViewerStore } from "@ogw_front/stores/viewer";
8
+ import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_typed_schemas.js";
9
+
10
+ interface Layer {
11
+ map: MapStyle;
12
+ visible: boolean;
13
+ opacity: number;
14
+ crop: boolean;
15
+ }
16
+
17
+ function ignoreError(): void {
18
+ // Already reported by the request feedback
19
+ }
20
+
21
+ interface MapToShow {
22
+ response: BasemapBuildResponse;
23
+ name: string;
24
+ layers: Layer[];
25
+ dataIds: string[];
26
+ }
27
+
28
+ interface BasemapViewer {
29
+ discardMap: (id: string, registered: boolean) => Promise<void>;
30
+ sendLayers: (id: string, layers: Layer[]) => Promise<void>;
31
+ showMap: (map: Readonly<MapToShow>, detailOf?: string) => Promise<void>;
32
+ }
33
+
34
+ // The stores are taken once: a call still running after a project reset reaches its own stores
35
+ function useBasemapViewer(): BasemapViewer {
36
+ const backStore = useBackStore();
37
+ const dataStore = useDataStore();
38
+ const viewerStore = useViewerStore();
39
+
40
+ // Best effort: a map left behind is only a leftover, never an error to show twice.
41
+ // A registered map leaves the viewer before the back deletes its files
42
+ async function discardMap(id: string, registered: boolean): Promise<void> {
43
+ if (registered) {
44
+ await dataStore.deregisterObject(id).catch(ignoreError);
45
+ }
46
+ await backStore
47
+ .request({ schema: back_schemas.opengeodeweb_back.basemap.delete, params: { id } })
48
+ .catch(ignoreError);
49
+ }
50
+
51
+ // The viewer recomposes its textures: no download, no new mesh
52
+ async function sendLayers(id: string, layers: Layer[]): Promise<void> {
53
+ await viewerStore.request({
54
+ schema: viewer_schemas.opengeodeweb_viewer.mesh.basemap_layers,
55
+ params: { id, layers },
56
+ });
57
+ }
58
+
59
+ // Registers a built map, shows it with the layers and drapes the top surfaces of the data
60
+ async function showMap(
61
+ { response, name, layers, dataIds }: Readonly<MapToShow>,
62
+ detailOf?: string,
63
+ ): Promise<void> {
64
+ await dataStore.registerObject(response.id, name);
65
+ await viewerStore.request({
66
+ schema: viewer_schemas.opengeodeweb_viewer.mesh.apply_basemap,
67
+ params: {
68
+ id: response.id,
69
+ columns: response.columns,
70
+ rows: response.rows,
71
+ maps: response.maps,
72
+ layers,
73
+ detail_of: detailOf,
74
+ },
75
+ });
76
+ await viewerStore.request({
77
+ schema: viewer_schemas.opengeodeweb_viewer.mesh.basemap_drape,
78
+ params: { id: response.id, data_ids: dataIds },
79
+ });
80
+ }
81
+
82
+ return { discardMap, sendLayers, showMap };
83
+ }
84
+
85
+ // At most one run at a time: calls made meanwhile (a slider dragged) run once more when it
86
+ // Returns, with the latest states
87
+ function coalesced(run: () => Promise<void>): () => Promise<void> {
88
+ let running: Promise<void> | undefined = undefined;
89
+ let again = false;
90
+ async function latest(): Promise<void> {
91
+ again = false;
92
+ await run();
93
+ if (again) {
94
+ await latest();
95
+ }
96
+ }
97
+ return async () => {
98
+ if (running !== undefined) {
99
+ again = true;
100
+ await running;
101
+ return;
102
+ }
103
+ running = latest();
104
+ try {
105
+ await running;
106
+ } finally {
107
+ running = undefined;
108
+ again = false;
109
+ }
110
+ };
111
+ }
112
+
113
+ export type { Layer };
114
+ export { coalesced, ignoreError, useBasemapViewer };
@@ -0,0 +1,136 @@
1
+ import back_schemas, {
2
+ type CRSList,
3
+ } from "@geode/opengeodeweb-back/opengeodeweb_back_typed_schemas.js";
4
+ import { oldestCrs, sameCrs } from "@ogw_front/utils/crs";
5
+ import { useBackStore } from "@ogw_front/stores/back";
6
+ import { useDataStore } from "@ogw_front/stores/data";
7
+
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
9
+ // oxlint-disable-next-line max-lines-per-function, max-statements
10
+ export const useCrsStore = defineStore("crs", () => {
11
+ const backStore = useBackStore();
12
+ // OpenGeode geosciences lists the same geographic CRS for 2D and 3D data: one list for all types
13
+ let geographicListPromise: Promise<CRSList[]> | undefined = undefined;
14
+ const crsEditEnabled = ref(false);
15
+ const crsEditRequest = ref<string | undefined>(undefined);
16
+ const dataStore = useDataStore();
17
+ const crsItems = dataStore.refCrsItems();
18
+ const projectCrs = ref<CRSList | undefined>(undefined);
19
+ const projectCrsEditRequest = ref(false);
20
+
21
+ // The project follows its data: once every georeferenced data is in one CRS, it is the project
22
+ // CRS. Data already mixed before any project CRS: the oldest one is the reference
23
+ watch(
24
+ () => {
25
+ const georeferenced = crsItems.value.filter((item) => item.crs !== undefined);
26
+ const [first] = georeferenced;
27
+ if (first === undefined) {
28
+ return undefined;
29
+ }
30
+ if (georeferenced.every((item) => sameCrs(item.crs, first.crs))) {
31
+ return first.crs;
32
+ }
33
+ return projectCrs.value ?? oldestCrs(georeferenced);
34
+ },
35
+ (reference) => {
36
+ if (reference !== undefined && !sameCrs(reference, projectCrs.value)) {
37
+ projectCrs.value = reference;
38
+ }
39
+ },
40
+ { immediate: true },
41
+ );
42
+
43
+ // Data without CRS are listed too (value undefined): they could not follow the project
44
+ const mismatchedCrs = computed(() => {
45
+ const project = projectCrs.value;
46
+ const mismatched = new Map<string, CRSList | undefined>();
47
+ for (const item of crsItems.value) {
48
+ if (project !== undefined && !sameCrs(item.crs, project)) {
49
+ mismatched.set(item.id, item.crs);
50
+ }
51
+ }
52
+ return mismatched;
53
+ });
54
+
55
+ async function fetchGeographicList(geodeObjectType: string): Promise<CRSList[]> {
56
+ try {
57
+ const response = await backStore.request({
58
+ schema: back_schemas.opengeodeweb_back.crs.geographic_list,
59
+ params: { geode_object_type: geodeObjectType },
60
+ });
61
+ if (response?.crs_list !== undefined) {
62
+ return response.crs_list;
63
+ }
64
+ } catch {
65
+ // The back store already reports the error to the user
66
+ }
67
+ // A failed request is not cached: the next call retries
68
+ geographicListPromise = undefined;
69
+ return [];
70
+ }
71
+
72
+ async function geographicList(geodeObjectType: string): Promise<CRSList[]> {
73
+ // The promise is cached, so dialogs opened together share a single request.
74
+ // The back still checks each CRS against the list of the data dimension
75
+ geographicListPromise ??= fetchGeographicList(geodeObjectType);
76
+ const list = await geographicListPromise;
77
+ return list;
78
+ }
79
+
80
+ function enableCrsEdit(): void {
81
+ crsEditEnabled.value = true;
82
+ }
83
+
84
+ function requestCrsEdit(id: string): void {
85
+ crsEditRequest.value = id;
86
+ }
87
+
88
+ function clearCrsEditRequest(): void {
89
+ crsEditRequest.value = undefined;
90
+ }
91
+
92
+ function setProjectCrs(crs: CRSList): void {
93
+ projectCrs.value = crs;
94
+ }
95
+
96
+ function requestProjectCrsEdit(): void {
97
+ projectCrsEditRequest.value = true;
98
+ }
99
+
100
+ function clearProjectCrsEditRequest(): void {
101
+ projectCrsEditRequest.value = false;
102
+ }
103
+
104
+ // A new project: its data set the project CRS again
105
+ function reset(): void {
106
+ projectCrs.value = undefined;
107
+ }
108
+
109
+ function exportStores(): { projectCrs?: CRSList } {
110
+ return { projectCrs: projectCrs.value };
111
+ }
112
+
113
+ // Called once the project data is imported: a project saved without it falls back to its oldest data
114
+ function importStores(snapshot: { projectCrs?: CRSList } | undefined): void {
115
+ projectCrs.value = snapshot?.projectCrs ?? oldestCrs(crsItems.value);
116
+ }
117
+
118
+ return {
119
+ crsItems,
120
+ geographicList,
121
+ crsEditEnabled,
122
+ enableCrsEdit,
123
+ crsEditRequest,
124
+ requestCrsEdit,
125
+ clearCrsEditRequest,
126
+ projectCrs,
127
+ mismatchedCrs,
128
+ setProjectCrs,
129
+ projectCrsEditRequest,
130
+ requestProjectCrsEdit,
131
+ clearProjectCrsEditRequest,
132
+ reset,
133
+ exportStores,
134
+ importStores,
135
+ };
136
+ });
@@ -1,5 +1,6 @@
1
1
  // oxlint-disable eslint/max-lines
2
2
  // Third party imports
3
+ import type { CRSList } from "@geode/opengeodeweb-back/opengeodeweb_back_typed_schemas.js";
3
4
  import type { Table } from "dexie";
4
5
  import { useObservable } from "@vueuse/rxjs";
5
6
  import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_typed_schemas.js";
@@ -22,8 +23,12 @@ interface DataItem {
22
23
  created_at: string;
23
24
  is_viewable?: boolean;
24
25
  binary_light_viewable?: string;
26
+ crs?: CRSList;
25
27
  }
26
28
 
29
+ // What the CRS features read of a data: light to copy on each change
30
+ type CrsItem = Pick<DataItem, "id" | "name" | "crs" | "created_at">;
31
+
27
32
  interface ModelComponentInput {
28
33
  geode_id: string;
29
34
  type: string;
@@ -43,6 +48,9 @@ interface NewDataItem {
43
48
  geode_object_type: string;
44
49
  is_viewable?: boolean;
45
50
  binary_light_viewable?: string;
51
+ crs?: CRSList;
52
+ // Set on saved data: kept by the project snapshot
53
+ created_at?: string;
46
54
  mesh_components?: ModelComponentInput[];
47
55
  collection_components?: ModelComponentInput[];
48
56
  nb_vertices?: number;
@@ -152,6 +160,17 @@ export const useDataStore = defineStore("data", () => {
152
160
  },
153
161
  );
154
162
  }
163
+ // The CRS features only need these fields: the geometry stays out of the copies made on each change
164
+ function refCrsItems(): Ref<CrsItem[]> {
165
+ return useObservable(
166
+ liveObservable(async () => {
167
+ const items = await data_db.toArray();
168
+ return items.map(({ id, name, crs, created_at }) => ({ id, name, crs, created_at }));
169
+ }),
170
+ { initialValue: [] as CrsItem[] },
171
+ );
172
+ }
173
+
155
174
  function refAllItems(): Ref<DataItem[]> {
156
175
  return useObservable(
157
176
  liveObservable(async () => {
@@ -219,6 +238,9 @@ export const useDataStore = defineStore("data", () => {
219
238
  if (new_item.binary_light_viewable !== undefined && new_item.binary_light_viewable !== null) {
220
239
  itemData.binary_light_viewable = new_item.binary_light_viewable;
221
240
  }
241
+ if (new_item.crs !== undefined) {
242
+ itemData.crs = new_item.crs;
243
+ }
222
244
  const id = await data_db.put(itemData);
223
245
  return id;
224
246
  }
@@ -375,6 +397,7 @@ export const useDataStore = defineStore("data", () => {
375
397
  }
376
398
  return {
377
399
  refAllItems,
400
+ refCrsItems,
378
401
  refRegisteredItems,
379
402
  isRegistered,
380
403
  item,
@@ -415,4 +438,4 @@ export const useDataStore = defineStore("data", () => {
415
438
  };
416
439
  });
417
440
 
418
- export type { DataItem, NewDataItem, ModelComponentInput, ModelComponentRelationRecord };
441
+ export type { CrsItem, DataItem, NewDataItem, ModelComponentInput, ModelComponentRelationRecord };
@@ -2,6 +2,7 @@ import type {
2
2
  ModelComponentStyle,
3
3
  ModelComponentTypeStyle,
4
4
  ObjectStyle,
5
+ SceneStyle,
5
6
  } from "@ogw_internal/stores/data_style/types";
6
7
  import type { Table } from "dexie";
7
8
  import { database } from "@ogw_internal/database/database.js";
@@ -11,11 +12,13 @@ import { useDataStore } from "@ogw_front/stores/data";
11
12
  import { useDataStyleState } from "@ogw_internal/stores/data_style/state";
12
13
  import { useMeshStyle } from "@ogw_internal/stores/data_style/mesh/index";
13
14
  import { useModelStyle } from "@ogw_internal/stores/data_style/model/index";
15
+ import { useSceneStyle } from "@ogw_internal/stores/data_style/scene";
14
16
 
15
17
  interface DataStyleSnapshot {
16
18
  readonly styles: Record<string, ObjectStyle>;
17
19
  readonly componentStyles: Record<string, ModelComponentStyle>;
18
20
  readonly modelComponentTypeStyles: Record<string, ModelComponentTypeStyle>;
21
+ readonly sceneStyle?: SceneStyle;
19
22
  }
20
23
 
21
24
  // The database's table map is dynamically assembled at runtime (see internal/database/database.ts), so its exported type is a loose `{}`; cast it to the shape it actually has at runtime rather than widening every call site.
@@ -38,6 +41,7 @@ export const useDataStyleStore = defineStore("dataStyle", () => {
38
41
  const dataStyleState = useDataStyleState();
39
42
  const meshStyleStore = useMeshStyle();
40
43
  const modelStyleStore = useModelStyle();
44
+ const sceneStyleStore = useSceneStyle();
41
45
  const attributeTimeStepStyle = useAttributeTimeStepStyle();
42
46
  const dataStore = useDataStore();
43
47
  // oxlint-disable-next-line no-unsafe-type-assertion -- the database Proxy is typed as `{}` at its export site; this cast documents its real runtime shape.
@@ -98,6 +102,7 @@ export const useDataStyleStore = defineStore("dataStyle", () => {
98
102
  styles: dataStyleState.styles.value,
99
103
  componentStyles: dataStyleState.componentStyles.value,
100
104
  modelComponentTypeStyles: dataStyleState.modelComponentTypeStyles.value,
105
+ sceneStyle: dataStyleState.sceneStyle.value,
101
106
  };
102
107
  }
103
108
 
@@ -135,6 +140,7 @@ export const useDataStyleStore = defineStore("dataStyle", () => {
135
140
  ...model_component_type_style_promises,
136
141
  ]);
137
142
  await dataStyleState.loadFromDatabase();
143
+ await sceneStyleStore.importSceneStyle(snapshot.sceneStyle);
138
144
  }
139
145
 
140
146
  async function applyAllStylesFromState(): Promise<void> {
@@ -152,6 +158,7 @@ export const useDataStyleStore = defineStore("dataStyle", () => {
152
158
  }
153
159
  });
154
160
  await Promise.all(promises);
161
+ await sceneStyleStore.applySceneStyle();
155
162
  }
156
163
 
157
164
  return {
@@ -165,6 +172,7 @@ export const useDataStyleStore = defineStore("dataStyle", () => {
165
172
  ...attributeTimeStepStyle,
166
173
  ...meshStyleStore,
167
174
  ...modelStyleStore,
175
+ ...sceneStyleStore,
168
176
  };
169
177
  });
170
178
 
@@ -5,6 +5,11 @@ const DEFAULT_FEEDBACKS_TIMEOUT_SECONDS = 10;
5
5
 
6
6
  type FeedbackType = "error" | "success" | "warning";
7
7
 
8
+ interface FeedbackAction {
9
+ label: string;
10
+ onClick: () => void;
11
+ }
12
+
8
13
  interface Feedback {
9
14
  id: string;
10
15
  type: FeedbackType;
@@ -12,6 +17,7 @@ interface Feedback {
12
17
  route?: string;
13
18
  name?: string;
14
19
  description?: string;
20
+ action?: FeedbackAction;
15
21
  }
16
22
 
17
23
  export const useFeedbackStore = defineStore("feedback", {
@@ -35,23 +41,25 @@ export const useFeedbackStore = defineStore("feedback", {
35
41
  this.delete_feedback(feedbackId);
36
42
  }, this.feedbacks_timeout_miliseconds);
37
43
  },
38
- add_success(description: string) {
44
+ add_success(description: string, action?: FeedbackAction) {
39
45
  const feedbackId = uuidv4();
40
46
  this.feedbacks.push({
41
47
  id: feedbackId,
42
48
  type: "success",
43
49
  description,
50
+ ...(action !== undefined && { action }),
44
51
  });
45
52
  setTimeout(() => {
46
53
  this.delete_feedback(feedbackId);
47
54
  }, this.feedbacks_timeout_miliseconds);
48
55
  },
49
- add_warning(description: string) {
56
+ add_warning(description: string, action?: FeedbackAction) {
50
57
  const feedbackId = uuidv4();
51
58
  this.feedbacks.push({
52
59
  id: feedbackId,
53
60
  type: "warning",
54
61
  description,
62
+ ...(action !== undefined && { action }),
55
63
  });
56
64
  setTimeout(() => {
57
65
  this.delete_feedback(feedbackId);
@@ -65,3 +73,5 @@ export const useFeedbackStore = defineStore("feedback", {
65
73
  },
66
74
  },
67
75
  });
76
+
77
+ export type { FeedbackAction };
@@ -111,7 +111,7 @@ export const useHybridViewerStore = defineStore("hybridViewer", () => {
111
111
  const camera = renderer?.getActiveCamera();
112
112
  return {
113
113
  zScale: sceneStore.zScale.value,
114
- camera_options: (camera ? getCameraOptions(camera) : undefined) ?? cameraStore.camera_options,
114
+ camera_options: (camera && getCameraOptions(camera)) ?? cameraStore.camera_options,
115
115
  };
116
116
  }
117
117