@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.
- package/.build/server/utils/cleanup.js +7 -2
- package/.build/server/utils/microservices.js +9 -81
- package/.build/server/utils/microservices_process.js +85 -0
- package/.build/server/utils/scripts.js +34 -23
- package/.build/server/utils/typed_handler.js +5 -1
- package/.build/server/utils/ws_client.js +7 -2
- package/.build/shared/utils/fetch_raw.js +2 -2
- package/.build/shared/utils/parse_boolean.js +2 -1
- package/app/assets/geode_objects.ts +1 -0
- package/app/components/BasemapAttribution.vue +28 -0
- package/app/components/ClippingPlanes.vue +22 -78
- package/app/components/CrsSelector.vue +53 -46
- package/app/components/DragAndDrop.vue +16 -79
- package/app/components/FeedBack/Snackers.vue +27 -0
- package/app/components/FileSelector.vue +9 -6
- package/app/components/HybridViewerTooltip.vue +8 -2
- package/app/components/MissingFilesSelector.vue +40 -23
- package/app/components/ObjectSelector.vue +34 -20
- package/app/components/ProjectCrs.vue +37 -0
- package/app/components/Screenshot.vue +17 -59
- package/app/components/ThresholdCard.vue +205 -0
- package/app/components/ThresholdFilter.vue +81 -216
- package/app/components/ViewToolbar.vue +15 -231
- package/app/components/Viewer/Basemap/CropOptions.vue +50 -0
- package/app/components/Viewer/Basemap/OpacityOptions.vue +52 -0
- package/app/components/Viewer/ContextMenu/CircularItems.vue +1 -2
- package/app/components/Viewer/ContextMenu/ContextMenu.vue +11 -6
- package/app/components/Viewer/ContextMenu/ContextMenuItem.vue +10 -7
- package/app/components/Viewer/ContextMenu/InfoCard.vue +30 -0
- package/app/components/Viewer/EdgedCurve/SpecificEdgesColoring.vue +209 -0
- package/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue +3 -191
- package/app/components/Viewer/Generic/Mesh/CellsColoring.vue +221 -0
- package/app/components/Viewer/Generic/Mesh/CellsOptions.vue +3 -210
- package/app/components/Viewer/Generic/Mesh/EdgesColoring.vue +211 -0
- package/app/components/Viewer/Generic/Mesh/EdgesOptions.vue +3 -192
- package/app/components/Viewer/Generic/Mesh/PointsOptions.vue +13 -0
- package/app/components/Viewer/Generic/Mesh/PolygonsColoring.vue +227 -0
- package/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue +3 -215
- package/app/components/Viewer/Generic/Mesh/PolyhedraColoring.vue +221 -0
- package/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue +3 -203
- package/app/components/Viewer/Generic/Model/BlocksOptions.vue +14 -12
- package/app/components/Viewer/Generic/Model/ComponentPointsOptions.vue +2 -18
- package/app/components/Viewer/Generic/Model/CornerComponentOptions.vue +145 -0
- package/app/components/Viewer/Generic/Model/CornersOptions.vue +15 -294
- package/app/components/Viewer/Generic/Model/CornersTypeOptions.vue +173 -0
- package/app/components/Viewer/Generic/Model/LineComponentOptions.vue +218 -0
- package/app/components/Viewer/Generic/Model/LinesOptions.vue +15 -427
- package/app/components/Viewer/Generic/Model/LinesTypeOptions.vue +229 -0
- package/app/components/Viewer/Generic/Model/ModelCardTabs.vue +35 -0
- package/app/components/Viewer/Generic/Model/ModelEdgesCard.vue +34 -25
- package/app/components/Viewer/Generic/Model/ModelPointsCard.vue +34 -25
- package/app/components/Viewer/Generic/Model/ModelStyleCard.vue +17 -5
- package/app/components/Viewer/Generic/Model/SurfacesOptions.vue +16 -12
- package/app/components/Viewer/ObjectTree/Base/ComponentRelations.vue +4 -1
- package/app/components/Viewer/ObjectTree/Base/ItemLabel.vue +71 -1
- package/app/components/Viewer/ObjectTree/Views/GlobalObjects.vue +55 -10
- package/app/components/Viewer/Options/AttributeRangeSelector.vue +11 -4
- package/app/components/Viewer/Options/AttributeSelector.vue +40 -136
- package/app/components/Viewer/Options/ColorPicker.vue +4 -1
- package/app/components/Viewer/Options/ColoringTypeSelector.vue +48 -74
- package/app/components/Viewer/Options/ColormapQuickPicker.vue +13 -7
- package/app/components/Viewer/Options/NoDataColorInfo.vue +56 -0
- package/app/components/Viewer/Options/Sliders/Opacity.vue +22 -0
- package/app/components/Viewer/PointSet/SpecificPointsOptions.vue +13 -0
- package/app/components/Viewer/Scene/BackgroundOptions.vue +37 -0
- package/app/components/Viewer/Scene/OrientationWidgetOptions.vue +48 -0
- package/app/components/Viewer/Scene/TextOptions.vue +63 -0
- package/app/components/Viewer/Solid/SpecificPolyhedraColoring.vue +217 -0
- package/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue +4 -199
- package/app/components/Viewer/Surface/PolygonsColoring.vue +224 -0
- package/app/components/Viewer/Surface/PolygonsOptions.vue +3 -213
- package/app/components/Viewer/Ui.vue +9 -0
- package/app/components/csv-preview/CsvPreviewer.vue +4 -1
- package/app/composables/attribute_coloring_style.ts +8 -2
- package/app/composables/attribute_selector.ts +126 -0
- package/app/composables/batch_style_model.ts +34 -0
- package/app/composables/clipping_slices.ts +166 -0
- package/app/composables/global_attribute_style.ts +4 -3
- package/app/composables/hover_highlight.ts +19 -18
- package/app/composables/live_data_item.ts +39 -0
- package/app/composables/model_tabs.ts +86 -0
- package/app/composables/overlapping_picker_menu.ts +43 -0
- package/app/composables/project_manager.ts +5 -81
- package/app/composables/project_manager_helpers/reset.ts +34 -0
- package/app/composables/project_manager_helpers/restore.ts +67 -0
- package/app/composables/project_manager_helpers/types.ts +24 -0
- package/app/composables/project_manager_helpers/viewer_session.ts +25 -0
- package/app/composables/stepper_tree.ts +10 -2
- package/app/composables/tree_filter.ts +11 -2
- package/app/composables/tree_keyboard_nav.ts +4 -2
- package/app/composables/use_overlapping_picker.ts +30 -42
- package/app/composables/view_toolbar_options.ts +126 -0
- package/app/composables/view_toolbar_tool_options.ts +115 -0
- package/app/composables/view_toolbar_tools.ts +108 -0
- package/app/composables/viewer_context_menu.ts +19 -1
- package/app/composables/virtual_tree.ts +20 -131
- package/app/composables/virtual_tree_flatten.ts +109 -0
- package/app/composables/virtual_tree_types.ts +81 -0
- package/app/stores/app.ts +8 -55
- package/app/stores/app_helpers/extension.ts +90 -51
- package/app/stores/app_helpers/registry.ts +69 -0
- package/app/stores/basemap.ts +52 -0
- package/app/stores/basemap_detail.ts +51 -0
- package/app/stores/basemap_helpers/builds.ts +158 -0
- package/app/stores/basemap_helpers/detail_layers.ts +72 -0
- package/app/stores/basemap_helpers/detail_map.ts +62 -0
- package/app/stores/basemap_helpers/detail_refresh.ts +134 -0
- package/app/stores/basemap_helpers/detail_view.ts +94 -0
- package/app/stores/basemap_helpers/extent.ts +40 -0
- package/app/stores/basemap_helpers/georeferenced.ts +50 -0
- package/app/stores/basemap_helpers/layers.ts +66 -0
- package/app/stores/basemap_helpers/settings.ts +87 -0
- package/app/stores/basemap_helpers/viewer.ts +114 -0
- package/app/stores/crs.ts +136 -0
- package/app/stores/data.ts +24 -1
- package/app/stores/data_style.ts +8 -0
- package/app/stores/feedback.ts +12 -2
- package/app/stores/hybrid_viewer.ts +1 -1
- package/app/stores/infra.ts +26 -21
- package/app/stores/menu.ts +8 -124
- package/app/stores/menu_helpers/basemap.ts +10 -0
- package/app/stores/menu_helpers/menus_data.ts +27 -0
- package/app/stores/menu_helpers/mesh/edged_curve.ts +12 -0
- package/app/stores/menu_helpers/mesh/grid.ts +24 -0
- package/app/stores/menu_helpers/mesh/point_set.ts +11 -0
- package/app/stores/menu_helpers/mesh/solid.ts +29 -0
- package/app/stores/menu_helpers/mesh/surface.ts +22 -0
- package/app/stores/menu_helpers/model.ts +25 -0
- package/app/stores/menu_helpers/scene.ts +10 -0
- package/app/stores/menu_helpers/types.ts +5 -0
- package/app/stores/treeview.ts +17 -10
- package/app/stores/viewer.ts +17 -79
- package/app/stores/viewer_helpers/actions.ts +68 -0
- package/app/stores/viewer_helpers/request.ts +61 -0
- package/app/utils/basemap_tree.ts +76 -0
- package/app/utils/clipping_planes.ts +4 -131
- package/app/utils/clipping_planes_scene.ts +131 -0
- package/app/utils/color_picker.ts +18 -15
- package/app/utils/coloring_styles.ts +101 -0
- package/app/utils/crs.ts +38 -0
- package/app/utils/default_styles/constants.ts +10 -0
- package/app/utils/default_styles/index.ts +17 -1
- package/app/utils/default_styles/mesh_components.ts +168 -0
- package/app/utils/default_styles/meshes.ts +13 -153
- package/app/utils/default_styles/model_components.ts +170 -0
- package/app/utils/default_styles/models.ts +16 -153
- package/app/utils/drag_and_drop.ts +80 -0
- package/app/utils/extension.ts +1 -1
- package/app/utils/import_workflow.ts +26 -11
- package/app/utils/model_component_coloring.ts +46 -0
- package/app/utils/threshold.ts +33 -0
- package/app/utils/threshold_sources.ts +51 -0
- package/app/utils/treeview.ts +12 -1
- package/app/utils/upload_path.ts +15 -9
- package/app/utils/visible_map_area.ts +129 -0
- package/internal/database/base_database.ts +2 -0
- package/internal/database/database.ts +47 -29
- package/internal/database/tables/scene_style.ts +6 -0
- package/internal/stores/data_style/mesh/base_style.ts +74 -0
- package/internal/stores/data_style/mesh/cells/cell.ts +27 -150
- package/internal/stores/data_style/mesh/cells/cell_attribute.ts +74 -0
- package/internal/stores/data_style/mesh/cells/cell_config.ts +152 -0
- package/internal/stores/data_style/mesh/cells/color.ts +3 -1
- package/internal/stores/data_style/mesh/cells/index.ts +17 -1
- package/internal/stores/data_style/mesh/cells/opacity.ts +54 -0
- package/internal/stores/data_style/mesh/cells/vertex.ts +26 -157
- package/internal/stores/data_style/mesh/cells/vertex_attribute.ts +80 -0
- package/internal/stores/data_style/mesh/cells/vertex_config.ts +152 -0
- package/internal/stores/data_style/mesh/edges/color.ts +3 -1
- package/internal/stores/data_style/mesh/edges/edge.ts +27 -150
- package/internal/stores/data_style/mesh/edges/edge_attribute.ts +74 -0
- package/internal/stores/data_style/mesh/edges/edge_config.ts +152 -0
- package/internal/stores/data_style/mesh/edges/index.ts +17 -1
- package/internal/stores/data_style/mesh/edges/opacity.ts +54 -0
- package/internal/stores/data_style/mesh/edges/vertex.ts +26 -157
- package/internal/stores/data_style/mesh/edges/vertex_attribute.ts +80 -0
- package/internal/stores/data_style/mesh/edges/vertex_config.ts +152 -0
- package/internal/stores/data_style/mesh/index.ts +2 -57
- package/internal/stores/data_style/mesh/points/color.ts +3 -1
- package/internal/stores/data_style/mesh/points/index.ts +17 -1
- package/internal/stores/data_style/mesh/points/opacity.ts +54 -0
- package/internal/stores/data_style/mesh/points/vertex.ts +26 -157
- package/internal/stores/data_style/mesh/points/vertex_attribute.ts +80 -0
- package/internal/stores/data_style/mesh/points/vertex_config.ts +152 -0
- package/internal/stores/data_style/mesh/polygons/color.ts +3 -1
- package/internal/stores/data_style/mesh/polygons/index.ts +17 -1
- package/internal/stores/data_style/mesh/polygons/opacity.ts +54 -0
- package/internal/stores/data_style/mesh/polygons/polygon.ts +27 -152
- package/internal/stores/data_style/mesh/polygons/polygon_attribute.ts +80 -0
- package/internal/stores/data_style/mesh/polygons/polygon_config.ts +148 -0
- package/internal/stores/data_style/mesh/polygons/vertex.ts +26 -157
- package/internal/stores/data_style/mesh/polygons/vertex_attribute.ts +80 -0
- package/internal/stores/data_style/mesh/polygons/vertex_config.ts +152 -0
- package/internal/stores/data_style/mesh/polyhedra/color.ts +3 -1
- package/internal/stores/data_style/mesh/polyhedra/index.ts +17 -1
- package/internal/stores/data_style/mesh/polyhedra/opacity.ts +54 -0
- package/internal/stores/data_style/mesh/polyhedra/polyhedron.ts +27 -160
- package/internal/stores/data_style/mesh/polyhedra/polyhedron_attribute.ts +82 -0
- package/internal/stores/data_style/mesh/polyhedra/polyhedron_config.ts +157 -0
- package/internal/stores/data_style/mesh/polyhedra/vertex.ts +26 -157
- package/internal/stores/data_style/mesh/polyhedra/vertex_attribute.ts +80 -0
- package/internal/stores/data_style/mesh/polyhedra/vertex_config.ts +152 -0
- package/internal/stores/data_style/model/blocks/apply_coloring.ts +173 -0
- package/internal/stores/data_style/model/blocks/color.ts +58 -57
- package/internal/stores/data_style/model/blocks/coloring_groups.ts +18 -0
- package/internal/stores/data_style/model/blocks/index.ts +12 -140
- package/internal/stores/data_style/model/blocks/polyhedron.ts +102 -54
- package/internal/stores/data_style/model/blocks/vertex.ts +102 -54
- package/internal/stores/data_style/model/color.ts +25 -26
- package/internal/stores/data_style/model/common.ts +10 -119
- package/internal/stores/data_style/model/common_mutations.ts +184 -0
- package/internal/stores/data_style/model/corners/index.ts +85 -78
- package/internal/stores/data_style/model/corners/vertex.ts +97 -49
- package/internal/stores/data_style/model/lines/apply_coloring.ts +154 -0
- package/internal/stores/data_style/model/lines/color.ts +53 -40
- package/internal/stores/data_style/model/lines/coloring_groups.ts +18 -0
- package/internal/stores/data_style/model/lines/edge.ts +102 -54
- package/internal/stores/data_style/model/lines/index.ts +10 -134
- package/internal/stores/data_style/model/lines/vertex.ts +102 -54
- package/internal/stores/data_style/model/surfaces/apply_coloring.ts +186 -0
- package/internal/stores/data_style/model/surfaces/color.ts +68 -56
- package/internal/stores/data_style/model/surfaces/coloring_groups.ts +18 -0
- package/internal/stores/data_style/model/surfaces/index.ts +16 -160
- package/internal/stores/data_style/model/surfaces/polygon.ts +94 -46
- package/internal/stores/data_style/model/surfaces/vertex.ts +94 -46
- package/internal/stores/data_style/model/visibility.ts +3 -156
- package/internal/stores/data_style/model/visibility_dispatch.ts +110 -0
- package/internal/stores/data_style/scene.ts +118 -0
- package/internal/stores/data_style/state.ts +5 -181
- package/internal/stores/data_style/state_shared.ts +199 -0
- package/internal/stores/data_style/types.ts +24 -1
- package/internal/stores/hybrid_viewer/brightness.ts +8 -2
- package/internal/stores/hybrid_viewer/camera.ts +7 -161
- package/internal/stores/hybrid_viewer/camera_animation.ts +4 -3
- package/internal/stores/hybrid_viewer/camera_helpers.ts +120 -0
- package/internal/stores/hybrid_viewer/camera_orientation.ts +60 -0
- package/internal/stores/hybrid_viewer/filters.ts +54 -11
- package/internal/stores/hybrid_viewer/highlight.ts +80 -63
- package/internal/stores/hybrid_viewer/ruler.ts +4 -3
- package/internal/stores/hybrid_viewer/scene.ts +34 -26
- package/internal/stores/hybrid_viewer/vtk_types.ts +2 -1
- package/internal/utils/ws_client.ts +8 -1
- package/package.json +5 -5
- package/server/api/local/extensions/run.post.ts +6 -4
- package/server/api/local/extensions/upload.put.ts +47 -20
- package/server/utils/cleanup.ts +12 -2
- package/server/utils/microservices.ts +10 -102
- package/server/utils/microservices_process.ts +127 -0
- package/server/utils/scripts.ts +35 -30
- package/server/utils/typed_handler.ts +8 -1
- package/server/utils/ws_client.ts +15 -2
- package/shared/utils/fetch_raw.ts +2 -2
- package/shared/utils/parse_boolean.ts +4 -1
- package/app/components/Viewer/Options/OptionsSection.vue +0 -76
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { useBasemapBuilds } from "./basemap_helpers/builds.js";
|
|
2
|
+
import { useBasemapLayers } from "./basemap_helpers/layers.js";
|
|
3
|
+
import { useBasemapSettings } from "./basemap_helpers/settings.js";
|
|
4
|
+
import { useDebounceFn } from "@vueuse/core";
|
|
5
|
+
import { useGeoreferenced } from "./basemap_helpers/georeferenced.js";
|
|
6
|
+
|
|
7
|
+
const REBUILD_DELAY_MILLISECONDS = 500;
|
|
8
|
+
|
|
9
|
+
export const useBasemapStore = defineStore("basemap", () => {
|
|
10
|
+
const { available, georeferencedIds, dataBounds, dataKey } = useGeoreferenced();
|
|
11
|
+
const layers = useBasemapLayers(georeferencedIds);
|
|
12
|
+
const { shown, maps, opacities, crop, layersParams, applyLayers, applyBasemap } = layers;
|
|
13
|
+
const { basemapId, grid, attribution, rebuild, reset } = useBasemapBuilds(layers, dataBounds);
|
|
14
|
+
const settings = useBasemapSettings(layers, basemapId, rebuild);
|
|
15
|
+
const { setMaps, setOpacity, setCrop, exportStores, importStores } = settings;
|
|
16
|
+
|
|
17
|
+
const scheduleRebuild = useDebounceFn(() => {
|
|
18
|
+
void rebuild();
|
|
19
|
+
}, REBUILD_DELAY_MILLISECONDS);
|
|
20
|
+
// Rebuilt when the georeferenced data or their extent change: data added, removed, converted,
|
|
21
|
+
// Aligned, or displayed after a project import
|
|
22
|
+
watch(dataKey, () => {
|
|
23
|
+
// A hidden basemap would be out of date once shown again: the rebuild removes it
|
|
24
|
+
if (maps.value.length > 0 || basemapId.value !== undefined) {
|
|
25
|
+
void scheduleRebuild();
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
maps,
|
|
31
|
+
shown,
|
|
32
|
+
opacities,
|
|
33
|
+
crop,
|
|
34
|
+
basemapId,
|
|
35
|
+
grid,
|
|
36
|
+
attribution,
|
|
37
|
+
available,
|
|
38
|
+
setMaps,
|
|
39
|
+
setOpacity,
|
|
40
|
+
setCrop,
|
|
41
|
+
rebuild,
|
|
42
|
+
reset,
|
|
43
|
+
layersParams,
|
|
44
|
+
applyLayers,
|
|
45
|
+
applyBasemap,
|
|
46
|
+
exportStores,
|
|
47
|
+
importStores,
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
export type { BasemapSnapshot } from "./basemap_helpers/settings.js";
|
|
52
|
+
export type { MapStyle } from "@ogw_front/utils/basemap_tree";
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useBasemapStore } from "@ogw_front/stores/basemap";
|
|
2
|
+
import { useDetailLayers } from "./basemap_helpers/detail_layers.js";
|
|
3
|
+
import { useDetailMap } from "./basemap_helpers/detail_map.js";
|
|
4
|
+
import { useDetailRefresh } from "./basemap_helpers/detail_refresh.js";
|
|
5
|
+
import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
|
|
6
|
+
|
|
7
|
+
// When the camera rests, the visible area of the basemap at the zoom of the screen
|
|
8
|
+
export const useBasemapDetailStore = defineStore("basemapDetail", () => {
|
|
9
|
+
const basemapStore = useBasemapStore();
|
|
10
|
+
const hybridViewerStore = useHybridViewerStore();
|
|
11
|
+
const detail = useDetailMap();
|
|
12
|
+
const { detailId, newRefresh, forget, clear } = detail;
|
|
13
|
+
const layers = useDetailLayers(detail);
|
|
14
|
+
const { scheduleRefresh, onCameraChange } = useDetailRefresh(detail, layers);
|
|
15
|
+
|
|
16
|
+
watch(() => hybridViewerStore.camera_options, onCameraChange, { deep: true });
|
|
17
|
+
watch(
|
|
18
|
+
() => hybridViewerStore.is_moving,
|
|
19
|
+
(moving) => {
|
|
20
|
+
if (moving) {
|
|
21
|
+
// The result of a refresh started before the move is obsolete
|
|
22
|
+
newRefresh();
|
|
23
|
+
} else {
|
|
24
|
+
scheduleRefresh();
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
);
|
|
28
|
+
// A new base (data changed, maps rebuilt) drops the detail, then a new one is built for it
|
|
29
|
+
// Once the camera rests
|
|
30
|
+
watch(
|
|
31
|
+
() => basemapStore.basemapId,
|
|
32
|
+
async (id) => {
|
|
33
|
+
await clear();
|
|
34
|
+
if (id !== undefined) {
|
|
35
|
+
scheduleRefresh();
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
);
|
|
39
|
+
watch(() => JSON.stringify(basemapStore.layersParams()), layers.syncLayers);
|
|
40
|
+
// A detail dropped for a missing map, or built while the maps changed, is built again
|
|
41
|
+
watch(() => basemapStore.maps.join(","), scheduleRefresh);
|
|
42
|
+
|
|
43
|
+
// A new project: the viewer and the back are already cleared, nothing is requested
|
|
44
|
+
basemapStore.$onAction(({ name }) => {
|
|
45
|
+
if (name === "reset") {
|
|
46
|
+
forget();
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
return { detailId };
|
|
51
|
+
});
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { type MapStyle, sortedMaps } from "@ogw_front/utils/basemap_tree";
|
|
2
|
+
import back_schemas, {
|
|
3
|
+
type BasemapBuildResponse,
|
|
4
|
+
type CRSList,
|
|
5
|
+
} from "@geode/opengeodeweb-back/opengeodeweb_back_typed_schemas.js";
|
|
6
|
+
import { ignoreError, useBasemapViewer } from "./viewer.js";
|
|
7
|
+
import type { BasemapLayers } from "./layers.js";
|
|
8
|
+
import type { Extent } from "./extent.js";
|
|
9
|
+
import type { Ref } from "vue";
|
|
10
|
+
import { useBackStore } from "@ogw_front/stores/back";
|
|
11
|
+
import { useCrsStore } from "@ogw_front/stores/crs";
|
|
12
|
+
import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
|
|
13
|
+
|
|
14
|
+
// The grid of the basemap shown, and the height it lies at
|
|
15
|
+
interface BasemapGrid extends Pick<BasemapBuildResponse, "bounds" | "columns" | "zoom"> {
|
|
16
|
+
z: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface BasemapBuilds {
|
|
20
|
+
basemapId: Ref<string | undefined>;
|
|
21
|
+
grid: Ref<BasemapGrid | undefined>;
|
|
22
|
+
attribution: Ref<string | undefined>;
|
|
23
|
+
rebuild: () => Promise<void>;
|
|
24
|
+
reset: () => void;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const BASEMAP_NAME = "basemap";
|
|
28
|
+
|
|
29
|
+
// The basemap downloaded for the visible maps around the data, one build replacing the other
|
|
30
|
+
// oxlint-disable max-lines-per-function, max-statements
|
|
31
|
+
function useBasemapBuilds(
|
|
32
|
+
layers: BasemapLayers,
|
|
33
|
+
dataBounds: () => Extent | undefined,
|
|
34
|
+
): BasemapBuilds {
|
|
35
|
+
const { maps, hidden, built, layersParams, applyLayers, applyBasemap } = layers;
|
|
36
|
+
const backStore = useBackStore();
|
|
37
|
+
const crsStore = useCrsStore();
|
|
38
|
+
const hybridViewerStore = useHybridViewerStore();
|
|
39
|
+
const { discardMap } = useBasemapViewer();
|
|
40
|
+
const basemapId = ref<string | undefined>(undefined);
|
|
41
|
+
// The detail store compares its resolution with the screen
|
|
42
|
+
const grid = ref<BasemapGrid | undefined>(undefined);
|
|
43
|
+
const attribution = ref<string | undefined>(undefined);
|
|
44
|
+
// Each build gets a number: a build finishing after a newer one started is discarded
|
|
45
|
+
let lastBuild = 0;
|
|
46
|
+
// Builds up to this number belong to a project the viewer and the back already cleared
|
|
47
|
+
let lastBuildOfPreviousProject = 0;
|
|
48
|
+
// The maps of the basemap shown: a build that fails or is superseded gives them back
|
|
49
|
+
let shownMaps: MapStyle[] = [];
|
|
50
|
+
|
|
51
|
+
// A build of a previous project: the viewer and the back already cleared it
|
|
52
|
+
async function discardBuild(build: number, id: string, registered: boolean): Promise<void> {
|
|
53
|
+
if (build > lastBuildOfPreviousProject) {
|
|
54
|
+
await discardMap(id, registered);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function forget(): void {
|
|
59
|
+
basemapId.value = undefined;
|
|
60
|
+
grid.value = undefined;
|
|
61
|
+
built.value = [];
|
|
62
|
+
shownMaps = [];
|
|
63
|
+
attribution.value = undefined;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async function clear(): Promise<void> {
|
|
67
|
+
const id = basemapId.value;
|
|
68
|
+
forget();
|
|
69
|
+
if (id === undefined) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
await discardMap(id, true);
|
|
73
|
+
await hybridViewerStore.remoteRender();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async function display(build: number, extent: Extent, crs: CRSList): Promise<void> {
|
|
77
|
+
const response = await backStore.request({
|
|
78
|
+
schema: back_schemas.opengeodeweb_back.basemap.build,
|
|
79
|
+
params: { maps: [...maps.value], crs, ...extent },
|
|
80
|
+
});
|
|
81
|
+
if (build !== lastBuild) {
|
|
82
|
+
// A newer build started: this result is obsolete
|
|
83
|
+
await discardBuild(build, response.id, false);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const previousId = basemapId.value;
|
|
87
|
+
// The layers are computed from the maps just built
|
|
88
|
+
const builtMaps = sortedMaps(response.maps.map(({ map }) => map));
|
|
89
|
+
built.value = builtMaps;
|
|
90
|
+
// Only while this build still owns the built maps: a newer build may have set its own
|
|
91
|
+
function giveBackMaps(): void {
|
|
92
|
+
if (built.value === builtMaps) {
|
|
93
|
+
built.value = shownMaps;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
let sentLayers = "";
|
|
97
|
+
try {
|
|
98
|
+
sentLayers = await applyBasemap(response, BASEMAP_NAME);
|
|
99
|
+
} catch (error) {
|
|
100
|
+
giveBackMaps();
|
|
101
|
+
// The new mesh must not stay registered without anyone tracking it
|
|
102
|
+
await discardBuild(build, response.id, true);
|
|
103
|
+
throw error;
|
|
104
|
+
}
|
|
105
|
+
if (build !== lastBuild) {
|
|
106
|
+
giveBackMaps();
|
|
107
|
+
// Superseded while applying: the new basemap must not stay displayed
|
|
108
|
+
await discardBuild(build, response.id, true);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
basemapId.value = response.id;
|
|
112
|
+
shownMaps = builtMaps;
|
|
113
|
+
const { bounds, zoom, columns } = response;
|
|
114
|
+
grid.value = { bounds, zoom, columns, z: extent.z };
|
|
115
|
+
attribution.value = response.attribution;
|
|
116
|
+
if (previousId !== undefined) {
|
|
117
|
+
await discardBuild(build, previousId, true);
|
|
118
|
+
}
|
|
119
|
+
// The states changed while the basemap was built: the viewer still has the old ones
|
|
120
|
+
if (JSON.stringify(layersParams()) !== sentLayers) {
|
|
121
|
+
await applyLayers(response.id);
|
|
122
|
+
}
|
|
123
|
+
// Always render: the first build has no previous basemap whose removal would render
|
|
124
|
+
await hybridViewerStore.remoteRender();
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
async function rebuild(): Promise<void> {
|
|
128
|
+
lastBuild += 1;
|
|
129
|
+
const build = lastBuild;
|
|
130
|
+
const extent = dataBounds();
|
|
131
|
+
const crs = crsStore.projectCrs;
|
|
132
|
+
if (maps.value.length === 0 || crs === undefined || extent === undefined) {
|
|
133
|
+
await clear();
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
try {
|
|
137
|
+
await display(build, extent, crs);
|
|
138
|
+
} catch {
|
|
139
|
+
// The request feedback already shows the error: data changes must not repeat it forever
|
|
140
|
+
if (build === lastBuild) {
|
|
141
|
+
hidden.value = true;
|
|
142
|
+
await clear().catch(ignoreError);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// A new project: the viewer and the back were cleared, so nothing is requested
|
|
148
|
+
function reset(): void {
|
|
149
|
+
lastBuild += 1;
|
|
150
|
+
lastBuildOfPreviousProject = lastBuild;
|
|
151
|
+
forget();
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return { basemapId, grid, attribution, rebuild, reset };
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export type { BasemapGrid };
|
|
158
|
+
export { useBasemapBuilds };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { coalesced, ignoreError, useBasemapViewer } from "./viewer.js";
|
|
2
|
+
import type { BasemapBuildResponse } from "@geode/opengeodeweb-back/opengeodeweb_back_typed_schemas.js";
|
|
3
|
+
import type { DetailMap } from "./detail_map.js";
|
|
4
|
+
import { useBasemapStore } from "@ogw_front/stores/basemap";
|
|
5
|
+
import { useDataStore } from "@ogw_front/stores/data";
|
|
6
|
+
import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
|
|
7
|
+
|
|
8
|
+
interface DetailLayers {
|
|
9
|
+
syncLayers: () => Promise<void>;
|
|
10
|
+
replaceDetail: (response: BasemapBuildResponse, sentLayers: string) => Promise<void>;
|
|
11
|
+
rememberStep: (response: BasemapBuildResponse) => Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// What the viewer shows of the detail: its layers, and the detail replacing the previous one
|
|
15
|
+
function useDetailLayers(detail: DetailMap): DetailLayers {
|
|
16
|
+
const dataStore = useDataStore();
|
|
17
|
+
const basemapStore = useBasemapStore();
|
|
18
|
+
const hybridViewerStore = useHybridViewerStore();
|
|
19
|
+
const { discardMap } = useBasemapViewer();
|
|
20
|
+
const { detailId, shown, clear } = detail;
|
|
21
|
+
|
|
22
|
+
// Eye, opacity and crop reach the detail as they reach the base, one request at a time while a
|
|
23
|
+
// Slider is dragged. Nothing visible, or a visible map the detail was built without (missing
|
|
24
|
+
// From its sharp patch): the detail goes, the next one has the maps
|
|
25
|
+
const syncLayers = coalesced(async () => {
|
|
26
|
+
const id = detailId.value;
|
|
27
|
+
if (id === undefined) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const { maps } = basemapStore;
|
|
31
|
+
if (maps.length === 0 || maps.some((mapStyle) => !shown.maps.includes(mapStyle))) {
|
|
32
|
+
await clear();
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
await basemapStore.applyLayers(id);
|
|
36
|
+
await hybridViewerStore.remoteRender();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
async function replaceDetail(response: BasemapBuildResponse, sentLayers: string): Promise<void> {
|
|
40
|
+
const previous = detailId.value;
|
|
41
|
+
detailId.value = response.id;
|
|
42
|
+
shown.grid = response;
|
|
43
|
+
shown.maps = response.maps.map(({ map }) => map);
|
|
44
|
+
// Out of the viewer before the render, deleted on the back after it: shown sooner
|
|
45
|
+
if (previous !== undefined) {
|
|
46
|
+
await dataStore.deregisterObject(previous).catch(ignoreError);
|
|
47
|
+
}
|
|
48
|
+
// The states changed while the detail was built: the viewer still has the old ones
|
|
49
|
+
if (JSON.stringify(basemapStore.layersParams()) === sentLayers) {
|
|
50
|
+
await hybridViewerStore.remoteRender();
|
|
51
|
+
} else {
|
|
52
|
+
await syncLayers();
|
|
53
|
+
}
|
|
54
|
+
if (previous !== undefined) {
|
|
55
|
+
void discardMap(previous, false);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// No finer zoom exists here: the detail still shown goes, and this view is remembered as a step
|
|
60
|
+
async function rememberStep(response: BasemapBuildResponse): Promise<void> {
|
|
61
|
+
const clearing = clear();
|
|
62
|
+
// The synchronous part of clear() has run: the step is set before any newer refresh
|
|
63
|
+
shown.grid = response;
|
|
64
|
+
await clearing;
|
|
65
|
+
await discardMap(response.id, false);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return { syncLayers, replaceDetail, rememberStep };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export type { DetailLayers };
|
|
72
|
+
export { useDetailLayers };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { MapGrid } from "@ogw_front/utils/visible_map_area";
|
|
2
|
+
import type { Ref } from "vue";
|
|
3
|
+
import { useBasemapStore } from "@ogw_front/stores/basemap";
|
|
4
|
+
import { useBasemapViewer } from "./viewer.js";
|
|
5
|
+
import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
|
|
6
|
+
|
|
7
|
+
interface ShownDetail {
|
|
8
|
+
// The grid of the detail shown: a new detail is built only when the view leaves its step
|
|
9
|
+
grid: MapGrid | undefined;
|
|
10
|
+
// The maps the detail shown was built with
|
|
11
|
+
maps: string[];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface DetailMap {
|
|
15
|
+
detailId: Ref<string | undefined>;
|
|
16
|
+
shown: ShownDetail;
|
|
17
|
+
// Each refresh gets a number: a result arriving after a newer refresh is discarded
|
|
18
|
+
newRefresh: () => number;
|
|
19
|
+
isObsolete: (refreshNumber: number, basemapId: string) => boolean;
|
|
20
|
+
forget: () => void;
|
|
21
|
+
clear: () => Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// The detail shown over the basemap
|
|
25
|
+
function useDetailMap(): DetailMap {
|
|
26
|
+
const basemapStore = useBasemapStore();
|
|
27
|
+
const hybridViewerStore = useHybridViewerStore();
|
|
28
|
+
const { discardMap } = useBasemapViewer();
|
|
29
|
+
const detailId = ref<string | undefined>(undefined);
|
|
30
|
+
const shown: ShownDetail = { grid: undefined, maps: [] };
|
|
31
|
+
let lastRefresh = 0;
|
|
32
|
+
|
|
33
|
+
function newRefresh(): number {
|
|
34
|
+
lastRefresh += 1;
|
|
35
|
+
return lastRefresh;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function isObsolete(refreshNumber: number, basemapId: string): boolean {
|
|
39
|
+
return refreshNumber !== lastRefresh || basemapId !== basemapStore.basemapId;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function forget(): void {
|
|
43
|
+
newRefresh();
|
|
44
|
+
detailId.value = undefined;
|
|
45
|
+
shown.grid = undefined;
|
|
46
|
+
shown.maps = [];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async function clear(): Promise<void> {
|
|
50
|
+
const id = detailId.value;
|
|
51
|
+
forget();
|
|
52
|
+
if (id !== undefined) {
|
|
53
|
+
await discardMap(id, true);
|
|
54
|
+
await hybridViewerStore.remoteRender();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return { detailId, shown, newRefresh, isObsolete, forget, clear };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export type { DetailMap };
|
|
62
|
+
export { useDetailMap };
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { type MapBounds, covers, stillSharp } from "@ogw_front/utils/visible_map_area";
|
|
2
|
+
import type { BasemapBuildResponse } from "@geode/opengeodeweb-back/opengeodeweb_back_typed_schemas.js";
|
|
3
|
+
import type { BasemapGrid } from "./builds.js";
|
|
4
|
+
import type { DetailLayers } from "./detail_layers.js";
|
|
5
|
+
import type { DetailMap } from "./detail_map.js";
|
|
6
|
+
import { useBasemapStore } from "@ogw_front/stores/basemap";
|
|
7
|
+
import { useBasemapViewer } from "./viewer.js";
|
|
8
|
+
import { useDebounceFn } from "@vueuse/core";
|
|
9
|
+
import { useDetailView } from "./detail_view.js";
|
|
10
|
+
import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
|
|
11
|
+
|
|
12
|
+
type BuildDetail = (grid: BasemapGrid, view: MapBounds, size: readonly number[]) => Promise<void>;
|
|
13
|
+
|
|
14
|
+
interface DetailRefresh {
|
|
15
|
+
// When the camera rests: a refresh waits for the last camera change
|
|
16
|
+
scheduleRefresh: () => void;
|
|
17
|
+
// A view leaving the detail would show it as a sharp patch in a blurred map: it goes at once,
|
|
18
|
+
// The base alone is shown until the next detail
|
|
19
|
+
onCameraChange: () => void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const REST_DELAY_MILLISECONDS = 250;
|
|
23
|
+
const DETAIL_NAME = "basemap detail";
|
|
24
|
+
|
|
25
|
+
// Builds the detail of a view for the basemap shown, unless a newer refresh or base came meanwhile
|
|
26
|
+
function useBuildDetail(detail: DetailMap, layers: DetailLayers): BuildDetail {
|
|
27
|
+
const basemapStore = useBasemapStore();
|
|
28
|
+
const { discardMap } = useBasemapViewer();
|
|
29
|
+
const { detailRequest } = useDetailView();
|
|
30
|
+
const { newRefresh, isObsolete } = detail;
|
|
31
|
+
|
|
32
|
+
// Shown unless a newer refresh or base came while it was applied
|
|
33
|
+
async function show(
|
|
34
|
+
response: BasemapBuildResponse,
|
|
35
|
+
basemapId: string,
|
|
36
|
+
refreshNumber: number,
|
|
37
|
+
): Promise<void> {
|
|
38
|
+
let sentLayers = "";
|
|
39
|
+
try {
|
|
40
|
+
sentLayers = await basemapStore.applyBasemap(response, DETAIL_NAME, basemapId);
|
|
41
|
+
} catch {
|
|
42
|
+
// The request feedback already shows the error: the detail must not stay registered
|
|
43
|
+
await discardMap(response.id, true);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (isObsolete(refreshNumber, basemapId)) {
|
|
47
|
+
await discardMap(response.id, true);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
await layers.replaceDetail(response, sentLayers);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return async (grid, view, size) => {
|
|
54
|
+
const { basemapId, maps } = basemapStore;
|
|
55
|
+
if (basemapId === undefined) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const refreshNumber = newRefresh();
|
|
59
|
+
const response = await detailRequest({ maps, visibleArea: view, z: grid.z }, size);
|
|
60
|
+
if (response === undefined) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (isObsolete(refreshNumber, basemapId)) {
|
|
64
|
+
await discardMap(response.id, false);
|
|
65
|
+
} else if (response.zoom <= grid.zoom) {
|
|
66
|
+
await layers.rememberStep(response);
|
|
67
|
+
} else {
|
|
68
|
+
await show(response, basemapId, refreshNumber);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// The visible area of the basemap at the zoom of the screen, built when the camera rests
|
|
74
|
+
function useDetailRefresh(detail: DetailMap, layers: DetailLayers): DetailRefresh {
|
|
75
|
+
const basemapStore = useBasemapStore();
|
|
76
|
+
const hybridViewerStore = useHybridViewerStore();
|
|
77
|
+
const { viewportSize, currentView } = useDetailView();
|
|
78
|
+
const build = useBuildDetail(detail, layers);
|
|
79
|
+
const { shown, clear } = detail;
|
|
80
|
+
|
|
81
|
+
async function refresh(): Promise<void> {
|
|
82
|
+
const { grid, basemapId } = basemapStore;
|
|
83
|
+
const size = viewportSize();
|
|
84
|
+
const resting = !hybridViewerStore.is_moving && basemapStore.maps.length > 0;
|
|
85
|
+
if (!resting || grid === undefined || basemapId === undefined || size === undefined) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const { visibleArea, wanted, sharperNeeded } = currentView(grid, size);
|
|
89
|
+
if (visibleArea === undefined || !sharperNeeded) {
|
|
90
|
+
await clear();
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
// Steps: the map shown is still right for this view, nothing to rebuild
|
|
94
|
+
if (shown.grid !== undefined && stillSharp(shown.grid, visibleArea, wanted)) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
await build(grid, visibleArea, size);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async function refreshQuietly(): Promise<void> {
|
|
101
|
+
try {
|
|
102
|
+
await refresh();
|
|
103
|
+
} catch (error) {
|
|
104
|
+
// Request failures are shown by the request feedback; logged too, so a programming error
|
|
105
|
+
// Is never hidden
|
|
106
|
+
// oxlint-disable-next-line no-console -- no other channel for an error nobody awaits
|
|
107
|
+
console.error("Basemap detail refresh failed", error);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const debouncedRefresh = useDebounceFn(() => {
|
|
112
|
+
void refreshQuietly();
|
|
113
|
+
}, REST_DELAY_MILLISECONDS);
|
|
114
|
+
|
|
115
|
+
function scheduleRefresh(): void {
|
|
116
|
+
void debouncedRefresh();
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function onCameraChange(): void {
|
|
120
|
+
const { grid } = basemapStore;
|
|
121
|
+
const size = viewportSize();
|
|
122
|
+
if (shown.grid !== undefined && grid !== undefined && size !== undefined) {
|
|
123
|
+
const { visibleArea } = currentView(grid, size);
|
|
124
|
+
if (visibleArea === undefined || !covers(shown.grid.bounds, visibleArea)) {
|
|
125
|
+
void clear();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
scheduleRefresh();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return { scheduleRefresh, onCameraChange };
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export { useDetailRefresh };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type MapBounds,
|
|
3
|
+
type ViewCamera,
|
|
4
|
+
mapResolution,
|
|
5
|
+
needsSharperMap,
|
|
6
|
+
screenPixelGroundSize,
|
|
7
|
+
visibleMapArea,
|
|
8
|
+
} from "@ogw_front/utils/visible_map_area";
|
|
9
|
+
import back_schemas, {
|
|
10
|
+
type BasemapBuildResponse,
|
|
11
|
+
} from "@geode/opengeodeweb-back/opengeodeweb_back_typed_schemas.js";
|
|
12
|
+
import type { BasemapGrid } from "./builds.js";
|
|
13
|
+
import type { MapStyle } from "@ogw_front/utils/basemap_tree";
|
|
14
|
+
import { useBackStore } from "@ogw_front/stores/back";
|
|
15
|
+
import { useCrsStore } from "@ogw_front/stores/crs";
|
|
16
|
+
import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
|
|
17
|
+
|
|
18
|
+
interface RenderWindowLike {
|
|
19
|
+
getApiSpecificRenderWindow: () => { getSize: () => [number, number] };
|
|
20
|
+
}
|
|
21
|
+
interface CurrentView {
|
|
22
|
+
visibleArea: MapBounds | undefined;
|
|
23
|
+
wanted: number;
|
|
24
|
+
sharperNeeded: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const MAX_DETAIL_PIXELS = 4096;
|
|
28
|
+
|
|
29
|
+
interface DetailView {
|
|
30
|
+
viewportSize: () => [number, number] | undefined;
|
|
31
|
+
currentView: (grid: BasemapGrid, size: readonly number[]) => CurrentView;
|
|
32
|
+
detailRequest: (
|
|
33
|
+
area: Readonly<{ maps: MapStyle[]; visibleArea: MapBounds; z: number }>,
|
|
34
|
+
size: readonly number[],
|
|
35
|
+
) => Promise<BasemapBuildResponse | undefined>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// The stores are taken once: a call still running after a project reset reaches its own stores
|
|
39
|
+
function useDetailView(): DetailView {
|
|
40
|
+
const backStore = useBackStore();
|
|
41
|
+
const crsStore = useCrsStore();
|
|
42
|
+
const hybridViewerStore = useHybridViewerStore();
|
|
43
|
+
|
|
44
|
+
function viewportSize(): [number, number] | undefined {
|
|
45
|
+
// The store holds the render window in a holder: the vtk.js typing of its API is partial
|
|
46
|
+
// oxlint-disable-next-line no-unsafe-type-assertion -- vtk.js render window API boundary
|
|
47
|
+
const renderWindow = hybridViewerStore.genericRenderWindow.value as unknown as
|
|
48
|
+
| RenderWindowLike
|
|
49
|
+
| undefined;
|
|
50
|
+
const size = renderWindow?.getApiSpecificRenderWindow().getSize();
|
|
51
|
+
if (size === undefined || size[0] === 0 || size[1] === 0) {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
return size;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// What the screen shows of the base, and the ground size of one of its pixels
|
|
58
|
+
function currentView(grid: BasemapGrid, size: readonly number[]): CurrentView {
|
|
59
|
+
// oxlint-disable-next-line no-unsafe-type-assertion -- camera_options carries the vtk.js camera fields
|
|
60
|
+
const camera = hybridViewerStore.camera_options as unknown as ViewCamera;
|
|
61
|
+
const planeZ = grid.z * hybridViewerStore.zScale;
|
|
62
|
+
const aspect = (size[0] ?? 1) / (size[1] ?? 1);
|
|
63
|
+
const visibleArea = visibleMapArea(camera, aspect, planeZ, grid.bounds);
|
|
64
|
+
const wanted = screenPixelGroundSize(camera, size[1] ?? 1);
|
|
65
|
+
return { visibleArea, wanted, sharperNeeded: needsSharperMap(mapResolution(grid), wanted) };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// The visible area at about one map pixel per screen pixel, without margin
|
|
69
|
+
async function detailRequest(
|
|
70
|
+
{ maps, visibleArea, z }: Readonly<{ maps: MapStyle[]; visibleArea: MapBounds; z: number }>,
|
|
71
|
+
size: readonly number[],
|
|
72
|
+
): Promise<BasemapBuildResponse | undefined> {
|
|
73
|
+
const crs = crsStore.projectCrs;
|
|
74
|
+
if (crs === undefined) {
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
const response = await backStore.request({
|
|
78
|
+
schema: back_schemas.opengeodeweb_back.basemap.build,
|
|
79
|
+
params: {
|
|
80
|
+
maps: [...maps],
|
|
81
|
+
crs,
|
|
82
|
+
bounds: visibleArea,
|
|
83
|
+
z,
|
|
84
|
+
margin: false,
|
|
85
|
+
max_pixels: Math.min(MAX_DETAIL_PIXELS, Math.max(...size)),
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
return response;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return { viewportSize, currentView, detailRequest };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export { useDetailView };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { BasemapBuildResponse } from "@geode/opengeodeweb-back/opengeodeweb_back_typed_schemas.js";
|
|
2
|
+
import type { MapStyle } from "@ogw_front/utils/basemap_tree";
|
|
3
|
+
|
|
4
|
+
interface Extent {
|
|
5
|
+
bounds: BasemapBuildResponse["bounds"];
|
|
6
|
+
z: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const X_MIN = 0;
|
|
10
|
+
const X_MAX = 1;
|
|
11
|
+
const Y_MIN = 2;
|
|
12
|
+
const Y_MAX = 3;
|
|
13
|
+
const Z_MAX = 5;
|
|
14
|
+
|
|
15
|
+
function everyMap<Value>(value: Value): Record<MapStyle, Value> {
|
|
16
|
+
return { satellite: value, plan: value, routes: value };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Unscaled polydata bounds: the actor bounds would include the z scale
|
|
20
|
+
function boxesExtent(boxes: readonly (readonly number[])[]): Extent | undefined {
|
|
21
|
+
if (boxes.length === 0) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
function side(index: number): number[] {
|
|
25
|
+
return boxes.map((box) => box[index] ?? 0);
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
bounds: {
|
|
29
|
+
x_min: Math.min(...side(X_MIN)),
|
|
30
|
+
y_min: Math.min(...side(Y_MIN)),
|
|
31
|
+
x_max: Math.max(...side(X_MAX)),
|
|
32
|
+
y_max: Math.max(...side(Y_MAX)),
|
|
33
|
+
},
|
|
34
|
+
// At the top of the data, like the ground above subsurface data, ready to drape surfaces
|
|
35
|
+
z: Math.max(...side(Z_MAX)),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export type { Extent };
|
|
40
|
+
export { boxesExtent, everyMap };
|