@geode/opengeodeweb-front 10.44.0-rc.6 → 10.44.0-rc.7

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 (30) hide show
  1. package/app/components/BasemapAttribution.vue +28 -0
  2. package/app/components/Viewer/Basemap/CropOptions.vue +50 -0
  3. package/app/components/Viewer/Basemap/OpacityOptions.vue +52 -0
  4. package/app/components/Viewer/ContextMenu/ContextMenu.vue +5 -1
  5. package/app/components/Viewer/ContextMenu/ContextMenuItem.vue +6 -2
  6. package/app/components/Viewer/ObjectTree/Views/GlobalObjects.vue +49 -10
  7. package/app/components/Viewer/Ui.vue +6 -0
  8. package/app/composables/project_manager_helpers/reset.ts +3 -0
  9. package/app/composables/project_manager_helpers/restore.ts +3 -0
  10. package/app/composables/project_manager_helpers/types.ts +2 -0
  11. package/app/composables/viewer_context_menu.ts +10 -0
  12. package/app/stores/basemap.ts +52 -0
  13. package/app/stores/basemap_detail.ts +51 -0
  14. package/app/stores/basemap_helpers/builds.ts +158 -0
  15. package/app/stores/basemap_helpers/detail_layers.ts +72 -0
  16. package/app/stores/basemap_helpers/detail_map.ts +62 -0
  17. package/app/stores/basemap_helpers/detail_refresh.ts +134 -0
  18. package/app/stores/basemap_helpers/detail_view.ts +94 -0
  19. package/app/stores/basemap_helpers/extent.ts +40 -0
  20. package/app/stores/basemap_helpers/georeferenced.ts +50 -0
  21. package/app/stores/basemap_helpers/layers.ts +66 -0
  22. package/app/stores/basemap_helpers/settings.ts +87 -0
  23. package/app/stores/basemap_helpers/viewer.ts +114 -0
  24. package/app/stores/menu_helpers/basemap.ts +10 -0
  25. package/app/stores/menu_helpers/menus_data.ts +2 -0
  26. package/app/utils/basemap_tree.ts +76 -0
  27. package/app/utils/treeview.ts +12 -1
  28. package/app/utils/visible_map_area.ts +129 -0
  29. package/internal/stores/hybrid_viewer/vtk_types.ts +2 -1
  30. package/package.json +1 -1
@@ -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,10 @@
1
+ import BasemapCropOptions from "@ogw_front/components/Viewer/Basemap/CropOptions.vue";
2
+ import BasemapOpacityOptions from "@ogw_front/components/Viewer/Basemap/OpacityOptions.vue";
3
+ import type { MenuItems } from "./types.js";
4
+
5
+ const basemapMenus: Record<string, MenuItems> = {
6
+ Basemap: [BasemapCropOptions],
7
+ Map: [BasemapOpacityOptions, BasemapCropOptions],
8
+ };
9
+
10
+ export { basemapMenus };
@@ -1,5 +1,6 @@
1
1
  import { modelComponentMenus, modelComponentTypeMenus, modelMenus } from "./model.js";
2
2
  import type { MenuItems } from "./types.js";
3
+ import { basemapMenus } from "./basemap.js";
3
4
  import { edgedCurveMenus } from "./mesh/edged_curve.js";
4
5
  import { gridMenus } from "./mesh/grid.js";
5
6
  import { pointSetMenus } from "./mesh/point_set.js";
@@ -17,6 +18,7 @@ const menusData: Record<string, Record<string, MenuItems>> = {
17
18
  model: modelMenus,
18
19
  model_component_type: modelComponentTypeMenus,
19
20
  model_component: modelComponentMenus,
21
+ basemap: basemapMenus,
20
22
  };
21
23
 
22
24
  export { menusData };
