gps-plus-slam-app-framework 1.0.0 → 1.0.6
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/dist/{app-selectors-DyMzxCEC.d.ts → app-selectors-CHt7DLuq.d.ts} +9 -8
- package/dist/ar/depth-sampler.js +1 -1
- package/dist/ar/tracking-state.js +1 -1
- package/dist/ar/webxr-session.js +1 -1
- package/dist/combined-root-state-B3SvPNjU.d.ts +6 -0
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.js +2 -0
- package/dist/create-slam-app-store-DBm7g2Zd.d.ts +85 -0
- package/dist/file-system-DD5TczSO.d.ts +84 -0
- package/dist/geo/h3-proximity.d.ts +2 -0
- package/dist/{ref-points/h3-ref-point.js → geo/h3-proximity.js} +16 -12
- package/dist/geo/index.d.ts +2 -0
- package/dist/geo/index.js +2 -0
- package/dist/gps-anchored-mesh-manager-CovAFK4g.d.ts +56 -0
- package/dist/gps-ar-pose-sampler-D_Zso40V.d.ts +43 -0
- package/dist/{recording-coordinator-DzflP07_.d.ts → gps-event-coordinator-fwvmVfku.d.ts} +6 -5
- package/dist/{h3-ref-point-CFhayNSZ.d.ts → h3-proximity-GwesPTFT.d.ts} +16 -12
- package/dist/index.d.ts +31 -34
- package/dist/index.js +14 -19
- package/dist/{leaflet-map-overlay-CvfQXTye.d.ts → leaflet-map-overlay-CQZcnxbc.d.ts} +10 -6
- package/dist/licensing/index.d.ts +1 -1
- package/dist/licensing/index.js +1 -1
- package/dist/{null-storage-backend-CsWvQwN8.d.ts → null-storage-backend-C0TiwwzQ.d.ts} +4 -2
- package/dist/{opfs-storage-ChOzF_Wp.d.ts → opfs-storage-Dlq1I_Gb.d.ts} +54 -51
- package/dist/opfs-storage-backend-Gt3rd76D.d.ts +13 -0
- package/dist/{persistence-middleware-DrptY02i.d.ts → persistence-middleware-z-75iisb.d.ts} +4 -4
- package/dist/{recording-replayer-oOzPITrd.d.ts → recording-replayer-BFhFs7Mc.d.ts} +2 -2
- package/dist/recording-slice-BiktUIWF.d.ts +28 -0
- package/dist/{replay-engine-DuX316ae.d.ts → replay-engine-B88Va62x.d.ts} +4 -1
- package/dist/sensors/gps-error-handler.d.ts +1 -1
- package/dist/sensors/gps.d.ts +1 -1
- package/dist/sensors/index.d.ts +3 -3
- package/dist/sensors/index.js +1 -1
- package/dist/sensors/permission-checker.d.ts +1 -1
- package/dist/state/app-selectors.d.ts +1 -1
- package/dist/state/create-slam-app-store.d.ts +2 -0
- package/dist/state/create-slam-app-store.js +61 -0
- package/dist/state/gps-ar-pose-sampler.d.ts +4 -0
- package/dist/state/gps-ar-pose-sampler.js +19 -0
- package/dist/state/{recording-coordinator.d.ts → gps-event-coordinator.d.ts} +1 -1
- package/dist/state/{recording-coordinator.js → gps-event-coordinator.js} +3 -4
- package/dist/state/index.d.ts +15 -16
- package/dist/state/index.js +7 -7
- package/dist/state/persistence-middleware.d.ts +1 -1
- package/dist/state/persistence-middleware.js +8 -8
- package/dist/state/recording-replayer.d.ts +3 -2
- package/dist/state/recording-replayer.js +2 -2
- package/dist/state/recording-slice.d.ts +2 -0
- package/dist/state/{recorder-slice.js → recording-slice.js} +7 -15
- package/dist/state/replay-engine.d.ts +1 -1
- package/dist/state/replay-engine.js +3 -3
- package/dist/state/store-subscribers.d.ts +2 -2
- package/dist/state/store-subscribers.js +1 -9
- package/dist/state/subscribe-to-selector.d.ts +1 -1
- package/dist/storage/file-system-utils.d.ts +1 -1
- package/dist/storage/file-system.d.ts +2 -2
- package/dist/storage/file-system.js +103 -94
- package/dist/storage/index.d.ts +9 -11
- package/dist/storage/index.js +5 -7
- package/dist/storage/null-storage-backend.d.ts +1 -1
- package/dist/storage/null-storage-backend.js +7 -0
- package/dist/storage/opfs-storage-backend.d.ts +1 -1
- package/dist/storage/opfs-storage-backend.js +7 -1
- package/dist/storage/opfs-storage.d.ts +2 -2
- package/dist/storage/opfs-storage.js +69 -85
- package/dist/storage/storage-backend.d.ts +2 -2
- package/dist/storage/zip-export.d.ts +2 -2
- package/dist/storage/zip-export.js +55 -62
- package/dist/storage/zip-reader.d.ts +2 -2
- package/dist/storage/zip-reader.js +24 -1
- package/dist/storage-backend-yVnuWGTr.d.ts +28 -0
- package/dist/{store-subscribers-CuoIzB5T.d.ts → store-subscribers-DKKHld49.d.ts} +1 -2
- package/dist/{subscribe-to-selector-UTZ0KkAc.d.ts → subscribe-to-selector-ghDKYtap.d.ts} +1 -1
- package/dist/test-utils/zip-round-trip-helpers.d.ts +1 -1
- package/dist/test-utils/zip-round-trip-helpers.js +4 -4
- package/dist/visualization/gps-anchored-mesh-manager.d.ts +2 -0
- package/dist/visualization/gps-anchored-mesh-manager.js +128 -0
- package/dist/visualization/gps-compass-cubes.d.ts +1 -1
- package/dist/visualization/gps-event-markers.d.ts +1 -1
- package/dist/visualization/index.d.ts +9 -9
- package/dist/visualization/index.js +2 -2
- package/dist/visualization/leaflet-map-overlay.d.ts +1 -1
- package/dist/visualization/leaflet-map-overlay.js +23 -19
- package/dist/visualization/lerp-utils.d.ts +1 -1
- package/dist/visualization/map-overlay.d.ts +1 -1
- package/dist/visualization/three-dispose.d.ts +1 -1
- package/dist/visualization/vis-colors.d.ts +1 -1
- package/dist/{zip-export-Rtpi75JJ.d.ts → zip-export-BjrQPv0X.d.ts} +58 -7
- package/dist/{zip-reader-D7pkpX8K.d.ts → zip-reader-KgJEXbca.d.ts} +33 -1
- package/package.json +15 -4
- package/dist/community-license-key-ChZLCJyO.d.ts +0 -21
- package/dist/file-system-BsQgYCU3.d.ts +0 -128
- package/dist/licensing/community-license-key.d.ts +0 -2
- package/dist/licensing/community-license-key.js +0 -21
- package/dist/opfs-storage-backend-CVcmfJHN.d.ts +0 -11
- package/dist/recorder-slice-fcwAXrsh.d.ts +0 -35
- package/dist/ref-point-importer-B_wn5ABk.d.ts +0 -62
- package/dist/ref-point-loader-Pt1smgHS.d.ts +0 -117
- package/dist/ref-points/h3-ref-point.d.ts +0 -2
- package/dist/ref-points/index.d.ts +0 -2
- package/dist/ref-points/index.js +0 -2
- package/dist/ref-points-slice-tC-Wd6XJ.d.ts +0 -48
- package/dist/reference-points-CFWy8_wj.d.ts +0 -68
- package/dist/routing-slice-BlHTM8eh.d.ts +0 -23
- package/dist/state/recorder-slice.d.ts +0 -2
- package/dist/state/ref-points-slice.d.ts +0 -2
- package/dist/state/ref-points-slice.js +0 -44
- package/dist/state/routing-slice.d.ts +0 -2
- package/dist/state/routing-slice.js +0 -13
- package/dist/state/store.d.ts +0 -9
- package/dist/state/store.js +0 -71
- package/dist/storage/ref-point-importer.d.ts +0 -2
- package/dist/storage/ref-point-importer.js +0 -163
- package/dist/storage/ref-point-loader.d.ts +0 -2
- package/dist/storage/ref-point-loader.js +0 -248
- package/dist/storage/ref-point-recovery.d.ts +0 -28
- package/dist/storage/ref-point-recovery.js +0 -159
- package/dist/storage-backend-BcEItnFr.d.ts +0 -20
- package/dist/store-C7PKOj8S.d.ts +0 -96
- package/dist/visualization/reference-points.d.ts +0 -2
- package/dist/visualization/reference-points.js +0 -160
- /package/dist/{file-system-utils-5cWO8Xyv.d.ts → file-system-utils-BH8FdyIu.d.ts} +0 -0
- /package/dist/{gps-Ddzr2KlX.d.ts → gps-GKc6_Cly.d.ts} +0 -0
- /package/dist/{gps-compass-cubes-C-6JEnpR.d.ts → gps-compass-cubes-jRIJMOuh.d.ts} +0 -0
- /package/dist/{gps-error-handler-VPuNOuf8.d.ts → gps-error-handler-CH1S528z.d.ts} +0 -0
- /package/dist/{gps-event-markers-DpEy2qRd.d.ts → gps-event-markers-sVyO9utS.d.ts} +0 -0
- /package/dist/{lerp-utils-87NWjUOD.d.ts → lerp-utils-CZgQlrmu.d.ts} +0 -0
- /package/dist/{map-overlay-DuiZuCTx.d.ts → map-overlay-C9ifl_4-.d.ts} +0 -0
- /package/dist/{permission-checker-jO2ziCWC.d.ts → permission-checker-Cu3nbH1S.d.ts} +0 -0
- /package/dist/{three-dispose-CCBHjE_a.d.ts → three-dispose-qt_r5wR1.d.ts} +0 -0
- /package/dist/{vis-colors-Qi2vlRGt.d.ts → vis-colors-BKkdTIKb.d.ts} +0 -0
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { n as RefPointMark } from "./ref-point-loader-Pt1smgHS.js";
|
|
2
|
-
import { LatLong } from "gps-plus-slam-js";
|
|
3
|
-
|
|
4
|
-
//#region ../src/visualization/reference-points.d.ts
|
|
5
|
-
/**
|
|
6
|
-
* Manager for reference point visualization
|
|
7
|
-
*/
|
|
8
|
-
declare class RefPointVisualizer {
|
|
9
|
-
private priorRefMeshes;
|
|
10
|
-
private currentRefMeshes;
|
|
11
|
-
private zeroRef;
|
|
12
|
-
/** Shared geometry for prior-session ref point meshes (lazy-created) */
|
|
13
|
-
private priorRefGeometry;
|
|
14
|
-
/** Shared material for prior-session ref point meshes (lazy-created) */
|
|
15
|
-
private priorRefMaterial;
|
|
16
|
-
/** Shared geometry for current-session ref point meshes (lazy-created) */
|
|
17
|
-
private currentRefGeometry;
|
|
18
|
-
/**
|
|
19
|
-
* Set the GPS zero reference (origin for coordinate conversion).
|
|
20
|
-
* Must be called before displaying reference points.
|
|
21
|
-
*
|
|
22
|
-
* @param zero - GPS coordinates of the origin
|
|
23
|
-
*/
|
|
24
|
-
setZeroRef(zero: LatLong): void;
|
|
25
|
-
/**
|
|
26
|
-
* Get the current zero reference
|
|
27
|
-
*/
|
|
28
|
-
getZeroRef(): LatLong | null;
|
|
29
|
-
/**
|
|
30
|
-
* Display reference points from prior sessions.
|
|
31
|
-
* Clears any existing prior ref points first.
|
|
32
|
-
*
|
|
33
|
-
* @param refPoints - Array of reference point marks to visualize
|
|
34
|
-
*/
|
|
35
|
-
displayPriorRefPoints(refPoints: RefPointMark[]): void;
|
|
36
|
-
/**
|
|
37
|
-
* Add a reference point from the current session.
|
|
38
|
-
*
|
|
39
|
-
* @param refPoint - Reference point mark to visualize
|
|
40
|
-
*/
|
|
41
|
-
addCurrentRefPoint(refPoint: RefPointMark): void;
|
|
42
|
-
/**
|
|
43
|
-
* Clear all prior reference point meshes from the scene.
|
|
44
|
-
*/
|
|
45
|
-
clearPriorRefPoints(): void;
|
|
46
|
-
/**
|
|
47
|
-
* Clear current session reference point meshes from the scene.
|
|
48
|
-
*/
|
|
49
|
-
clearCurrentRefPoints(): void;
|
|
50
|
-
/**
|
|
51
|
-
* Clear all visualizations and reset state.
|
|
52
|
-
*/
|
|
53
|
-
clearAll(): void;
|
|
54
|
-
/**
|
|
55
|
-
* Get count of visible reference points.
|
|
56
|
-
*/
|
|
57
|
-
getCounts(): {
|
|
58
|
-
prior: number;
|
|
59
|
-
current: number;
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Singleton instance for global use.
|
|
64
|
-
* Import this to visualize reference points.
|
|
65
|
-
*/
|
|
66
|
-
declare const refPointVisualizer: RefPointVisualizer;
|
|
67
|
-
//#endregion
|
|
68
|
-
export { refPointVisualizer as n, RefPointVisualizer as t };
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import * as _$_reduxjs_toolkit0 from "@reduxjs/toolkit";
|
|
2
|
-
|
|
3
|
-
//#region ../src/state/routing-slice.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Routing Slice — Redux state for current application screen.
|
|
6
|
-
*
|
|
7
|
-
* Bug 2 fix (SPA architecture audit): Moves `currentScreen` from a
|
|
8
|
-
* module-level variable in navigation.ts into Redux, making it the
|
|
9
|
-
* single source of truth for screen state. This enables time-travel
|
|
10
|
-
* debugging and prevents desync between navigation state and Redux.
|
|
11
|
-
*
|
|
12
|
-
* @see docs/2026-04-06-spa-architecture-audit.md — Bug 2
|
|
13
|
-
* @see docs_guides/spa-architecture-best-practices.md — §4 State-Driven Routing
|
|
14
|
-
*/
|
|
15
|
-
/** Application screen states for history-based navigation. */
|
|
16
|
-
type AppScreen = 'setup' | 'ar' | 'recording' | 'summary';
|
|
17
|
-
interface RoutingState {
|
|
18
|
-
currentScreen: AppScreen;
|
|
19
|
-
}
|
|
20
|
-
declare const navigateTo: _$_reduxjs_toolkit0.ActionCreatorWithPayload<AppScreen, "routing/navigateTo">;
|
|
21
|
-
declare const routingReducer: _$_reduxjs_toolkit0.Reducer<RoutingState>;
|
|
22
|
-
//#endregion
|
|
23
|
-
export { routingReducer as i, RoutingState as n, navigateTo as r, AppScreen as t };
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { a as recordWriteFailure, c as startSession, i as recordDepthSample, n as SessionMetadata, o as recorderReducer, r as endSession, s as setCurrentScenarioName, t as RecorderState } from "../recorder-slice-fcwAXrsh.js";
|
|
2
|
-
export { RecorderState, SessionMetadata, endSession, recordDepthSample, recordWriteFailure, recorderReducer, setCurrentScenarioName, startSession };
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { a as resetRefPointsState, i as refPointsReducer, n as clearSessionRefPointUsage, o as selectCachedKnownRefPoints, r as incrementRefPointUsage, s as setImportedRefPoints, t as RefPointsState } from "../ref-points-slice-tC-Wd6XJ.js";
|
|
2
|
-
export { RefPointsState, clearSessionRefPointUsage, incrementRefPointUsage, refPointsReducer, resetRefPointsState, selectCachedKnownRefPoints, setImportedRefPoints };
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { gpsToH3 } from "../ref-points/h3-ref-point.js";
|
|
2
|
-
import { createSelector, createSlice } from "@reduxjs/toolkit";
|
|
3
|
-
//#region ../src/state/ref-points-slice.ts
|
|
4
|
-
const initialState = {
|
|
5
|
-
importedRefPoints: [],
|
|
6
|
-
sessionRefPointUsage: {}
|
|
7
|
-
};
|
|
8
|
-
const refPointsSlice = createSlice({
|
|
9
|
-
name: "refPoints",
|
|
10
|
-
initialState,
|
|
11
|
-
reducers: {
|
|
12
|
-
setImportedRefPoints(state, action) {
|
|
13
|
-
state.importedRefPoints = action.payload;
|
|
14
|
-
},
|
|
15
|
-
incrementRefPointUsage(state, action) {
|
|
16
|
-
const id = action.payload;
|
|
17
|
-
state.sessionRefPointUsage[id] = (state.sessionRefPointUsage[id] ?? 0) + 1;
|
|
18
|
-
},
|
|
19
|
-
clearSessionRefPointUsage(state) {
|
|
20
|
-
state.sessionRefPointUsage = {};
|
|
21
|
-
},
|
|
22
|
-
resetRefPointsState() {
|
|
23
|
-
return initialState;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
const { setImportedRefPoints, incrementRefPointUsage, clearSessionRefPointUsage, resetRefPointsState } = refPointsSlice.actions;
|
|
28
|
-
const refPointsReducer = refPointsSlice.reducer;
|
|
29
|
-
/**
|
|
30
|
-
* Memoized selector that derives KnownRefPoint[] (with H3 indices) from
|
|
31
|
-
* importedRefPoints. Replaces the closure-based `recomputeKnownRefPoints()`
|
|
32
|
-
* in ref-point-handlers.ts.
|
|
33
|
-
*
|
|
34
|
-
* Uses createSelector (reselect) for standard RTK memoization — recomputes
|
|
35
|
-
* only when the importedRefPoints array reference changes.
|
|
36
|
-
*/
|
|
37
|
-
const selectCachedKnownRefPoints = createSelector((state) => state.importedRefPoints, (importedRefPoints) => importedRefPoints.map((rp) => ({
|
|
38
|
-
h3Index: gpsToH3(rp.lat, rp.lon),
|
|
39
|
-
displayName: rp.name || rp.id,
|
|
40
|
-
lat: rp.lat,
|
|
41
|
-
lon: rp.lon
|
|
42
|
-
})));
|
|
43
|
-
//#endregion
|
|
44
|
-
export { clearSessionRefPointUsage, incrementRefPointUsage, refPointsReducer, resetRefPointsState, selectCachedKnownRefPoints, setImportedRefPoints };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { createSlice } from "@reduxjs/toolkit";
|
|
2
|
-
//#region ../src/state/routing-slice.ts
|
|
3
|
-
const routingSlice = createSlice({
|
|
4
|
-
name: "routing",
|
|
5
|
-
initialState: { currentScreen: "setup" },
|
|
6
|
-
reducers: { navigateTo(state, action) {
|
|
7
|
-
state.currentScreen = action.payload;
|
|
8
|
-
} }
|
|
9
|
-
});
|
|
10
|
-
const { navigateTo } = routingSlice.actions;
|
|
11
|
-
const routingReducer = routingSlice.reducer;
|
|
12
|
-
//#endregion
|
|
13
|
-
export { navigateTo, routingReducer };
|
package/dist/state/store.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { i as DepthSample, r as DepthPoint } from "../ar-types-B-ORgk6Z.js";
|
|
2
|
-
import { s as RecordingOptions } from "../recording-options-BYUFX8iU.js";
|
|
3
|
-
import { n as SessionMetadata } from "../opfs-storage-ChOzF_Wp.js";
|
|
4
|
-
import { t as StorageBackend } from "../storage-backend-BcEItnFr.js";
|
|
5
|
-
import { a as recordWriteFailure, c as startSession, i as recordDepthSample, n as SessionMetadata$1, r as endSession, s as setCurrentScenarioName, t as RecorderState } from "../recorder-slice-fcwAXrsh.js";
|
|
6
|
-
import { a as resetRefPointsState, n as clearSessionRefPointUsage, o as selectCachedKnownRefPoints, r as incrementRefPointUsage, s as setImportedRefPoints, t as RefPointsState } from "../ref-points-slice-tC-Wd6XJ.js";
|
|
7
|
-
import { n as RefPointMark } from "../ref-point-loader-Pt1smgHS.js";
|
|
8
|
-
import { _ as setZeroPos, a as MarkReferencePointPayload, c as RecordGpsEventPayload, d as RootState, f as add2dImage, g as recordGpsEvent, h as markReferencePoint, i as LatLong, l as RecorderStore, m as createRecorderStore, n as CombinedRootState, o as RawDeviceOrientation, p as calcRelativeCoordsInMeters, r as GpsPoint, s as RawGpsPoint, t as AppDispatch, u as RecorderStoreOptions } from "../store-C7PKOj8S.js";
|
|
9
|
-
export { AppDispatch, CombinedRootState, DepthPoint, DepthSample, GpsPoint, LatLong, MarkReferencePointPayload, SessionMetadata as OpfsSessionMetadata, RawDeviceOrientation, RawGpsPoint, RecordGpsEventPayload, RecorderState, RecorderStore, RecorderStoreOptions, RecordingOptions, RefPointMark, RefPointsState, RootState, SessionMetadata$1 as SessionMetadata, StorageBackend, add2dImage, calcRelativeCoordsInMeters, clearSessionRefPointUsage, createRecorderStore, endSession, incrementRefPointUsage, markReferencePoint, recordDepthSample, recordGpsEvent, recordWriteFailure, resetRefPointsState, selectCachedKnownRefPoints, setCurrentScenarioName, setImportedRefPoints, setZeroPos, startSession };
|
package/dist/state/store.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { endSession, recordDepthSample, recordWriteFailure, recorderReducer, setCurrentScenarioName, startSession } from "./recorder-slice.js";
|
|
2
|
-
import { clearSessionRefPointUsage, incrementRefPointUsage, refPointsReducer, resetRefPointsState, selectCachedKnownRefPoints, setImportedRefPoints } from "./ref-points-slice.js";
|
|
3
|
-
import { routingReducer } from "./routing-slice.js";
|
|
4
|
-
import { OpfsStorageBackend } from "../storage/opfs-storage-backend.js";
|
|
5
|
-
import { createPersistenceMiddleware } from "./persistence-middleware.js";
|
|
6
|
-
import "../licensing/community-license-key.js";
|
|
7
|
-
import { configureStore } from "@reduxjs/toolkit";
|
|
8
|
-
import { add2dImage, arElementsReducer, calcRelativeCoordsInMeters, gpsDataReducer, gpsElementsReducer, markReferencePoint, recordGpsEvent, sanitizeForDevTools, setZeroPos, validateLicenseKey } from "gps-plus-slam-js";
|
|
9
|
-
//#region ../src/state/store.ts
|
|
10
|
-
/**
|
|
11
|
-
* Redux Store for Recorder App
|
|
12
|
-
*
|
|
13
|
-
* Uses Redux Toolkit's configureStore to combine all reducers (library +
|
|
14
|
-
* app-level) into a single store. Action persistence during recording is
|
|
15
|
-
* handled by the persistence middleware.
|
|
16
|
-
*
|
|
17
|
-
* ARCHITECTURE NOTE: See docs/architecture-ar-gps-pose-separation.md
|
|
18
|
-
* The library's recordGpsEvent action captures paired AR+GPS data
|
|
19
|
-
* that feeds directly into the alignment algorithm.
|
|
20
|
-
*
|
|
21
|
-
* Migration note (§4 — architecture-observations-consolidated.md):
|
|
22
|
-
* Previously the store used a manual wrapper pattern with action.type.startsWith()
|
|
23
|
-
* prefix matching to route actions between a library store and local state
|
|
24
|
-
* variables. This has been replaced with a single configureStore call that
|
|
25
|
-
* combines all 6 reducers declaratively.
|
|
26
|
-
*/
|
|
27
|
-
/**
|
|
28
|
-
* Create the recorder store using Redux Toolkit's configureStore.
|
|
29
|
-
*
|
|
30
|
-
* Combines all 6 reducers (3 library: gpsData, gpsElements, arElements;
|
|
31
|
-
* 3 app: recorder, refPoints, routing) into a single store with the
|
|
32
|
-
* persistence middleware for action recording.
|
|
33
|
-
*
|
|
34
|
-
* @param options - Optional configuration including callbacks
|
|
35
|
-
*/
|
|
36
|
-
function createRecorderStore(options = {}) {
|
|
37
|
-
const { onWriteFailure } = options;
|
|
38
|
-
const storageBackend = options.storageBackend ?? new OpfsStorageBackend();
|
|
39
|
-
const enableDevChecks = options.enableDevChecks ?? true;
|
|
40
|
-
validateLicenseKey(options.licenseKey ?? "eyJ0eXBlIjoiY29tbXVuaXR5IiwiZXhwIjoxODA4NzcyNDI3fQ.YYNf0IdqniZdMzRXCuvewxsQQ01XNywrKsfL5IpiJotfFJfqtrGg4u9z0QFhXeszPtUhnvgC8_oOnbOkbXPuAw");
|
|
41
|
-
const store = configureStore({
|
|
42
|
-
reducer: {
|
|
43
|
-
gpsData: gpsDataReducer,
|
|
44
|
-
gpsElements: gpsElementsReducer,
|
|
45
|
-
arElements: arElementsReducer,
|
|
46
|
-
recorder: recorderReducer,
|
|
47
|
-
refPoints: refPointsReducer,
|
|
48
|
-
routing: routingReducer
|
|
49
|
-
},
|
|
50
|
-
middleware: (getDefaultMiddleware) => getDefaultMiddleware({
|
|
51
|
-
serializableCheck: enableDevChecks,
|
|
52
|
-
immutableCheck: enableDevChecks
|
|
53
|
-
}).concat(createPersistenceMiddleware({
|
|
54
|
-
storageBackend,
|
|
55
|
-
onWriteFailure
|
|
56
|
-
})),
|
|
57
|
-
devTools: {
|
|
58
|
-
actionSanitizer: sanitizeForDevTools,
|
|
59
|
-
stateSanitizer: sanitizeForDevTools
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
return {
|
|
63
|
-
getState: () => store.getState(),
|
|
64
|
-
dispatch: store.dispatch,
|
|
65
|
-
subscribe: (listener) => store.subscribe(listener),
|
|
66
|
-
writeFrame: (blob, index) => storageBackend.writeFrame(blob, index),
|
|
67
|
-
writeSessionMetadata: (metadata) => storageBackend.writeSessionMetadata(metadata)
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
//#endregion
|
|
71
|
-
export { add2dImage, calcRelativeCoordsInMeters, clearSessionRefPointUsage, createRecorderStore, endSession, incrementRefPointUsage, markReferencePoint, recordDepthSample, recordGpsEvent, recordWriteFailure, resetRefPointsState, selectCachedKnownRefPoints, setCurrentScenarioName, setImportedRefPoints, setZeroPos, startSession };
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import { createLogger } from "../utils/logger.js";
|
|
2
|
-
import { h3RefsMatch, isH3Index } from "../ref-points/h3-ref-point.js";
|
|
3
|
-
import { BlobReader, TextWriter, ZipReader } from "@zip.js/zip.js";
|
|
4
|
-
//#region ../src/storage/ref-point-importer.ts
|
|
5
|
-
/**
|
|
6
|
-
* Reference Point Importer Module
|
|
7
|
-
*
|
|
8
|
-
* Extracts reference points from ZIP files in a folder, enabling reuse of
|
|
9
|
-
* ref points from previous recording sessions.
|
|
10
|
-
*
|
|
11
|
-
* This module:
|
|
12
|
-
* 1. Enumerates all *.zip files in a folder
|
|
13
|
-
* 2. Opens each ZIP and looks for refPoints/*.json files
|
|
14
|
-
* 3. Parses and validates each ref point definition
|
|
15
|
-
* 4. Merges and deduplicates ref points by ID
|
|
16
|
-
*
|
|
17
|
-
* Uses @zip.js/zip.js for ZIP reading (same library as zip-export.ts).
|
|
18
|
-
*/
|
|
19
|
-
const log = createLogger("RefPointImporter");
|
|
20
|
-
/**
|
|
21
|
-
* Check if a file name is a ZIP file (case-insensitive).
|
|
22
|
-
*/
|
|
23
|
-
function isZipFileName(name) {
|
|
24
|
-
return name.toLowerCase().endsWith(".zip");
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Check if a ZIP entry path is a ref point JSON file.
|
|
28
|
-
* Expected path: refPoints/{id}.json
|
|
29
|
-
*/
|
|
30
|
-
function isRefPointEntry(entryPath) {
|
|
31
|
-
return entryPath.startsWith("refPoints/") && entryPath.endsWith(".json") && entryPath !== "refPoints/";
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Type guard to validate parsed JSON matches RefPointDefinition shape.
|
|
35
|
-
* Validates at least one observation exists with required nested properties.
|
|
36
|
-
*/
|
|
37
|
-
function isValidRefPointDefinition(value) {
|
|
38
|
-
if (typeof value !== "object" || value === null) return false;
|
|
39
|
-
const obj = value;
|
|
40
|
-
if (typeof obj.id !== "string" || typeof obj.name !== "string" || typeof obj.createdAt !== "number" || !Array.isArray(obj.observations)) return false;
|
|
41
|
-
if (obj.observations.length === 0) return true;
|
|
42
|
-
const firstObs = obj.observations[0];
|
|
43
|
-
if (typeof firstObs !== "object" || firstObs === null) return false;
|
|
44
|
-
const gpsPoint = firstObs.gpsPoint;
|
|
45
|
-
if (typeof gpsPoint !== "object" || gpsPoint === null || typeof gpsPoint.latitude !== "number" || typeof gpsPoint.longitude !== "number") return false;
|
|
46
|
-
return true;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Convert a RefPointDefinition to an ImportedRefPoint.
|
|
50
|
-
* Extracts GPS coordinates from the first observation.
|
|
51
|
-
*/
|
|
52
|
-
function toImportedRefPoint(def, sourceZipName) {
|
|
53
|
-
if (def.observations.length === 0) return null;
|
|
54
|
-
const firstObs = def.observations[0];
|
|
55
|
-
return {
|
|
56
|
-
id: def.id,
|
|
57
|
-
name: def.name,
|
|
58
|
-
lat: firstObs.gpsPoint.latitude,
|
|
59
|
-
lon: firstObs.gpsPoint.longitude,
|
|
60
|
-
alt: firstObs.gpsPoint.altitude,
|
|
61
|
-
sourceZipName
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Extract reference points from a single ZIP file.
|
|
66
|
-
*
|
|
67
|
-
* @param zipBlob - The ZIP file as a Blob
|
|
68
|
-
* @param zipFileName - Name of the ZIP file (for error messages)
|
|
69
|
-
* @returns Array of imported ref points and any errors
|
|
70
|
-
*/
|
|
71
|
-
async function extractRefPointsFromZip(zipBlob, zipFileName) {
|
|
72
|
-
const refPoints = [];
|
|
73
|
-
const errors = [];
|
|
74
|
-
const zipReader = new ZipReader(new BlobReader(zipBlob));
|
|
75
|
-
try {
|
|
76
|
-
const entries = await zipReader.getEntries();
|
|
77
|
-
for (const entry of entries) {
|
|
78
|
-
if (entry.directory) continue;
|
|
79
|
-
if (!isRefPointEntry(entry.filename)) continue;
|
|
80
|
-
try {
|
|
81
|
-
const textWriter = new TextWriter();
|
|
82
|
-
const jsonText = await entry.getData(textWriter);
|
|
83
|
-
let parsed;
|
|
84
|
-
try {
|
|
85
|
-
parsed = JSON.parse(jsonText);
|
|
86
|
-
} catch (parseErr) {
|
|
87
|
-
errors.push(`${zipFileName}/${entry.filename}: Invalid JSON - ${parseErr.message}`);
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
if (!isValidRefPointDefinition(parsed)) {
|
|
91
|
-
errors.push(`${zipFileName}/${entry.filename}: Invalid ref point schema`);
|
|
92
|
-
continue;
|
|
93
|
-
}
|
|
94
|
-
const imported = toImportedRefPoint(parsed, zipFileName);
|
|
95
|
-
if (imported) refPoints.push(imported);
|
|
96
|
-
} catch (entryErr) {
|
|
97
|
-
errors.push(`${zipFileName}/${entry.filename}: ${entryErr.message}`);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
} finally {
|
|
101
|
-
await zipReader.close();
|
|
102
|
-
}
|
|
103
|
-
return {
|
|
104
|
-
refPoints,
|
|
105
|
-
errors
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Import reference points from all ZIP files in a folder.
|
|
110
|
-
*
|
|
111
|
-
* Enumerates all *.zip files in the folder, extracts refPoints/*.json from each,
|
|
112
|
-
* and merges them into a deduplicated list.
|
|
113
|
-
*
|
|
114
|
-
* Deduplication: If the same ref point ID appears in multiple ZIPs, the first
|
|
115
|
-
* occurrence is kept (based on iteration order).
|
|
116
|
-
*
|
|
117
|
-
* @param folderHandle - Read-only directory handle from showDirectoryPicker
|
|
118
|
-
* @returns Result containing merged ref points, scan count, and errors
|
|
119
|
-
*/
|
|
120
|
-
async function importRefPointsFromFolder(folderHandle) {
|
|
121
|
-
const allRefPoints = [];
|
|
122
|
-
const seenIds = /* @__PURE__ */ new Set();
|
|
123
|
-
const allErrors = [];
|
|
124
|
-
let zipFilesScanned = 0;
|
|
125
|
-
log.info(`Scanning folder: ${folderHandle.name}`);
|
|
126
|
-
try {
|
|
127
|
-
for await (const entry of folderHandle.values()) {
|
|
128
|
-
if (entry.kind !== "file" || !isZipFileName(entry.name)) continue;
|
|
129
|
-
log.debug(`Processing ZIP: ${entry.name}`);
|
|
130
|
-
try {
|
|
131
|
-
const { refPoints, errors } = await extractRefPointsFromZip(await (await folderHandle.getFileHandle(entry.name)).getFile(), entry.name);
|
|
132
|
-
zipFilesScanned++;
|
|
133
|
-
allErrors.push(...errors);
|
|
134
|
-
for (const refPoint of refPoints) if (!(isH3Index(refPoint.id) ? allRefPoints.some((existing) => isH3Index(existing.id) && h3RefsMatch(existing.id, refPoint.id)) : seenIds.has(refPoint.id))) {
|
|
135
|
-
seenIds.add(refPoint.id);
|
|
136
|
-
allRefPoints.push(refPoint);
|
|
137
|
-
} else log.debug(`Skipping duplicate ref point: ${refPoint.id} from ${entry.name}`);
|
|
138
|
-
} catch (zipErr) {
|
|
139
|
-
const errorMsg = `Failed to process ${entry.name}: ${zipErr.message}`;
|
|
140
|
-
log.warn(errorMsg);
|
|
141
|
-
allErrors.push(errorMsg);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
log.info(`Imported ${allRefPoints.length} ref points from ${zipFilesScanned} ZIP files`);
|
|
145
|
-
return {
|
|
146
|
-
success: true,
|
|
147
|
-
refPoints: allRefPoints,
|
|
148
|
-
zipFilesScanned,
|
|
149
|
-
errors: allErrors
|
|
150
|
-
};
|
|
151
|
-
} catch (err) {
|
|
152
|
-
const errorMsg = `Failed to scan folder: ${err.message}`;
|
|
153
|
-
log.error(errorMsg);
|
|
154
|
-
return {
|
|
155
|
-
success: false,
|
|
156
|
-
refPoints: allRefPoints,
|
|
157
|
-
zipFilesScanned,
|
|
158
|
-
errors: [...allErrors, errorMsg]
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
//#endregion
|
|
163
|
-
export { importRefPointsFromFolder };
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { a as flattenRefPointsToMarks, c as loadRefPoint, i as averageGpsPerRefPoint, l as saveRefPointObservation, n as RefPointMark, o as listRefPointIds, r as RefPointObservation, s as loadAllRefPoints, t as RefPointDefinition, u as writeRefPointDefinition } from "../ref-point-loader-Pt1smgHS.js";
|
|
2
|
-
export { RefPointDefinition, RefPointMark, RefPointObservation, averageGpsPerRefPoint, flattenRefPointsToMarks, listRefPointIds, loadAllRefPoints, loadRefPoint, saveRefPointObservation, writeRefPointDefinition };
|
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
import { createLogger } from "../utils/logger.js";
|
|
2
|
-
//#region ../src/storage/ref-point-loader.ts
|
|
3
|
-
const log = createLogger("RefPointLoader");
|
|
4
|
-
/**
|
|
5
|
-
* Check if arPose has required position and rotation arrays.
|
|
6
|
-
*/
|
|
7
|
-
function hasValidArPose(o) {
|
|
8
|
-
if (typeof o.arPose !== "object" || o.arPose === null) return false;
|
|
9
|
-
const arPose = o.arPose;
|
|
10
|
-
return Array.isArray(arPose.position) && Array.isArray(arPose.rotation);
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Check if gpsPoint has required lat/lon numbers.
|
|
14
|
-
*/
|
|
15
|
-
function hasValidGpsPoint(o) {
|
|
16
|
-
if (typeof o.gpsPoint !== "object" || o.gpsPoint === null) return false;
|
|
17
|
-
const gpsPoint = o.gpsPoint;
|
|
18
|
-
return typeof gpsPoint.latitude === "number" && typeof gpsPoint.longitude === "number";
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Type guard to validate a single observation has required nested properties.
|
|
22
|
-
* Prevents runtime errors from accessing arPose.position or gpsPoint.latitude on malformed data.
|
|
23
|
-
*/
|
|
24
|
-
function isValidObservation(obs) {
|
|
25
|
-
if (typeof obs !== "object" || obs === null) return false;
|
|
26
|
-
const o = obs;
|
|
27
|
-
return hasValidArPose(o) && hasValidGpsPoint(o);
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Type guard to validate parsed JSON matches RefPointDefinition shape.
|
|
31
|
-
* Prevents runtime errors from malformed or corrupted JSON files.
|
|
32
|
-
* Also validates each observation to ensure nested properties exist.
|
|
33
|
-
*/
|
|
34
|
-
function isRefPointDefinition(value) {
|
|
35
|
-
if (typeof value !== "object" || value === null) return false;
|
|
36
|
-
const obj = value;
|
|
37
|
-
if (typeof obj.id !== "string" || typeof obj.name !== "string" || typeof obj.createdAt !== "number" || !Array.isArray(obj.observations)) return false;
|
|
38
|
-
return obj.observations.every(isValidObservation);
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Parse a single reference point file and validate its schema.
|
|
42
|
-
* Returns null if parsing fails or schema is invalid.
|
|
43
|
-
*/
|
|
44
|
-
async function parseRefPointFile(fileHandle, fileName) {
|
|
45
|
-
try {
|
|
46
|
-
const text = await (await fileHandle.getFile()).text();
|
|
47
|
-
const parsed = JSON.parse(text);
|
|
48
|
-
if (isRefPointDefinition(parsed)) return parsed;
|
|
49
|
-
log.warn(`Invalid schema in ${fileName}`);
|
|
50
|
-
return null;
|
|
51
|
-
} catch (parseErr) {
|
|
52
|
-
log.error(`Failed to parse ${fileName}:`, parseErr);
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Load all reference point definitions from the scenario's refPoints/ directory.
|
|
58
|
-
*
|
|
59
|
-
* @param scenarioHandle - File system handle for the scenario folder
|
|
60
|
-
* @returns Array of all reference point definitions
|
|
61
|
-
*/
|
|
62
|
-
async function loadAllRefPoints(scenarioHandle) {
|
|
63
|
-
try {
|
|
64
|
-
const refPointsHandle = await scenarioHandle.getDirectoryHandle("refPoints");
|
|
65
|
-
const refPoints = [];
|
|
66
|
-
for await (const [name, handle] of refPointsHandle.entries()) {
|
|
67
|
-
if (handle.kind !== "file" || !name.endsWith(".json")) continue;
|
|
68
|
-
const parsed = await parseRefPointFile(handle, name);
|
|
69
|
-
if (parsed) refPoints.push(parsed);
|
|
70
|
-
}
|
|
71
|
-
return refPoints;
|
|
72
|
-
} catch (err) {
|
|
73
|
-
log.debug("No refPoints directory found (yet):", err);
|
|
74
|
-
return [];
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Load a specific reference point by ID.
|
|
79
|
-
*
|
|
80
|
-
* @param scenarioHandle - File system handle for the scenario folder
|
|
81
|
-
* @param pointId - Reference point ID
|
|
82
|
-
* @returns Reference point definition or null if not found
|
|
83
|
-
*/
|
|
84
|
-
async function loadRefPoint(scenarioHandle, pointId) {
|
|
85
|
-
try {
|
|
86
|
-
const text = await (await (await (await scenarioHandle.getDirectoryHandle("refPoints")).getFileHandle(`${pointId}.json`)).getFile()).text();
|
|
87
|
-
const parsed = JSON.parse(text);
|
|
88
|
-
if (!isRefPointDefinition(parsed)) {
|
|
89
|
-
log.warn(`Invalid schema for ${pointId}`);
|
|
90
|
-
return null;
|
|
91
|
-
}
|
|
92
|
-
return parsed;
|
|
93
|
-
} catch (err) {
|
|
94
|
-
log.debug(`Reference point ${pointId} not found:`, err);
|
|
95
|
-
return null;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Save or update a reference point observation.
|
|
100
|
-
* Creates the refPoints/ directory if it doesn't exist.
|
|
101
|
-
* If the reference point exists, appends the new observation.
|
|
102
|
-
* If it doesn't exist, creates a new reference point file.
|
|
103
|
-
*
|
|
104
|
-
* @param scenarioHandle - File system handle for the scenario folder
|
|
105
|
-
* @param pointId - Reference point ID
|
|
106
|
-
* @param pointName - Human-readable name for the reference point
|
|
107
|
-
* @param observation - New observation to add
|
|
108
|
-
*/
|
|
109
|
-
async function saveRefPointObservation(scenarioHandle, pointId, pointName, observation) {
|
|
110
|
-
try {
|
|
111
|
-
const refPointsHandle = await scenarioHandle.getDirectoryHandle("refPoints", { create: true });
|
|
112
|
-
const existing = await loadRefPoint(scenarioHandle, pointId);
|
|
113
|
-
const definition = existing ? {
|
|
114
|
-
...existing,
|
|
115
|
-
observations: [...existing.observations, observation]
|
|
116
|
-
} : {
|
|
117
|
-
id: pointId,
|
|
118
|
-
name: pointName,
|
|
119
|
-
createdAt: observation.timestamp,
|
|
120
|
-
observations: [observation]
|
|
121
|
-
};
|
|
122
|
-
const writable = await (await refPointsHandle.getFileHandle(`${pointId}.json`, { create: true })).createWritable();
|
|
123
|
-
let writeError = null;
|
|
124
|
-
try {
|
|
125
|
-
await writable.write(JSON.stringify(definition, null, 2));
|
|
126
|
-
await writable.close();
|
|
127
|
-
} catch (error) {
|
|
128
|
-
writeError = error;
|
|
129
|
-
} finally {
|
|
130
|
-
if (writeError !== null) try {
|
|
131
|
-
await writable.abort();
|
|
132
|
-
} catch {}
|
|
133
|
-
}
|
|
134
|
-
if (writeError !== null) {
|
|
135
|
-
if (writeError instanceof Error) throw writeError;
|
|
136
|
-
throw new Error("OPFS write failed");
|
|
137
|
-
}
|
|
138
|
-
log.info(`Saved observation for ${pointId} (${definition.observations.length} total observations)`);
|
|
139
|
-
} catch (err) {
|
|
140
|
-
log.error(`Failed to save reference point ${pointId}:`, err);
|
|
141
|
-
throw err;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Write a complete RefPointDefinition to OPFS.
|
|
146
|
-
* Creates the refPoints/ directory if it doesn't exist.
|
|
147
|
-
* Used by the recovery flow to restore definitions extracted from ZIPs.
|
|
148
|
-
*
|
|
149
|
-
* @param scenarioHandle - File system handle for the scenario folder
|
|
150
|
-
* @param definition - Complete ref point definition to write
|
|
151
|
-
*/
|
|
152
|
-
async function writeRefPointDefinition(scenarioHandle, definition) {
|
|
153
|
-
const writable = await (await (await scenarioHandle.getDirectoryHandle("refPoints", { create: true })).getFileHandle(`${definition.id}.json`, { create: true })).createWritable();
|
|
154
|
-
let writeError = null;
|
|
155
|
-
try {
|
|
156
|
-
await writable.write(JSON.stringify(definition, null, 2));
|
|
157
|
-
await writable.close();
|
|
158
|
-
} catch (error) {
|
|
159
|
-
writeError = error;
|
|
160
|
-
} finally {
|
|
161
|
-
if (writeError !== null) try {
|
|
162
|
-
await writable.abort();
|
|
163
|
-
} catch {}
|
|
164
|
-
}
|
|
165
|
-
if (writeError !== null) {
|
|
166
|
-
if (writeError instanceof Error) throw writeError;
|
|
167
|
-
throw new Error("OPFS write failed");
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Get list of all reference point IDs in the scenario.
|
|
172
|
-
* Useful for autocomplete/suggestions.
|
|
173
|
-
*
|
|
174
|
-
* @param scenarioHandle - File system handle for the scenario folder
|
|
175
|
-
* @returns Array of reference point IDs
|
|
176
|
-
*/
|
|
177
|
-
async function listRefPointIds(scenarioHandle) {
|
|
178
|
-
try {
|
|
179
|
-
const refPointsHandle = await scenarioHandle.getDirectoryHandle("refPoints");
|
|
180
|
-
const ids = [];
|
|
181
|
-
for await (const [name, handle] of refPointsHandle.entries()) if (handle.kind === "file" && name.endsWith(".json")) ids.push(name.slice(0, -5));
|
|
182
|
-
return ids.sort();
|
|
183
|
-
} catch (err) {
|
|
184
|
-
log.debug("No refPoints directory found (yet):", err);
|
|
185
|
-
return [];
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Flatten an array of RefPointDefinition objects into individual RefPointMark
|
|
190
|
-
* observations suitable for visualization.
|
|
191
|
-
*
|
|
192
|
-
* @param refPointDefs - Array of reference point definitions with observations
|
|
193
|
-
* @returns Flat array of individual marks (one per observation)
|
|
194
|
-
*/
|
|
195
|
-
function flattenRefPointsToMarks(refPointDefs) {
|
|
196
|
-
return refPointDefs.flatMap((def) => def.observations.map((obs) => {
|
|
197
|
-
const src = obs.fusedGpsPoint ?? obs.gpsPoint;
|
|
198
|
-
const gpsPosition = {
|
|
199
|
-
lat: src.latitude,
|
|
200
|
-
lon: src.longitude,
|
|
201
|
-
altitude: src.altitude
|
|
202
|
-
};
|
|
203
|
-
return {
|
|
204
|
-
id: def.id,
|
|
205
|
-
odomPosition: obs.arPose.position,
|
|
206
|
-
odomRotation: obs.arPose.rotation,
|
|
207
|
-
gpsPosition,
|
|
208
|
-
timestamp: obs.timestamp
|
|
209
|
-
};
|
|
210
|
-
}));
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* Compute one averaged GPS position per reference point ID.
|
|
214
|
-
* For each observation, prefers `fusedGpsPoint` (sub-meter accuracy) when
|
|
215
|
-
* available, falling back to raw `gpsPoint`. Returns the centroid (mean
|
|
216
|
-
* lat/lon) across all observations.
|
|
217
|
-
*/
|
|
218
|
-
function averageGpsPerRefPoint(refPointDefs) {
|
|
219
|
-
return refPointDefs.filter((def) => def.observations.length > 0).map((def) => {
|
|
220
|
-
const coords = def.observations.map((obs) => {
|
|
221
|
-
if (obs.fusedGpsPoint) return {
|
|
222
|
-
lat: obs.fusedGpsPoint.latitude,
|
|
223
|
-
lon: obs.fusedGpsPoint.longitude,
|
|
224
|
-
alt: obs.fusedGpsPoint.altitude
|
|
225
|
-
};
|
|
226
|
-
if (typeof obs.gpsPoint.latitude === "number" && typeof obs.gpsPoint.longitude === "number") return {
|
|
227
|
-
lat: obs.gpsPoint.latitude,
|
|
228
|
-
lon: obs.gpsPoint.longitude,
|
|
229
|
-
alt: obs.gpsPoint.altitude
|
|
230
|
-
};
|
|
231
|
-
return null;
|
|
232
|
-
}).filter((c) => c !== null);
|
|
233
|
-
if (coords.length === 0) return null;
|
|
234
|
-
const avgLat = coords.reduce((s, c) => s + c.lat, 0) / coords.length;
|
|
235
|
-
const avgLon = coords.reduce((s, c) => s + c.lon, 0) / coords.length;
|
|
236
|
-
const alts = coords.filter((c) => c.alt != null);
|
|
237
|
-
const avgAlt = alts.length > 0 ? alts.reduce((s, c) => s + c.alt, 0) / alts.length : void 0;
|
|
238
|
-
return {
|
|
239
|
-
id: def.id,
|
|
240
|
-
name: def.name,
|
|
241
|
-
lat: avgLat,
|
|
242
|
-
lon: avgLon,
|
|
243
|
-
alt: avgAlt
|
|
244
|
-
};
|
|
245
|
-
}).filter((r) => r !== null);
|
|
246
|
-
}
|
|
247
|
-
//#endregion
|
|
248
|
-
export { averageGpsPerRefPoint, flattenRefPointsToMarks, listRefPointIds, loadAllRefPoints, loadRefPoint, saveRefPointObservation, writeRefPointDefinition };
|