@ingissa/navcore-simulator 1.0.4 → 1.0.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 (173) hide show
  1. package/LICENSE +3 -0
  2. package/README.md +10 -18
  3. package/dist/core/src/NavCore.d.ts +142 -0
  4. package/dist/core/src/NavCore.d.ts.map +1 -0
  5. package/dist/core/src/NavCore.js +390 -0
  6. package/dist/core/src/bearing/BearingEngine.d.ts +24 -0
  7. package/dist/core/src/bearing/BearingEngine.d.ts.map +1 -0
  8. package/dist/core/src/bearing/BearingEngine.js +50 -0
  9. package/dist/core/src/constants.d.ts +34 -0
  10. package/dist/core/src/constants.d.ts.map +1 -0
  11. package/dist/core/src/constants.js +41 -0
  12. package/dist/core/src/corridor/DeviationDetector.d.ts +33 -0
  13. package/dist/core/src/corridor/DeviationDetector.d.ts.map +1 -0
  14. package/dist/core/src/corridor/DeviationDetector.js +83 -0
  15. package/dist/core/src/corridor/DynamicCorridor.d.ts +13 -0
  16. package/dist/core/src/corridor/DynamicCorridor.d.ts.map +1 -0
  17. package/dist/core/src/corridor/DynamicCorridor.js +26 -0
  18. package/dist/core/src/dead-reckoning/DeadReckoning.d.ts +35 -0
  19. package/dist/core/src/dead-reckoning/DeadReckoning.d.ts.map +1 -0
  20. package/dist/core/src/dead-reckoning/DeadReckoning.js +49 -0
  21. package/dist/core/src/directions/DirectionsProvider.d.ts +70 -0
  22. package/dist/core/src/directions/DirectionsProvider.d.ts.map +1 -0
  23. package/dist/core/src/directions/DirectionsProvider.js +7 -0
  24. package/dist/core/src/directions/OSRMDirectionsProvider.d.ts +26 -0
  25. package/dist/core/src/directions/OSRMDirectionsProvider.d.ts.map +1 -0
  26. package/dist/core/src/directions/OSRMDirectionsProvider.js +90 -0
  27. package/dist/core/src/directions/OpenRouteServiceProvider.d.ts +30 -0
  28. package/dist/core/src/directions/OpenRouteServiceProvider.d.ts.map +1 -0
  29. package/dist/core/src/directions/OpenRouteServiceProvider.js +111 -0
  30. package/dist/core/src/directions/ValhallaDirectionsProvider.d.ts +33 -0
  31. package/dist/core/src/directions/ValhallaDirectionsProvider.d.ts.map +1 -0
  32. package/dist/core/src/directions/ValhallaDirectionsProvider.js +155 -0
  33. package/dist/core/src/eta/ETAEngine.d.ts +61 -0
  34. package/dist/core/src/eta/ETAEngine.d.ts.map +1 -0
  35. package/dist/core/src/eta/ETAEngine.js +74 -0
  36. package/dist/core/src/features.d.ts +76 -0
  37. package/dist/core/src/features.d.ts.map +1 -0
  38. package/dist/core/src/features.js +76 -0
  39. package/dist/core/src/geo/bearing.d.ts +11 -0
  40. package/dist/core/src/geo/bearing.d.ts.map +1 -0
  41. package/dist/core/src/geo/bearing.js +25 -0
  42. package/dist/core/src/geo/cumulative.d.ts +9 -0
  43. package/dist/core/src/geo/cumulative.d.ts.map +1 -0
  44. package/dist/core/src/geo/cumulative.js +20 -0
  45. package/dist/core/src/geo/haversine.d.ts +13 -0
  46. package/dist/core/src/geo/haversine.d.ts.map +1 -0
  47. package/dist/core/src/geo/haversine.js +39 -0
  48. package/dist/core/src/geo/projection.d.ts +7 -0
  49. package/dist/core/src/geo/projection.d.ts.map +1 -0
  50. package/dist/core/src/geo/projection.js +17 -0
  51. package/dist/core/src/geofencing/GeofencingEngine.d.ts +93 -0
  52. package/dist/core/src/geofencing/GeofencingEngine.d.ts.map +1 -0
  53. package/dist/core/src/geofencing/GeofencingEngine.js +154 -0
  54. package/dist/core/src/index.d.ts +66 -0
  55. package/dist/core/src/index.d.ts.map +1 -0
  56. package/dist/core/src/index.js +62 -0
  57. package/dist/core/src/kalman/KalmanFilter2D.d.ts +46 -0
  58. package/dist/core/src/kalman/KalmanFilter2D.d.ts.map +1 -0
  59. package/dist/core/src/kalman/KalmanFilter2D.js +77 -0
  60. package/dist/core/src/license/LicenseManager.d.ts +40 -0
  61. package/dist/core/src/license/LicenseManager.d.ts.map +1 -0
  62. package/dist/core/src/license/LicenseManager.js +119 -0
  63. package/dist/core/src/license/verifyP256Signature.d.ts +2 -0
  64. package/dist/core/src/license/verifyP256Signature.d.ts.map +1 -0
  65. package/dist/core/src/license/verifyP256Signature.js +26 -0
  66. package/dist/core/src/off-route/NavigationFSM.d.ts +42 -0
  67. package/dist/core/src/off-route/NavigationFSM.d.ts.map +1 -0
  68. package/dist/core/src/off-route/NavigationFSM.js +56 -0
  69. package/dist/core/src/off-route/OffRouteFSM.d.ts +70 -0
  70. package/dist/core/src/off-route/OffRouteFSM.d.ts.map +1 -0
  71. package/dist/core/src/off-route/OffRouteFSM.js +151 -0
  72. package/dist/core/src/predictor/RouteOffsetPredictor.d.ts +24 -0
  73. package/dist/core/src/predictor/RouteOffsetPredictor.d.ts.map +1 -0
  74. package/dist/core/src/predictor/RouteOffsetPredictor.js +55 -0
  75. package/dist/core/src/progress/InstructionEditor.d.ts +77 -0
  76. package/dist/core/src/progress/InstructionEditor.d.ts.map +1 -0
  77. package/dist/core/src/progress/InstructionEditor.js +151 -0
  78. package/dist/core/src/progress/InstructionResolver.d.ts +25 -0
  79. package/dist/core/src/progress/InstructionResolver.d.ts.map +1 -0
  80. package/dist/core/src/progress/InstructionResolver.js +78 -0
  81. package/dist/core/src/progress/ProgressTracker.d.ts +12 -0
  82. package/dist/core/src/progress/ProgressTracker.d.ts.map +1 -0
  83. package/dist/core/src/progress/ProgressTracker.js +22 -0
  84. package/dist/core/src/renderer/MapRendererAdapter.d.ts +72 -0
  85. package/dist/core/src/renderer/MapRendererAdapter.d.ts.map +1 -0
  86. package/dist/core/src/renderer/MapRendererAdapter.js +19 -0
  87. package/dist/core/src/route-builder/CustomRouteBuilder.d.ts +83 -0
  88. package/dist/core/src/route-builder/CustomRouteBuilder.d.ts.map +1 -0
  89. package/dist/core/src/route-builder/CustomRouteBuilder.js +160 -0
  90. package/dist/core/src/route-plan/RoutePlan.d.ts +38 -0
  91. package/dist/core/src/route-plan/RoutePlan.d.ts.map +1 -0
  92. package/dist/core/src/route-plan/RoutePlan.js +102 -0
  93. package/dist/core/src/session/NavigationSession.d.ts +81 -0
  94. package/dist/core/src/session/NavigationSession.d.ts.map +1 -0
  95. package/dist/core/src/session/NavigationSession.js +115 -0
  96. package/dist/core/src/snapper/ParallelRoadResolver.d.ts +86 -0
  97. package/dist/core/src/snapper/ParallelRoadResolver.d.ts.map +1 -0
  98. package/dist/core/src/snapper/ParallelRoadResolver.js +83 -0
  99. package/dist/core/src/snapper/RouteSnapper.d.ts +38 -0
  100. package/dist/core/src/snapper/RouteSnapper.d.ts.map +1 -0
  101. package/dist/core/src/snapper/RouteSnapper.js +80 -0
  102. package/dist/core/src/voice/VoiceTriggerEngine.d.ts +80 -0
  103. package/dist/core/src/voice/VoiceTriggerEngine.d.ts.map +1 -0
  104. package/dist/core/src/voice/VoiceTriggerEngine.js +108 -0
  105. package/dist/simulator/src/core/NoiseEngine.d.ts +46 -0
  106. package/dist/simulator/src/core/NoiseEngine.d.ts.map +1 -0
  107. package/dist/simulator/src/core/NoiseEngine.js +106 -0
  108. package/dist/simulator/src/core/RouteWalker.d.ts +78 -0
  109. package/dist/simulator/src/core/RouteWalker.d.ts.map +1 -0
  110. package/dist/simulator/src/core/RouteWalker.js +180 -0
  111. package/dist/simulator/src/core/SimulatorEngine.d.ts +53 -0
  112. package/dist/simulator/src/core/SimulatorEngine.d.ts.map +1 -0
  113. package/dist/simulator/src/core/SimulatorEngine.js +298 -0
  114. package/dist/simulator/src/core/types.d.ts +157 -0
  115. package/dist/simulator/src/core/types.d.ts.map +1 -0
  116. package/dist/simulator/src/core/types.js +7 -0
  117. package/dist/simulator/src/fleet/FleetSimulator.d.ts +60 -0
  118. package/dist/simulator/src/fleet/FleetSimulator.d.ts.map +1 -0
  119. package/dist/simulator/src/fleet/FleetSimulator.js +114 -0
  120. package/dist/simulator/src/index.d.ts +28 -0
  121. package/dist/simulator/src/index.d.ts.map +1 -0
  122. package/dist/simulator/src/index.js +29 -0
  123. package/dist/simulator/src/node.d.ts +26 -0
  124. package/dist/simulator/src/node.d.ts.map +1 -0
  125. package/dist/simulator/src/node.js +25 -0
  126. package/dist/simulator/src/react-native/SimulatorControls.d.ts +35 -0
  127. package/dist/simulator/src/react-native/SimulatorControls.d.ts.map +1 -0
  128. package/dist/simulator/src/react-native/SimulatorControls.js +254 -0
  129. package/dist/simulator/src/react-native/useSimulator.d.ts +59 -0
  130. package/dist/simulator/src/react-native/useSimulator.d.ts.map +1 -0
  131. package/dist/simulator/src/react-native/useSimulator.js +100 -0
  132. package/dist/simulator/src/replay/GpxParser.d.ts +40 -0
  133. package/dist/simulator/src/replay/GpxParser.d.ts.map +1 -0
  134. package/dist/simulator/src/replay/GpxParser.js +95 -0
  135. package/dist/simulator/src/replay/SessionRecorder.d.ts +37 -0
  136. package/dist/simulator/src/replay/SessionRecorder.d.ts.map +1 -0
  137. package/dist/simulator/src/replay/SessionRecorder.js +120 -0
  138. package/dist/simulator/src/scenarios/ScenarioInjector.d.ts +55 -0
  139. package/dist/simulator/src/scenarios/ScenarioInjector.d.ts.map +1 -0
  140. package/dist/simulator/src/scenarios/ScenarioInjector.js +150 -0
  141. package/package.json +23 -23
  142. package/src/__tests__/integration/simulator-pipeline.test.ts +233 -0
  143. package/src/core/NoiseEngine.ts +137 -0
  144. package/src/core/RouteWalker.ts +227 -0
  145. package/src/core/SimulatorEngine.ts +364 -0
  146. package/src/core/__tests__/NoiseEngine.test.ts +131 -0
  147. package/src/core/__tests__/RouteWalker.test.ts +139 -0
  148. package/src/core/__tests__/SimulatorEngine.test.ts +317 -0
  149. package/src/core/types.ts +191 -0
  150. package/src/fleet/FleetSimulator.ts +162 -0
  151. package/src/index.ts +54 -0
  152. package/src/node.ts +48 -0
  153. package/src/react-native/SimulatorControls.tsx +473 -0
  154. package/src/react-native/useSimulator.ts +155 -0
  155. package/src/replay/GpxParser.ts +122 -0
  156. package/src/replay/SessionRecorder.ts +138 -0
  157. package/src/replay/__tests__/GpxParser.test.ts +136 -0
  158. package/src/scenarios/ScenarioInjector.ts +170 -0
  159. package/src/scenarios/__tests__/ScenarioInjector.test.ts +171 -0
  160. package/dist/index-i9TY71RY.d.mts +0 -494
  161. package/dist/index-i9TY71RY.d.ts +0 -494
  162. package/dist/index.d.mts +0 -1
  163. package/dist/index.d.ts +0 -1
  164. package/dist/index.js +0 -937
  165. package/dist/index.mjs +0 -929
  166. package/dist/node.d.mts +0 -1
  167. package/dist/node.d.ts +0 -1
  168. package/dist/node.js +0 -937
  169. package/dist/node.mjs +0 -929
  170. package/dist/react-native.d.mts +0 -82
  171. package/dist/react-native.d.ts +0 -82
  172. package/dist/react-native.js +0 -1370
  173. package/dist/react-native.mjs +0 -1360
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Pre-calculated cumulative distance caches.
3
+ */
4
+ import { haversineDistance } from './haversine';
5
+ /** Forward cumulative distances: result[i] = metres from route[0] to route[i]. O(n) build. */
6
+ export function buildForwardCumulativeDistances(route) {
7
+ const cum = new Float64Array(route.length);
8
+ for (let i = 1; i < route.length; i++) {
9
+ cum[i] = cum[i - 1] + haversineDistance(route[i - 1][1], route[i - 1][0], route[i][1], route[i][0]);
10
+ }
11
+ return cum;
12
+ }
13
+ /** Reverse cumulative distances: result[i] = metres from vertex i to the end. O(1) reads. */
14
+ export function buildReverseCumulativeDistances(route) {
15
+ const cum = new Float64Array(route.length);
16
+ for (let i = route.length - 2; i >= 0; i--) {
17
+ cum[i] = cum[i + 1] + haversineDistance(route[i][1], route[i][0], route[i + 1][1], route[i + 1][0]);
18
+ }
19
+ return cum;
20
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Haversine geographic math utilities.
3
+ * ZERO dependencies — pure math.
4
+ */
5
+ /** [longitude, latitude] coordinate */
6
+ export type Coordinate = [number, number];
7
+ /** Haversine distance between two points in metres */
8
+ export declare function haversineDistance(lat1: number, lon1: number, lat2: number, lon2: number): number;
9
+ /** Forward Haversine: compute destination given start, bearing (°), distance (m) */
10
+ export declare function destinationPoint(lat: number, lon: number, brng: number, dist: number): Coordinate;
11
+ /** Bearing between two [lng, lat] coordinates in degrees [0, 360) */
12
+ export declare function getBearingBetweenPoints(c1: Coordinate, c2: Coordinate): number;
13
+ //# sourceMappingURL=haversine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"haversine.d.ts","sourceRoot":"","sources":["../../../../../core/src/geo/haversine.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,uCAAuC;AACvC,MAAM,MAAM,UAAU,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAI1C,sDAAsD;AACtD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAShG;AAED,oFAAoF;AACpF,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,CAgBjG;AAED,qEAAqE;AACrE,wBAAgB,uBAAuB,CAAC,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,UAAU,GAAG,MAAM,CAa9E"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Haversine geographic math utilities.
3
+ * ZERO dependencies — pure math.
4
+ */
5
+ const R_EARTH = 6371000;
6
+ /** Haversine distance between two points in metres */
7
+ export function haversineDistance(lat1, lon1, lat2, lon2) {
8
+ const dLat = (lat2 - lat1) * (Math.PI / 180);
9
+ const dLon = (lon2 - lon1) * (Math.PI / 180);
10
+ const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
11
+ Math.cos(lat1 * (Math.PI / 180)) * Math.cos(lat2 * (Math.PI / 180)) *
12
+ Math.sin(dLon / 2) * Math.sin(dLon / 2);
13
+ const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
14
+ return R_EARTH * c;
15
+ }
16
+ /** Forward Haversine: compute destination given start, bearing (°), distance (m) */
17
+ export function destinationPoint(lat, lon, brng, dist) {
18
+ const angularDist = dist / R_EARTH;
19
+ const brngRad = brng * (Math.PI / 180);
20
+ const latRad = lat * (Math.PI / 180);
21
+ const lonRad = lon * (Math.PI / 180);
22
+ const destLatRad = Math.asin(Math.sin(latRad) * Math.cos(angularDist) +
23
+ Math.cos(latRad) * Math.sin(angularDist) * Math.cos(brngRad));
24
+ const destLonRad = lonRad + Math.atan2(Math.sin(brngRad) * Math.sin(angularDist) * Math.cos(latRad), Math.cos(angularDist) - Math.sin(latRad) * Math.sin(destLatRad));
25
+ return [((destLonRad * 180 / Math.PI) + 540) % 360 - 180, destLatRad * 180 / Math.PI];
26
+ }
27
+ /** Bearing between two [lng, lat] coordinates in degrees [0, 360) */
28
+ export function getBearingBetweenPoints(c1, c2) {
29
+ const lat1 = c1[1] * (Math.PI / 180);
30
+ const lon1 = c1[0] * (Math.PI / 180);
31
+ const lat2 = c2[1] * (Math.PI / 180);
32
+ const lon2 = c2[0] * (Math.PI / 180);
33
+ const y = Math.sin(lon2 - lon1) * Math.cos(lat2);
34
+ const x = Math.cos(lat1) * Math.sin(lat2) -
35
+ Math.sin(lat1) * Math.cos(lat2) * Math.cos(lon2 - lon1);
36
+ let brng = Math.atan2(y, x) * (180 / Math.PI);
37
+ brng = (brng + 360) % 360;
38
+ return brng;
39
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Vector projection utilities for coordinate snapping.
3
+ */
4
+ import type { Coordinate } from './haversine';
5
+ /** Project point p onto line segment [a, b]. Returns the projected coordinate. */
6
+ export declare function projectPointOnSegment(p: Coordinate, a: Coordinate, b: Coordinate): Coordinate;
7
+ //# sourceMappingURL=projection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projection.d.ts","sourceRoot":"","sources":["../../../../../core/src/geo/projection.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,kFAAkF;AAClF,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,UAAU,CAe7F"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Vector projection utilities for coordinate snapping.
3
+ */
4
+ /** Project point p onto line segment [a, b]. Returns the projected coordinate. */
5
+ export function projectPointOnSegment(p, a, b) {
6
+ const [px, py] = p;
7
+ const [ax, ay] = a;
8
+ const [bx, by] = b;
9
+ const dx = bx - ax;
10
+ const dy = by - ay;
11
+ const lenSq = dx * dx + dy * dy;
12
+ if (lenSq === 0)
13
+ return a;
14
+ let t = ((px - ax) * dx + (py - ay) * dy) / lenSq;
15
+ t = Math.max(0, Math.min(1, t));
16
+ return [ax + t * dx, ay + t * dy];
17
+ }
@@ -0,0 +1,93 @@
1
+ /**
2
+ * GeofencingEngine
3
+ *
4
+ * Circular and polygon geofences — zero server dependency.
5
+ * Uses haversine distance for circles and ray-casting for polygons.
6
+ *
7
+ * FEATURE: GEOFENCING
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * const geo = new GeofencingEngine({ dwellThresholdMs: 5000 });
12
+ * geo.addCircle('school-zone', 'School Zone', [2.347, 48.859], 50, { speedLimit: 30 });
13
+ * geo.addPolygon('exam-area', 'Exam District', [[2.34, 48.85], [2.36, 48.85], [2.36, 48.87], [2.34, 48.87]]);
14
+ *
15
+ * engine.on('update', ({ snappedCoord }) => {
16
+ * const events = geo.update(snappedCoord);
17
+ * for (const evt of events) {
18
+ * // evt.name is the human-readable zone name
19
+ * console.log(`${evt.type}: ${evt.name} (${evt.id})`);
20
+ * }
21
+ * });
22
+ * ```
23
+ */
24
+ import type { Coordinate } from '../geo/haversine';
25
+ export type GeofenceType = 'circle' | 'polygon';
26
+ export type GeofenceEventType = 'enter' | 'exit' | 'dwell';
27
+ export interface GeofenceEvent {
28
+ /** Geofence ID that triggered the event */
29
+ id: string;
30
+ /** Human-readable name of the geofence */
31
+ name: string;
32
+ type: GeofenceEventType;
33
+ /** Coordinate that triggered the event */
34
+ coord: Coordinate;
35
+ /** Milliseconds spent inside (for dwell events) */
36
+ dwellMs?: number;
37
+ /** Custom metadata passed at creation */
38
+ meta?: unknown;
39
+ }
40
+ export interface ZoneDefinition {
41
+ id: string;
42
+ name: string;
43
+ type: 'circle' | 'polygon';
44
+ center?: Coordinate;
45
+ radiusMeters?: number;
46
+ coords?: Coordinate[];
47
+ meta?: unknown;
48
+ }
49
+ export interface GeofencingOptions {
50
+ /**
51
+ * Milliseconds a vehicle must remain inside a geofence before a 'dwell' event fires.
52
+ * Default: 10000ms (10 seconds).
53
+ */
54
+ dwellThresholdMs?: number;
55
+ /** Initial zones to register on creation */
56
+ zones?: ZoneDefinition[];
57
+ /** Callback for all geofence events */
58
+ onEvent?: (event: GeofenceEvent) => void;
59
+ }
60
+ export declare class GeofencingEngine {
61
+ private fences;
62
+ private states;
63
+ private readonly options;
64
+ constructor(options?: GeofencingOptions);
65
+ /** Add a circular geofence. Returns the ID. */
66
+ addCircle(id: string, name: string, center: Coordinate, radiusM: number, meta?: unknown): string;
67
+ /**
68
+ * Add a polygon geofence. Coords are [lng, lat] pairs.
69
+ * The polygon is auto-closed (first == last not required).
70
+ */
71
+ addPolygon(id: string, name: string, coords: Coordinate[], meta?: unknown): string;
72
+ /** Remove a geofence by ID */
73
+ remove(id: string): void;
74
+ /** Remove all geofences */
75
+ clear(): void;
76
+ /** List all registered geofence IDs */
77
+ listIds(): string[];
78
+ /**
79
+ * Feed the current coordinate and receive a (possibly empty) list of events.
80
+ * Call this on every NavCore state update.
81
+ */
82
+ update(coord: Coordinate): GeofenceEvent[];
83
+ /** Check if a coordinate is currently inside a named geofence */
84
+ isInside(id: string, coord: Coordinate): boolean;
85
+ private contains;
86
+ /**
87
+ * Ray-casting point-in-polygon algorithm.
88
+ * Works in [lng, lat] space (sufficient for small areas; use projected
89
+ * coords for very large polygons spanning many degrees).
90
+ */
91
+ private pointInPolygon;
92
+ }
93
+ //# sourceMappingURL=GeofencingE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M,CAAoC;IAClD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAsC;gBAElD,OAAO,CAAC,EAAE,iBAAiB;IAgBvC,+CAA+C;IAC/C,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM;IAMhG;;;OAGG;IACH,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM;IAOlF,8BAA8B;IAC9B,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAKxB,2BAA2B;IAC3B,KAAK,IAAI,IAAI;IAKb,uCAAuC;IACvC,OAAO,IAAI,MAAM,EAAE;IAMnB;;;OAGG;IACH,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,aAAa,EAAE;IA2C1C,iEAAiE;IACjE,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO;IAQhD,OAAO,CAAC,QAAQ;IAWhB;;;;OAIG;IACH,OAAO,CAAC,cAAc;CAkBvB"}
@@ -0,0 +1,154 @@
1
+ /**
2
+ * GeofencingEngine
3
+ *
4
+ * Circular and polygon geofences — zero server dependency.
5
+ * Uses haversine distance for circles and ray-casting for polygons.
6
+ *
7
+ * FEATURE: GEOFENCING
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * const geo = new GeofencingEngine({ dwellThresholdMs: 5000 });
12
+ * geo.addCircle('school-zone', 'School Zone', [2.347, 48.859], 50, { speedLimit: 30 });
13
+ * geo.addPolygon('exam-area', 'Exam District', [[2.34, 48.85], [2.36, 48.85], [2.36, 48.87], [2.34, 48.87]]);
14
+ *
15
+ * engine.on('update', ({ snappedCoord }) => {
16
+ * const events = geo.update(snappedCoord);
17
+ * for (const evt of events) {
18
+ * // evt.name is the human-readable zone name
19
+ * console.log(`${evt.type}: ${evt.name} (${evt.id})`);
20
+ * }
21
+ * });
22
+ * ```
23
+ */
24
+ import { haversineDistance } from '../geo/haversine';
25
+ const DEFAULTS = {
26
+ dwellThresholdMs: 10000,
27
+ };
28
+ export class GeofencingEngine {
29
+ constructor(options) {
30
+ this.fences = new Map();
31
+ this.states = new Map();
32
+ this.options = { ...DEFAULTS, ...options };
33
+ if (this.options.zones) {
34
+ for (const z of this.options.zones) {
35
+ if (z.type === 'circle' && z.center && z.radiusMeters) {
36
+ this.addCircle(z.id, z.name, z.center, z.radiusMeters, z.meta);
37
+ }
38
+ else if (z.type === 'polygon' && z.coords) {
39
+ this.addPolygon(z.id, z.name, z.coords, z.meta);
40
+ }
41
+ }
42
+ }
43
+ }
44
+ // ── Registration ────────────────────────────────────────────────────────────
45
+ /** Add a circular geofence. Returns the ID. */
46
+ addCircle(id, name, center, radiusM, meta) {
47
+ this.fences.set(id, { kind: 'circle', id, name, center, radiusM, meta });
48
+ this.states.set(id, { inside: false, enteredAtMs: null });
49
+ return id;
50
+ }
51
+ /**
52
+ * Add a polygon geofence. Coords are [lng, lat] pairs.
53
+ * The polygon is auto-closed (first == last not required).
54
+ */
55
+ addPolygon(id, name, coords, meta) {
56
+ if (coords.length < 3)
57
+ throw new Error('[Geofencing] Polygon requires at least 3 coordinates');
58
+ this.fences.set(id, { kind: 'polygon', id, name, coords, meta });
59
+ this.states.set(id, { inside: false, enteredAtMs: null });
60
+ return id;
61
+ }
62
+ /** Remove a geofence by ID */
63
+ remove(id) {
64
+ this.fences.delete(id);
65
+ this.states.delete(id);
66
+ }
67
+ /** Remove all geofences */
68
+ clear() {
69
+ this.fences.clear();
70
+ this.states.clear();
71
+ }
72
+ /** List all registered geofence IDs */
73
+ listIds() {
74
+ return Array.from(this.fences.keys());
75
+ }
76
+ // ── Update ──────────────────────────────────────────────────────────────────
77
+ /**
78
+ * Feed the current coordinate and receive a (possibly empty) list of events.
79
+ * Call this on every NavCore state update.
80
+ */
81
+ update(coord) {
82
+ if (!coord)
83
+ return [];
84
+ const events = [];
85
+ const now = Date.now();
86
+ for (const [id, fence] of this.fences) {
87
+ const state = this.states.get(id);
88
+ const isNowInside = this.contains(fence, coord);
89
+ if (!state.inside && isNowInside) {
90
+ // Enter
91
+ state.inside = true;
92
+ state.enteredAtMs = now;
93
+ const event = { id, name: fence.name, type: 'enter', coord, meta: fence.meta };
94
+ events.push(event);
95
+ this.options.onEvent?.(event);
96
+ }
97
+ else if (state.inside && !isNowInside) {
98
+ // Exit
99
+ state.inside = false;
100
+ const dwellMs = state.enteredAtMs ? now - state.enteredAtMs : 0;
101
+ state.enteredAtMs = null;
102
+ const event = { id, name: fence.name, type: 'exit', coord, dwellMs, meta: fence.meta };
103
+ events.push(event);
104
+ this.options.onEvent?.(event);
105
+ }
106
+ else if (state.inside && state.enteredAtMs !== null) {
107
+ // Dwell check
108
+ const dwellMs = now - state.enteredAtMs;
109
+ if (dwellMs >= this.options.dwellThresholdMs) {
110
+ const event = { id, name: fence.name, type: 'dwell', coord, dwellMs, meta: fence.meta };
111
+ events.push(event);
112
+ this.options.onEvent?.(event);
113
+ // Reset so dwell fires every threshold interval
114
+ state.enteredAtMs = now;
115
+ }
116
+ }
117
+ }
118
+ return events;
119
+ }
120
+ /** Check if a coordinate is currently inside a named geofence */
121
+ isInside(id, coord) {
122
+ const fence = this.fences.get(id);
123
+ if (!fence)
124
+ return false;
125
+ return this.contains(fence, coord);
126
+ }
127
+ // ── Geometry ────────────────────────────────────────────────────────────────
128
+ contains(fence, coord) {
129
+ if (fence.kind === 'circle') {
130
+ const distM = haversineDistance(coord[1], coord[0], fence.center[1], fence.center[0]);
131
+ return distM <= fence.radiusM;
132
+ }
133
+ return this.pointInPolygon(coord, fence.coords);
134
+ }
135
+ /**
136
+ * Ray-casting point-in-polygon algorithm.
137
+ * Works in [lng, lat] space (sufficient for small areas; use projected
138
+ * coords for very large polygons spanning many degrees).
139
+ */
140
+ pointInPolygon(point, polygon) {
141
+ const [px, py] = point;
142
+ let inside = false;
143
+ const n = polygon.length;
144
+ for (let i = 0, j = n - 1; i < n; j = i++) {
145
+ const [xi, yi] = polygon[i];
146
+ const [xj, yj] = polygon[j];
147
+ const intersects = yi > py !== yj > py &&
148
+ px < ((xj - xi) * (py - yi)) / (yj - yi) + xi;
149
+ if (intersects)
150
+ inside = !inside;
151
+ }
152
+ return inside;
153
+ }
154
+ }
@@ -0,0 +1,66 @@
1
+ /**
2
+ * @navcore/core — Navigation Engine
3
+ *
4
+ * Navigation logic is pure TypeScript; license verification includes a portable P-256 fallback.
5
+ * Works in Node.js, browsers, React Native, and CI/CD.
6
+ *
7
+ * Tier model:
8
+ * CORE — free / MIT. Import from '@ingissa/navcore-core/core'
9
+ * PRO — commercial. Import from '@ingissa/navcore-core/pro'
10
+ * Full engine (NavCore class) — available from '@ingissa/navcore-core'
11
+ *
12
+ * @packageDocumentation
13
+ */
14
+ export { haversineDistance, destinationPoint, getBearingBetweenPoints as geoGetBearing } from './geo/haversine';
15
+ export { normalizeAngle, getBearingBetweenPoints, interpolatePoint } from './geo/bearing';
16
+ export { projectPointOnSegment } from './geo/projection';
17
+ export { buildForwardCumulativeDistances, buildReverseCumulativeDistances } from './geo/cumulative';
18
+ export { KalmanFilter2D, kalmanUpdate2D } from './kalman/KalmanFilter2D';
19
+ export type { Kalman2DState } from './kalman/KalmanFilter2D';
20
+ export { RouteSnapper } from './snapper/RouteSnapper';
21
+ export type { SnapResult, SnapperOptions } from './snapper/RouteSnapper';
22
+ export { ParallelRoadResolver } from './snapper/ParallelRoadResolver';
23
+ export type { SnapCandidate, ResolvedCandidate, ParallelRoadResolverOptions, } from './snapper/ParallelRoadResolver';
24
+ export { DeadReckoningEngine, computeDeadReckoningOnRoute } from './dead-reckoning/DeadReckoning';
25
+ export { DeviationDetector } from './corridor/DeviationDetector';
26
+ export { calculateDynamicCorridor } from './corridor/DynamicCorridor';
27
+ export { calculateRobustBearing, blendBearing, getSpeedAdaptiveAlpha, applyBearingSmoothing, } from './bearing/BearingEngine';
28
+ export { validateProgressUpdate } from './progress/ProgressTracker';
29
+ export { resolveNextInstruction } from './progress/InstructionResolver';
30
+ export type { NavInstruction } from './progress/InstructionResolver';
31
+ export { InstructionEditor } from './progress/InstructionEditor';
32
+ export type { RichInstruction, InstructionType } from './progress/InstructionEditor';
33
+ export { advancePredictor, applyGpsCorrection, pointAtOffset } from './predictor/RouteOffsetPredictor';
34
+ export { NavigationFSM } from './off-route/NavigationFSM';
35
+ export type { NavLifecycleState, LifecycleEvent, LifecycleContext } from './off-route/NavigationFSM';
36
+ export { OffRouteFSM } from './off-route/OffRouteFSM';
37
+ export type { OffRouteState, OffRouteEvent, OffRouteContext, TempRoute, RejoinTarget } from './off-route/OffRouteFSM';
38
+ export { CustomRouteBuilder } from './route-builder/CustomRouteBuilder';
39
+ export type { CustomWaypoint, WaypointOptions, BuildOptions } from './route-builder/CustomRouteBuilder';
40
+ export type { DirectionsProvider, DirectionsOptions, DirectionsResult, DirectionsLeg, DirectionsStep, DirectionsManeuver, } from './directions/DirectionsProvider';
41
+ export { OSRMDirectionsProvider } from './directions/OSRMDirectionsProvider';
42
+ export type { OSRMConfig } from './directions/OSRMDirectionsProvider';
43
+ export { ValhallaDirectionsProvider } from './directions/ValhallaDirectionsProvider';
44
+ export type { ValhallaConfig, ValhallaCostingModel } from './directions/ValhallaDirectionsProvider';
45
+ export { OpenRouteServiceProvider } from './directions/OpenRouteServiceProvider';
46
+ export type { ORSConfig, ORSProfile } from './directions/OpenRouteServiceProvider';
47
+ export { createRoutePlan } from './route-plan/RoutePlan';
48
+ export type { RoutePlan, CreateRoutePlanOptions } from './route-plan/RoutePlan';
49
+ export { NavigationSession, createNavigationSession } from './session/NavigationSession';
50
+ export type { NavigationSessionOptions, NavigationSessionEventMap, NavigationRequest, OriginDestinationNavigationRequest, CoordinatesNavigationRequest, } from './session/NavigationSession';
51
+ export type { MapRendererAdapter, RouteStyle, VehicleStyle, CameraOptions, } from './renderer/MapRendererAdapter';
52
+ export { VoiceTriggerEngine } from './voice/VoiceTriggerEngine';
53
+ export type { VoiceCue, VoicePriority, VoiceTriggerOptions } from './voice/VoiceTriggerEngine';
54
+ export { ETAEngine } from './eta/ETAEngine';
55
+ export type { ETAResult, ETAOptions } from './eta/ETAEngine';
56
+ export { GeofencingEngine } from './geofencing/GeofencingEngine';
57
+ export type { GeofenceEvent, GeofenceEventType, GeofenceType, GeofencingOptions, ZoneDefinition, } from './geofencing/GeofencingEngine';
58
+ export { LicenseManager } from './license/LicenseManager';
59
+ export type { LicenseStatus, LicensePayload } from './license/LicenseManager';
60
+ export * as Constants from './constants';
61
+ export { FEATURES } from './features';
62
+ export type { FeatureKey } from './features';
63
+ export { NavCore } from './NavCore';
64
+ export type { NavCoreOptions, NavGpsUpdate, NavCoreState } from './NavCore';
65
+ export type { Coordinate } from './geo/haversine';
66
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../core/src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,uBAAuB,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChH,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,+BAA+B,EAAE,+BAA+B,EAAE,MAAM,kBAAkB,CAAC;AAGpG,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzE,YAAY,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAG7D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAG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AAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG9E,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG7C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAG5E,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * @navcore/core — Navigation Engine
3
+ *
4
+ * Navigation logic is pure TypeScript; license verification includes a portable P-256 fallback.
5
+ * Works in Node.js, browsers, React Native, and CI/CD.
6
+ *
7
+ * Tier model:
8
+ * CORE — free / MIT. Import from '@ingissa/navcore-core/core'
9
+ * PRO — commercial. Import from '@ingissa/navcore-core/pro'
10
+ * Full engine (NavCore class) — available from '@ingissa/navcore-core'
11
+ *
12
+ * @packageDocumentation
13
+ */
14
+ // ── CORE — Geo Utilities (free) ───────────────────────────────────────────────
15
+ export { haversineDistance, destinationPoint, getBearingBetweenPoints as geoGetBearing } from './geo/haversine';
16
+ export { normalizeAngle, getBearingBetweenPoints, interpolatePoint } from './geo/bearing';
17
+ export { projectPointOnSegment } from './geo/projection';
18
+ export { buildForwardCumulativeDistances, buildReverseCumulativeDistances } from './geo/cumulative';
19
+ // ── CORE — Kalman Filter (free) ───────────────────────────────────────────────
20
+ export { KalmanFilter2D, kalmanUpdate2D } from './kalman/KalmanFilter2D';
21
+ // ── CORE — Basic Route Snapper (free) ─────────────────────────────────────────
22
+ export { RouteSnapper } from './snapper/RouteSnapper';
23
+ // ── PRO — Parallel Road Resolver (license required) ───────────────────────────
24
+ export { ParallelRoadResolver } from './snapper/ParallelRoadResolver';
25
+ // ── PRO — Dead Reckoning (license required) ───────────────────────────────────
26
+ export { DeadReckoningEngine, computeDeadReckoningOnRoute } from './dead-reckoning/DeadReckoning';
27
+ // ── PRO — Corridor & Deviation (license required) ─────────────────────────────
28
+ export { DeviationDetector } from './corridor/DeviationDetector';
29
+ export { calculateDynamicCorridor } from './corridor/DynamicCorridor';
30
+ // ── PRO — Bearing Engine (license required) ───────────────────────────────────
31
+ export { calculateRobustBearing, blendBearing, getSpeedAdaptiveAlpha, applyBearingSmoothing, } from './bearing/BearingEngine';
32
+ // ── PRO — Progress & Instructions (license required) ──────────────────────────
33
+ export { validateProgressUpdate } from './progress/ProgressTracker';
34
+ export { resolveNextInstruction } from './progress/InstructionResolver';
35
+ // ── PRO — Instruction Editor (license required) ───────────────────────────────
36
+ export { InstructionEditor } from './progress/InstructionEditor';
37
+ // ── PRO — Route Offset Predictor (license required) ───────────────────────────
38
+ export { advancePredictor, applyGpsCorrection, pointAtOffset } from './predictor/RouteOffsetPredictor';
39
+ // ── PRO — Navigation FSM (license required) ───────────────────────────────────
40
+ export { NavigationFSM } from './off-route/NavigationFSM';
41
+ export { OffRouteFSM } from './off-route/OffRouteFSM';
42
+ // ── CORE — Route Builder (free) ───────────────────────────────────────────────
43
+ export { CustomRouteBuilder } from './route-builder/CustomRouteBuilder';
44
+ export { OSRMDirectionsProvider } from './directions/OSRMDirectionsProvider';
45
+ export { ValhallaDirectionsProvider } from './directions/ValhallaDirectionsProvider';
46
+ export { OpenRouteServiceProvider } from './directions/OpenRouteServiceProvider';
47
+ // ── Route Plan — provider response → navigation-ready engine input ───────────
48
+ export { createRoutePlan } from './route-plan/RoutePlan';
49
+ // ── Navigation Session — ergonomic provider → engine workflow ───────────────
50
+ export { NavigationSession, createNavigationSession } from './session/NavigationSession';
51
+ // ── PRO — Voice Trigger Engine (license required) ─────────────────────────────
52
+ export { VoiceTriggerEngine } from './voice/VoiceTriggerEngine';
53
+ // ── PRO — ETA Engine (license required) ───────────────────────────────────────
54
+ export { ETAEngine } from './eta/ETAEngine';
55
+ // ── PRO — Geofencing Engine (license required) ────────────────────────────────
56
+ export { GeofencingEngine } from './geofencing/GeofencingEngine';
57
+ export { LicenseManager } from './license/LicenseManager';
58
+ // ── CORE — Constants & Features (free) ────────────────────────────────────────
59
+ export * as Constants from './constants';
60
+ export { FEATURES } from './features';
61
+ // ── Main Orchestrator (full engine — license-gated internally) ────────────────
62
+ export { NavCore } from './NavCore';
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Module 1: KalmanFilter2D
3
+ * GPS noise reduction using a 2D Kalman filter.
4
+ * ZERO dependencies — pure math.
5
+ */
6
+ export interface Kalman2DState {
7
+ x: number;
8
+ y: number;
9
+ vx: number;
10
+ vy: number;
11
+ P: number;
12
+ }
13
+ /**
14
+ * Perform a single Kalman update step.
15
+ *
16
+ * @param state Current state (mutated in place for perf)
17
+ * @param measX Measured longitude
18
+ * @param measY Measured latitude
19
+ * @param accuracy GPS accuracy in metres (used to scale R)
20
+ * @param dt Time delta in seconds
21
+ * @param Q Process noise (default 0.00001)
22
+ * @param rBase Measurement noise base (default 0.00005)
23
+ * @returns Updated state
24
+ */
25
+ export declare function kalmanUpdate2D(state: Kalman2DState, measX: number, measY: number, accuracy: number, dt: number, Q?: number, rBase?: number): Kalman2DState;
26
+ /**
27
+ * KalmanFilter2D class wrapper for stateful usage.
28
+ */
29
+ export declare class KalmanFilter2D {
30
+ private state;
31
+ private readonly Q;
32
+ private readonly rBase;
33
+ private lastTimestamp;
34
+ constructor(Q?: number, rBase?: number);
35
+ /** Initialize with a known position */
36
+ init(lng: number, lat: number, timestamp: number): void;
37
+ /** Process a GPS measurement, returns filtered [lng, lat] */
38
+ update(lng: number, lat: number, accuracy: number, timestamp: number): [number, number];
39
+ /** Get current filtered position */
40
+ getPosition(): [number, number];
41
+ /** Get the internal state for inspection/serialization */
42
+ getState(): Kalman2DState;
43
+ /** Reset the filter */
44
+ reset(): void;
45
+ }
46
+ //# sourceMappingURL=KalmanFilter2D.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KalmanFilter2D.d.ts","sourceRoot":"","sources":["../../../../../core/src/kalman/KalmanFilter2D.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,aAAa;IAC5B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,CAAC,EAAE,MAAM,CAAC;CACX;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,aAAa,EACpB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,MAAM,EACV,CAAC,GAAE,MAAgB,EACnB,KAAK,GAAE,MAAgB,GACtB,aAAa,CAyBf;AAED;;GAEG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,KAAK,CAAgB;IAC7B,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAS;IAC3B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,aAAa,CAAa;gBAEtB,CAAC,GAAE,MAAgB,EAAE,KAAK,GAAE,MAAgB;IAMxD,uCAAuC;IACvC,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;IAKvD,6DAA6D;IAC7D,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAavF,oCAAoC;IACpC,WAAW,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;IAI/B,0DAA0D;IAC1D,QAAQ,IAAI,aAAa;IAIzB,uBAAuB;IACvB,KAAK,IAAI,IAAI;CAId"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Module 1: KalmanFilter2D
3
+ * GPS noise reduction using a 2D Kalman filter.
4
+ * ZERO dependencies — pure math.
5
+ */
6
+ /**
7
+ * Perform a single Kalman update step.
8
+ *
9
+ * @param state Current state (mutated in place for perf)
10
+ * @param measX Measured longitude
11
+ * @param measY Measured latitude
12
+ * @param accuracy GPS accuracy in metres (used to scale R)
13
+ * @param dt Time delta in seconds
14
+ * @param Q Process noise (default 0.00001)
15
+ * @param rBase Measurement noise base (default 0.00005)
16
+ * @returns Updated state
17
+ */
18
+ export function kalmanUpdate2D(state, measX, measY, accuracy, dt, Q = 0.00001, rBase = 0.00005) {
19
+ // Predict
20
+ state.x += state.vx * dt;
21
+ state.y += state.vy * dt;
22
+ state.P += Q;
23
+ // Measurement noise: higher accuracy = lower R
24
+ const R = rBase * Math.max(1, accuracy / 5);
25
+ // Update
26
+ const K = state.P / (state.P + R);
27
+ const innovX = measX - state.x;
28
+ const innovY = measY - state.y;
29
+ state.x += K * innovX;
30
+ state.y += K * innovY;
31
+ if (dt > 0) {
32
+ state.vx = innovX / dt * K;
33
+ state.vy = innovY / dt * K;
34
+ }
35
+ state.P = (1 - K) * state.P;
36
+ return state;
37
+ }
38
+ /**
39
+ * KalmanFilter2D class wrapper for stateful usage.
40
+ */
41
+ export class KalmanFilter2D {
42
+ constructor(Q = 0.00001, rBase = 0.00005) {
43
+ this.lastTimestamp = 0;
44
+ this.Q = Q;
45
+ this.rBase = rBase;
46
+ this.state = { x: 0, y: 0, vx: 0, vy: 0, P: 1 };
47
+ }
48
+ /** Initialize with a known position */
49
+ init(lng, lat, timestamp) {
50
+ this.state = { x: lng, y: lat, vx: 0, vy: 0, P: 1 };
51
+ this.lastTimestamp = timestamp;
52
+ }
53
+ /** Process a GPS measurement, returns filtered [lng, lat] */
54
+ update(lng, lat, accuracy, timestamp) {
55
+ if (this.lastTimestamp === 0) {
56
+ this.init(lng, lat, timestamp);
57
+ return [lng, lat];
58
+ }
59
+ const dt = Math.max(0.001, (timestamp - this.lastTimestamp) / 1000);
60
+ this.lastTimestamp = timestamp;
61
+ kalmanUpdate2D(this.state, lng, lat, accuracy, dt, this.Q, this.rBase);
62
+ return [this.state.x, this.state.y];
63
+ }
64
+ /** Get current filtered position */
65
+ getPosition() {
66
+ return [this.state.x, this.state.y];
67
+ }
68
+ /** Get the internal state for inspection/serialization */
69
+ getState() {
70
+ return { ...this.state };
71
+ }
72
+ /** Reset the filter */
73
+ reset() {
74
+ this.state = { x: 0, y: 0, vx: 0, vy: 0, P: 1 };
75
+ this.lastTimestamp = 0;
76
+ }
77
+ }