@@ -0,0 +1,76 @@
1
+ type MapStyle = "satellite" | "plan" | "routes";
2
+
3
+ interface BasemapTreeGroup {
4
+ id: string;
5
+ title: string;
6
+ children: { id: string; title: string }[];
7
+ }
8
+
9
+ // Tree order and stacking order: from the bottom up, the routes stay readable on top
10
+ const MAP_STYLES: readonly MapStyle[] = ["satellite", "plan", "routes"];
11
+ const MAP_TITLES: Record<MapStyle, string> = {
12
+ satellite: "Satellite",
13
+ plan: "Plan",
14
+ routes: "Routes",
15
+ };
16
+ const BASEMAP_GROUP_ID = "basemap";
17
+ const MAP_ID_PREFIX = `${BASEMAP_GROUP_ID}:`;
18
+
19
+ function mapId(style: MapStyle): string {
20
+ return `${MAP_ID_PREFIX}${style}`;
21
+ }
22
+
23
+ function mapStyleOf(id: string): MapStyle | undefined {
24
+ return MAP_STYLES.find((style) => mapId(style) === id);
25
+ }
26
+
27
+ function sortedMaps(maps: readonly string[]): MapStyle[] {
28
+ return MAP_STYLES.filter((style) => maps.includes(style));
29
+ }
30
+
31
+ // Tree ids of the basemap: never project data
32
+ function isBasemapId(id: string): boolean {
33
+ return id === BASEMAP_GROUP_ID || id.startsWith(MAP_ID_PREFIX);
34
+ }
35
+
36
+ function basemapGroup(): BasemapTreeGroup {
37
+ return {
38
+ id: BASEMAP_GROUP_ID,
39
+ title: "Basemap",
40
+ children: MAP_STYLES.map((style) => ({ id: mapId(style), title: MAP_TITLES[style] })),
41
+ };
42
+ }
43
+
44
+ // Each map eye shows or hides its map. The classic tree adds the group and every map on a
45
+ // Group click: that click hides the visible maps, or shows the last visible maps again
46
+ function nextBasemapMaps(
47
+ current: readonly MapStyle[],
48
+ last: readonly MapStyle[],
49
+ added: readonly string[],
50
+ removed: readonly string[],
51
+ ): MapStyle[] {
52
+ const addedMaps = added.flatMap((id) => mapStyleOf(id) ?? []);
53
+ if (added.includes(BASEMAP_GROUP_ID) || addedMaps.length > 1) {
54
+ if (current.length === 0) {
55
+ return [...last];
56
+ }
57
+ return [];
58
+ }
59
+ const removedMaps = removed.flatMap((id) => mapStyleOf(id) ?? []);
60
+ if (removed.includes(BASEMAP_GROUP_ID) && removedMaps.length === 0) {
61
+ return [];
62
+ }
63
+ return sortedMaps([...current, ...addedMaps].filter((style) => !removedMaps.includes(style)));
64
+ }
65
+
66
+ export type { MapStyle };
67
+ export {
68
+ BASEMAP_GROUP_ID,
69
+ MAP_STYLES,
70
+ basemapGroup,
71
+ isBasemapId,
72
+ mapId,
73
+ mapStyleOf,
74
+ nextBasemapMaps,
75
+ sortedMaps,
76
+ };
@@ -29,7 +29,18 @@ interface ModelComponentMenuPayload {
29
29
  targetComponentIds?: string[];
30
30
  }
31
31
 
32
- type TreeMenuPayload = DataMenuPayload | GeodeObjectTypeMenuPayload | ModelComponentMenuPayload;
32
+ // The basemap category and its maps: not project data
33
+ interface BasemapMenuPayload {
34
+ event: MouseEvent;
35
+ itemId: string;
36
+ context_type: "basemap";
37
+ }
38
+
39
+ type TreeMenuPayload =
40
+ | DataMenuPayload
41
+ | GeodeObjectTypeMenuPayload
42
+ | ModelComponentMenuPayload
43
+ | BasemapMenuPayload;
33
44
 
34
45
  export { compareSelections };
