@twinmatrix/spatialverse-sdk-web 0.0.2 → 0.0.4
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/lib/cjs/index.js +9 -9
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js +213 -294
- package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js +40 -41
- package/lib/cjs/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/3DMap/MainMap.js +170 -196
- package/lib/cjs/meta-atlas-sdk/3DMap/MainMap.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js +167 -215
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js +28 -30
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js +861 -1170
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js +166 -159
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/interfaces.js +6 -6
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/interfaces.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js +6 -6
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routeLayers.js +3 -3
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routeLayers.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js +523 -610
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js +149 -154
- package/lib/cjs/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/customStyles.js +2 -2
- package/lib/cjs/meta-atlas-sdk/customStyles.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/customerLayer.js +15 -29
- package/lib/cjs/meta-atlas-sdk/customerLayer.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/customerLayerVariant.js +5 -5
- package/lib/cjs/meta-atlas-sdk/customerLayerVariant.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/meta-atlas-sdk.js +809 -1033
- package/lib/cjs/meta-atlas-sdk/meta-atlas-sdk.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/utils/helpers.js +32 -49
- package/lib/cjs/meta-atlas-sdk/utils/helpers.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/utils/local-storage.js +21 -34
- package/lib/cjs/meta-atlas-sdk/utils/local-storage.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/utils/mapobjects-store.js +6 -6
- package/lib/cjs/meta-atlas-sdk/utils/mapobjects-store.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/utils/routing-store.js +6 -6
- package/lib/cjs/meta-atlas-sdk/utils/routing-store.js.map +1 -1
- package/lib/cjs/meta-atlas-sdk/utils/routing-visualizer/index.js +363 -491
- package/lib/cjs/meta-atlas-sdk/utils/routing-visualizer/index.js.map +1 -1
- package/lib/cjs/react/MetaAtlasMap.js +127 -0
- package/lib/cjs/react/MetaAtlasMap.js.map +1 -0
- package/lib/cjs/react/hooks/useDrawing/index.js +17 -18
- package/lib/cjs/react/hooks/useDrawing/index.js.map +1 -1
- package/lib/cjs/react/hooks/useFocus/index.js +48 -55
- package/lib/cjs/react/hooks/useFocus/index.js.map +1 -1
- package/lib/cjs/react/hooks/useMapEvents/index.js +40 -47
- package/lib/cjs/react/hooks/useMapEvents/index.js.map +1 -1
- package/lib/cjs/react/hooks/useMapOverlays/index.js +20 -21
- package/lib/cjs/react/hooks/useMapOverlays/index.js.map +1 -1
- package/lib/cjs/react/hooks/useMetaAtlas/index.js +77 -95
- package/lib/cjs/react/hooks/useMetaAtlas/index.js.map +1 -1
- package/lib/cjs/react/hooks/useMetaAtlas.js +78 -96
- package/lib/cjs/react/hooks/useMetaAtlas.js.map +1 -1
- package/lib/cjs/react/hooks/useRouting/index.js +21 -20
- package/lib/cjs/react/hooks/useRouting/index.js.map +1 -1
- package/lib/cjs/react/hooks/useSearch/index.js +35 -34
- package/lib/cjs/react/hooks/useSearch/index.js.map +1 -1
- package/lib/cjs/react/hooks/useStampRally/index.js +26 -23
- package/lib/cjs/react/hooks/useStampRally/index.js.map +1 -1
- package/lib/cjs/react/hooks/useStampRally/utils.js +2 -2
- package/lib/cjs/react/hooks/useStampRally/utils.js.map +1 -1
- package/lib/cjs/react/index.js +31 -31
- package/lib/cjs/react/index.js.map +1 -1
- package/lib/cjs/react/stores/useMapDataStore.js +47 -62
- package/lib/cjs/react/stores/useMapDataStore.js.map +1 -1
- package/lib/cjs/react/stores/useMetaAtlasStore.js +27 -40
- package/lib/cjs/react/stores/useMetaAtlasStore.js.map +1 -1
- package/lib/esm/index.js +3 -7
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js +4 -3
- package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/CustomThreeJsWrapper.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js +14 -12
- package/lib/esm/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/utils.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/3DMap/MainMap.js +204 -200
- package/lib/esm/meta-atlas-sdk/3DMap/MainMap.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js +6 -6
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetch-published-json.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js +4 -3
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/fetchMapObjectsData.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js +53 -42
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/meta-atlas-sdk-core.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js +18 -16
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/index.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js +3 -3
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/mapObjectsHelper.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js +73 -79
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/routing-helpers.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js +16 -15
- package/lib/esm/meta-atlas-sdk/MetaAtlasCore/routing-core/utils.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/customerLayer.js +4 -1
- package/lib/esm/meta-atlas-sdk/customerLayer.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/meta-atlas-sdk.js +148 -124
- package/lib/esm/meta-atlas-sdk/meta-atlas-sdk.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/utils/helpers.js +4 -2
- package/lib/esm/meta-atlas-sdk/utils/helpers.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/utils/local-storage.js +6 -1
- package/lib/esm/meta-atlas-sdk/utils/local-storage.js.map +1 -1
- package/lib/esm/meta-atlas-sdk/utils/routing-visualizer/index.js +115 -109
- package/lib/esm/meta-atlas-sdk/utils/routing-visualizer/index.js.map +1 -1
- package/lib/esm/react/MetaAtlasMap.js +120 -0
- package/lib/esm/react/MetaAtlasMap.js.map +1 -0
- package/lib/esm/react/hooks/useDrawing/index.js +2 -2
- package/lib/esm/react/hooks/useDrawing/index.js.map +1 -1
- package/lib/esm/react/hooks/useFocus/index.js +4 -3
- package/lib/esm/react/hooks/useFocus/index.js.map +1 -1
- package/lib/esm/react/hooks/useMapEvents/index.js +9 -6
- package/lib/esm/react/hooks/useMapEvents/index.js.map +1 -1
- package/lib/esm/react/hooks/useMapOverlays/index.js +2 -2
- package/lib/esm/react/hooks/useMapOverlays/index.js.map +1 -1
- package/lib/esm/react/hooks/useMetaAtlas/index.js +162 -60
- package/lib/esm/react/hooks/useMetaAtlas/index.js.map +1 -1
- package/lib/esm/react/hooks/useMetaAtlas.js +162 -60
- package/lib/esm/react/hooks/useMetaAtlas.js.map +1 -1
- package/lib/esm/react/hooks/useRouting/index.js +2 -2
- package/lib/esm/react/hooks/useRouting/index.js.map +1 -1
- package/lib/esm/react/hooks/useSearch/index.js +2 -2
- package/lib/esm/react/hooks/useSearch/index.js.map +1 -1
- package/lib/esm/react/hooks/useStampRally/index.js +15 -12
- package/lib/esm/react/hooks/useStampRally/index.js.map +1 -1
- package/lib/esm/react/hooks/useStampRally/utils.js +1 -1
- package/lib/esm/react/hooks/useStampRally/utils.js.map +1 -1
- package/lib/esm/react/index.js +11 -15
- package/lib/esm/react/index.js.map +1 -1
- package/lib/esm/react/stores/useMapDataStore.js +17 -21
- package/lib/esm/react/stores/useMapDataStore.js.map +1 -1
- package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraSync.d.ts +30 -0
- package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraSync.d.ts.map +1 -0
- package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraUtils.d.ts +5 -0
- package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/CameraUtils.d.ts.map +1 -0
- package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/constants.d.ts +21 -0
- package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/constants.d.ts.map +1 -0
- package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/suncalc.d.ts +27 -0
- package/lib/types/meta-atlas-sdk/3DMap/CustomThreeJsWrapper/utility/suncalc.d.ts.map +1 -0
- package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/draw_marker.d.ts +18 -0
- package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/draw_marker.d.ts.map +1 -0
- package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/marker_select.d.ts +37 -0
- package/lib/types/meta-atlas-sdk/mapbox_draw_custom_modes/marker_select.d.ts.map +1 -0
- package/package.json +10 -7
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
2
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
3
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
1
4
|
import { cloneDeep } from 'lodash';
|
|
2
5
|
import maplibregl from 'maplibre-gl';
|
|
3
6
|
import { point as turfPoint, point } from '@turf/helpers';
|
|
@@ -6,34 +9,112 @@ import { nearestPointOnLine } from "@turf/nearest-point-on-line";
|
|
|
6
9
|
// import { distance } from "@turf/distance";
|
|
7
10
|
import * as turf from '@turf/turf';
|
|
8
11
|
import { transformTranslate } from "@turf/transform-translate";
|
|
9
|
-
import { DISTANCE_UNIT, WALK_SPEED, RouteDimension } from
|
|
10
|
-
import { ManeuverType, createRoute, generateInstructions, generateOverviewSegment, getFeaturesForPatch, getLineStringFeaturesOfRouteSegment, getPatch, highlightRouteSegment, isOverviewSegment } from
|
|
11
|
-
import { routeAnimateLayers, routeLayers } from
|
|
12
|
+
import { DISTANCE_UNIT, WALK_SPEED, RouteDimension } from "../../MetaAtlasCore/routing-core/interfaces.js";
|
|
13
|
+
import { ManeuverType, createRoute, generateInstructions, generateOverviewSegment, getFeaturesForPatch, getLineStringFeaturesOfRouteSegment, getPatch, highlightRouteSegment, isOverviewSegment } from "../../MetaAtlasCore/routing-core/routing-helpers.js";
|
|
14
|
+
import { routeAnimateLayers, routeLayers } from "../../MetaAtlasCore/routing-core/routeLayers.js";
|
|
12
15
|
import { lineString } from '@turf/turf';
|
|
13
|
-
import useRouteDataStore from
|
|
16
|
+
import useRouteDataStore from "../routing-store.js";
|
|
14
17
|
export class RoutingVisualizer {
|
|
15
|
-
// Routing
|
|
16
|
-
routeSourceName = 'routeGeojson';
|
|
17
|
-
patchFeatureCollection = {
|
|
18
|
-
type: 'FeatureCollection',
|
|
19
|
-
features: []
|
|
20
|
-
};
|
|
21
|
-
highlightedSegmentNumber = -1;
|
|
22
|
-
currentPatchNumber = -1;
|
|
23
|
-
|
|
24
|
-
// Routing animation
|
|
25
|
-
animateRouteSourceName = 'routeAnimateGeojson';
|
|
26
|
-
animationFrameID = -1;
|
|
27
|
-
animateRouteSegmentFeatureCollection = {
|
|
28
|
-
type: 'FeatureCollection',
|
|
29
|
-
features: []
|
|
30
|
-
};
|
|
31
|
-
animationStartTime = 0;
|
|
32
|
-
end = {
|
|
33
|
-
from: 0,
|
|
34
|
-
to: 0
|
|
35
|
-
};
|
|
36
18
|
constructor(sdk) {
|
|
19
|
+
// Routing
|
|
20
|
+
_defineProperty(this, "routeSourceName", 'routeGeojson');
|
|
21
|
+
_defineProperty(this, "patchFeatureCollection", {
|
|
22
|
+
type: 'FeatureCollection',
|
|
23
|
+
features: []
|
|
24
|
+
});
|
|
25
|
+
_defineProperty(this, "highlightedSegmentNumber", -1);
|
|
26
|
+
_defineProperty(this, "currentPatchNumber", -1);
|
|
27
|
+
// Routing animation
|
|
28
|
+
_defineProperty(this, "animateRouteSourceName", 'routeAnimateGeojson');
|
|
29
|
+
_defineProperty(this, "animationFrameID", -1);
|
|
30
|
+
_defineProperty(this, "animateRouteSegmentFeatureCollection", {
|
|
31
|
+
type: 'FeatureCollection',
|
|
32
|
+
features: []
|
|
33
|
+
});
|
|
34
|
+
_defineProperty(this, "animationStartTime", 0);
|
|
35
|
+
_defineProperty(this, "end", {
|
|
36
|
+
from: 0,
|
|
37
|
+
to: 0
|
|
38
|
+
});
|
|
39
|
+
_defineProperty(this, "animateHighlightedRouteSegment", () => {
|
|
40
|
+
const routeFeature = cloneDeep(this.animateRouteSegmentFeatureCollection.features[0]);
|
|
41
|
+
if (routeFeature) {
|
|
42
|
+
const currentTime = Date.now();
|
|
43
|
+
const elapsed = currentTime - this.animationStartTime;
|
|
44
|
+
const writeToSource = (feature, coords) => {
|
|
45
|
+
//@ts-ignore
|
|
46
|
+
feature.geometry.coordinates = coords;
|
|
47
|
+
const routeSource = this.map.getSource(this.animateRouteSourceName);
|
|
48
|
+
if (routeSource) {
|
|
49
|
+
//@ts-ignore
|
|
50
|
+
routeSource.setData({
|
|
51
|
+
type: 'FeatureCollection',
|
|
52
|
+
features: [feature]
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const animationDuration = 2000;
|
|
57
|
+
if (elapsed < animationDuration) {
|
|
58
|
+
const progress = 1 - elapsed / animationDuration;
|
|
59
|
+
|
|
60
|
+
//@ts-ignore
|
|
61
|
+
const fullRoute = routeFeature.geometry.coordinates;
|
|
62
|
+
const {
|
|
63
|
+
end
|
|
64
|
+
} = this;
|
|
65
|
+
let currentEnd;
|
|
66
|
+
if (progress > 0.5) {
|
|
67
|
+
const customProgress = 2 * (progress - 0.5); // map 0.5 - 1 to 0 - 1 range
|
|
68
|
+
currentEnd = end.from * (1.0 - customProgress) + customProgress * end.to;
|
|
69
|
+
} else {
|
|
70
|
+
const customProgress = progress * 2; // map 0 - 0.5 to 0 - 1 range
|
|
71
|
+
currentEnd = end.from * (1.0 - customProgress) + customProgress * end.to;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// calculate distance along the line using current animation percentage
|
|
75
|
+
// percentage travels 1 - 0
|
|
76
|
+
let prevsum = 0;
|
|
77
|
+
let actsum = 0;
|
|
78
|
+
let i = fullRoute.length - 1;
|
|
79
|
+
while (actsum < currentEnd && i > 0) {
|
|
80
|
+
prevsum = actsum;
|
|
81
|
+
actsum += turf.distance(point(fullRoute[i]), point(fullRoute[i - 1]));
|
|
82
|
+
i -= 1;
|
|
83
|
+
}
|
|
84
|
+
if (progress > 0.5) {
|
|
85
|
+
// Reverse animation
|
|
86
|
+
// if (actsum <= currentEnd) {
|
|
87
|
+
// const actRoute = [
|
|
88
|
+
// ...fullRoute.slice(fullRoute.length - 2, fullRoute.length),
|
|
89
|
+
// ];
|
|
90
|
+
// return {fullRoute, end: {...end, current: currentEnd}, actRoute};
|
|
91
|
+
// }
|
|
92
|
+
|
|
93
|
+
// Return coordinates from line start to current percentage point
|
|
94
|
+
const r = (currentEnd - prevsum) / (actsum - prevsum);
|
|
95
|
+
const or = 1.0 - r;
|
|
96
|
+
const actRoute = [...fullRoute.slice(0, i + 1), [fullRoute[i][0] * r + fullRoute[i + 1][0] * or, fullRoute[i][1] * r + fullRoute[i + 1][1] * or]];
|
|
97
|
+
writeToSource(routeFeature, actRoute);
|
|
98
|
+
} else {
|
|
99
|
+
// Forward animation
|
|
100
|
+
if (actsum <= currentEnd) {
|
|
101
|
+
// Return last two points of the line as final result
|
|
102
|
+
const actRoute = [...fullRoute.slice(fullRoute.length - 2, fullRoute.length)];
|
|
103
|
+
writeToSource(routeFeature, actRoute);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Return coordinates from line end to current percentage point
|
|
107
|
+
const r = (currentEnd - prevsum) / (actsum - prevsum);
|
|
108
|
+
const or = 1.0 - r;
|
|
109
|
+
const actRoute = [[fullRoute[i][0] * r + fullRoute[i + 1][0] * or, fullRoute[i][1] * r + fullRoute[i + 1][1] * or], ...fullRoute.slice(i + 1, fullRoute.length)];
|
|
110
|
+
writeToSource(routeFeature, actRoute);
|
|
111
|
+
}
|
|
112
|
+
this.animationFrameID = requestAnimationFrame(this.animateHighlightedRouteSegment);
|
|
113
|
+
} else {
|
|
114
|
+
this.resetRouteSegmentAnimation();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
});
|
|
37
118
|
this.main = sdk;
|
|
38
119
|
}
|
|
39
120
|
|
|
@@ -72,8 +153,10 @@ export class RoutingVisualizer {
|
|
|
72
153
|
}
|
|
73
154
|
|
|
74
155
|
// eslint-disable-next-line class-methods-use-this
|
|
75
|
-
async computeRoute(startMapObjectId, endMapObjectId
|
|
76
|
-
|
|
156
|
+
async computeRoute(startMapObjectId, endMapObjectId) {
|
|
157
|
+
let wheelChairAccessibleRouting = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
158
|
+
let shouldAddOverviewSegment = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
159
|
+
let indexOffset = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
|
|
77
160
|
this.currentPatchNumber = -1;
|
|
78
161
|
const generatedRoute = await createRoute(startMapObjectId, endMapObjectId, wheelChairAccessibleRouting, shouldAddOverviewSegment, indexOffset);
|
|
79
162
|
console.log('internal generated: ', generatedRoute);
|
|
@@ -113,7 +196,8 @@ export class RoutingVisualizer {
|
|
|
113
196
|
allSegments[segmentIndex].features[featureIndex] = lineStringToUpdate;
|
|
114
197
|
allSegments[segmentIndex].coordinates = lineStringToUpdate.geometry.coordinates;
|
|
115
198
|
}
|
|
116
|
-
async computeRoutes(mapObjectIds
|
|
199
|
+
async computeRoutes(mapObjectIds) {
|
|
200
|
+
let wheelChairAccessibleRouteOnly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
117
201
|
if (mapObjectIds.length < 2) {
|
|
118
202
|
console.warn('Invalid array passed to computeRoutes');
|
|
119
203
|
return undefined;
|
|
@@ -184,7 +268,7 @@ export class RoutingVisualizer {
|
|
|
184
268
|
if (generatedRoute.segments.length > 0) {
|
|
185
269
|
const segmentOverview = generatedRoute.segments[0];
|
|
186
270
|
segmentOverview.maneuverType = ManeuverType.SectionOverview;
|
|
187
|
-
segmentOverview.instructions = [
|
|
271
|
+
segmentOverview.instructions = ["".concat(segmentOverview.startEdge.name, " to ").concat(segmentOverview.endEdge.name)];
|
|
188
272
|
}
|
|
189
273
|
for (let j = 0; j < generatedRoute.segments.length; j += 1) {
|
|
190
274
|
const segment = generatedRoute.segments[j];
|
|
@@ -237,85 +321,6 @@ export class RoutingVisualizer {
|
|
|
237
321
|
if (routeFeature.geometry.type === 'LineString') this.animateHighlightedRouteSegment();
|
|
238
322
|
}
|
|
239
323
|
}
|
|
240
|
-
animateHighlightedRouteSegment = () => {
|
|
241
|
-
const routeFeature = cloneDeep(this.animateRouteSegmentFeatureCollection.features[0]);
|
|
242
|
-
if (routeFeature) {
|
|
243
|
-
const currentTime = Date.now();
|
|
244
|
-
const elapsed = currentTime - this.animationStartTime;
|
|
245
|
-
const writeToSource = (feature, coords) => {
|
|
246
|
-
//@ts-ignore
|
|
247
|
-
feature.geometry.coordinates = coords;
|
|
248
|
-
const routeSource = this.map.getSource(this.animateRouteSourceName);
|
|
249
|
-
if (routeSource) {
|
|
250
|
-
//@ts-ignore
|
|
251
|
-
routeSource.setData({
|
|
252
|
-
type: 'FeatureCollection',
|
|
253
|
-
features: [feature]
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
};
|
|
257
|
-
const animationDuration = 2000;
|
|
258
|
-
if (elapsed < animationDuration) {
|
|
259
|
-
const progress = 1 - elapsed / animationDuration;
|
|
260
|
-
|
|
261
|
-
//@ts-ignore
|
|
262
|
-
const fullRoute = routeFeature.geometry.coordinates;
|
|
263
|
-
const {
|
|
264
|
-
end
|
|
265
|
-
} = this;
|
|
266
|
-
let currentEnd;
|
|
267
|
-
if (progress > 0.5) {
|
|
268
|
-
const customProgress = 2 * (progress - 0.5); // map 0.5 - 1 to 0 - 1 range
|
|
269
|
-
currentEnd = end.from * (1.0 - customProgress) + customProgress * end.to;
|
|
270
|
-
} else {
|
|
271
|
-
const customProgress = progress * 2; // map 0 - 0.5 to 0 - 1 range
|
|
272
|
-
currentEnd = end.from * (1.0 - customProgress) + customProgress * end.to;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
// calculate distance along the line using current animation percentage
|
|
276
|
-
// percentage travels 1 - 0
|
|
277
|
-
let prevsum = 0;
|
|
278
|
-
let actsum = 0;
|
|
279
|
-
let i = fullRoute.length - 1;
|
|
280
|
-
while (actsum < currentEnd && i > 0) {
|
|
281
|
-
prevsum = actsum;
|
|
282
|
-
actsum += turf.distance(point(fullRoute[i]), point(fullRoute[i - 1]));
|
|
283
|
-
i -= 1;
|
|
284
|
-
}
|
|
285
|
-
if (progress > 0.5) {
|
|
286
|
-
// Reverse animation
|
|
287
|
-
// if (actsum <= currentEnd) {
|
|
288
|
-
// const actRoute = [
|
|
289
|
-
// ...fullRoute.slice(fullRoute.length - 2, fullRoute.length),
|
|
290
|
-
// ];
|
|
291
|
-
// return {fullRoute, end: {...end, current: currentEnd}, actRoute};
|
|
292
|
-
// }
|
|
293
|
-
|
|
294
|
-
// Return coordinates from line start to current percentage point
|
|
295
|
-
const r = (currentEnd - prevsum) / (actsum - prevsum);
|
|
296
|
-
const or = 1.0 - r;
|
|
297
|
-
const actRoute = [...fullRoute.slice(0, i + 1), [fullRoute[i][0] * r + fullRoute[i + 1][0] * or, fullRoute[i][1] * r + fullRoute[i + 1][1] * or]];
|
|
298
|
-
writeToSource(routeFeature, actRoute);
|
|
299
|
-
} else {
|
|
300
|
-
// Forward animation
|
|
301
|
-
if (actsum <= currentEnd) {
|
|
302
|
-
// Return last two points of the line as final result
|
|
303
|
-
const actRoute = [...fullRoute.slice(fullRoute.length - 2, fullRoute.length)];
|
|
304
|
-
writeToSource(routeFeature, actRoute);
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
// Return coordinates from line end to current percentage point
|
|
308
|
-
const r = (currentEnd - prevsum) / (actsum - prevsum);
|
|
309
|
-
const or = 1.0 - r;
|
|
310
|
-
const actRoute = [[fullRoute[i][0] * r + fullRoute[i + 1][0] * or, fullRoute[i][1] * r + fullRoute[i + 1][1] * or], ...fullRoute.slice(i + 1, fullRoute.length)];
|
|
311
|
-
writeToSource(routeFeature, actRoute);
|
|
312
|
-
}
|
|
313
|
-
this.animationFrameID = requestAnimationFrame(this.animateHighlightedRouteSegment);
|
|
314
|
-
} else {
|
|
315
|
-
this.resetRouteSegmentAnimation();
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
};
|
|
319
324
|
updateFeaturesToAnimate(segmentNumber, whereDimensionForFeatures) {
|
|
320
325
|
if (this.route && this.route.segments.length > segmentNumber) {
|
|
321
326
|
const routeSegment = this.route.segments[segmentNumber];
|
|
@@ -347,7 +352,8 @@ export class RoutingVisualizer {
|
|
|
347
352
|
}
|
|
348
353
|
}
|
|
349
354
|
}
|
|
350
|
-
highlightRouteSegment(segmentNumberToHighlight
|
|
355
|
+
highlightRouteSegment(segmentNumberToHighlight) {
|
|
356
|
+
let updateFilters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
351
357
|
const {
|
|
352
358
|
route
|
|
353
359
|
} = this;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["cloneDeep","maplibregl","point","turfPoint","length","nearestPointOnLine","turf","transformTranslate","DISTANCE_UNIT","WALK_SPEED","RouteDimension","ManeuverType","createRoute","generateInstructions","generateOverviewSegment","getFeaturesForPatch","getLineStringFeaturesOfRouteSegment","getPatch","highlightRouteSegment","isOverviewSegment","routeAnimateLayers","routeLayers","lineString","useRouteDataStore","RoutingVisualizer","routeSourceName","patchFeatureCollection","type","features","highlightedSegmentNumber","currentPatchNumber","animateRouteSourceName","animationFrameID","animateRouteSegmentFeatureCollection","animationStartTime","end","from","to","constructor","sdk","main","getCurrentFocus","filterWhereDimension","dimension","focusTo","setupRouting","map","addSource","data","layer","source","addLayer","computeRoute","startMapObjectId","endMapObjectId","wheelChairAccessibleRouting","shouldAddOverviewSegment","indexOffset","generatedRoute","console","log","segments","handleAllRouteUpdate","allSegments","userPosition","segmentIndex","featureLineStringToUpdate","filter","f","geometry","lineStringToUpdate","coordinates","slice","subLine","nearestPoint","sourceCoords","unshift","coordsToUpdate","index","properties","coordsToKeep","featureIndex","i","computeRoutes","mapObjectIds","wheelChairAccessibleRouteOnly","warn","undefined","mergedRoute","walkingDistance","transportDistance","walkingTime","transportTime","distanceUnit","speed","dummySegment","push","id","routeData","getState","project","feats","queryRenderedFeatures","Edge","hasOwnProperty","mapObjectId","edgeData","lines","segmentOverview","maneuverType","SectionOverview","instructions","startEdge","name","endEdge","j","segment","overviewSegment","updateRouteSource","updatedFeatureCollection","routeSource","getSource","setData","updateAnimateRouteSource","setActiveRoute","route","getActiveRoute","resetRouteSegmentAnimation","Date","now","cancelAnimationFrame","routeFeature","animateHighlightedRouteSegment","currentTime","elapsed","writeToSource","feature","coords","animationDuration","progress","fullRoute","currentEnd","customProgress","prevsum","actsum","distance","r","or","actRoute","requestAnimationFrame","updateFeaturesToAnimate","segmentNumber","whereDimensionForFeatures","routeSegment","lineFeaturesOfSegment","ls","nearest","toDist","location","segmentNumberToHighlight","updateFilters","segmentWhereDimension","ExitPortal","Static","whereDimension","routeFeaturesToUse","segmentPatchNumber","patchNumber","featureCollectionToDraw","includeOverviewFeatures","patchNumberForOverviewFeatures","updatedFeatures","getStartCoords","canvas","getCanvas","w","clientWidth","h","clientHeight","fitBoundsConfig","padding","top","bottom","left","right","duration","bearing","getBearing","pitch","getPitch","currentPatchFeatures","startCoords","sw","LngLat","ne","llb","LngLatBounds","element","extend","coord","fitBounds","transformedFeatures","forwardTransformed","reverseTransformed","bbox","clearRoute"],"sources":["../../../../../src/meta-atlas-sdk/utils/routing-visualizer/index.ts"],"sourcesContent":["import { cloneDeep } from 'lodash';\nimport maplibregl, { Feature, Map } from 'maplibre-gl';\nimport {\n Units, point as turfPoint,\n point,\n} from '@turf/helpers';\nimport length from '@turf/length';\nimport { nearestPointOnLine } from \"@turf/nearest-point-on-line\";\n// import { distance } from \"@turf/distance\";\nimport * as turf from '@turf/turf';\nimport { transformTranslate } from \"@turf/transform-translate\";\nimport { FeatureCollection } from 'geojson';\nimport { DISTANCE_UNIT, WALK_SPEED, RouteDimension, UserPosition } from '../../MetaAtlasCore/routing-core/interfaces';\nimport {\n ManeuverType, Route, RouteSegment, createRoute, generateInstructions, generateOverviewSegment, getFeaturesForPatch, getLineStringFeaturesOfRouteSegment, getPatch, highlightRouteSegment,\n isOverviewSegment,\n} from '../../MetaAtlasCore/routing-core/routing-helpers';\nimport { routeAnimateLayers, routeLayers } from '../../MetaAtlasCore/routing-core/routeLayers';\nimport { lineString } from '@turf/turf';\nimport useRouteDataStore from '../routing-store';\n\nexport class RoutingVisualizer {\n map: Map;\n\n // Routing\n routeSourceName = 'routeGeojson';\n\n patchFeatureCollection = {\n type: 'FeatureCollection',\n features: [],\n } as FeatureCollection;\n\n route: Route | null;\n\n highlightedSegmentNumber = -1;\n\n currentPatchNumber = -1;\n\n // Routing animation\n animateRouteSourceName = 'routeAnimateGeojson';\n\n animationFrameID = -1;\n\n animateRouteSegmentFeatureCollection = {\n type: 'FeatureCollection',\n features: [],\n } as FeatureCollection;\n\n animationStartTime = 0;\n\n end = {\n from: 0,\n to: 0,\n };\n\n main: any;\n\n constructor(sdk: any) {\n this.main = sdk\n }\n\n // MetaAtlasCore To Editor\n // eslint-disable-next-line class-methods-use-this\n getCurrentFocus() {\n return this.main.getCurrentFocus();\n }\n\n // eslint-disable-next-line class-methods-use-this\n filterWhereDimension(dimension: string) {\n this.main.focusTo(dimension, false);\n }\n\n // Routing\n setupRouting(map: Map) {\n this.map = map;\n this.map.addSource(this.routeSourceName, {\n type: 'geojson',\n data: this.patchFeatureCollection,\n });\n\n for (const layer of routeLayers) {\n (layer as any).source = this.routeSourceName;\n this.map.addLayer(layer as any);\n }\n\n // Animation data\n this.map.addSource(this.animateRouteSourceName, {\n type: 'geojson',\n data: this.animateRouteSegmentFeatureCollection,\n });\n\n for (const layer of routeAnimateLayers) {\n (layer as any).source = this.animateRouteSourceName;\n this.map.addLayer(layer as any);\n }\n }\n\n // eslint-disable-next-line class-methods-use-this\n async computeRoute(\n startMapObjectId: string,\n endMapObjectId: string,\n wheelChairAccessibleRouting = false,\n shouldAddOverviewSegment = true,\n indexOffset = 0, // offset for patch and segment numbers calculation\n ): Promise<Route> {\n this.currentPatchNumber = -1;\n\n const generatedRoute = await createRoute(\n startMapObjectId,\n endMapObjectId,\n wheelChairAccessibleRouting,\n shouldAddOverviewSegment,\n indexOffset,\n );\n\n console.log('internal generated: ', generatedRoute);\n\n // Generate textual instructions\n generateInstructions(generatedRoute);\n console.log(generatedRoute.segments);\n\n return generatedRoute;\n }\n\n handleAllRouteUpdate(allSegments: any, userPosition: UserPosition, segmentIndex) {\n // Get the LineString Feature of the route\n const featureLineStringToUpdate = allSegments[segmentIndex].features.filter(\n f => f.geometry.type === 'LineString'\n )[0];\n\n // Create a LineString with the coordinates of the route that would be updated accordingly\n const lineStringToUpdate = lineString(featureLineStringToUpdate.geometry.coordinates.slice(1));\n\n // Create a subset of LineString that contains the first two coords of the route which actually represent the route edge\n const subLine = lineString([\n featureLineStringToUpdate.geometry.coordinates[0],\n featureLineStringToUpdate.geometry.coordinates[1]\n ]);\n\n // Find the nearest point to the user position on the sub line and update the LineString.\n const nearestPoint = nearestPointOnLine(subLine, userPosition.sourceCoords);\n lineStringToUpdate.geometry.coordinates.unshift(userPosition.sourceCoords, nearestPoint.geometry.coordinates);\n const coordsToUpdate = lineStringToUpdate.geometry.coordinates;\n const index = nearestPoint.properties.index;\n const coordsToKeep = coordsToUpdate.slice(index);\n lineStringToUpdate.geometry.coordinates = coordsToKeep;\n lineStringToUpdate.geometry.coordinates.unshift(userPosition.sourceCoords);\n lineStringToUpdate.properties = featureLineStringToUpdate.properties;\n let featureIndex = -1;\n allSegments[segmentIndex].features.map((f, i) => {\n if (f.geometry.type === 'LineString') {\n featureIndex = i;\n }\n });\n\n // Update the new LineString in the route\n allSegments[segmentIndex].features[featureIndex] = lineStringToUpdate;\n allSegments[segmentIndex].coordinates = lineStringToUpdate.geometry.coordinates;\n }\n\n async computeRoutes(mapObjectIds: string[], wheelChairAccessibleRouteOnly = false): Promise<Route | undefined> {\n if (mapObjectIds.length < 2) {\n console.warn('Invalid array passed to computeRoutes');\n return undefined;\n }\n\n console.log('calling computeRoutes with mapObjectIds: ', mapObjectIds);\n\n const mergedRoute = {\n segments: [] as RouteSegment[],\n walkingDistance: 0,\n transportDistance: 0,\n walkingTime: 0,\n transportTime: 0,\n\n distanceUnit: DISTANCE_UNIT as Units,\n speed: WALK_SPEED,\n } as Route;\n\n // Dummy segment for overview segment\n const dummySegment = {};\n mergedRoute.segments.push(dummySegment as any);\n let indexOffset = 1; // Index set to 1, since overview segment will be added to 0th index\n\n for (let index = 0; index < mapObjectIds.length - 1; index += 1) {\n let startMapObjectId = mapObjectIds[index];\n const endMapObjectId = mapObjectIds[index + 1];\n\n const shouldAddOverviewSegment = true; // include overview segment in first route\n\n const id = mapObjectIds[0] as unknown as UserPosition;\n if (typeof mapObjectIds[0] !== 'string') {\n // Run queryRenderedFeatures.\n const routeData = useRouteDataStore.getState().data;\n const point = this.map.project([id.sourceCoords[0], id.sourceCoords[1]]);\n const feats = this.map.queryRenderedFeatures(point);\n feats.map(f => {\n if (routeData[RouteDimension.Edge].hasOwnProperty(f.properties.mapObjectId)) {\n const edgeData = routeData[RouteDimension.Edge][f.properties.mapObjectId];\n if (edgeData.lines.length > 0) {\n startMapObjectId = f.properties.mapObjectId;\n }\n }\n });\n }\n\n // eslint-disable-next-line no-await-in-loop\n const generatedRoute = await this.computeRoute(startMapObjectId, endMapObjectId, wheelChairAccessibleRouteOnly, shouldAddOverviewSegment, indexOffset);\n const allSegments = generatedRoute.segments;\n // if (typeof mapObjectIds[index] !== 'string' && typeof startMapObjectId === 'string') {\n // //Handle SectionOverview:\n // this.handleAllRouteUpdate(allSegments, id as UserPosition, 0);\n\n // // Handle the second segment.\n // const secondSegmentFeatures = generatedRoute.segments[1].features;\n // if (secondSegmentFeatures.length < 3 && secondSegmentFeatures[0].geometry.type === 'Point') {\n // secondSegmentFeatures[0].geometry.coordinates = id.sourceCoords;\n // allSegments[1].coordinates = id.sourceCoords as any;\n // } else {\n // this.handleAllRouteUpdate(allSegments, id as UserPosition, 1);\n // }\n\n // // Handle third segment\n // const thirdSegmentFeatures = generatedRoute.segments[2].features;\n // if (thirdSegmentFeatures.length < 3 && thirdSegmentFeatures.geometry.type === 'Point') {\n // allSegments[1].features[0].geometry.coordinates = id.sourceCoords;\n // allSegments[1].coordinates = id.sourceCoords as any;\n // } else {\n // this.handleAllRouteUpdate(allSegments, id as UserPosition, 2);\n // }\n // }\n \n if (generatedRoute.segments.length > 0) {\n const segmentOverview = generatedRoute.segments[0];\n segmentOverview.maneuverType = ManeuverType.SectionOverview;\n segmentOverview.instructions = [`${segmentOverview.startEdge.name} to ${segmentOverview.endEdge.name}`];\n }\n for (let j = 0; j < generatedRoute.segments.length; j += 1) {\n const segment = generatedRoute.segments[j];\n mergedRoute.segments.push(segment);\n }\n mergedRoute.walkingDistance += generatedRoute.walkingDistance;\n mergedRoute.transportDistance += generatedRoute.transportDistance;\n mergedRoute.walkingTime += generatedRoute.walkingTime;\n mergedRoute.transportTime += generatedRoute.transportTime;\n\n // Increment by segment count\n indexOffset += generatedRoute.segments.length;\n }\n\n if (mergedRoute.segments.length > 1) { // Use 1 here because 1 dummy segment will always be included\n const overviewSegment = generateOverviewSegment(mergedRoute);\n mergedRoute.segments[0] = overviewSegment;\n } else {\n mergedRoute.segments.length = 0; // Remove dummy segment\n }\n\n console.log('merged route: ', mergedRoute);\n\n return mergedRoute;\n }\n\n updateRouteSource(updatedFeatureCollection: FeatureCollection) {\n if (!this.map) return false;\n this.patchFeatureCollection = updatedFeatureCollection;\n const routeSource = (this.map.getSource(this.routeSourceName) as maplibregl.GeoJSONSource);\n if (routeSource) routeSource.setData(updatedFeatureCollection);\n\n return true;\n }\n\n updateAnimateRouteSource(updatedFeatureCollection: FeatureCollection) {\n if (!this.map) return false;\n this.animateRouteSegmentFeatureCollection = updatedFeatureCollection;\n const routeSource = (this.map.getSource(this.animateRouteSourceName) as maplibregl.GeoJSONSource);\n if (routeSource) routeSource.setData(updatedFeatureCollection);\n\n return true;\n }\n\n setActiveRoute(route: Route) {\n this.route = route;\n }\n\n getActiveRoute(): Route | null {\n return this.route;\n }\n\n resetRouteSegmentAnimation() {\n this.animationStartTime = Date.now();\n cancelAnimationFrame(this.animationFrameID);\n if (this.animateRouteSegmentFeatureCollection.features.length > 0) {\n const routeFeature = this.animateRouteSegmentFeatureCollection.features[0] as unknown as Feature;\n //@ts-ignore\n if (routeFeature.geometry.type === 'LineString') this.animateHighlightedRouteSegment();\n }\n }\n\n animateHighlightedRouteSegment = () => {\n const routeFeature = cloneDeep(this.animateRouteSegmentFeatureCollection.features[0]) as Feature;\n if (routeFeature) {\n const currentTime = Date.now();\n const elapsed = currentTime - this.animationStartTime;\n\n const writeToSource = (feature: Feature, coords: []) => {\n //@ts-ignore\n feature.geometry.coordinates = coords;\n const routeSource = (this.map.getSource(this.animateRouteSourceName) as maplibregl.GeoJSONSource);\n if (routeSource) {\n //@ts-ignore\n routeSource.setData({\n type: 'FeatureCollection',\n features: [feature],\n } as FeatureCollection);\n }\n };\n const animationDuration = 2000;\n if (elapsed < animationDuration) {\n const progress = 1 - elapsed / animationDuration;\n\n //@ts-ignore\n const fullRoute = routeFeature.geometry.coordinates;\n const { end } = this;\n\n let currentEnd;\n if (progress > 0.5) {\n const customProgress = 2 * (progress - 0.5); // map 0.5 - 1 to 0 - 1 range\n currentEnd = end.from * (1.0 - customProgress) + customProgress * end.to;\n } else {\n const customProgress = progress * 2; // map 0 - 0.5 to 0 - 1 range\n currentEnd = end.from * (1.0 - customProgress) + customProgress * end.to;\n }\n\n // calculate distance along the line using current animation percentage\n // percentage travels 1 - 0\n let prevsum = 0;\n let actsum = 0;\n let i = fullRoute.length - 1;\n while (actsum < currentEnd && i > 0) {\n prevsum = actsum;\n actsum += turf.distance(point(fullRoute[i]), point(fullRoute[i - 1]));\n i -= 1;\n }\n if (progress > 0.5) {\n // Reverse animation\n // if (actsum <= currentEnd) {\n // const actRoute = [\n // ...fullRoute.slice(fullRoute.length - 2, fullRoute.length),\n // ];\n // return {fullRoute, end: {...end, current: currentEnd}, actRoute};\n // }\n\n // Return coordinates from line start to current percentage point\n const r = (currentEnd - prevsum) / (actsum - prevsum);\n const or = 1.0 - r;\n\n const actRoute = [\n ...fullRoute.slice(0, i + 1),\n [\n fullRoute[i][0] * r + fullRoute[i + 1][0] * or,\n fullRoute[i][1] * r + fullRoute[i + 1][1] * or,\n ],\n ];\n\n writeToSource(routeFeature, actRoute as any);\n } else {\n // Forward animation\n if (actsum <= currentEnd) {\n // Return last two points of the line as final result\n const actRoute = [\n ...fullRoute.slice(fullRoute.length - 2, fullRoute.length),\n ];\n\n writeToSource(routeFeature, actRoute as any);\n }\n\n // Return coordinates from line end to current percentage point\n const r = (currentEnd - prevsum) / (actsum - prevsum);\n const or = 1.0 - r;\n\n const actRoute = [\n [\n fullRoute[i][0] * r + fullRoute[i + 1][0] * or,\n fullRoute[i][1] * r + fullRoute[i + 1][1] * or,\n ],\n ...fullRoute.slice(i + 1, fullRoute.length),\n ];\n\n writeToSource(routeFeature, actRoute as any);\n }\n\n this.animationFrameID = requestAnimationFrame(\n this.animateHighlightedRouteSegment,\n );\n } else {\n this.resetRouteSegmentAnimation();\n }\n }\n };\n\n updateFeaturesToAnimate(segmentNumber: number, whereDimensionForFeatures: string) {\n if (this.route && this.route.segments.length > segmentNumber) {\n const routeSegment = this.route.segments[segmentNumber];\n // set features for animated segment source\n if (routeSegment.features.length > 0) {\n const lineFeaturesOfSegment =\n // include where dimension here?\n getLineStringFeaturesOfRouteSegment(\n routeSegment,\n whereDimensionForFeatures,\n );\n\n if (lineFeaturesOfSegment.length > 0) {\n this.updateAnimateRouteSource({\n type: 'FeatureCollection',\n features: lineFeaturesOfSegment,\n } as FeatureCollection);\n\n const ls = lineFeaturesOfSegment[0];\n //@ts-ignore\n const nearest = nearestPointOnLine(ls as any, point(lineFeaturesOfSegment[0].geometry.coordinates[0]));\n const toDist = length(ls) - nearest.properties.location;\n this.end = {\n from: 0,\n to: toDist,\n };\n } else {\n this.updateAnimateRouteSource({\n type: 'FeatureCollection',\n features: [],\n } as FeatureCollection);\n }\n\n this.resetRouteSegmentAnimation();\n }\n }\n }\n\n highlightRouteSegment(segmentNumberToHighlight: number, updateFilters = true) {\n const { route } = this;\n if (route && route.segments.length > segmentNumberToHighlight) {\n if (\n route.segments[segmentNumberToHighlight].coordinates.length > 0\n ) {\n this.highlightedSegmentNumber = segmentNumberToHighlight;\n const routeSegment = route.segments[segmentNumberToHighlight];\n\n const segmentWhereDimension = routeSegment.maneuverType === ManeuverType.ExitPortal || routeSegment.maneuverType === ManeuverType.Static\n ? routeSegment.endEdge.whereDimension\n : routeSegment.startEdge.whereDimension;\n let routeFeaturesToUse = this.patchFeatureCollection.features;\n\n // update visible route features if required\n const segmentPatchNumber = (\n routeSegment.features[0].properties as any\n ).patchNumber;\n if (this.currentPatchNumber !== segmentPatchNumber) {\n this.currentPatchNumber = segmentPatchNumber;\n const featureCollectionToDraw = {\n type: 'FeatureCollection',\n features: getFeaturesForPatch(route, segmentPatchNumber, {\n includeOverviewFeatures: isOverviewSegment(routeSegment),\n patchNumberForOverviewFeatures: segmentPatchNumber,\n }),\n } as FeatureCollection;\n\n routeFeaturesToUse = featureCollectionToDraw.features;\n }\n\n if (\n segmentWhereDimension\n && segmentWhereDimension !== this.getCurrentFocus()\n && updateFilters\n ) {\n this.filterWhereDimension(segmentWhereDimension);\n }\n\n // update highlighted route segment\n const updatedFeatures = highlightRouteSegment(\n routeFeaturesToUse as any,\n segmentNumberToHighlight,\n );\n\n this.updateRouteSource({\n type: 'FeatureCollection',\n features: updatedFeatures,\n });\n\n if (!isOverviewSegment(routeSegment)) {\n this.updateFeaturesToAnimate(\n segmentNumberToHighlight,\n segmentWhereDimension,\n );\n } else {\n // clear animation source\n this.updateAnimateRouteSource({\n type: 'FeatureCollection',\n features: [],\n } as FeatureCollection);\n }\n\n // animate camera to segment\n if (routeSegment) {\n const getStartCoords = (feature: Feature) => {\n //@ts-ignore\n if (feature.geometry.type === 'Point') {\n //@ts-ignore\n return feature.geometry.coordinates;\n }\n\n //@ts-ignore\n return feature.geometry.coordinates[0];\n };\n\n const canvas = this.map.getCanvas();\n const w = canvas.clientWidth;\n const h = canvas.clientHeight;\n const fitBoundsConfig = {\n padding: {\n top: h * 0.2, bottom: h * 0.2, left: w * 0.2, right: w * 0.2,\n },\n duration: 1000,\n bearing: this.map.getBearing(),\n pitch: this.map.getPitch(),\n };\n if (routeSegment.coordinates.length > 1) {\n const currentPatchFeatures = getPatch(route, routeSegment.patchNumber);\n const startCoords = getStartCoords(currentPatchFeatures[0] as any);\n // let index = 0;\n // for (index = 0; index < currentPatchFeatures.length; index++) {\n // const element = currentPatchFeatures[index];\n // if (element.properties.segmentNumber === segmentNumberToHighlight) {\n // startCoords = getStartCoords(element);\n // }\n // }\n const sw = new maplibregl.LngLat(startCoords[0], startCoords[1]);\n const ne = new maplibregl.LngLat(startCoords[0], startCoords[1]);\n const llb = new maplibregl.LngLatBounds(sw, ne);\n for (let index = 0; index < currentPatchFeatures.length; index++) {\n const element = currentPatchFeatures[index];\n if (element.geometry.type === 'Point') {\n llb.extend(element.geometry.coordinates as any);\n } else {\n //@ts-ignore\n for (const coord of element.geometry.coordinates) {\n llb.extend(coord);\n }\n }\n }\n\n this.map.fitBounds(\n llb,\n fitBoundsConfig,\n );\n } else {\n // Translate the point slightly to get another point which can used for the fitBounds function.\n const transformedFeatures = {\n type: 'FeatureCollection',\n features: [turfPoint(routeSegment.coordinates[0])],\n } as FeatureCollection;\n const forwardTransformed = transformTranslate(\n transformedFeatures as any,\n 0.025,\n 3,\n ).features[0].geometry.coordinates;\n\n const reverseTransformed = transformTranslate(\n transformedFeatures as any,\n -0.025,\n -3,\n ).features[0].geometry.coordinates;\n\n const bbox = [reverseTransformed, forwardTransformed];\n this.map.fitBounds(\n bbox as any,\n fitBoundsConfig,\n );\n }\n }\n } else {\n console.log('at vertical portal segment, ignoring!');\n }\n\n console.log(route.segments[segmentNumberToHighlight].instructions);\n } else {\n console.warn(\n 'Invalid segment number passed to highlightRouteSegment',\n );\n }\n }\n\n clearRoute() {\n const featureCollectionToDraw = {\n type: 'FeatureCollection',\n features: [],\n } as FeatureCollection;\n\n this.updateRouteSource(featureCollectionToDraw);\n this.updateAnimateRouteSource(featureCollectionToDraw);\n this.route = null;\n cancelAnimationFrame(this.animationFrameID);\n }\n}\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,QAAQ;AAClC,OAAOC,UAAU,MAAwB,aAAa;AACtD,SACSC,KAAK,IAAIC,SAAS,EACzBD,KAAK,QACA,eAAe;AACtB,OAAOE,MAAM,MAAM,cAAc;AACjC,SAASC,kBAAkB,QAAQ,6BAA6B;AAChE;AACA,OAAO,KAAKC,IAAI,MAAM,YAAY;AAClC,SAASC,kBAAkB,QAAQ,2BAA2B;AAE9D,SAASC,aAAa,EAAEC,UAAU,EAAEC,c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I,IAAI,EACJzB,eACF,CAAC;UACH;QACF;MACF,CAAC,MAAM;QACLxH,OAAO,CAACC,GAAG,CAAC,uCAAuC,CAAC;MACtD;MAEAD,OAAO,CAACC,GAAG,CAACiE,KAAK,CAAChE,QAAQ,CAACkG,wBAAwB,CAAC,CAAChD,YAAY,CAAC;IACpE,CAAC,MAAM;MACLpD,OAAO,CAAC2B,IAAI,CACV,wDACF,CAAC;IACH;EACF;EAEAuH,UAAUA,CAAA,EAAG;IACX,MAAMrC,uBAAuB,GAAG;MAC9B7I,IAAI,EAAE,mBAAmB;MACzBC,QAAQ,EAAE;IACZ,CAAsB;IAEtB,IAAI,CAAC0F,iBAAiB,CAACkD,uBAAuB,CAAC;IAC/C,IAAI,CAAC7C,wBAAwB,CAAC6C,uBAAuB,CAAC;IACtD,IAAI,CAAC3C,KAAK,GAAG,IAAI;IACjBK,oBAAoB,CAAC,IAAI,CAAClG,gBAAgB,CAAC;EAC7C;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["cloneDeep","maplibregl","point","turfPoint","length","nearestPointOnLine","turf","transformTranslate","DISTANCE_UNIT","WALK_SPEED","RouteDimension","ManeuverType","createRoute","generateInstructions","generateOverviewSegment","getFeaturesForPatch","getLineStringFeaturesOfRouteSegment","getPatch","highlightRouteSegment","isOverviewSegment","routeAnimateLayers","routeLayers","lineString","useRouteDataStore","RoutingVisualizer","constructor","sdk","_defineProperty","type","features","from","to","routeFeature","animateRouteSegmentFeatureCollection","currentTime","Date","now","elapsed","animationStartTime","writeToSource","feature","coords","geometry","coordinates","routeSource","map","getSource","animateRouteSourceName","setData","animationDuration","progress","fullRoute","end","currentEnd","customProgress","prevsum","actsum","i","distance","r","or","actRoute","slice","animationFrameID","requestAnimationFrame","animateHighlightedRouteSegment","resetRouteSegmentAnimation","main","getCurrentFocus","filterWhereDimension","dimension","focusTo","setupRouting","addSource","routeSourceName","data","patchFeatureCollection","layer","source","addLayer","computeRoute","startMapObjectId","endMapObjectId","wheelChairAccessibleRouting","arguments","undefined","shouldAddOverviewSegment","indexOffset","currentPatchNumber","generatedRoute","console","log","segments","handleAllRouteUpdate","allSegments","userPosition","segmentIndex","featureLineStringToUpdate","filter","f","lineStringToUpdate","subLine","nearestPoint","sourceCoords","unshift","coordsToUpdate","index","properties","coordsToKeep","featureIndex","computeRoutes","mapObjectIds","wheelChairAccessibleRouteOnly","warn","mergedRoute","walkingDistance","transportDistance","walkingTime","transportTime","distanceUnit","speed","dummySegment","push","id","routeData","getState","project","feats","queryRenderedFeatures","Edge","hasOwnProperty","mapObjectId","edgeData","lines","segmentOverview","maneuverType","SectionOverview","instructions","concat","startEdge","name","endEdge","j","segment","overviewSegment","updateRouteSource","updatedFeatureCollection","updateAnimateRouteSource","setActiveRoute","route","getActiveRoute","cancelAnimationFrame","updateFeaturesToAnimate","segmentNumber","whereDimensionForFeatures","routeSegment","lineFeaturesOfSegment","ls","nearest","toDist","location","segmentNumberToHighlight","updateFilters","highlightedSegmentNumber","segmentWhereDimension","ExitPortal","Static","whereDimension","routeFeaturesToUse","segmentPatchNumber","patchNumber","featureCollectionToDraw","includeOverviewFeatures","patchNumberForOverviewFeatures","updatedFeatures","getStartCoords","canvas","getCanvas","w","clientWidth","h","clientHeight","fitBoundsConfig","padding","top","bottom","left","right","duration","bearing","getBearing","pitch","getPitch","currentPatchFeatures","startCoords","sw","LngLat","ne","llb","LngLatBounds","element","extend","coord","fitBounds","transformedFeatures","forwardTransformed","reverseTransformed","bbox","clearRoute"],"sources":["../../../../../src/meta-atlas-sdk/utils/routing-visualizer/index.ts"],"sourcesContent":["import { cloneDeep } from 'lodash';\nimport maplibregl, { Feature, Map } from 'maplibre-gl';\nimport {\n Units, point as turfPoint,\n point,\n} from '@turf/helpers';\nimport length from '@turf/length';\nimport { nearestPointOnLine } from \"@turf/nearest-point-on-line\";\n// import { distance } from \"@turf/distance\";\nimport * as turf from '@turf/turf';\nimport { transformTranslate } from \"@turf/transform-translate\";\nimport { FeatureCollection } from 'geojson';\nimport { DISTANCE_UNIT, WALK_SPEED, RouteDimension, UserPosition } from '../../MetaAtlasCore/routing-core/interfaces';\nimport {\n ManeuverType, Route, RouteSegment, createRoute, generateInstructions, generateOverviewSegment, getFeaturesForPatch, getLineStringFeaturesOfRouteSegment, getPatch, highlightRouteSegment,\n isOverviewSegment,\n} from '../../MetaAtlasCore/routing-core/routing-helpers';\nimport { routeAnimateLayers, routeLayers } from '../../MetaAtlasCore/routing-core/routeLayers';\nimport { lineString } from '@turf/turf';\nimport useRouteDataStore from '../routing-store';\n\nexport class RoutingVisualizer {\n map: Map;\n\n // Routing\n routeSourceName = 'routeGeojson';\n\n patchFeatureCollection = {\n type: 'FeatureCollection',\n features: [],\n } as FeatureCollection;\n\n route: Route | null;\n\n highlightedSegmentNumber = -1;\n\n currentPatchNumber = -1;\n\n // Routing animation\n animateRouteSourceName = 'routeAnimateGeojson';\n\n animationFrameID = -1;\n\n animateRouteSegmentFeatureCollection = {\n type: 'FeatureCollection',\n features: [],\n } as FeatureCollection;\n\n animationStartTime = 0;\n\n end = {\n from: 0,\n to: 0,\n };\n\n main: any;\n\n constructor(sdk: any) {\n this.main = sdk\n }\n\n // MetaAtlasCore To Editor\n // eslint-disable-next-line class-methods-use-this\n getCurrentFocus() {\n return this.main.getCurrentFocus();\n }\n\n // eslint-disable-next-line class-methods-use-this\n filterWhereDimension(dimension: string) {\n this.main.focusTo(dimension, false);\n }\n\n // Routing\n setupRouting(map: Map) {\n this.map = map;\n this.map.addSource(this.routeSourceName, {\n type: 'geojson',\n data: this.patchFeatureCollection,\n });\n\n for (const layer of routeLayers) {\n (layer as any).source = this.routeSourceName;\n this.map.addLayer(layer as any);\n }\n\n // Animation data\n this.map.addSource(this.animateRouteSourceName, {\n type: 'geojson',\n data: this.animateRouteSegmentFeatureCollection,\n });\n\n for (const layer of routeAnimateLayers) {\n (layer as any).source = this.animateRouteSourceName;\n this.map.addLayer(layer as any);\n }\n }\n\n // eslint-disable-next-line class-methods-use-this\n async computeRoute(\n startMapObjectId: string,\n endMapObjectId: string,\n wheelChairAccessibleRouting = false,\n shouldAddOverviewSegment = true,\n indexOffset = 0, // offset for patch and segment numbers calculation\n ): Promise<Route> {\n this.currentPatchNumber = -1;\n\n const generatedRoute = await createRoute(\n startMapObjectId,\n endMapObjectId,\n wheelChairAccessibleRouting,\n shouldAddOverviewSegment,\n indexOffset,\n );\n\n console.log('internal generated: ', generatedRoute);\n\n // Generate textual instructions\n generateInstructions(generatedRoute);\n console.log(generatedRoute.segments);\n\n return generatedRoute;\n }\n\n handleAllRouteUpdate(allSegments: any, userPosition: UserPosition, segmentIndex) {\n // Get the LineString Feature of the route\n const featureLineStringToUpdate = allSegments[segmentIndex].features.filter(\n f => f.geometry.type === 'LineString'\n )[0];\n\n // Create a LineString with the coordinates of the route that would be updated accordingly\n const lineStringToUpdate = lineString(featureLineStringToUpdate.geometry.coordinates.slice(1));\n\n // Create a subset of LineString that contains the first two coords of the route which actually represent the route edge\n const subLine = lineString([\n featureLineStringToUpdate.geometry.coordinates[0],\n featureLineStringToUpdate.geometry.coordinates[1]\n ]);\n\n // Find the nearest point to the user position on the sub line and update the LineString.\n const nearestPoint = nearestPointOnLine(subLine, userPosition.sourceCoords);\n lineStringToUpdate.geometry.coordinates.unshift(userPosition.sourceCoords, nearestPoint.geometry.coordinates);\n const coordsToUpdate = lineStringToUpdate.geometry.coordinates;\n const index = nearestPoint.properties.index;\n const coordsToKeep = coordsToUpdate.slice(index);\n lineStringToUpdate.geometry.coordinates = coordsToKeep;\n lineStringToUpdate.geometry.coordinates.unshift(userPosition.sourceCoords);\n lineStringToUpdate.properties = featureLineStringToUpdate.properties;\n let featureIndex = -1;\n allSegments[segmentIndex].features.map((f, i) => {\n if (f.geometry.type === 'LineString') {\n featureIndex = i;\n }\n });\n\n // Update the new LineString in the route\n allSegments[segmentIndex].features[featureIndex] = lineStringToUpdate;\n allSegments[segmentIndex].coordinates = lineStringToUpdate.geometry.coordinates;\n }\n\n async computeRoutes(mapObjectIds: string[], wheelChairAccessibleRouteOnly = false): Promise<Route | undefined> {\n if (mapObjectIds.length < 2) {\n console.warn('Invalid array passed to computeRoutes');\n return undefined;\n }\n\n console.log('calling computeRoutes with mapObjectIds: ', mapObjectIds);\n\n const mergedRoute = {\n segments: [] as RouteSegment[],\n walkingDistance: 0,\n transportDistance: 0,\n walkingTime: 0,\n transportTime: 0,\n\n distanceUnit: DISTANCE_UNIT as Units,\n speed: WALK_SPEED,\n } as Route;\n\n // Dummy segment for overview segment\n const dummySegment = {};\n mergedRoute.segments.push(dummySegment as any);\n let indexOffset = 1; // Index set to 1, since overview segment will be added to 0th index\n\n for (let index = 0; index < mapObjectIds.length - 1; index += 1) {\n let startMapObjectId = mapObjectIds[index];\n const endMapObjectId = mapObjectIds[index + 1];\n\n const shouldAddOverviewSegment = true; // include overview segment in first route\n\n const id = mapObjectIds[0] as unknown as UserPosition;\n if (typeof mapObjectIds[0] !== 'string') {\n // Run queryRenderedFeatures.\n const routeData = useRouteDataStore.getState().data;\n const point = this.map.project([id.sourceCoords[0], id.sourceCoords[1]]);\n const feats = this.map.queryRenderedFeatures(point);\n feats.map(f => {\n if (routeData[RouteDimension.Edge].hasOwnProperty(f.properties.mapObjectId)) {\n const edgeData = routeData[RouteDimension.Edge][f.properties.mapObjectId];\n if (edgeData.lines.length > 0) {\n startMapObjectId = f.properties.mapObjectId;\n }\n }\n });\n }\n\n // eslint-disable-next-line no-await-in-loop\n const generatedRoute = await this.computeRoute(startMapObjectId, endMapObjectId, wheelChairAccessibleRouteOnly, shouldAddOverviewSegment, indexOffset);\n const allSegments = generatedRoute.segments;\n // if (typeof mapObjectIds[index] !== 'string' && typeof startMapObjectId === 'string') {\n // //Handle SectionOverview:\n // this.handleAllRouteUpdate(allSegments, id as UserPosition, 0);\n\n // // Handle the second segment.\n // const secondSegmentFeatures = generatedRoute.segments[1].features;\n // if (secondSegmentFeatures.length < 3 && secondSegmentFeatures[0].geometry.type === 'Point') {\n // secondSegmentFeatures[0].geometry.coordinates = id.sourceCoords;\n // allSegments[1].coordinates = id.sourceCoords as any;\n // } else {\n // this.handleAllRouteUpdate(allSegments, id as UserPosition, 1);\n // }\n\n // // Handle third segment\n // const thirdSegmentFeatures = generatedRoute.segments[2].features;\n // if (thirdSegmentFeatures.length < 3 && thirdSegmentFeatures.geometry.type === 'Point') {\n // allSegments[1].features[0].geometry.coordinates = id.sourceCoords;\n // allSegments[1].coordinates = id.sourceCoords as any;\n // } else {\n // this.handleAllRouteUpdate(allSegments, id as UserPosition, 2);\n // }\n // }\n \n if (generatedRoute.segments.length > 0) {\n const segmentOverview = generatedRoute.segments[0];\n segmentOverview.maneuverType = ManeuverType.SectionOverview;\n segmentOverview.instructions = [`${segmentOverview.startEdge.name} to ${segmentOverview.endEdge.name}`];\n }\n for (let j = 0; j < generatedRoute.segments.length; j += 1) {\n const segment = generatedRoute.segments[j];\n mergedRoute.segments.push(segment);\n }\n mergedRoute.walkingDistance += generatedRoute.walkingDistance;\n mergedRoute.transportDistance += generatedRoute.transportDistance;\n mergedRoute.walkingTime += generatedRoute.walkingTime;\n mergedRoute.transportTime += generatedRoute.transportTime;\n\n // Increment by segment count\n indexOffset += generatedRoute.segments.length;\n }\n\n if (mergedRoute.segments.length > 1) { // Use 1 here because 1 dummy segment will always be included\n const overviewSegment = generateOverviewSegment(mergedRoute);\n mergedRoute.segments[0] = overviewSegment;\n } else {\n mergedRoute.segments.length = 0; // Remove dummy segment\n }\n\n console.log('merged route: ', mergedRoute);\n\n return mergedRoute;\n }\n\n updateRouteSource(updatedFeatureCollection: FeatureCollection) {\n if (!this.map) return false;\n this.patchFeatureCollection = updatedFeatureCollection;\n const routeSource = (this.map.getSource(this.routeSourceName) as maplibregl.GeoJSONSource);\n if (routeSource) routeSource.setData(updatedFeatureCollection);\n\n return true;\n }\n\n updateAnimateRouteSource(updatedFeatureCollection: FeatureCollection) {\n if (!this.map) return false;\n this.animateRouteSegmentFeatureCollection = updatedFeatureCollection;\n const routeSource = (this.map.getSource(this.animateRouteSourceName) as maplibregl.GeoJSONSource);\n if (routeSource) routeSource.setData(updatedFeatureCollection);\n\n return true;\n }\n\n setActiveRoute(route: Route) {\n this.route = route;\n }\n\n getActiveRoute(): Route | null {\n return this.route;\n }\n\n resetRouteSegmentAnimation() {\n this.animationStartTime = Date.now();\n cancelAnimationFrame(this.animationFrameID);\n if (this.animateRouteSegmentFeatureCollection.features.length > 0) {\n const routeFeature = this.animateRouteSegmentFeatureCollection.features[0] as unknown as Feature;\n //@ts-ignore\n if (routeFeature.geometry.type === 'LineString') this.animateHighlightedRouteSegment();\n }\n }\n\n animateHighlightedRouteSegment = () => {\n const routeFeature = cloneDeep(this.animateRouteSegmentFeatureCollection.features[0]) as Feature;\n if (routeFeature) {\n const currentTime = Date.now();\n const elapsed = currentTime - this.animationStartTime;\n\n const writeToSource = (feature: Feature, coords: []) => {\n //@ts-ignore\n feature.geometry.coordinates = coords;\n const routeSource = (this.map.getSource(this.animateRouteSourceName) as maplibregl.GeoJSONSource);\n if (routeSource) {\n //@ts-ignore\n routeSource.setData({\n type: 'FeatureCollection',\n features: [feature],\n } as FeatureCollection);\n }\n };\n const animationDuration = 2000;\n if (elapsed < animationDuration) {\n const progress = 1 - elapsed / animationDuration;\n\n //@ts-ignore\n const fullRoute = routeFeature.geometry.coordinates;\n const { end } = this;\n\n let currentEnd;\n if (progress > 0.5) {\n const customProgress = 2 * (progress - 0.5); // map 0.5 - 1 to 0 - 1 range\n currentEnd = end.from * (1.0 - customProgress) + customProgress * end.to;\n } else {\n const customProgress = progress * 2; // map 0 - 0.5 to 0 - 1 range\n currentEnd = end.from * (1.0 - customProgress) + customProgress * end.to;\n }\n\n // calculate distance along the line using current animation percentage\n // percentage travels 1 - 0\n let prevsum = 0;\n let actsum = 0;\n let i = fullRoute.length - 1;\n while (actsum < currentEnd && i > 0) {\n prevsum = actsum;\n actsum += turf.distance(point(fullRoute[i]), point(fullRoute[i - 1]));\n i -= 1;\n }\n if (progress > 0.5) {\n // Reverse animation\n // if (actsum <= currentEnd) {\n // const actRoute = [\n // ...fullRoute.slice(fullRoute.length - 2, fullRoute.length),\n // ];\n // return {fullRoute, end: {...end, current: currentEnd}, actRoute};\n // }\n\n // Return coordinates from line start to current percentage point\n const r = (currentEnd - prevsum) / (actsum - prevsum);\n const or = 1.0 - r;\n\n const actRoute = [\n ...fullRoute.slice(0, i + 1),\n [\n fullRoute[i][0] * r + fullRoute[i + 1][0] * or,\n fullRoute[i][1] * r + fullRoute[i + 1][1] * or,\n ],\n ];\n\n writeToSource(routeFeature, actRoute as any);\n } else {\n // Forward animation\n if (actsum <= currentEnd) {\n // Return last two points of the line as final result\n const actRoute = [\n ...fullRoute.slice(fullRoute.length - 2, fullRoute.length),\n ];\n\n writeToSource(routeFeature, actRoute as any);\n }\n\n // Return coordinates from line end to current percentage point\n const r = (currentEnd - prevsum) / (actsum - prevsum);\n const or = 1.0 - r;\n\n const actRoute = [\n [\n fullRoute[i][0] * r + fullRoute[i + 1][0] * or,\n fullRoute[i][1] * r + fullRoute[i + 1][1] * or,\n ],\n ...fullRoute.slice(i + 1, fullRoute.length),\n ];\n\n writeToSource(routeFeature, actRoute as any);\n }\n\n this.animationFrameID = requestAnimationFrame(\n this.animateHighlightedRouteSegment,\n );\n } else {\n this.resetRouteSegmentAnimation();\n }\n }\n };\n\n updateFeaturesToAnimate(segmentNumber: number, whereDimensionForFeatures: string) {\n if (this.route && this.route.segments.length > segmentNumber) {\n const routeSegment = this.route.segments[segmentNumber];\n // set features for animated segment source\n if (routeSegment.features.length > 0) {\n const lineFeaturesOfSegment =\n // include where dimension here?\n getLineStringFeaturesOfRouteSegment(\n routeSegment,\n whereDimensionForFeatures,\n );\n\n if (lineFeaturesOfSegment.length > 0) {\n this.updateAnimateRouteSource({\n type: 'FeatureCollection',\n features: lineFeaturesOfSegment,\n } as FeatureCollection);\n\n const ls = lineFeaturesOfSegment[0];\n //@ts-ignore\n const nearest = nearestPointOnLine(ls as any, point(lineFeaturesOfSegment[0].geometry.coordinates[0]));\n const toDist = length(ls) - nearest.properties.location;\n this.end = {\n from: 0,\n to: toDist,\n };\n } else {\n this.updateAnimateRouteSource({\n type: 'FeatureCollection',\n features: [],\n } as FeatureCollection);\n }\n\n this.resetRouteSegmentAnimation();\n }\n }\n }\n\n highlightRouteSegment(segmentNumberToHighlight: number, updateFilters = true) {\n const { route } = this;\n if (route && route.segments.length > segmentNumberToHighlight) {\n if (\n route.segments[segmentNumberToHighlight].coordinates.length > 0\n ) {\n this.highlightedSegmentNumber = segmentNumberToHighlight;\n const routeSegment = route.segments[segmentNumberToHighlight];\n\n const segmentWhereDimension = routeSegment.maneuverType === ManeuverType.ExitPortal || routeSegment.maneuverType === ManeuverType.Static\n ? routeSegment.endEdge.whereDimension\n : routeSegment.startEdge.whereDimension;\n let routeFeaturesToUse = this.patchFeatureCollection.features;\n\n // update visible route features if required\n const segmentPatchNumber = (\n routeSegment.features[0].properties as any\n ).patchNumber;\n if (this.currentPatchNumber !== segmentPatchNumber) {\n this.currentPatchNumber = segmentPatchNumber;\n const featureCollectionToDraw = {\n type: 'FeatureCollection',\n features: getFeaturesForPatch(route, segmentPatchNumber, {\n includeOverviewFeatures: isOverviewSegment(routeSegment),\n patchNumberForOverviewFeatures: segmentPatchNumber,\n }),\n } as FeatureCollection;\n\n routeFeaturesToUse = featureCollectionToDraw.features;\n }\n\n if (\n segmentWhereDimension\n && segmentWhereDimension !== this.getCurrentFocus()\n && updateFilters\n ) {\n this.filterWhereDimension(segmentWhereDimension);\n }\n\n // update highlighted route segment\n const updatedFeatures = highlightRouteSegment(\n routeFeaturesToUse as any,\n segmentNumberToHighlight,\n );\n\n this.updateRouteSource({\n type: 'FeatureCollection',\n features: updatedFeatures,\n });\n\n if (!isOverviewSegment(routeSegment)) {\n this.updateFeaturesToAnimate(\n segmentNumberToHighlight,\n segmentWhereDimension,\n );\n } else {\n // clear animation source\n this.updateAnimateRouteSource({\n type: 'FeatureCollection',\n features: [],\n } as FeatureCollection);\n }\n\n // animate camera to segment\n if (routeSegment) {\n const getStartCoords = (feature: Feature) => {\n //@ts-ignore\n if (feature.geometry.type === 'Point') {\n //@ts-ignore\n return feature.geometry.coordinates;\n }\n\n //@ts-ignore\n return feature.geometry.coordinates[0];\n };\n\n const canvas = this.map.getCanvas();\n const w = canvas.clientWidth;\n const h = canvas.clientHeight;\n const fitBoundsConfig = {\n padding: {\n top: h * 0.2, bottom: h * 0.2, left: w * 0.2, right: w * 0.2,\n },\n duration: 1000,\n bearing: this.map.getBearing(),\n pitch: this.map.getPitch(),\n };\n if (routeSegment.coordinates.length > 1) {\n const currentPatchFeatures = getPatch(route, routeSegment.patchNumber);\n const startCoords = getStartCoords(currentPatchFeatures[0] as any);\n // let index = 0;\n // for (index = 0; index < currentPatchFeatures.length; index++) {\n // const element = currentPatchFeatures[index];\n // if (element.properties.segmentNumber === segmentNumberToHighlight) {\n // startCoords = getStartCoords(element);\n // }\n // }\n const sw = new maplibregl.LngLat(startCoords[0], startCoords[1]);\n const ne = new maplibregl.LngLat(startCoords[0], startCoords[1]);\n const llb = new maplibregl.LngLatBounds(sw, ne);\n for (let index = 0; index < currentPatchFeatures.length; index++) {\n const element = currentPatchFeatures[index];\n if (element.geometry.type === 'Point') {\n llb.extend(element.geometry.coordinates as any);\n } else {\n //@ts-ignore\n for (const coord of element.geometry.coordinates) {\n llb.extend(coord);\n }\n }\n }\n\n this.map.fitBounds(\n llb,\n fitBoundsConfig,\n );\n } else {\n // Translate the point slightly to get another point which can used for the fitBounds function.\n const transformedFeatures = {\n type: 'FeatureCollection',\n features: [turfPoint(routeSegment.coordinates[0])],\n } as FeatureCollection;\n const forwardTransformed = transformTranslate(\n transformedFeatures as any,\n 0.025,\n 3,\n ).features[0].geometry.coordinates;\n\n const reverseTransformed = transformTranslate(\n transformedFeatures as any,\n -0.025,\n -3,\n ).features[0].geometry.coordinates;\n\n const bbox = [reverseTransformed, forwardTransformed];\n this.map.fitBounds(\n bbox as any,\n fitBoundsConfig,\n );\n }\n }\n } else {\n console.log('at vertical portal segment, ignoring!');\n }\n\n console.log(route.segments[segmentNumberToHighlight].instructions);\n } else {\n console.warn(\n 'Invalid segment number passed to highlightRouteSegment',\n );\n }\n }\n\n clearRoute() {\n const featureCollectionToDraw = {\n type: 'FeatureCollection',\n features: [],\n } as FeatureCollection;\n\n this.updateRouteSource(featureCollectionToDraw);\n this.updateAnimateRouteSource(featureCollectionToDraw);\n this.route = null;\n cancelAnimationFrame(this.animationFrameID);\n }\n}\n"],"mappings":";;;AAAA,SAASA,SAAS,QAAQ,QAAQ;AAClC,OAAOC,UAAU,MAAwB,aAAa;AACtD,SACSC,KAAK,IAAIC,SAAS,EACzBD,KAAK,QACA,eAAe;AACtB,OAAOE,MAAM,MAAM,cAAc;AACjC,SAASC,kBAAkB,QAAQ,6BAA6B;AAChE;AACA,OAAO,KAAKC,IAAI,MAAM,YAAY;AAClC,SAASC,kBAAkB,QAAQ,2BAA2B;AAAC,SAEtDC,aAAa,EAAEC,UAAU,EAAEC,cAAc;AAAA,SAEhDC,YAAY,EAAuBC,WAAW,EAAEC,oBAAoB,EAAEC,uBAAuB,EAAEC,mBAAmB,EAAEC,mCAAmC,EAAEC,QAAQ,EAAEC,qBAAqB,EACxLC,iBAAiB;AAAA,SAEVC,kBAAkB,EAAEC,WAAW;AACxC,SAASC,UAAU,QAAQ,YAAY;AAAC,OACjCC,iBAAiB;AAExB,OAAO,MAAMC,iBAAiB,CAAC;EAoC7BC,WAAWA,CAACC,GAAQ,EAAE;IAjCtB;IAAAC,eAAA,0BACkB,cAAc;IAAAA,eAAA,iCAEP;MACvBC,IAAI,EAAE,mBAAmB;MACzBC,QAAQ,EAAE;IACZ,CAAC;IAAAF,eAAA,mCAI0B,CAAC,CAAC;IAAAA,eAAA,6BAER,CAAC,CAAC;IAEvB;IAAAA,eAAA,iCACyB,qBAAqB;IAAAA,eAAA,2BAE3B,CAAC,CAAC;IAAAA,eAAA,+CAEkB;MACrCC,IAAI,E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IACX,MAAMrC,uBAAuB,GAAG;MAC9B/I,IAAI,EAAE,mBAAmB;MACzBC,QAAQ,EAAE;IACZ,CAAsB;IAEtB,IAAI,CAACoH,iBAAiB,CAAC0B,uBAAuB,CAAC;IAC/C,IAAI,CAACxB,wBAAwB,CAACwB,uBAAuB,CAAC;IACtD,IAAI,CAACtB,KAAK,GAAG,IAAI;IACjBE,oBAAoB,CAAC,IAAI,CAACxF,gBAAgB,CAAC;EAC7C;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { useRef, useEffect, useCallback, useMemo } from 'react';
|
|
2
|
+
import { Map } from 'react-map-gl/maplibre';
|
|
3
|
+
import maplibregl from 'maplibre-gl';
|
|
4
|
+
import 'maplibre-gl/dist/maplibre-gl.css';
|
|
5
|
+
import { MetaAtlasSdk, DEFAULT_MAP_STYLE } from "../meta-atlas-sdk/meta-atlas-sdk.js";
|
|
6
|
+
import { useMetaAtlasStore } from "./stores/useMetaAtlasStore.js";
|
|
7
|
+
import { useFocus } from "./hooks/useFocus/index.js";
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
export function MetaAtlasMap(_ref) {
|
|
10
|
+
let {
|
|
11
|
+
accessToken,
|
|
12
|
+
secretKey,
|
|
13
|
+
role = 'changipublic',
|
|
14
|
+
onLoad,
|
|
15
|
+
onLoadFail,
|
|
16
|
+
onRoutingStatusUpdate = _loaded => {},
|
|
17
|
+
onSearchStatusUpdate = _loaded => {},
|
|
18
|
+
initialViewState: initialViewStateProp,
|
|
19
|
+
style,
|
|
20
|
+
children
|
|
21
|
+
} = _ref;
|
|
22
|
+
const mapRef = useRef(null);
|
|
23
|
+
|
|
24
|
+
// Get store state and actions
|
|
25
|
+
const sdk = useMetaAtlasStore(state => state.sdk);
|
|
26
|
+
const mapCoreReady = useMetaAtlasStore(state => state.mapCoreReady);
|
|
27
|
+
const setSdk = useMetaAtlasStore(state => state.setSdk);
|
|
28
|
+
const setMapCoreReady = useMetaAtlasStore(state => state.setMapCoreReady);
|
|
29
|
+
const setRoutingReady = useMetaAtlasStore(state => state.setRoutingReady);
|
|
30
|
+
const setSearchReady = useMetaAtlasStore(state => state.setSearchReady);
|
|
31
|
+
const setError = useMetaAtlasStore(state => state.setError);
|
|
32
|
+
|
|
33
|
+
// Get camera props from focusTree when not provided as prop
|
|
34
|
+
const {
|
|
35
|
+
getRootSiteCameraProps,
|
|
36
|
+
isReady
|
|
37
|
+
} = useFocus();
|
|
38
|
+
|
|
39
|
+
// Default fallback view state
|
|
40
|
+
const defaultViewState = null;
|
|
41
|
+
|
|
42
|
+
// Compute initialViewState: use prop if provided, otherwise try to get from focusTree
|
|
43
|
+
const initialViewState = useMemo(() => {
|
|
44
|
+
// If prop is provided, use it
|
|
45
|
+
if (initialViewStateProp) {
|
|
46
|
+
return initialViewStateProp;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Try to get from focusTree root site camera config
|
|
50
|
+
const cameraProps = getRootSiteCameraProps('web');
|
|
51
|
+
if (cameraProps) {
|
|
52
|
+
return {
|
|
53
|
+
longitude: cameraProps.longitude,
|
|
54
|
+
latitude: cameraProps.latitude,
|
|
55
|
+
zoom: cameraProps.zoom,
|
|
56
|
+
bearing: cameraProps.bearing,
|
|
57
|
+
pitch: cameraProps.pitch
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Fallback to default
|
|
62
|
+
return defaultViewState;
|
|
63
|
+
}, [initialViewStateProp, isReady, getRootSiteCameraProps]);
|
|
64
|
+
|
|
65
|
+
// Initialize SDK instance
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
const handleLoad = () => {
|
|
68
|
+
onLoad === null || onLoad === void 0 || onLoad();
|
|
69
|
+
};
|
|
70
|
+
const handleLoadFail = errorMessage => {
|
|
71
|
+
setError(errorMessage);
|
|
72
|
+
setMapCoreReady(false);
|
|
73
|
+
onLoadFail === null || onLoadFail === void 0 || onLoadFail(errorMessage);
|
|
74
|
+
};
|
|
75
|
+
const handleRoutingStatusUpdate = isReady => {
|
|
76
|
+
setRoutingReady(isReady);
|
|
77
|
+
onRoutingStatusUpdate === null || onRoutingStatusUpdate === void 0 || onRoutingStatusUpdate(isReady);
|
|
78
|
+
};
|
|
79
|
+
const handleSearchStatusUpdate = isReady => {
|
|
80
|
+
setSearchReady(isReady);
|
|
81
|
+
onSearchStatusUpdate === null || onSearchStatusUpdate === void 0 || onSearchStatusUpdate(isReady);
|
|
82
|
+
};
|
|
83
|
+
const sdkInstance = new MetaAtlasSdk(accessToken, secretKey, handleLoad, handleLoadFail, handleRoutingStatusUpdate, handleSearchStatusUpdate);
|
|
84
|
+
setSdk(sdkInstance);
|
|
85
|
+
return () => {
|
|
86
|
+
// Cleanup if needed
|
|
87
|
+
// Note: SDK cleanup logic can be added here if needed
|
|
88
|
+
};
|
|
89
|
+
}, [accessToken, secretKey]);
|
|
90
|
+
|
|
91
|
+
// Attach SDK to map instance when map is ready
|
|
92
|
+
const handleMapLoad = useCallback(() => {
|
|
93
|
+
if (mapRef.current && sdk && !mapCoreReady) {
|
|
94
|
+
console.log('map load', mapRef.current);
|
|
95
|
+
const mapInstance = mapRef.current.getMap();
|
|
96
|
+
|
|
97
|
+
// Initialize SDK with the map instance
|
|
98
|
+
sdk.setupMap(role, mapInstance);
|
|
99
|
+
setMapCoreReady(true);
|
|
100
|
+
}
|
|
101
|
+
}, [sdk, setMapCoreReady, mapCoreReady]);
|
|
102
|
+
|
|
103
|
+
// Don't render map until initialViewState is available
|
|
104
|
+
if (!initialViewState) {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
return /*#__PURE__*/_jsx(Map, {
|
|
108
|
+
ref: mapRef,
|
|
109
|
+
mapLib: maplibregl,
|
|
110
|
+
initialViewState: initialViewState,
|
|
111
|
+
onLoad: handleMapLoad,
|
|
112
|
+
style: style || {
|
|
113
|
+
width: '100%',
|
|
114
|
+
height: '100%'
|
|
115
|
+
},
|
|
116
|
+
mapStyle: DEFAULT_MAP_STYLE,
|
|
117
|
+
children: children
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=MetaAtlasMap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MetaAtlasMap.js","names":["useRef","useEffect","useCallback","useMemo","Map","maplibregl","MetaAtlasSdk","DEFAULT_MAP_STYLE","useMetaAtlasStore","useFocus","jsx","_jsx","MetaAtlasMap","_ref","accessToken","secretKey","role","onLoad","onLoadFail","onRoutingStatusUpdate","_loaded","onSearchStatusUpdate","initialViewState","initialViewStateProp","style","children","mapRef","sdk","state","mapCoreReady","setSdk","setMapCoreReady","setRoutingReady","setSearchReady","setError","getRootSiteCameraProps","isReady","defaultViewState","cameraProps","longitude","latitude","zoom","bearing","pitch","handleLoad","handleLoadFail","errorMessage","handleRoutingStatusUpdate","handleSearchStatusUpdate","sdkInstance","handleMapLoad","current","console","log","mapInstance","getMap","setupMap","ref","mapLib","width","height","mapStyle"],"sources":["../../../src/react/MetaAtlasMap.tsx"],"sourcesContent":["import { useRef, useEffect, useCallback, useMemo } from 'react';\nimport { Map, MapRef } from 'react-map-gl/maplibre';\nimport maplibregl from 'maplibre-gl';\nimport 'maplibre-gl/dist/maplibre-gl.css';\nimport { MetaAtlasSdk, DEFAULT_MAP_STYLE } from '../meta-atlas-sdk/meta-atlas-sdk';\nimport { useMetaAtlasStore } from './stores/useMetaAtlasStore';\nimport { MetaAtlasMapProps } from './types';\nimport { useFocus } from './hooks/useFocus';\n\nexport function MetaAtlasMap({\n accessToken,\n secretKey,\n role = 'changipublic',\n onLoad,\n onLoadFail,\n onRoutingStatusUpdate = (_loaded: boolean) => {},\n onSearchStatusUpdate = (_loaded: boolean) => {},\n initialViewState: initialViewStateProp,\n style,\n children,\n}: MetaAtlasMapProps) {\n const mapRef = useRef<MapRef>(null);\n \n // Get store state and actions\n const sdk = useMetaAtlasStore((state) => state.sdk);\n const mapCoreReady = useMetaAtlasStore((state) => state.mapCoreReady);\n const setSdk = useMetaAtlasStore((state) => state.setSdk);\n const setMapCoreReady = useMetaAtlasStore((state) => state.setMapCoreReady);\n const setRoutingReady = useMetaAtlasStore((state) => state.setRoutingReady);\n const setSearchReady = useMetaAtlasStore((state) => state.setSearchReady);\n const setError = useMetaAtlasStore((state) => state.setError);\n\n // Get camera props from focusTree when not provided as prop\n const { getRootSiteCameraProps, isReady } = useFocus();\n \n // Default fallback view state\n const defaultViewState = null;\n\n // Compute initialViewState: use prop if provided, otherwise try to get from focusTree\n const initialViewState = useMemo(() => {\n // If prop is provided, use it\n if (initialViewStateProp) {\n return initialViewStateProp;\n }\n \n // Try to get from focusTree root site camera config\n const cameraProps = getRootSiteCameraProps('web');\n if (cameraProps) {\n return {\n longitude: cameraProps.longitude,\n latitude: cameraProps.latitude,\n zoom: cameraProps.zoom,\n bearing: cameraProps.bearing,\n pitch: cameraProps.pitch,\n };\n }\n \n // Fallback to default\n return defaultViewState;\n }, [initialViewStateProp, isReady, getRootSiteCameraProps]);\n\n // Initialize SDK instance\n useEffect(() => {\n const handleLoad = () => {\n onLoad?.();\n };\n\n const handleLoadFail = (errorMessage: string) => {\n setError(errorMessage);\n setMapCoreReady(false);\n onLoadFail?.(errorMessage);\n };\n\n const handleRoutingStatusUpdate = (isReady: boolean) => {\n setRoutingReady(isReady);\n onRoutingStatusUpdate?.(isReady);\n };\n\n const handleSearchStatusUpdate = (isReady: boolean) => {\n setSearchReady(isReady);\n onSearchStatusUpdate?.(isReady);\n };\n\n const sdkInstance = new MetaAtlasSdk(\n accessToken,\n secretKey,\n handleLoad,\n handleLoadFail,\n handleRoutingStatusUpdate,\n handleSearchStatusUpdate\n );\n\n setSdk(sdkInstance);\n\n return () => {\n // Cleanup if needed\n // Note: SDK cleanup logic can be added here if needed\n };\n }, [accessToken, secretKey]);\n\n // Attach SDK to map instance when map is ready\n const handleMapLoad = useCallback(() => {\n if (mapRef.current && sdk && !mapCoreReady) {\n console.log('map load', mapRef.current);\n const mapInstance = mapRef.current.getMap();\n \n // Initialize SDK with the map instance\n sdk.setupMap(role, mapInstance as any);\n \n setMapCoreReady(true); \n }\n }, [sdk, setMapCoreReady, mapCoreReady]);\n \n // Don't render map until initialViewState is available\n if (!initialViewState) {\n return null;\n }\n\n return (\n <Map\n ref={mapRef}\n mapLib={maplibregl as any}\n initialViewState={initialViewState}\n onLoad={handleMapLoad}\n style={style || { width: '100%', height: '100%' }}\n mapStyle={DEFAULT_MAP_STYLE}\n >\n {children}\n </Map>\n );\n}\n\n"],"mappings":"AAAA,SAASA,MAAM,EAAEC,SAAS,EAAEC,WAAW,EAAEC,OAAO,QAAQ,OAAO;AAC/D,SAASC,GAAG,QAAgB,uBAAuB;AACnD,OAAOC,UAAU,MAAM,aAAa;AACpC,OAAO,kCAAkC;AAAC,SACjCC,YAAY,EAAEC,iBAAiB;AAAA,SAC/BC,iBAAiB;AAAA,SAEjBC,QAAQ;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAEjB,OAAO,SAASC,YAAYA,CAAAC,IAAA,EAWN;EAAA,IAXO;IAC3BC,WAAW;IACXC,SAAS;IACTC,IAAI,GAAG,cAAc;IACrBC,MAAM;IACNC,UAAU;IACVC,qBAAqB,GAAIC,OAAgB,IAAK,CAAC,CAAC;IAChDC,oBAAoB,GAAID,OAAgB,IAAK,CAAC,CAAC;IAC/CE,gBAAgB,EAAEC,oBAAoB;IACtCC,KAAK;IACLC;EACiB,CAAC,GAAAZ,IAAA;EAClB,MAAMa,MAAM,GAAG1B,MAAM,CAAS,IAAI,CAAC;;EAEnC;EACA,MAAM2B,GAAG,GAAGnB,iBAAiB,CAAEoB,KAAK,IAAKA,KAAK,CAACD,GAAG,CAAC;EACnD,MAAME,YAAY,GAAGrB,iBAAiB,CAAEoB,KAAK,IAAKA,KAAK,CAACC,YAAY,CAAC;EACrE,MAAMC,MAAM,GAAGtB,iBAAiB,CAAEoB,KAAK,IAAKA,KAAK,CAACE,MAAM,CAAC;EACzD,MAAMC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AiB;IACnCL,MAAM,EAAEiC,aAAc;IACtB1B,KAAK,EAAEA,KAAK,IAAI;MAAEmC,KAAK,EAAE,MAAM;MAAEC,MAAM,EAAE;IAAO,CAAE;IAClDC,QAAQ,EAAEtD,iBAAkB;IAAAkB,QAAA,EAE3BA;EAAQ,CACN,CAAC;AAEV","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useMetaAtlas } from
|
|
2
|
-
import { useMetaAtlasStore } from
|
|
1
|
+
import { useMetaAtlas } from "../useMetaAtlas/index.js";
|
|
2
|
+
import { useMetaAtlasStore } from "../../stores/useMetaAtlasStore.js";
|
|
3
3
|
export function useDrawing() {
|
|
4
4
|
const {
|
|
5
5
|
drawGeometryOnMap,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useMetaAtlas","useMetaAtlasStore","useDrawing","drawGeometryOnMap","addDrawingsToBaseMap","editDrawing","removeDrawing","getDrawingById","isInDrawMode","mapCoreReady","state","isReady"],"sources":["../../../../../src/react/hooks/useDrawing/index.ts"],"sourcesContent":["import { useMetaAtlas } from '../useMetaAtlas';\nimport { useMetaAtlasStore } from '../../stores/useMetaAtlasStore';\nimport { UseDrawingReturn } from './types';\n\nexport function useDrawing(): UseDrawingReturn {\n const { \n drawGeometryOnMap, \n addDrawingsToBaseMap, \n editDrawing, \n removeDrawing, \n getDrawingById, \n isInDrawMode,\n } = useMetaAtlas();\n \n const mapCoreReady = useMetaAtlasStore((state) => state.mapCoreReady);\n\n return {\n drawGeometryOnMap,\n addDrawingsToBaseMap,\n editDrawing,\n removeDrawing,\n getDrawingById,\n isInDrawMode,\n isReady: mapCoreReady, // Use mapCoreReady flag\n };\n}\n\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":["useMetaAtlas","useMetaAtlasStore","useDrawing","drawGeometryOnMap","addDrawingsToBaseMap","editDrawing","removeDrawing","getDrawingById","isInDrawMode","mapCoreReady","state","isReady"],"sources":["../../../../../src/react/hooks/useDrawing/index.ts"],"sourcesContent":["import { useMetaAtlas } from '../useMetaAtlas';\nimport { useMetaAtlasStore } from '../../stores/useMetaAtlasStore';\nimport { UseDrawingReturn } from './types';\n\nexport function useDrawing(): UseDrawingReturn {\n const { \n drawGeometryOnMap, \n addDrawingsToBaseMap, \n editDrawing, \n removeDrawing, \n getDrawingById, \n isInDrawMode,\n } = useMetaAtlas();\n \n const mapCoreReady = useMetaAtlasStore((state) => state.mapCoreReady);\n\n return {\n drawGeometryOnMap,\n addDrawingsToBaseMap,\n editDrawing,\n removeDrawing,\n getDrawingById,\n isInDrawMode,\n isReady: mapCoreReady, // Use mapCoreReady flag\n };\n}\n\n"],"mappings":"SAASA,YAAY;AAAA,SACZC,iBAAiB;AAG1B,OAAO,SAASC,UAAUA,CAAA,EAAqB;EAC7C,MAAM;IACJC,iBAAiB;IACjBC,oBAAoB;IACpBC,WAAW;IACXC,aAAa;IACbC,cAAc;IACdC;EACF,CAAC,GAAGR,YAAY,CAAC,CAAC;EAElB,MAAMS,YAAY,GAAGR,iBAAiB,CAAES,KAAK,IAAKA,KAAK,CAACD,YAAY,CAAC;EAErE,OAAO;IACLN,iBAAiB;IACjBC,oBAAoB;IACpBC,WAAW;IACXC,aAAa;IACbC,cAAc;IACdC,YAAY;IACZG,OAAO,EAAEF,YAAY,CAAE;EACzB,CAAC;AACH","ignoreList":[]}
|