35
46
  export type {
@@ -0,0 +1,129 @@
1
+ import { cross, multiplyAccumulate, normalize, subtract } from "@kitware/vtk.js/Common/Core/Math";
2
+ import type { CameraOptions } from "@ogw_internal/stores/hybrid_viewer/vtk_types";
3
+ import type { Vector3 } from "@kitware/vtk.js/types";
4
+
5
+ interface MapBounds {
6
+ x_min: number;
7
+ y_min: number;
8
+ x_max: number;
9
+ y_max: number;
10
+ }
11
+
12
+ // A map built by the back: its area and its number of tile columns
13
+ interface MapGrid {
14
+ bounds: MapBounds;
15
+ columns: number;
16
+ }
17
+
18
+ type ViewCamera = Pick<
19
+ CameraOptions,
20
+ "position" | "focal_point" | "view_up" | "view_angle" | "distance"
21
+ >;
22
+
23
+ // About one tile level (x2): the map changes by steps, not at every small move
24
+ const DETAIL_RATIO = 1.5;
25
+ const TILE_SIZE = 256;
26
+ const DEGREES = 180;
27
+ const HALF = 2;
28
+
29
+ // The ground size of one pixel of the map
30
+ function mapResolution(grid: MapGrid): number {
31
+ return (grid.bounds.x_max - grid.bounds.x_min) / (grid.columns * TILE_SIZE);
32
+ }
33
+
34
+ // Where a corner ray meets the map plane, or, past the horizon, the base edge in its direction
35
+ function groundPoint(
36
+ origin: Vector3,
37
+ direction: Vector3,
38
+ planeZ: number,
39
+ reach: number,
40
+ ): [number, number] {
41
+ const distance = (planeZ - origin[2]) / direction[2];
42
+ if (direction[2] < 0 && distance > 0) {
43
+ return [origin[0] + direction[0] * distance, origin[1] + direction[1] * distance];
44
+ }
45
+ const flat = Math.hypot(direction[0], direction[1]) || 1;
46
+ return [origin[0] + (direction[0] / flat) * reach, origin[1] + (direction[1] / flat) * reach];
47
+ }
48
+
49
+ // The part of the base map the screen shows, from the rays of its 4 corners
50
+ function visibleMapArea(
51
+ camera: ViewCamera,
52
+ aspect: number,
53
+ planeZ: number,
54
+ base: MapBounds,
55
+ ): MapBounds | undefined {
56
+ const forward = subtract(camera.focal_point, camera.position, [0, 0, 0]);
57
+ normalize(forward);
58
+ const right = cross(forward, camera.view_up, [0, 0, 0]);
59
+ normalize(right);
60
+ const upward = cross(right, forward, [0, 0, 0]);
61
+ const halfHeight = Math.tan((camera.view_angle * Math.PI) / DEGREES / HALF);
62
+ const halfWidth = halfHeight * aspect;
63
+ const reach = Math.hypot(base.x_max - base.x_min, base.y_max - base.y_min);
64
+ const corners = [
65
+ [-1, -1],
66
+ [1, -1],
67
+ [1, 1],
68
+ [-1, 1],
69
+ ].map(([column = 0, row = 0]) => {
70
+ const direction = multiplyAccumulate(forward, right, column * halfWidth, [0, 0, 0]);
71
+ multiplyAccumulate(direction, upward, row * halfHeight, direction);
72
+ return groundPoint(camera.position, direction, planeZ, reach);
73
+ });
74
+ const xValues = corners.map((corner) => corner[0]);
75
+ const yValues = corners.map((corner) => corner[1]);
76
+ const visibleArea = {
77
+ x_min: Math.max(base.x_min, Math.min(...xValues)),
78
+ y_min: Math.max(base.y_min, Math.min(...yValues)),
79
+ x_max: Math.min(base.x_max, Math.max(...xValues)),
80
+ y_max: Math.min(base.y_max, Math.max(...yValues)),
81
+ };
82
+ if (visibleArea.x_min >= visibleArea.x_max || visibleArea.y_min >= visibleArea.y_max) {
83
+ return undefined;
84
+ }
85
+ return visibleArea;
86
+ }
87
+
88
+ // The ground size of one screen pixel at the focal point
89
+ function screenPixelGroundSize(camera: ViewCamera, viewportHeight: number): number {
90
+ return (
91
+ (HALF * camera.distance * Math.tan((camera.view_angle * Math.PI) / DEGREES / HALF)) /
92
+ viewportHeight
93
+ );
94
+ }
95
+
96
+ // Below this gain the detail would look the same as the base
97
+ function needsSharperMap(baseResolution: number, wanted: number): boolean {
98
+ return baseResolution > DETAIL_RATIO * wanted;
99
+ }
100
+
101
+ // Whether the map area covers the whole visible area
102
+ function covers(area: MapBounds, visible: MapBounds): boolean {
103
+ return (
104
+ visible.x_min >= area.x_min &&
105
+ visible.y_min >= area.y_min &&
106
+ visible.x_max <= area.x_max &&
107
+ visible.y_max <= area.y_max
108
+ );
109
+ }
110
+
111
+ // A detail map stays while the view keeps within its area and its step of resolution
112
+ function stillSharp(detail: MapGrid, visible: MapBounds, wanted: number): boolean {
113
+ const resolution = mapResolution(detail);
114
+ return (
115
+ covers(detail.bounds, visible) &&
116
+ resolution <= wanted * DETAIL_RATIO &&
117
+ resolution >= wanted / DETAIL_RATIO
118
+ );
119
+ }
120
+
121
+ export type { MapBounds, MapGrid, ViewCamera };
122
+ export {
123
+ covers,
124
+ mapResolution,
125
+ needsSharperMap,
126
+ screenPixelGroundSize,
127
+ stillSharp,
128
+ visibleMapArea,
129
+ };
@@ -1,5 +1,6 @@
1
1
  import type { Vector3 } from "@kitware/vtk.js/types";
2
2
  import type vtkActor from "@kitware/vtk.js/Rendering/Core/Actor";
3
+ import type vtkPolyData from "@kitware/vtk.js/Common/DataModel/PolyData";
3
4
 
4
5
  // The camera state as exchanged with the viewer microservice (snake_case field names, plain arrays) - distinct from vtk.js's own vtkCamera object.
5
6
  interface CameraOptions {
@@ -13,7 +14,7 @@ interface CameraOptions {
13
14
 
14
15
  interface HybridDbEntry {
15
16
  actor: vtkActor;
16
- polydata: unknown;
17
+ polydata: vtkPolyData;
17
18
  mapper: unknown;
18
19
  }
19
20
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geode/opengeodeweb-front",
3
- "version": "10.44.0-rc.6",
3
+ "version": "10.44.0-rc.7",
4
4
  "description": "OpenSource Vue/Nuxt/Pinia/Vuetify framework for web applications",
5
5
  "homepage": "https://github.com/Geode-solutions/OpenGeodeWeb-Front",
6
6
  "bugs": {