@mapvx/web-js 4.0.2 → 4.0.3-dev.2
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/README.md +7 -7
- package/dist/cjs/index.js +4 -2
- package/dist/es/assets/icons.d.ts +0 -1
- package/dist/es/assets/icons.js +0 -50
- package/dist/es/config/draco.d.ts +0 -1
- package/dist/es/config/draco.js +0 -10
- package/dist/es/config/sdkConfig.d.ts +0 -1
- package/dist/es/config/sdkConfig.js +0 -1
- package/dist/es/controllers/markerLayoutController.d.ts +0 -1
- package/dist/es/controllers/markerLayoutController.js +0 -103
- package/dist/es/controllers/routeController.d.ts +0 -1
- package/dist/es/controllers/routeController.js +1 -473
- package/dist/es/domain/models/_internal.d.ts +0 -1
- package/dist/es/domain/models/_internal.js +0 -8
- package/dist/es/domain/models/animation.d.ts +0 -1
- package/dist/es/domain/models/animation.js +0 -6
- package/dist/es/domain/models/banner.d.ts +0 -1
- package/dist/es/domain/models/banner.js +0 -10
- package/dist/es/domain/models/campaign.d.ts +0 -1
- package/dist/es/domain/models/campaign.js +0 -29
- package/dist/es/domain/models/categories.d.ts +0 -1
- package/dist/es/domain/models/categories.js +0 -20
- package/dist/es/domain/models/circle.d.ts +0 -1
- package/dist/es/domain/models/circle.js +0 -118
- package/dist/es/domain/models/cityFilterOption.d.ts +0 -1
- package/dist/es/domain/models/cityFilterOption.js +0 -1
- package/dist/es/domain/models/configuration.d.ts +0 -1
- package/dist/es/domain/models/configuration.js +0 -1
- package/dist/es/domain/models/cssCustomization.d.ts +0 -1
- package/dist/es/domain/models/cssCustomization.js +0 -1
- package/dist/es/domain/models/fitOptions.d.ts +0 -1
- package/dist/es/domain/models/fitOptions.js +0 -1
- package/dist/es/domain/models/innerFloors.d.ts +0 -1
- package/dist/es/domain/models/innerFloors.js +0 -1
- package/dist/es/domain/models/institution.d.ts +0 -1
- package/dist/es/domain/models/institution.js +0 -26
- package/dist/es/domain/models/latLng.d.ts +0 -1
- package/dist/es/domain/models/latLng.js +0 -1
- package/dist/es/domain/models/location.d.ts +0 -1
- package/dist/es/domain/models/location.js +0 -1
- package/dist/es/domain/models/loggeable.d.ts +0 -1
- package/dist/es/domain/models/loggeable.js +0 -24
- package/dist/es/domain/models/mapCamera.d.ts +0 -1
- package/dist/es/domain/models/mapCamera.js +0 -1
- package/dist/es/domain/models/mapConfig.d.ts +0 -1
- package/dist/es/domain/models/mapConfig.js +1 -17
- package/dist/es/domain/models/marker.d.ts +0 -1
- package/dist/es/domain/models/marker.js +0 -292
- package/dist/es/domain/models/multilanguage.d.ts +0 -1
- package/dist/es/domain/models/multilanguage.js +0 -10
- package/dist/es/domain/models/openingHours.d.ts +0 -1
- package/dist/es/domain/models/openingHours.js +0 -1
- package/dist/es/domain/models/place.d.ts +0 -1
- package/dist/es/domain/models/place.js +0 -68
- package/dist/es/domain/models/platform.d.ts +0 -1
- package/dist/es/domain/models/platform.js +0 -1
- package/dist/es/domain/models/popover.d.ts +0 -1
- package/dist/es/domain/models/popover.js +0 -1
- package/dist/es/domain/models/product.d.ts +0 -1
- package/dist/es/domain/models/product.js +0 -1
- package/dist/es/domain/models/property.d.ts +0 -1
- package/dist/es/domain/models/property.js +0 -16
- package/dist/es/domain/models/route.d.ts +0 -1
- package/dist/es/domain/models/route.js +0 -71
- package/dist/es/domain/models/routeConfiguration.d.ts +0 -1
- package/dist/es/domain/models/routeConfiguration.js +0 -36
- package/dist/es/domain/models/routeInstance.d.ts +0 -1
- package/dist/es/domain/models/routeInstance.js +0 -8
- package/dist/es/domain/models/routeStyle.d.ts +0 -1
- package/dist/es/domain/models/routeStyle.js +0 -1
- package/dist/es/domain/models/scene3D.d.ts +0 -1
- package/dist/es/domain/models/scene3D.js +0 -1
- package/dist/es/domain/models/transport.d.ts +0 -1
- package/dist/es/domain/models/transport.js +0 -12
- package/dist/es/domain/ports/ICache.d.ts +0 -1
- package/dist/es/domain/ports/ICache.js +0 -1
- package/dist/es/domain/ports/IHttpClient.d.ts +0 -1
- package/dist/es/domain/ports/IHttpClient.js +0 -1
- package/dist/es/domain/ports/ILogger.d.ts +0 -1
- package/dist/es/domain/ports/ILogger.js +0 -9
- package/dist/es/domain/ports/index.d.ts +0 -1
- package/dist/es/domain/ports/index.js +0 -5
- package/dist/es/index.d.ts +0 -1
- package/dist/es/index.js +1 -28
- package/dist/es/infrastructure/cache/CacheManager.d.ts +0 -1
- package/dist/es/infrastructure/cache/CacheManager.js +0 -94
- package/dist/es/infrastructure/cache/LRUCache.d.ts +0 -1
- package/dist/es/infrastructure/cache/LRUCache.js +0 -57
- package/dist/es/infrastructure/cache/PersistentCache.d.ts +0 -1
- package/dist/es/infrastructure/cache/PersistentCache.js +0 -51
- package/dist/es/infrastructure/cache/cacheConfig.d.ts +0 -1
- package/dist/es/infrastructure/cache/cacheConfig.js +8 -27
- package/dist/es/infrastructure/http/FetchHttpClient.d.ts +0 -1
- package/dist/es/infrastructure/http/FetchHttpClient.js +0 -36
- package/dist/es/infrastructure/logging/MVXLogger.d.ts +0 -1
- package/dist/es/infrastructure/logging/MVXLogger.js +0 -37
- package/dist/es/interfaces/cache.d.ts +0 -1
- package/dist/es/interfaces/cache.js +0 -1
- package/dist/es/interfaces/healthResponse.d.ts +0 -1
- package/dist/es/interfaces/healthResponse.js +0 -1
- package/dist/es/interfaces/institutionResponse.d.ts +0 -1
- package/dist/es/interfaces/institutionResponse.js +0 -1
- package/dist/es/interfaces/metadata.d.ts +0 -1
- package/dist/es/interfaces/metadata.js +0 -1
- package/dist/es/interfaces/placeResponse.d.ts +0 -1
- package/dist/es/interfaces/placeResponse.js +0 -1
- package/dist/es/interfaces/routeCacheResponse.d.ts +0 -1
- package/dist/es/interfaces/routeCacheResponse.js +0 -1
- package/dist/es/interfaces/routeResponse.d.ts +0 -1
- package/dist/es/interfaces/routeResponse.js +0 -1
- package/dist/es/interfaces/styleResponse.d.ts +0 -1
- package/dist/es/interfaces/styleResponse.js +0 -1
- package/dist/es/logger/logger.d.ts +0 -1
- package/dist/es/logger/logger.js +0 -10
- package/dist/es/logger/sentry.d.ts +0 -1
- package/dist/es/logger/sentry.js +1 -39
- package/dist/es/map/fitCamera.d.ts +0 -1
- package/dist/es/map/fitCamera.js +0 -44
- package/dist/es/map/generated/maplibreWorkerSource.d.ts +0 -1
- package/dist/es/map/generated/maplibreWorkerSource.js +0 -12
- package/dist/es/map/installMapLibreWorker.d.ts +0 -1
- package/dist/es/map/installMapLibreWorker.js +0 -100
- package/dist/es/map/liveMapFitTransform.d.ts +0 -1
- package/dist/es/map/liveMapFitTransform.js +0 -82
- package/dist/es/map/map.d.ts +0 -1
- package/dist/es/map/map.js +4 -681
- package/dist/es/map/mapInteractionOptions.d.ts +0 -1
- package/dist/es/map/mapInteractionOptions.js +0 -35
- package/dist/es/map/scene3DController.d.ts +0 -1
- package/dist/es/map/scene3DController.js +0 -221
- package/dist/es/repository/repository.d.ts +0 -1
- package/dist/es/repository/repository.js +0 -56
- package/dist/es/repository/requester.d.ts +0 -1
- package/dist/es/repository/requester.js +0 -233
- package/dist/es/sdk.d.ts +0 -1
- package/dist/es/sdk.js +0 -35
- package/dist/es/utils/3d.d.ts +0 -1
- package/dist/es/utils/3d.js +0 -79
- package/dist/es/utils/deckLayers.d.ts +0 -1
- package/dist/es/utils/deckLayers.js +1 -27
- package/dist/es/utils/error.d.ts +0 -1
- package/dist/es/utils/error.js +0 -7
- package/dist/es/utils/images.d.ts +0 -1
- package/dist/es/utils/images.js +0 -7
- package/dist/es/utils/loadGlb.d.ts +0 -1
- package/dist/es/utils/loadGlb.js +2 -96
- package/dist/es/utils/mapvxHostname.d.ts +0 -1
- package/dist/es/utils/mapvxHostname.js +0 -11
- package/dist/es/utils/nav-functions.d.ts +0 -1
- package/dist/es/utils/nav-functions.js +0 -82
- package/dist/es/utils/opening-hours-helper.d.ts +0 -1
- package/dist/es/utils/opening-hours-helper.js +6 -382
- package/dist/es/utils/preconnect.d.ts +0 -1
- package/dist/es/utils/preconnect.js +0 -61
- package/dist/es/utils/route-utils.d.ts +0 -1
- package/dist/es/utils/route-utils.js +0 -25
- package/dist/es/utils/semaphore.d.ts +0 -1
- package/dist/es/utils/semaphore.js +0 -78
- package/dist/es/utils/three.d.ts +0 -1
- package/dist/es/utils/three.js +0 -43
- package/dist/es/utils/threeScene.d.ts +0 -1
- package/dist/es/utils/threeScene.js +0 -38
- package/dist/es/utils/update-css.d.ts +0 -1
- package/dist/es/utils/update-css.js +0 -26
- package/dist/es/utils/utils.d.ts +0 -1
- package/dist/es/utils/utils.js +0 -53
- package/dist/umd/index.js +4 -29240
- package/dist/umd/index.js.LICENSE.txt +1 -0
- package/dist/umd/styles.css +0 -1
- package/dist/umd/styles.js +3 -32
- package/package.json +12 -6
- package/dist/cjs/index.js.map +0 -1
- package/dist/es/assets/icons.d.ts.map +0 -1
- package/dist/es/assets/icons.js.map +0 -1
- package/dist/es/config/draco.d.ts.map +0 -1
- package/dist/es/config/draco.js.map +0 -1
- package/dist/es/config/sdkConfig.d.ts.map +0 -1
- package/dist/es/config/sdkConfig.js.map +0 -1
- package/dist/es/controllers/markerLayoutController.d.ts.map +0 -1
- package/dist/es/controllers/markerLayoutController.js.map +0 -1
- package/dist/es/controllers/routeController.d.ts.map +0 -1
- package/dist/es/controllers/routeController.js.map +0 -1
- package/dist/es/domain/models/_internal.d.ts.map +0 -1
- package/dist/es/domain/models/_internal.js.map +0 -1
- package/dist/es/domain/models/animation.d.ts.map +0 -1
- package/dist/es/domain/models/animation.js.map +0 -1
- package/dist/es/domain/models/banner.d.ts.map +0 -1
- package/dist/es/domain/models/banner.js.map +0 -1
- package/dist/es/domain/models/campaign.d.ts.map +0 -1
- package/dist/es/domain/models/campaign.js.map +0 -1
- package/dist/es/domain/models/categories.d.ts.map +0 -1
- package/dist/es/domain/models/categories.js.map +0 -1
- package/dist/es/domain/models/circle.d.ts.map +0 -1
- package/dist/es/domain/models/circle.js.map +0 -1
- package/dist/es/domain/models/cityFilterOption.d.ts.map +0 -1
- package/dist/es/domain/models/cityFilterOption.js.map +0 -1
- package/dist/es/domain/models/configuration.d.ts.map +0 -1
- package/dist/es/domain/models/configuration.js.map +0 -1
- package/dist/es/domain/models/cssCustomization.d.ts.map +0 -1
- package/dist/es/domain/models/cssCustomization.js.map +0 -1
- package/dist/es/domain/models/fitOptions.d.ts.map +0 -1
- package/dist/es/domain/models/fitOptions.js.map +0 -1
- package/dist/es/domain/models/innerFloors.d.ts.map +0 -1
- package/dist/es/domain/models/innerFloors.js.map +0 -1
- package/dist/es/domain/models/institution.d.ts.map +0 -1
- package/dist/es/domain/models/institution.js.map +0 -1
- package/dist/es/domain/models/latLng.d.ts.map +0 -1
- package/dist/es/domain/models/latLng.js.map +0 -1
- package/dist/es/domain/models/location.d.ts.map +0 -1
- package/dist/es/domain/models/location.js.map +0 -1
- package/dist/es/domain/models/loggeable.d.ts.map +0 -1
- package/dist/es/domain/models/loggeable.js.map +0 -1
- package/dist/es/domain/models/mapCamera.d.ts.map +0 -1
- package/dist/es/domain/models/mapCamera.js.map +0 -1
- package/dist/es/domain/models/mapConfig.d.ts.map +0 -1
- package/dist/es/domain/models/mapConfig.js.map +0 -1
- package/dist/es/domain/models/marker.d.ts.map +0 -1
- package/dist/es/domain/models/marker.js.map +0 -1
- package/dist/es/domain/models/multilanguage.d.ts.map +0 -1
- package/dist/es/domain/models/multilanguage.js.map +0 -1
- package/dist/es/domain/models/openingHours.d.ts.map +0 -1
- package/dist/es/domain/models/openingHours.js.map +0 -1
- package/dist/es/domain/models/place.d.ts.map +0 -1
- package/dist/es/domain/models/place.js.map +0 -1
- package/dist/es/domain/models/platform.d.ts.map +0 -1
- package/dist/es/domain/models/platform.js.map +0 -1
- package/dist/es/domain/models/popover.d.ts.map +0 -1
- package/dist/es/domain/models/popover.js.map +0 -1
- package/dist/es/domain/models/product.d.ts.map +0 -1
- package/dist/es/domain/models/product.js.map +0 -1
- package/dist/es/domain/models/property.d.ts.map +0 -1
- package/dist/es/domain/models/property.js.map +0 -1
- package/dist/es/domain/models/route.d.ts.map +0 -1
- package/dist/es/domain/models/route.js.map +0 -1
- package/dist/es/domain/models/routeConfiguration.d.ts.map +0 -1
- package/dist/es/domain/models/routeConfiguration.js.map +0 -1
- package/dist/es/domain/models/routeInstance.d.ts.map +0 -1
- package/dist/es/domain/models/routeInstance.js.map +0 -1
- package/dist/es/domain/models/routeStyle.d.ts.map +0 -1
- package/dist/es/domain/models/routeStyle.js.map +0 -1
- package/dist/es/domain/models/scene3D.d.ts.map +0 -1
- package/dist/es/domain/models/scene3D.js.map +0 -1
- package/dist/es/domain/models/transport.d.ts.map +0 -1
- package/dist/es/domain/models/transport.js.map +0 -1
- package/dist/es/domain/ports/ICache.d.ts.map +0 -1
- package/dist/es/domain/ports/ICache.js.map +0 -1
- package/dist/es/domain/ports/IHttpClient.d.ts.map +0 -1
- package/dist/es/domain/ports/IHttpClient.js.map +0 -1
- package/dist/es/domain/ports/ILogger.d.ts.map +0 -1
- package/dist/es/domain/ports/ILogger.js.map +0 -1
- package/dist/es/domain/ports/index.d.ts.map +0 -1
- package/dist/es/domain/ports/index.js.map +0 -1
- package/dist/es/index.d.ts.map +0 -1
- package/dist/es/index.js.map +0 -1
- package/dist/es/infrastructure/cache/CacheManager.d.ts.map +0 -1
- package/dist/es/infrastructure/cache/CacheManager.js.map +0 -1
- package/dist/es/infrastructure/cache/LRUCache.d.ts.map +0 -1
- package/dist/es/infrastructure/cache/LRUCache.js.map +0 -1
- package/dist/es/infrastructure/cache/PersistentCache.d.ts.map +0 -1
- package/dist/es/infrastructure/cache/PersistentCache.js.map +0 -1
- package/dist/es/infrastructure/cache/cacheConfig.d.ts.map +0 -1
- package/dist/es/infrastructure/cache/cacheConfig.js.map +0 -1
- package/dist/es/infrastructure/http/FetchHttpClient.d.ts.map +0 -1
- package/dist/es/infrastructure/http/FetchHttpClient.js.map +0 -1
- package/dist/es/infrastructure/logging/MVXLogger.d.ts.map +0 -1
- package/dist/es/infrastructure/logging/MVXLogger.js.map +0 -1
- package/dist/es/interfaces/cache.d.ts.map +0 -1
- package/dist/es/interfaces/cache.js.map +0 -1
- package/dist/es/interfaces/healthResponse.d.ts.map +0 -1
- package/dist/es/interfaces/healthResponse.js.map +0 -1
- package/dist/es/interfaces/institutionResponse.d.ts.map +0 -1
- package/dist/es/interfaces/institutionResponse.js.map +0 -1
- package/dist/es/interfaces/metadata.d.ts.map +0 -1
- package/dist/es/interfaces/metadata.js.map +0 -1
- package/dist/es/interfaces/placeResponse.d.ts.map +0 -1
- package/dist/es/interfaces/placeResponse.js.map +0 -1
- package/dist/es/interfaces/routeCacheResponse.d.ts.map +0 -1
- package/dist/es/interfaces/routeCacheResponse.js.map +0 -1
- package/dist/es/interfaces/routeResponse.d.ts.map +0 -1
- package/dist/es/interfaces/routeResponse.js.map +0 -1
- package/dist/es/interfaces/styleResponse.d.ts.map +0 -1
- package/dist/es/interfaces/styleResponse.js.map +0 -1
- package/dist/es/logger/logger.d.ts.map +0 -1
- package/dist/es/logger/logger.js.map +0 -1
- package/dist/es/logger/sentry.d.ts.map +0 -1
- package/dist/es/logger/sentry.js.map +0 -1
- package/dist/es/map/fitCamera.d.ts.map +0 -1
- package/dist/es/map/fitCamera.js.map +0 -1
- package/dist/es/map/generated/maplibreWorkerSource.d.ts.map +0 -1
- package/dist/es/map/generated/maplibreWorkerSource.js.map +0 -1
- package/dist/es/map/installMapLibreWorker.d.ts.map +0 -1
- package/dist/es/map/installMapLibreWorker.js.map +0 -1
- package/dist/es/map/liveMapFitTransform.d.ts.map +0 -1
- package/dist/es/map/liveMapFitTransform.js.map +0 -1
- package/dist/es/map/map.d.ts.map +0 -1
- package/dist/es/map/map.js.map +0 -1
- package/dist/es/map/mapInteractionOptions.d.ts.map +0 -1
- package/dist/es/map/mapInteractionOptions.js.map +0 -1
- package/dist/es/map/scene3DController.d.ts.map +0 -1
- package/dist/es/map/scene3DController.js.map +0 -1
- package/dist/es/repository/repository.d.ts.map +0 -1
- package/dist/es/repository/repository.js.map +0 -1
- package/dist/es/repository/requester.d.ts.map +0 -1
- package/dist/es/repository/requester.js.map +0 -1
- package/dist/es/sdk.d.ts.map +0 -1
- package/dist/es/sdk.js.map +0 -1
- package/dist/es/utils/3d.d.ts.map +0 -1
- package/dist/es/utils/3d.js.map +0 -1
- package/dist/es/utils/deckLayers.d.ts.map +0 -1
- package/dist/es/utils/deckLayers.js.map +0 -1
- package/dist/es/utils/error.d.ts.map +0 -1
- package/dist/es/utils/error.js.map +0 -1
- package/dist/es/utils/images.d.ts.map +0 -1
- package/dist/es/utils/images.js.map +0 -1
- package/dist/es/utils/loadGlb.d.ts.map +0 -1
- package/dist/es/utils/loadGlb.js.map +0 -1
- package/dist/es/utils/mapvxHostname.d.ts.map +0 -1
- package/dist/es/utils/mapvxHostname.js.map +0 -1
- package/dist/es/utils/nav-functions.d.ts.map +0 -1
- package/dist/es/utils/nav-functions.js.map +0 -1
- package/dist/es/utils/opening-hours-helper.d.ts.map +0 -1
- package/dist/es/utils/opening-hours-helper.js.map +0 -1
- package/dist/es/utils/preconnect.d.ts.map +0 -1
- package/dist/es/utils/preconnect.js.map +0 -1
- package/dist/es/utils/route-utils.d.ts.map +0 -1
- package/dist/es/utils/route-utils.js.map +0 -1
- package/dist/es/utils/semaphore.d.ts.map +0 -1
- package/dist/es/utils/semaphore.js.map +0 -1
- package/dist/es/utils/three.d.ts.map +0 -1
- package/dist/es/utils/three.js.map +0 -1
- package/dist/es/utils/threeScene.d.ts.map +0 -1
- package/dist/es/utils/threeScene.js.map +0 -1
- package/dist/es/utils/update-css.d.ts.map +0 -1
- package/dist/es/utils/update-css.js.map +0 -1
- package/dist/es/utils/utils.d.ts.map +0 -1
- package/dist/es/utils/utils.js.map +0 -1
- package/dist/umd/index.js.map +0 -1
- package/dist/umd/styles.css.map +0 -1
- package/dist/umd/styles.js.map +0 -1
|
@@ -2,35 +2,15 @@ import { MarkerAttribute } from "../domain/models/marker";
|
|
|
2
2
|
import { createRouteInstance } from "../domain/models/routeInstance";
|
|
3
3
|
import { NavFunctions, compareLatLng } from "../utils/nav-functions";
|
|
4
4
|
import { createPositionsForStops, createStops } from "../utils/utils";
|
|
5
|
-
/**
|
|
6
|
-
* Default padding values for auto-fit by place feature.
|
|
7
|
-
* Used when padding is not explicitly provided in the animation configuration.
|
|
8
|
-
*/
|
|
9
5
|
const DEFAULT_AUTO_FIT_PADDING = {
|
|
10
6
|
top: 150,
|
|
11
7
|
right: 150,
|
|
12
8
|
bottom: 150,
|
|
13
9
|
left: 150,
|
|
14
10
|
};
|
|
15
|
-
/**
|
|
16
|
-
* Longest a step waits for its line to be uploaded before animating anyway, so
|
|
17
|
-
* a stalled worker never freezes the route.
|
|
18
|
-
*
|
|
19
|
-
* A deadline rather than a frame count. `animateStep` is handed a `timestamp`
|
|
20
|
-
* already, and a frame count would stretch to three seconds or more on the
|
|
21
|
-
* 20-30 fps panels this wait exists for — the devices where a frozen marker at
|
|
22
|
-
* every step boundary is most visible.
|
|
23
|
-
*/
|
|
24
11
|
const MAX_SOURCE_WAIT_MS = 1500;
|
|
25
|
-
/** Fully transparent: the part of a step line the reveal has not reached yet. */
|
|
26
12
|
const TRANSPARENT_COLOR = "rgba(0, 0, 0, 0)";
|
|
27
13
|
const REVEAL_EDGE = 1 / 256;
|
|
28
|
-
/**
|
|
29
|
-
* A `line-gradient` ramp that is `color` along the whole line.
|
|
30
|
-
*
|
|
31
|
-
* `line-gradient` only accepts an expression, so "no cut-off at all" still has to be spelled as a
|
|
32
|
-
* ramp. Two stops at the domain ends are the cheapest way to say it and keep them ascending.
|
|
33
|
-
*/
|
|
34
14
|
const constantRamp = (color) => [
|
|
35
15
|
"interpolate",
|
|
36
16
|
["linear"],
|
|
@@ -40,37 +20,7 @@ const constantRamp = (color) => [
|
|
|
40
20
|
1,
|
|
41
21
|
color,
|
|
42
22
|
];
|
|
43
|
-
/**
|
|
44
|
-
* Longest gap between two frames, in milliseconds, that still counts as
|
|
45
|
-
* animation time.
|
|
46
|
-
*
|
|
47
|
-
* The frame loop charges the marker for however much wall clock has elapsed,
|
|
48
|
-
* which is what makes a step take `stepTime` at any frame rate. A gap larger
|
|
49
|
-
* than any frame rate can explain is not slow rendering, though — it is time
|
|
50
|
-
* the animation did not run at all. `requestAnimationFrame` does not fire in a
|
|
51
|
-
* backgrounded tab, so the first frame after the page comes back carries the
|
|
52
|
-
* entire absence, and charging it advanced the draw by the whole gap: one
|
|
53
|
-
* frame 10 s late at 50 m/s consumed exactly a hundred vertices in a single
|
|
54
|
-
* `setData`, with the camera following the line as it jumped.
|
|
55
|
-
*
|
|
56
|
-
* Such a gap is therefore not charged (see `animateStep`). This is deliberately
|
|
57
|
-
* NOT a clamp on how far one frame may advance: clamping would cap the catch-up
|
|
58
|
-
* and hand back the frame-rate independence this loop exists to provide, and it
|
|
59
|
-
* would still be wrong — the marker would sprint to catch up through time
|
|
60
|
-
* nobody watched. Skipping the gap instead is what a pause does, which is what
|
|
61
|
-
* an absence is.
|
|
62
|
-
*
|
|
63
|
-
* 500 ms is two frames per second. Real rendering does not sustain anything
|
|
64
|
-
* near that low, so the threshold only ever separates absence from rendering,
|
|
65
|
-
* and never shortens the catch-up of a genuinely slow frame.
|
|
66
|
-
*/
|
|
67
23
|
const MAX_FRAME_GAP_MS = 500;
|
|
68
|
-
/**
|
|
69
|
-
* Represents the controller for routes on the map.
|
|
70
|
-
* Supports multiple simultaneous routes with independent customizations,
|
|
71
|
-
* animations, and lifecycle management.
|
|
72
|
-
* @group Routes
|
|
73
|
-
*/
|
|
74
24
|
export class RouteController {
|
|
75
25
|
constructor(map) {
|
|
76
26
|
this.routes = new Map();
|
|
@@ -79,22 +29,10 @@ export class RouteController {
|
|
|
79
29
|
get map() {
|
|
80
30
|
return this.mapvxMap.map;
|
|
81
31
|
}
|
|
82
|
-
/**
|
|
83
|
-
* Resolve a route instance by ID, or fall back to the last added route.
|
|
84
|
-
*/
|
|
85
32
|
resolveInstance(routeId) {
|
|
86
33
|
const id = routeId !== null && routeId !== void 0 ? routeId : this.lastAddedRouteId;
|
|
87
34
|
return id ? this.routes.get(id) : undefined;
|
|
88
35
|
}
|
|
89
|
-
/**
|
|
90
|
-
* Add MapLibre sources and layers for a single route instance.
|
|
91
|
-
*
|
|
92
|
-
* All three sources set `lineMetrics`: maplibre computes `line-progress` only
|
|
93
|
-
* when a source asks it to. The CURRENT layer needs it to reveal the step
|
|
94
|
-
* line as the marker advances, and `preparePaintForLayer` emits a
|
|
95
|
-
* `line-progress` gradient for a GradientStyle on any of the three — without
|
|
96
|
-
* it, a consumer setting a gradient route style silently got no gradient.
|
|
97
|
-
*/
|
|
98
36
|
addSourcesAndLayersForRoute(instance) {
|
|
99
37
|
this.map.addSource(instance.aheadId, {
|
|
100
38
|
type: "geojson",
|
|
@@ -139,9 +77,6 @@ export class RouteController {
|
|
|
139
77
|
},
|
|
140
78
|
});
|
|
141
79
|
}
|
|
142
|
-
/**
|
|
143
|
-
* Remove MapLibre sources and layers for a single route instance.
|
|
144
|
-
*/
|
|
145
80
|
removeSourcesAndLayersForRoute(instance) {
|
|
146
81
|
const ids = [instance.aheadId, instance.behindId, instance.currentId];
|
|
147
82
|
for (const id of ids) {
|
|
@@ -149,20 +84,14 @@ export class RouteController {
|
|
|
149
84
|
this.map.removeLayer(id);
|
|
150
85
|
}
|
|
151
86
|
catch (_a) {
|
|
152
|
-
// Layer may not exist
|
|
153
87
|
}
|
|
154
88
|
try {
|
|
155
89
|
this.map.removeSource(id);
|
|
156
90
|
}
|
|
157
91
|
catch (_b) {
|
|
158
|
-
// Source may not exist
|
|
159
92
|
}
|
|
160
93
|
}
|
|
161
94
|
}
|
|
162
|
-
/**
|
|
163
|
-
* Re-add sources and layers for all active routes.
|
|
164
|
-
* Should be called when the map style is reloaded.
|
|
165
|
-
*/
|
|
166
95
|
addSourcesAndLayers() {
|
|
167
96
|
for (const instance of this.routes.values()) {
|
|
168
97
|
this.addSourcesAndLayersForRoute(instance);
|
|
@@ -170,39 +99,15 @@ export class RouteController {
|
|
|
170
99
|
}
|
|
171
100
|
this.syncRouteCollision();
|
|
172
101
|
}
|
|
173
|
-
/**
|
|
174
|
-
* Re-apply the paint a style reload dropped.
|
|
175
|
-
*
|
|
176
|
-
* {@link addSourcesAndLayersForRoute} re-adds the layers with no paint at all, so
|
|
177
|
-
* without this the route keeps its geometry but loses its colors — and the CURRENT
|
|
178
|
-
* layer loses its `line-gradient`, which is the only thing hiding the part of the
|
|
179
|
-
* step the marker has not reached yet: the whole step would be drawn at once.
|
|
180
|
-
*/
|
|
181
102
|
restoreLayerPaint(instance) {
|
|
182
103
|
var _a;
|
|
183
104
|
for (const [layerId, drawConfig] of Object.entries(instance.layerDrawConfigs)) {
|
|
184
105
|
this.setLayerPaint(instance, layerId, drawConfig);
|
|
185
106
|
}
|
|
186
|
-
// `?? 0`: a step whose geometry was loaded while the style was mid-swap
|
|
187
|
-
// never got a reveal recorded, because `applyReveal` bails when there is no
|
|
188
|
-
// layer to paint. Leaving the gradient off entirely then draws the whole
|
|
189
|
-
// step at once in the traveled color, and the `awaitingSources` hold, the
|
|
190
|
-
// rotation phase, the floor-change wait and a pause can each postpone the
|
|
191
|
-
// frame that would correct it — indefinitely, in the case of a pause.
|
|
192
|
-
// Revealing nothing is the safe default.
|
|
193
107
|
const reveal = (_a = instance.revealFraction) !== null && _a !== void 0 ? _a : 0;
|
|
194
|
-
// Force the update: `applyReveal` skips a fraction it believes is already on
|
|
195
|
-
// the map, and the fresh layer has no gradient at all.
|
|
196
108
|
instance.revealFraction = undefined;
|
|
197
109
|
this.applyReveal(instance, reveal);
|
|
198
110
|
}
|
|
199
|
-
/**
|
|
200
|
-
* Recompute the GLB route-transparency collision path from all active routes and push it to the
|
|
201
|
-
* map. Every polyline point of every step is tagged with the floor its segment is drawn on (same
|
|
202
|
-
* derivation as the route line's `floor_key`), so a 3D building only fades when a route is visibly
|
|
203
|
-
* crossing it on the displayed floor. The map ignores this unless the 3D scene is active, so it is
|
|
204
|
-
* safe to call unconditionally.
|
|
205
|
-
*/
|
|
206
111
|
syncRouteCollision() {
|
|
207
112
|
const points = [];
|
|
208
113
|
for (const instance of this.routes.values()) {
|
|
@@ -215,11 +120,6 @@ export class RouteController {
|
|
|
215
120
|
}
|
|
216
121
|
this.mapvxMap.setRouteCollisionPath(points);
|
|
217
122
|
}
|
|
218
|
-
/**
|
|
219
|
-
* Add a route to the map.
|
|
220
|
-
* @param route The route to add.
|
|
221
|
-
* @param drawConfig The draw configuration for the route.
|
|
222
|
-
*/
|
|
223
123
|
addRoute(route, drawConfig) {
|
|
224
124
|
const instance = createRouteInstance(route);
|
|
225
125
|
this.routes.set(instance.id, instance);
|
|
@@ -230,22 +130,12 @@ export class RouteController {
|
|
|
230
130
|
this.updateLayerFilter(instance.aheadId);
|
|
231
131
|
this.syncRouteCollision();
|
|
232
132
|
}
|
|
233
|
-
/**
|
|
234
|
-
* Update the visual progress of a route based on an external user position.
|
|
235
|
-
* Splits the route into behind (already traveled) and ahead (remaining) sections
|
|
236
|
-
* at the point on the route closest to the given position.
|
|
237
|
-
*
|
|
238
|
-
* @param routeId The ID of the route to update.
|
|
239
|
-
* @param position The current user position (will be projected onto the route).
|
|
240
|
-
* @param behindDrawConfig The draw configuration for the behind (traveled) portion.
|
|
241
|
-
*/
|
|
242
133
|
updateRouteProgress(routeId, position, behindDrawConfig) {
|
|
243
134
|
const instance = this.routes.get(routeId);
|
|
244
135
|
if (!instance)
|
|
245
136
|
return;
|
|
246
137
|
const route = instance.route;
|
|
247
138
|
const steps = route.steps;
|
|
248
|
-
// Find the closest point on the route to the position
|
|
249
139
|
let bestDist = Infinity;
|
|
250
140
|
let bestStepIndex = 0;
|
|
251
141
|
let bestCoordIndex = 0;
|
|
@@ -264,8 +154,6 @@ export class RouteController {
|
|
|
264
154
|
}
|
|
265
155
|
}
|
|
266
156
|
}
|
|
267
|
-
// Build behind features: all complete steps before the best step,
|
|
268
|
-
// plus the partial segment of the current step up to the projected point
|
|
269
157
|
const behindFeatures = [];
|
|
270
158
|
for (let s = 0; s < bestStepIndex; s++) {
|
|
271
159
|
behindFeatures.push({
|
|
@@ -277,14 +165,12 @@ export class RouteController {
|
|
|
277
165
|
},
|
|
278
166
|
});
|
|
279
167
|
}
|
|
280
|
-
// Partial behind feature for the current step (up to projected point)
|
|
281
168
|
const currentStep = steps[bestStepIndex];
|
|
282
169
|
const currentCoords = currentStep.coordinates;
|
|
283
170
|
const partialBehindCoords = [];
|
|
284
171
|
for (let c = 0; c <= bestCoordIndex; c++) {
|
|
285
172
|
partialBehindCoords.push([currentCoords[c].lng, currentCoords[c].lat]);
|
|
286
173
|
}
|
|
287
|
-
// Add the projected point
|
|
288
174
|
const a = currentCoords[bestCoordIndex];
|
|
289
175
|
const b = currentCoords[Math.min(bestCoordIndex + 1, currentCoords.length - 1)];
|
|
290
176
|
const projLat = a.lat + bestFraction * (b.lat - a.lat);
|
|
@@ -297,7 +183,6 @@ export class RouteController {
|
|
|
297
183
|
geometry: { type: "LineString", coordinates: partialBehindCoords },
|
|
298
184
|
});
|
|
299
185
|
}
|
|
300
|
-
// Build ahead features: partial remainder of current step + all remaining steps
|
|
301
186
|
const aheadFeatures = [];
|
|
302
187
|
const partialAheadCoords = [[projLng, projLat]];
|
|
303
188
|
for (let c = bestCoordIndex + 1; c < currentCoords.length; c++) {
|
|
@@ -320,21 +205,16 @@ export class RouteController {
|
|
|
320
205
|
},
|
|
321
206
|
});
|
|
322
207
|
}
|
|
323
|
-
// Update sources
|
|
324
208
|
instance.behindSourceData.features = behindFeatures;
|
|
325
209
|
const behindSource = this.map.getSource(instance.behindId);
|
|
326
210
|
behindSource === null || behindSource === void 0 ? void 0 : behindSource.setData(instance.behindSourceData);
|
|
327
211
|
instance.aheadSourceData.features = aheadFeatures;
|
|
328
212
|
const aheadSource = this.map.getSource(instance.aheadId);
|
|
329
213
|
aheadSource === null || aheadSource === void 0 ? void 0 : aheadSource.setData(instance.aheadSourceData);
|
|
330
|
-
// Ensure paint is set on the behind layer
|
|
331
214
|
this.setLayerPaint(instance, instance.behindId, behindDrawConfig);
|
|
332
215
|
this.updateLayerFilter(instance.behindId);
|
|
333
216
|
this.updateLayerFilter(instance.aheadId);
|
|
334
217
|
}
|
|
335
|
-
/**
|
|
336
|
-
* Project a point onto a line segment and return the clamped fraction and squared distance.
|
|
337
|
-
*/
|
|
338
218
|
projectPointToSegment(p, a, b) {
|
|
339
219
|
const dx = b.lng - a.lng;
|
|
340
220
|
const dy = b.lat - a.lat;
|
|
@@ -364,22 +244,12 @@ export class RouteController {
|
|
|
364
244
|
source === null || source === void 0 ? void 0 : source.setData(instance.behindSourceData);
|
|
365
245
|
}
|
|
366
246
|
}
|
|
367
|
-
/**
|
|
368
|
-
* Upload the whole polyline of `step` as the CURRENT feature and reset its
|
|
369
|
-
* reveal to zero. The line is then drawn progressively by moving a
|
|
370
|
-
* `line-progress` cut-off (see {@link applyReveal}) instead of re-uploading a
|
|
371
|
-
* growing geometry every frame: a paint change is applied synchronously, while
|
|
372
|
-
* a `setData` goes through the worker and lands several frames after the DOM
|
|
373
|
-
* marker already moved — on a slow device the marker visibly ran ahead of
|
|
374
|
-
* its line.
|
|
375
|
-
*/
|
|
376
247
|
loadStepGeometry(instance, step) {
|
|
377
248
|
var _a;
|
|
378
249
|
instance.currentSourceData.properties = {
|
|
379
250
|
floor_key: this.getFloorKeyForStep(step),
|
|
380
251
|
};
|
|
381
252
|
const coordinates = (_a = step === null || step === void 0 ? void 0 : step.coordinates) !== null && _a !== void 0 ? _a : [];
|
|
382
|
-
// A LineString needs at least two positions; anything shorter draws nothing.
|
|
383
253
|
instance.currentSourceData.geometry.coordinates =
|
|
384
254
|
coordinates.length >= 2 ? coordinates.map((c) => [c.lng, c.lat]) : [];
|
|
385
255
|
const cumulative = [0];
|
|
@@ -392,10 +262,6 @@ export class RouteController {
|
|
|
392
262
|
const source = this.map.getSource(instance.currentId);
|
|
393
263
|
source === null || source === void 0 ? void 0 : source.setData(instance.currentSourceData);
|
|
394
264
|
}
|
|
395
|
-
/**
|
|
396
|
-
* Fraction of the step line up to `coordinatesIndex` plus `extraMeters` along
|
|
397
|
-
* the following segment.
|
|
398
|
-
*/
|
|
399
265
|
fractionAlongStep(instance, coordinatesIndex, extraMeters) {
|
|
400
266
|
var _a;
|
|
401
267
|
const metrics = instance.stepMetrics;
|
|
@@ -404,16 +270,6 @@ export class RouteController {
|
|
|
404
270
|
const index = Math.min(coordinatesIndex, metrics.cumulative.length - 1);
|
|
405
271
|
return (((_a = metrics.cumulative[index]) !== null && _a !== void 0 ? _a : 0) + extraMeters) / metrics.total;
|
|
406
272
|
}
|
|
407
|
-
/**
|
|
408
|
-
* Show the first `fraction` of the CURRENT step line: a `line-gradient` step on
|
|
409
|
-
* `line-progress` that turns transparent past the cut-off. MapLibre treats it
|
|
410
|
-
* as a plain paint update (a 256px ramp re-rendered on the next draw), so the
|
|
411
|
-
* line head and the marker move in the same frame.
|
|
412
|
-
*
|
|
413
|
-
* The paint is set with `validate: false`: this runs on every animation frame and
|
|
414
|
-
* the expression is built here, not taken from a consumer, so re-parsing and
|
|
415
|
-
* re-validating it 60 times a second is pure overhead on a totem-class device.
|
|
416
|
-
*/
|
|
417
273
|
applyReveal(instance, fraction) {
|
|
418
274
|
const color = instance.currentLineColor;
|
|
419
275
|
if (color === undefined)
|
|
@@ -421,40 +277,14 @@ export class RouteController {
|
|
|
421
277
|
const clamped = Math.max(0, Math.min(1, fraction));
|
|
422
278
|
if (instance.revealFraction === clamped)
|
|
423
279
|
return;
|
|
424
|
-
// A full style swap removes the route's sources and layers and re-adds them a
|
|
425
|
-
// few frames later. Painting a layer that is not there fires a MapLibre error on
|
|
426
|
-
// every animation frame; `revealFraction` is deliberately left untouched so
|
|
427
|
-
// `restoreLayerPaint` re-applies this reveal once the layers are back.
|
|
428
280
|
if (!this.hasSource(instance.currentId))
|
|
429
281
|
return;
|
|
430
282
|
instance.revealFraction = clamped;
|
|
431
283
|
this.map.setPaintProperty(instance.currentId, "line-gradient", this.revealGradient(color, clamped), { validate: false });
|
|
432
284
|
}
|
|
433
|
-
/**
|
|
434
|
-
* The `line-gradient` that shows the first `fraction` of the step line and
|
|
435
|
-
* nothing after it.
|
|
436
|
-
*
|
|
437
|
-
* Deliberately built on `interpolate` rather than the `step` this reads like.
|
|
438
|
-
* `LineStyleLayer._handleSpecialPaintPropertyUpdate` sets `stepInterpolant`
|
|
439
|
-
* for any `step` root, and `stepInterpolant` swaps the gradient ramp from a
|
|
440
|
-
* fixed 256 texels to
|
|
441
|
-
* `clamp(nextPowerOfTwo(lineLength * 1024 * potentialOverzoom), 256, maxTextureSize)`
|
|
442
|
-
* — 4096 to 16384 in practice. Every `setPaintProperty` here bumps
|
|
443
|
-
* `gradientVersion`, so that ramp would be re-rendered and re-uploaded once
|
|
444
|
-
* per visible tile per frame, which is the opposite of what this reveal is
|
|
445
|
-
* for. An `interpolate` root keeps the ramp at 256 texels; the cost is a
|
|
446
|
-
* one-texel soft edge at the cut-off instead of a hard one.
|
|
447
|
-
*/
|
|
448
285
|
revealGradient(color, fraction) {
|
|
449
|
-
// The degenerate ends carry no cut-off — nothing revealed is transparent throughout, fully
|
|
450
|
-
// revealed is the line's own color throughout — but they are still emitted as constant ramps
|
|
451
|
-
// rather than as a bare color. MapLibre v6 types `line-gradient` as expression-only, and a
|
|
452
|
-
// flat two-stop `interpolate` expresses "this color everywhere" while keeping the stops
|
|
453
|
-
// strictly ascending, which is the constraint that kept these ends cut-off-free to begin with.
|
|
454
286
|
if (fraction <= 0)
|
|
455
287
|
return constantRamp(TRANSPARENT_COLOR);
|
|
456
|
-
// `line-progress` reaches exactly 1 at the last vertex, so a fully revealed
|
|
457
|
-
// line is just the line's own color, with no cut-off to express.
|
|
458
288
|
if (fraction >= 1)
|
|
459
289
|
return constantRamp(color);
|
|
460
290
|
return [
|
|
@@ -463,37 +293,20 @@ export class RouteController {
|
|
|
463
293
|
["line-progress"],
|
|
464
294
|
fraction,
|
|
465
295
|
color,
|
|
466
|
-
// `interpolate` clamps to its domain, so one texel past the cut-off is
|
|
467
|
-
// enough to make everything beyond it transparent.
|
|
468
296
|
Math.min(fraction + REVEAL_EDGE, 1),
|
|
469
297
|
TRANSPARENT_COLOR,
|
|
470
298
|
];
|
|
471
299
|
}
|
|
472
|
-
/**
|
|
473
|
-
* Whether the route's three sources have finished uploading their latest
|
|
474
|
-
* data, i.e. what is on screen matches what was last set. Maps without
|
|
475
|
-
* `isSourceLoaded` (test doubles) count as ready.
|
|
476
|
-
*/
|
|
477
300
|
stepSourcesReady(instance) {
|
|
478
301
|
try {
|
|
479
|
-
// CURRENT alone. It carries the step being drawn, which is what has to be
|
|
480
|
-
// on screen for the line, the floor and the marker to change together.
|
|
481
|
-
// AHEAD and BEHIND hold the whole route and are rewritten in full at every
|
|
482
|
-
// boundary, so waiting on them made the freeze at each step scale with the
|
|
483
|
-
// route's total length rather than the step's — and on a long route that
|
|
484
|
-
// is the difference between imperceptible and hitting the deadline.
|
|
485
302
|
if (!this.map.getSource(instance.currentId))
|
|
486
303
|
return false;
|
|
487
304
|
return this.map.isSourceLoaded(instance.currentId) !== false;
|
|
488
305
|
}
|
|
489
306
|
catch (_a) {
|
|
490
|
-
// The map is briefly style-less mid-swap and `getSource` throws there. This runs
|
|
491
|
-
// inside a `requestAnimationFrame` callback, where an exception would kill the
|
|
492
|
-
// animation loop for good, so treat it as "not ready yet" instead.
|
|
493
307
|
return false;
|
|
494
308
|
}
|
|
495
309
|
}
|
|
496
|
-
/** Whether `sourceId` is currently on the map (false while a style swap is in flight). */
|
|
497
310
|
hasSource(sourceId) {
|
|
498
311
|
try {
|
|
499
312
|
return this.map.getSource(sourceId) != null;
|
|
@@ -502,11 +315,6 @@ export class RouteController {
|
|
|
502
315
|
return false;
|
|
503
316
|
}
|
|
504
317
|
}
|
|
505
|
-
/**
|
|
506
|
-
* Apply a floor switch that was deferred until the next step's line was
|
|
507
|
-
* uploaded, then put the marker where that step starts. Floor, line and
|
|
508
|
-
* marker change in the same frame.
|
|
509
|
-
*/
|
|
510
318
|
applyPendingFloor(instance) {
|
|
511
319
|
var _a;
|
|
512
320
|
const pending = (_a = instance.conditions) === null || _a === void 0 ? void 0 : _a.pendingFloor;
|
|
@@ -519,29 +327,18 @@ export class RouteController {
|
|
|
519
327
|
setLayerPaint(instance, layerId, drawConfig) {
|
|
520
328
|
instance.layerDrawConfigs[layerId] = drawConfig;
|
|
521
329
|
const paintConfig = this.preparePaintForLayer(drawConfig);
|
|
522
|
-
// v6 types the property name as `keyof AllPaintProperties` rather than `string`. The config is
|
|
523
|
-
// built here from a known set of paint keys, so the cast asserts what this code already knows.
|
|
524
330
|
for (const [property, value] of Object.entries(paintConfig)) {
|
|
525
331
|
this.map.setPaintProperty(layerId, property, value);
|
|
526
332
|
}
|
|
527
333
|
}
|
|
528
|
-
/**
|
|
529
|
-
* Set the paint the step line is drawn with, resolving its color once.
|
|
530
|
-
*
|
|
531
|
-
* See {@link RouteInstance.currentLineColor}: resolving a gradient allocates
|
|
532
|
-
* and can throw, and the reveal would otherwise redo it on every frame.
|
|
533
|
-
*/
|
|
534
334
|
setCurrentDrawConfig(instance, drawConfig) {
|
|
535
335
|
instance.currentDrawConfig = drawConfig;
|
|
536
336
|
instance.currentLineColor = this.lineColorExpression(drawConfig);
|
|
537
337
|
}
|
|
538
|
-
/** The color of a route line: a solid color or a `line-progress` gradient ramp. */
|
|
539
338
|
lineColorExpression(drawConfig) {
|
|
540
339
|
if ("color" in drawConfig.routeStyle) {
|
|
541
|
-
// Check for propriety unique to SolidStyle
|
|
542
340
|
return drawConfig.routeStyle.color;
|
|
543
341
|
}
|
|
544
|
-
// Is GradienteStyle
|
|
545
342
|
const { colors, positions } = drawConfig.routeStyle;
|
|
546
343
|
const positionsToUse = positions !== null && positions !== void 0 ? positions : createPositionsForStops(colors.length);
|
|
547
344
|
if (positionsToUse.length !== colors.length) {
|
|
@@ -555,7 +352,7 @@ export class RouteController {
|
|
|
555
352
|
if (typeof color === "string") {
|
|
556
353
|
return {
|
|
557
354
|
"line-color": color,
|
|
558
|
-
"line-gradient": null,
|
|
355
|
+
"line-gradient": null,
|
|
559
356
|
"line-width": drawConfig.polylineWidth,
|
|
560
357
|
};
|
|
561
358
|
}
|
|
@@ -565,44 +362,20 @@ export class RouteController {
|
|
|
565
362
|
"line-width": drawConfig.polylineWidth,
|
|
566
363
|
};
|
|
567
364
|
}
|
|
568
|
-
/**
|
|
569
|
-
* Update the filter of the layer referenced with a ID.
|
|
570
|
-
*
|
|
571
|
-
* @see {@link https://maplibre.org/maplibre-gl-js/docs/API/classes/Map/#setfilter}
|
|
572
|
-
* @param layerId The ID for the layer.
|
|
573
|
-
*/
|
|
574
365
|
updateLayerFilter(layerId, floorId) {
|
|
575
366
|
const newFloorId = floorId !== null && floorId !== void 0 ? floorId : this.mapvxMap.getCurrentFloor();
|
|
576
367
|
if (newFloorId === undefined)
|
|
577
368
|
return;
|
|
578
|
-
// `getLayer` is a map lookup; `getStyle()` serialises every source and
|
|
579
|
-
// layer in the style just to answer the same question. This runs three
|
|
580
|
-
// times per route per floor change, and each preceding `setFilter`
|
|
581
|
-
// invalidates maplibre's serialised-layer cache, so the later calls used to
|
|
582
|
-
// re-serialise from scratch.
|
|
583
369
|
if (this.map.getLayer(layerId) != null) {
|
|
584
370
|
this.map.setFilter(layerId, ["==", ["get", "floor_key"], newFloorId]);
|
|
585
371
|
}
|
|
586
372
|
}
|
|
587
|
-
/**
|
|
588
|
-
* Determines the correct floor_key for a route step.
|
|
589
|
-
* Outdoor steps (without startInsideFloor) should use the outdoor floor key,
|
|
590
|
-
* not the current floor which might be indoor.
|
|
591
|
-
* Elevator steps are always drawn on startInsideFloor; floor is updated to endInsideFloor
|
|
592
|
-
* only when the step completes (see prepareForNextStep / animateStep).
|
|
593
|
-
* @param step The route step to determine the floor_key for
|
|
594
|
-
* @returns The floor_key string to use for the step
|
|
595
|
-
*/
|
|
596
373
|
getFloorKeyForStep(step) {
|
|
597
374
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
598
375
|
if (!step) {
|
|
599
376
|
return this.mapvxMap.getCurrentFloor();
|
|
600
377
|
}
|
|
601
|
-
// If step has startInsideFloor, use it (unless it's a non-elevator floor change step)
|
|
602
378
|
if (((_b = (_a = step.startInsideFloor) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0) {
|
|
603
|
-
// If step changes floors (different start and end) and is not an elevator step,
|
|
604
|
-
// use endInsideFloor so the step is drawn on the destination floor.
|
|
605
|
-
// Elevator steps are drawn on startInsideFloor; floor updates on step completion.
|
|
606
379
|
if (((_d = (_c = step.endInsideFloor) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0) > 0 &&
|
|
607
380
|
step.startInsideFloor !== step.endInsideFloor &&
|
|
608
381
|
!step.elevatorStep) {
|
|
@@ -610,11 +383,9 @@ export class RouteController {
|
|
|
610
383
|
}
|
|
611
384
|
return step.startInsideFloor;
|
|
612
385
|
}
|
|
613
|
-
// If step has endInsideFloor but no startInsideFloor (entering building), use endInsideFloor
|
|
614
386
|
if (((_f = (_e = step.endInsideFloor) === null || _e === void 0 ? void 0 : _e.length) !== null && _f !== void 0 ? _f : 0) > 0) {
|
|
615
387
|
return step.endInsideFloor;
|
|
616
388
|
}
|
|
617
|
-
// If step is outdoor (no startInsideFloor and no endInsideFloor), use outdoor floor key
|
|
618
389
|
const innerFloors = this.mapvxMap.getInnerFloors();
|
|
619
390
|
const outdoorFloor = innerFloors.find((floor) => floor.reachableFromGPS === true);
|
|
620
391
|
return (_g = outdoorFloor === null || outdoorFloor === void 0 ? void 0 : outdoorFloor.key) !== null && _g !== void 0 ? _g : "";
|
|
@@ -632,10 +403,6 @@ export class RouteController {
|
|
|
632
403
|
});
|
|
633
404
|
return features;
|
|
634
405
|
}
|
|
635
|
-
/**
|
|
636
|
-
* Update the layers for all active routes.
|
|
637
|
-
* @param floorId The floor ID to update the layers for.
|
|
638
|
-
*/
|
|
639
406
|
updateRouteLayers(floorId) {
|
|
640
407
|
for (const instance of this.routes.values()) {
|
|
641
408
|
this.updateLayerFilter(instance.aheadId, floorId);
|
|
@@ -643,11 +410,6 @@ export class RouteController {
|
|
|
643
410
|
this.updateLayerFilter(instance.currentId, floorId);
|
|
644
411
|
}
|
|
645
412
|
}
|
|
646
|
-
/**
|
|
647
|
-
* Every active route's marker. Used by `MarkerLayoutController` so marker
|
|
648
|
-
* labels are never placed on top of a route's own marker.
|
|
649
|
-
* @internal
|
|
650
|
-
*/
|
|
651
413
|
getRouteMarkers() {
|
|
652
414
|
const markers = [];
|
|
653
415
|
for (const instance of this.routes.values()) {
|
|
@@ -656,17 +418,8 @@ export class RouteController {
|
|
|
656
418
|
}
|
|
657
419
|
return markers;
|
|
658
420
|
}
|
|
659
|
-
/**
|
|
660
|
-
* Update the visibility of route markers for all active routes.
|
|
661
|
-
* @param floorId The floor ID to update the visibility for.
|
|
662
|
-
*/
|
|
663
421
|
updateRouteMarkerVisibility(floorId) {
|
|
664
422
|
var _a, _b, _c, _d;
|
|
665
|
-
// An outdoor step gives its marker an empty floorId, which never equals a
|
|
666
|
-
// real floor key — so on a venue with buildings the route arrow used to be
|
|
667
|
-
// hidden the moment the map filtered by one, and only reappeared because
|
|
668
|
-
// the animation re-attached the marker on its next frame. Outdoors is an
|
|
669
|
-
// allowance markers and circles already make; the route arrow makes it too.
|
|
670
423
|
const isOutdoor = this.mapvxMap.isOutdoorFloor(floorId);
|
|
671
424
|
for (const instance of this.routes.values()) {
|
|
672
425
|
const markerFloorId = (_b = (_a = instance.routeMarker) === null || _a === void 0 ? void 0 : _a.floorId) !== null && _b !== void 0 ? _b : "";
|
|
@@ -684,12 +437,6 @@ export class RouteController {
|
|
|
684
437
|
this.updateRouteMarkerVisibility(floorKey);
|
|
685
438
|
}
|
|
686
439
|
}
|
|
687
|
-
/**
|
|
688
|
-
* Start the animation of a route.
|
|
689
|
-
* @param route The route to animate.
|
|
690
|
-
* @param drawConfig The draw configuration for the route.
|
|
691
|
-
* @param animationConfig The animation configuration for the route.
|
|
692
|
-
*/
|
|
693
440
|
startAnimating(route, drawConfig, animationConfig) {
|
|
694
441
|
var _a, _b, _c;
|
|
695
442
|
const instance = createRouteInstance(route);
|
|
@@ -715,7 +462,6 @@ export class RouteController {
|
|
|
715
462
|
rotationAlignment: "map",
|
|
716
463
|
});
|
|
717
464
|
instance.routeMarker.addToMap(this.map);
|
|
718
|
-
// Auto-fit by place if enabled
|
|
719
465
|
if (((_a = animationConfig.autoFitByPlace) === null || _a === void 0 ? void 0 : _a.enabled) && route.steps.length > 0) {
|
|
720
466
|
if (firstStep.startInsidePlace) {
|
|
721
467
|
instance.currentPlaceId = firstStep.startInsidePlace;
|
|
@@ -725,12 +471,6 @@ export class RouteController {
|
|
|
725
471
|
this.mapvxMap.fitRouteByPlace(route, firstStep.startInsidePlace, fitOptions);
|
|
726
472
|
}
|
|
727
473
|
}
|
|
728
|
-
// The conditions go in before the consumer hears about the start, for the same reason
|
|
729
|
-
// `restartAnimation` orders it that way. `animationStatus` is already "STARTED" here, so a
|
|
730
|
-
// consumer that pauses from inside this callback — showing a modal per step, say — passed
|
|
731
|
-
// `internalPause`'s status guard and then died on its `instance.conditions == null` check:
|
|
732
|
-
// the pause was dropped in silence, the loop kept running, and because the status stayed
|
|
733
|
-
// "STARTED" the matching `resumeAnimation()` bailed out too.
|
|
734
474
|
instance.conditions = {
|
|
735
475
|
index: 0,
|
|
736
476
|
coordinatesIndex: 0,
|
|
@@ -747,19 +487,6 @@ export class RouteController {
|
|
|
747
487
|
(_c = animationConfig.callBack) === null || _c === void 0 ? void 0 : _c.call(animationConfig, { isFinished: false, step: firstStep });
|
|
748
488
|
this.syncRouteCollision();
|
|
749
489
|
}
|
|
750
|
-
/**
|
|
751
|
-
* Tear one route instance down.
|
|
752
|
-
*
|
|
753
|
-
* `applyPendingFloorChange` decides what happens to a floor switch this
|
|
754
|
-
* instance had decided on but not yet shown. Removing a single route mid-walk
|
|
755
|
-
* applies it: the consumer may be removing the route from the step callback,
|
|
756
|
-
* and dropping the switch would leave the map on the floor the route has
|
|
757
|
-
* already left. Clearing every route does not — a floor switch is a visible
|
|
758
|
-
* camera and filter change plus an `onFloorChange` to the consumer, and
|
|
759
|
-
* `removeAllRoutes` is what teardown calls, where moving the map is
|
|
760
|
-
* a side effect nobody asked for and a consumer that re-enters from
|
|
761
|
-
* `onFloorChange` re-enters teardown.
|
|
762
|
-
*/
|
|
763
490
|
clearRouteInstance(instance, applyPendingFloorChange = true) {
|
|
764
491
|
var _a;
|
|
765
492
|
if (applyPendingFloorChange) {
|
|
@@ -785,10 +512,6 @@ export class RouteController {
|
|
|
785
512
|
instance.animationConfig = undefined;
|
|
786
513
|
instance.currentPlaceId = undefined;
|
|
787
514
|
}
|
|
788
|
-
/**
|
|
789
|
-
* Remove a route from the map.
|
|
790
|
-
* @param routeId The ID of the route to remove. If not provided, removes the last added route.
|
|
791
|
-
*/
|
|
792
515
|
removeRoute(routeId) {
|
|
793
516
|
const instance = this.resolveInstance(routeId);
|
|
794
517
|
if (!instance)
|
|
@@ -802,9 +525,6 @@ export class RouteController {
|
|
|
802
525
|
}
|
|
803
526
|
this.syncRouteCollision();
|
|
804
527
|
}
|
|
805
|
-
/**
|
|
806
|
-
* Remove all routes from the map.
|
|
807
|
-
*/
|
|
808
528
|
removeAllRoutes() {
|
|
809
529
|
for (const instance of this.routes.values()) {
|
|
810
530
|
this.clearRouteInstance(instance, false);
|
|
@@ -814,10 +534,6 @@ export class RouteController {
|
|
|
814
534
|
this.lastAddedRouteId = undefined;
|
|
815
535
|
this.syncRouteCollision();
|
|
816
536
|
}
|
|
817
|
-
/**
|
|
818
|
-
* Get the IDs of all active routes on the map.
|
|
819
|
-
* @returns Array of route IDs.
|
|
820
|
-
*/
|
|
821
537
|
getRouteIds() {
|
|
822
538
|
return [...this.routes.keys()];
|
|
823
539
|
}
|
|
@@ -829,10 +545,6 @@ export class RouteController {
|
|
|
829
545
|
cancelAnimationFrame(instance.conditions.animationId);
|
|
830
546
|
instance.animationStatus = "PAUSED";
|
|
831
547
|
}
|
|
832
|
-
/**
|
|
833
|
-
* Pause the animation of a route.
|
|
834
|
-
* @param routeId The ID of the route. If not provided, pauses the last added route.
|
|
835
|
-
*/
|
|
836
548
|
pauseAnimation(routeId) {
|
|
837
549
|
const instance = this.resolveInstance(routeId);
|
|
838
550
|
if (!instance)
|
|
@@ -848,20 +560,12 @@ export class RouteController {
|
|
|
848
560
|
instance.conditions.animationId = requestAnimationFrame((time) => this.animateStep(time, instance));
|
|
849
561
|
instance.animationStatus = "STARTED";
|
|
850
562
|
}
|
|
851
|
-
/**
|
|
852
|
-
* Resume the animation of a route.
|
|
853
|
-
* @param routeId The ID of the route. If not provided, resumes the last added route.
|
|
854
|
-
*/
|
|
855
563
|
resumeAnimation(routeId) {
|
|
856
564
|
const instance = this.resolveInstance(routeId);
|
|
857
565
|
if (!instance)
|
|
858
566
|
return;
|
|
859
567
|
this.internalResume(instance);
|
|
860
568
|
}
|
|
861
|
-
/**
|
|
862
|
-
* Restart the animation of a route.
|
|
863
|
-
* @param routeId The ID of the route. If not provided, restarts the last added route.
|
|
864
|
-
*/
|
|
865
569
|
restartAnimation(routeId) {
|
|
866
570
|
var _a, _b, _c, _d, _e;
|
|
867
571
|
const instance = this.resolveInstance(routeId);
|
|
@@ -887,7 +591,6 @@ export class RouteController {
|
|
|
887
591
|
this.setSourceData(instance, instance.behindId, []);
|
|
888
592
|
this.loadStepGeometry(instance, firstStep);
|
|
889
593
|
(_a = this.setMarkerRotation(instance, 0)) === null || _a === void 0 ? void 0 : _a.setLngLat(firstStep.startLocation).addTo(this.map);
|
|
890
|
-
// Auto-fit by place if enabled
|
|
891
594
|
if (((_b = instance.animationConfig.autoFitByPlace) === null || _b === void 0 ? void 0 : _b.enabled) && instance.route.steps.length > 0) {
|
|
892
595
|
if (firstStep.startInsidePlace) {
|
|
893
596
|
instance.currentPlaceId = firstStep.startInsidePlace;
|
|
@@ -897,14 +600,6 @@ export class RouteController {
|
|
|
897
600
|
this.mapvxMap.fitRouteByPlace(instance.route, firstStep.startInsidePlace, fitOptions);
|
|
898
601
|
}
|
|
899
602
|
}
|
|
900
|
-
// The new conditions go in before the consumer hears about the restart.
|
|
901
|
-
// Invoking the callback first left `instance.conditions` pointing at the
|
|
902
|
-
// previous run, so a consumer that pauses from inside it — showing a modal
|
|
903
|
-
// per step, say — cancelled a frame id that had already fired, marked the
|
|
904
|
-
// instance PAUSED, and then had a live loop installed underneath it. The
|
|
905
|
-
// next resume passed the "not paused" guard and started a second loop on
|
|
906
|
-
// the same instance; each schedules its own successor, so the doubling was
|
|
907
|
-
// permanent.
|
|
908
603
|
instance.conditions = {
|
|
909
604
|
index: 0,
|
|
910
605
|
coordinatesIndex: 0,
|
|
@@ -920,10 +615,6 @@ export class RouteController {
|
|
|
920
615
|
};
|
|
921
616
|
(_e = (_d = instance.animationConfig).callBack) === null || _e === void 0 ? void 0 : _e.call(_d, { isFinished: false, step: firstStep });
|
|
922
617
|
}
|
|
923
|
-
/**
|
|
924
|
-
* Stop the animation of a route.
|
|
925
|
-
* @param routeId The ID of the route. If not provided, stops the last added route.
|
|
926
|
-
*/
|
|
927
618
|
stopAnimation(routeId) {
|
|
928
619
|
const instance = this.resolveInstance(routeId);
|
|
929
620
|
if (!instance)
|
|
@@ -931,15 +622,8 @@ export class RouteController {
|
|
|
931
622
|
if (instance.animationStatus == "FINISHED") {
|
|
932
623
|
return;
|
|
933
624
|
}
|
|
934
|
-
// todo hacer cosas para detener animación
|
|
935
625
|
instance.animationStatus = "FINISHED";
|
|
936
626
|
}
|
|
937
|
-
/**
|
|
938
|
-
* Add a step animation to a route.
|
|
939
|
-
* @param route The route to animate.
|
|
940
|
-
* @param drawConfig The draw configuration for the route.
|
|
941
|
-
* @param animationConfig The animation configuration for the route.
|
|
942
|
-
*/
|
|
943
627
|
addStepAnimation(route, drawConfig, animationConfig) {
|
|
944
628
|
var _a, _b, _c;
|
|
945
629
|
const instance = createRouteInstance(route);
|
|
@@ -966,7 +650,6 @@ export class RouteController {
|
|
|
966
650
|
});
|
|
967
651
|
instance.routeMarker.addToMap(this.map);
|
|
968
652
|
this.cameraFollow(instance, firstStep.startLocation);
|
|
969
|
-
// Auto-fit by place if enabled
|
|
970
653
|
if (((_a = animationConfig.autoFitByPlace) === null || _a === void 0 ? void 0 : _a.enabled) && route.steps.length > 0) {
|
|
971
654
|
if (firstStep.startInsidePlace) {
|
|
972
655
|
instance.currentPlaceId = firstStep.startInsidePlace;
|
|
@@ -976,11 +659,6 @@ export class RouteController {
|
|
|
976
659
|
this.mapvxMap.fitRouteByPlace(route, firstStep.startInsidePlace, fitOptions);
|
|
977
660
|
}
|
|
978
661
|
}
|
|
979
|
-
// The conditions go in before the consumer hears about the route, as they
|
|
980
|
-
// do in `startAnimating`. Invoking the callback first left `conditions`
|
|
981
|
-
// undefined, so a consumer advancing the route from it — the step-by-step
|
|
982
|
-
// integration draws its first step this way — hit `nextStepAnimation`'s
|
|
983
|
-
// null check and got an exception instead of a step.
|
|
984
662
|
instance.conditions = {
|
|
985
663
|
index: 0,
|
|
986
664
|
coordinatesIndex: 0,
|
|
@@ -1008,16 +686,9 @@ export class RouteController {
|
|
|
1008
686
|
this.setSourceData(instance, instance.aheadId, aheadSteps);
|
|
1009
687
|
this.loadStepGeometry(instance, step);
|
|
1010
688
|
instance.conditions.index = index;
|
|
1011
|
-
// The status settles before either callback, as everywhere else: no frame
|
|
1012
|
-
// is live once `animateStep` hands over to `onFinish`, so "WAITING" is
|
|
1013
|
-
// already true here. Writing it afterwards overwrote the "ANIMATING" of a
|
|
1014
|
-
// consumer that chained the next step from this callback, and the
|
|
1015
|
-
// following `nextStepAnimation` then skipped its cancel and installed a
|
|
1016
|
-
// second self-sustaining loop on the same instance.
|
|
1017
689
|
instance.stepAnimationStatus = "WAITING";
|
|
1018
690
|
if (index < route.steps.length) {
|
|
1019
691
|
const nextStep = route.steps[index];
|
|
1020
|
-
// Auto-fit by place if enabled and place changed
|
|
1021
692
|
if (((_a = animationConfig.autoFitByPlace) === null || _a === void 0 ? void 0 : _a.enabled) && nextStep && instance.route != null) {
|
|
1022
693
|
const stepPlaceId = nextStep.startInsidePlace || nextStep.endInsidePlace;
|
|
1023
694
|
if (stepPlaceId && stepPlaceId !== instance.currentPlaceId) {
|
|
@@ -1038,10 +709,6 @@ export class RouteController {
|
|
|
1038
709
|
(_c = animationConfig.callBack) === null || _c === void 0 ? void 0 : _c.call(animationConfig, { isFinished: false, step: firstStep });
|
|
1039
710
|
this.syncRouteCollision();
|
|
1040
711
|
}
|
|
1041
|
-
/**
|
|
1042
|
-
* Animate the next step of a route.
|
|
1043
|
-
* @param routeId The ID of the route. If not provided, uses the last added route.
|
|
1044
|
-
*/
|
|
1045
712
|
nextStepAnimation(routeId) {
|
|
1046
713
|
const instance = this.resolveInstance(routeId);
|
|
1047
714
|
if (!instance) {
|
|
@@ -1070,10 +737,6 @@ export class RouteController {
|
|
|
1070
737
|
throw new Error("Error: Does not exist next step to animate");
|
|
1071
738
|
}
|
|
1072
739
|
}
|
|
1073
|
-
/**
|
|
1074
|
-
* Go to the previous step of a route.
|
|
1075
|
-
* @param routeId The ID of the route. If not provided, uses the last added route.
|
|
1076
|
-
*/
|
|
1077
740
|
previousStepAnimation(routeId) {
|
|
1078
741
|
var _a, _b, _c, _d;
|
|
1079
742
|
const instance = this.resolveInstance(routeId);
|
|
@@ -1118,7 +781,6 @@ export class RouteController {
|
|
|
1118
781
|
else {
|
|
1119
782
|
this.setMarkerRotation(instance, 0);
|
|
1120
783
|
}
|
|
1121
|
-
// Auto-fit by place if enabled and place changed
|
|
1122
784
|
if (((_a = instance.animationConfig.autoFitByPlace) === null || _a === void 0 ? void 0 : _a.enabled) && step && instance.route != null) {
|
|
1123
785
|
const stepPlaceId = step.startInsidePlace || step.endInsidePlace;
|
|
1124
786
|
if (stepPlaceId && stepPlaceId !== instance.currentPlaceId) {
|
|
@@ -1138,10 +800,6 @@ export class RouteController {
|
|
|
1138
800
|
throw new Error("previous step doesn't exists to animate");
|
|
1139
801
|
}
|
|
1140
802
|
}
|
|
1141
|
-
/**
|
|
1142
|
-
* Center on the current step of a route.
|
|
1143
|
-
* @param routeId The ID of the route. If not provided, uses the last added route.
|
|
1144
|
-
*/
|
|
1145
803
|
centerOnCurrentStep(routeId) {
|
|
1146
804
|
var _a;
|
|
1147
805
|
const instance = this.resolveInstance(routeId);
|
|
@@ -1180,23 +838,9 @@ export class RouteController {
|
|
|
1180
838
|
instance.conditions.coordinatesIndex = 0;
|
|
1181
839
|
instance.conditions.progress = 0;
|
|
1182
840
|
instance.conditions.rotatingIcon = true;
|
|
1183
|
-
// The step starts once its line (and the updated behind/ahead lines) are
|
|
1184
|
-
// on screen; a floor switch decided by the previous step, or implied by a
|
|
1185
|
-
// step that starts on another floor, is applied at that same moment.
|
|
1186
841
|
instance.conditions.awaitingSources = true;
|
|
1187
842
|
instance.conditions.awaitDeadline = undefined;
|
|
1188
|
-
// Compared against the floor the PREVIOUS step ended on, not the map's current
|
|
1189
|
-
// floor: the route decides its own floor changes, so a user who browsed to
|
|
1190
|
-
// another floor mid-animation is not yanked back at every step boundary.
|
|
1191
843
|
const previousStep = instance.route.steps[index];
|
|
1192
|
-
// Against the previous step's *effective* floor, not its raw
|
|
1193
|
-
// `endInsideFloor`. Venue data routinely carries `startInsideFloor` with
|
|
1194
|
-
// no `endInsideFloor` — `getFloorKeyForStep` exists to resolve exactly
|
|
1195
|
-
// that shape — and comparing against the raw field made every boundary
|
|
1196
|
-
// on such a route look like a floor change: the map moved, the consumer
|
|
1197
|
-
// got an `onFloorChange`, a settle poll ran and the step callback was
|
|
1198
|
-
// deferred a frame, at each step. A user who had browsed to another floor
|
|
1199
|
-
// was yanked back, which is what the deferral above is meant to avoid.
|
|
1200
844
|
const previousFloor = this.getFloorKeyForStep(previousStep);
|
|
1201
845
|
if (!instance.conditions.pendingFloor &&
|
|
1202
846
|
step.startInsideFloor &&
|
|
@@ -1210,7 +854,6 @@ export class RouteController {
|
|
|
1210
854
|
if (!compareLatLng(instance.route.steps[index].endLocation, step.startLocation))
|
|
1211
855
|
instance.conditions.nextFloorFirstStepIndex = index + 2;
|
|
1212
856
|
instance.conditions.animationId = requestAnimationFrame((time) => this.animateStep(time, instance));
|
|
1213
|
-
// Auto-fit by place if enabled and place changed
|
|
1214
857
|
if (((_a = instance.animationConfig.autoFitByPlace) === null || _a === void 0 ? void 0 : _a.enabled) && step && instance.route != null) {
|
|
1215
858
|
const stepPlaceId = step.startInsidePlace || step.endInsidePlace;
|
|
1216
859
|
if (stepPlaceId && stepPlaceId !== instance.currentPlaceId) {
|
|
@@ -1222,9 +865,6 @@ export class RouteController {
|
|
|
1222
865
|
}
|
|
1223
866
|
}
|
|
1224
867
|
if (instance.conditions.pendingFloor) {
|
|
1225
|
-
// The switch lands a few frames later, in `animateStep`. Firing the callback
|
|
1226
|
-
// now would report the step while the map is still on the previous floor —
|
|
1227
|
-
// and a consumer that stops the route from it would drop the switch entirely.
|
|
1228
868
|
instance.conditions.pendingStepCallback = step;
|
|
1229
869
|
}
|
|
1230
870
|
else {
|
|
@@ -1232,25 +872,9 @@ export class RouteController {
|
|
|
1232
872
|
}
|
|
1233
873
|
}
|
|
1234
874
|
else {
|
|
1235
|
-
// finishes animation
|
|
1236
875
|
this.applyPendingFloor(instance);
|
|
1237
|
-
// That reached `onFloorChange`, and a consumer removing the route from it
|
|
1238
|
-
// has already had `clearRouteInstance` null `animationConfig` and settle
|
|
1239
|
-
// the status at "NO_ROUTE". Both lines below write through it — the
|
|
1240
|
-
// `?.` is on `callBack`, not on `animationConfig` — so without this the
|
|
1241
|
-
// branch threw a TypeError out of the rAF callback, and overwrote a
|
|
1242
|
-
// finished instance's status with "FINISHED". `animateStep`'s release
|
|
1243
|
-
// path takes the same guard after the same call.
|
|
1244
876
|
if (instance.conditions == null || instance.animationConfig == null)
|
|
1245
877
|
return;
|
|
1246
|
-
// The status settles before the consumer hears that the route finished,
|
|
1247
|
-
// for the same reason `startAnimating` and `restartAnimation` order it
|
|
1248
|
-
// that way. A consumer that relaunches from this callback — looping a
|
|
1249
|
-
// kiosk demo is the ordinary case — got its fresh "STARTED" overwritten
|
|
1250
|
-
// by the "FINISHED" written afterwards, and was left with a live loop the
|
|
1251
|
-
// controller believed was over: `pauseAnimation` and `stopAnimation` both
|
|
1252
|
-
// bailed on the status guard, and the next `restartAnimation` skipped its
|
|
1253
|
-
// cancel and installed a second self-sustaining loop.
|
|
1254
878
|
instance.animationStatus = "FINISHED";
|
|
1255
879
|
(_f = (_e = instance.animationConfig).callBack) === null || _f === void 0 ? void 0 : _f.call(_e, { isFinished: true, step: null });
|
|
1256
880
|
}
|
|
@@ -1263,9 +887,6 @@ export class RouteController {
|
|
|
1263
887
|
let { startTime, resetTime, progress, waitStartTime } = instance.conditions;
|
|
1264
888
|
const { coordinatesIndex, iconRotation, index, onFinish, rotatingIcon } = instance.conditions;
|
|
1265
889
|
const { stepTime, minimumSpeed, iconRotationTime, changeFloorTime } = instance.animationConfig;
|
|
1266
|
-
// How long this frame took to arrive. Recorded before any early return, so
|
|
1267
|
-
// the next frame measures from the last one delivered rather than from the
|
|
1268
|
-
// last one that drew.
|
|
1269
890
|
const previousFrameTime = instance.conditions.lastFrameTime;
|
|
1270
891
|
instance.conditions.lastFrameTime = timestamp;
|
|
1271
892
|
if (startTime == null) {
|
|
@@ -1275,18 +896,11 @@ export class RouteController {
|
|
|
1275
896
|
}
|
|
1276
897
|
if (instance.conditions.awaitingSources) {
|
|
1277
898
|
let deadline = (_a = instance.conditions.awaitDeadline) !== null && _a !== void 0 ? _a : timestamp + MAX_SOURCE_WAIT_MS;
|
|
1278
|
-
// The deadline is wall clock, and this block returns before the frame-gap
|
|
1279
|
-
// branch below can ever run, so it needs that branch's shift applied here
|
|
1280
|
-
// — the same one `waitStartTime` gets, for the same reason. A backgrounded
|
|
1281
|
-
// tab or a pause longer than the deadline would otherwise release the step
|
|
1282
|
-
// on the first frame back without once asking whether its line is on
|
|
1283
|
-
// screen, which is the desync the wait exists to prevent.
|
|
1284
899
|
if (previousFrameTime != null && timestamp - previousFrameTime > MAX_FRAME_GAP_MS) {
|
|
1285
900
|
deadline += timestamp - previousFrameTime;
|
|
1286
901
|
}
|
|
1287
902
|
instance.conditions.awaitDeadline = deadline;
|
|
1288
903
|
if (!this.stepSourcesReady(instance) && timestamp < deadline) {
|
|
1289
|
-
// Hold the clock: the step starts when its line can be seen.
|
|
1290
904
|
instance.conditions.startTime = timestamp;
|
|
1291
905
|
instance.conditions.animationId = requestAnimationFrame((time) => this.animateStep(time, instance));
|
|
1292
906
|
return;
|
|
@@ -1296,23 +910,8 @@ export class RouteController {
|
|
|
1296
910
|
instance.conditions.startTime = timestamp;
|
|
1297
911
|
const heldStep = instance.conditions.pendingStepCallback;
|
|
1298
912
|
instance.conditions.pendingStepCallback = undefined;
|
|
1299
|
-
// The frame that releases the wait draws nothing: it queues its successor
|
|
1300
|
-
// and hands control to the consumer, and that successor does the drawing.
|
|
1301
|
-
//
|
|
1302
|
-
// The queue has to come first. Both calls below reach consumer code —
|
|
1303
|
-
// `applyPendingFloor` through the `onFloorChange` handler, and the held
|
|
1304
|
-
// step callback directly — and a `pauseAnimation()` from either one
|
|
1305
|
-
// cancels whatever id sits in `conditions.animationId`. While that id was
|
|
1306
|
-
// the frame already executing, cancelling it did nothing: the loop kept
|
|
1307
|
-
// running under a `PAUSED` status, and the matching `resumeAnimation()`
|
|
1308
|
-
// passed its status guard and installed a second concurrent rAF chain on
|
|
1309
|
-
// the same instance. Queueing first gives that pause a pending frame to
|
|
1310
|
-
// cancel, and returning afterwards means this frame does not queue a
|
|
1311
|
-
// replacement for the one it just cancelled.
|
|
1312
913
|
instance.conditions.animationId = requestAnimationFrame((time) => this.animateStep(time, instance));
|
|
1313
914
|
this.applyPendingFloor(instance);
|
|
1314
|
-
// `onFloorChange` may have removed the route; everything below reads
|
|
1315
|
-
// `conditions`.
|
|
1316
915
|
if (instance.conditions == null || instance.animationConfig == null)
|
|
1317
916
|
return;
|
|
1318
917
|
if (heldStep) {
|
|
@@ -1327,23 +926,11 @@ export class RouteController {
|
|
|
1327
926
|
instance.conditions.resetTime = resetTime;
|
|
1328
927
|
}
|
|
1329
928
|
else if (previousFrameTime != null && timestamp - previousFrameTime > MAX_FRAME_GAP_MS) {
|
|
1330
|
-
// Absence, not slow rendering: see MAX_FRAME_GAP_MS. Shift the clock
|
|
1331
|
-
// forward by the gap instead of charging it, exactly as resuming from a
|
|
1332
|
-
// pause does above, so this frame redraws where the last one left off
|
|
1333
|
-
// and the next resumes from there.
|
|
1334
929
|
const gap = timestamp - previousFrameTime;
|
|
1335
|
-
// What the previous frame had charged. Equal to `progress` whenever the
|
|
1336
|
-
// two are in step, but the rotation branches above set `startTime` to
|
|
1337
|
-
// the frame timestamp without resetting `progress`, so reading the
|
|
1338
|
-
// stored value would carry a whole rotation's worth of time into the
|
|
1339
|
-
// first frame back. Recomputed instead, which is 0 in exactly that case.
|
|
1340
930
|
progress = previousFrameTime - startTime;
|
|
1341
931
|
instance.conditions.progress = progress;
|
|
1342
932
|
startTime = timestamp - progress;
|
|
1343
933
|
instance.conditions.startTime = startTime;
|
|
1344
|
-
// The floor-change wait runs on the raw timestamp rather than on
|
|
1345
|
-
// `progress`, so it needs the same shift or an absence would satisfy it
|
|
1346
|
-
// outright.
|
|
1347
934
|
if (waitStartTime != null) {
|
|
1348
935
|
waitStartTime += gap;
|
|
1349
936
|
instance.conditions.waitStartTime = waitStartTime;
|
|
@@ -1353,8 +940,6 @@ export class RouteController {
|
|
|
1353
940
|
progress = timestamp - startTime;
|
|
1354
941
|
instance.conditions.progress = progress;
|
|
1355
942
|
}
|
|
1356
|
-
// Not const: the segment loop below rewinds it as it charges the clock for
|
|
1357
|
-
// each segment it consumes within the frame.
|
|
1358
943
|
let progressInSeconds = progress / 1000;
|
|
1359
944
|
const step = instance.route.steps[index];
|
|
1360
945
|
if (step.coordinates.length <= 0) {
|
|
@@ -1392,14 +977,6 @@ export class RouteController {
|
|
|
1392
977
|
return;
|
|
1393
978
|
}
|
|
1394
979
|
}
|
|
1395
|
-
// There has to be a floor to switch *to*. An absent `startInsideFloor` is
|
|
1396
|
-
// meaningful — that is a step entering the building from outdoors — but an
|
|
1397
|
-
// absent `endInsideFloor` is not: venue data routinely omits it on a step
|
|
1398
|
-
// that does not change floor, and reading that as "different" made every
|
|
1399
|
-
// such step stall for `changeFloorTime` and then queue a switch whose
|
|
1400
|
-
// `floorKey` was `undefined`. `updatePlaceFloorForRouting` drops that
|
|
1401
|
-
// silently, but not before it has occupied the `pendingFloor` slot the
|
|
1402
|
-
// step boundary needed for a real one.
|
|
1403
980
|
if (step.endInsideFloor && step.startInsideFloor !== step.endInsideFloor) {
|
|
1404
981
|
if (waitStartTime == null) {
|
|
1405
982
|
instance.conditions.waitStartTime = timestamp;
|
|
@@ -1413,13 +990,10 @@ export class RouteController {
|
|
|
1413
990
|
else {
|
|
1414
991
|
instance.conditions.waitStartTime = undefined;
|
|
1415
992
|
if (instance.conditions.isStepByStep) {
|
|
1416
|
-
// Step-by-step mode is user-driven: switch right away, as before.
|
|
1417
993
|
this.updatePlaceFloorForRouting(instance, step.endInsidePlace, step.endInsideFloor);
|
|
1418
994
|
this.setMarkerLngLat(instance, step.endLocation);
|
|
1419
995
|
}
|
|
1420
996
|
else {
|
|
1421
|
-
// Defer the switch until the next step's line is uploaded, so floor,
|
|
1422
|
-
// line and marker change together (see applyPendingFloor).
|
|
1423
997
|
instance.conditions.pendingFloor = {
|
|
1424
998
|
placeId: step.endInsidePlace,
|
|
1425
999
|
floorKey: step.endInsideFloor,
|
|
@@ -1431,32 +1005,15 @@ export class RouteController {
|
|
|
1431
1005
|
}
|
|
1432
1006
|
}
|
|
1433
1007
|
const speed = Math.max(step.distance / stepTime, minimumSpeed !== null && minimumSpeed !== void 0 ? minimumSpeed : 0);
|
|
1434
|
-
// Consume every whole segment the elapsed time pays for inside this one
|
|
1435
|
-
// frame, carrying the sub-segment remainder into the next.
|
|
1436
|
-
//
|
|
1437
|
-
// Advancing a single vertex per frame — and restarting the clock at each
|
|
1438
|
-
// one, which threw the overshoot away — made a step's duration depend on
|
|
1439
|
-
// the frame rate: it cost `stepTime` plus up to one frame per vertex,
|
|
1440
|
-
// and once `speed * frameInterval` exceeded a segment's length it
|
|
1441
|
-
// ignored `stepTime` altogether and collapsed to `vertexCount / fps`.
|
|
1442
|
-
// Encoded polylines quantise near 1.1 m, so that regime was the common
|
|
1443
|
-
// one, not the corner case.
|
|
1444
|
-
//
|
|
1445
|
-
// The step's whole polyline is already uploaded (see `loadStepGeometry`),
|
|
1446
|
-
// so a frame commits nothing: it only moves the reveal cut-off, which is
|
|
1447
|
-
// the same distance that moves the marker.
|
|
1448
1008
|
let segmentStart = start;
|
|
1449
1009
|
let segmentEnd = end;
|
|
1450
1010
|
let segmentDistance = NavFunctions.distance(segmentStart, segmentEnd);
|
|
1451
1011
|
while (speed * progressInSeconds > segmentDistance) {
|
|
1452
1012
|
if (instance.conditions.coordinatesIndex + 2 >= step.coordinates.length) {
|
|
1453
|
-
// `segmentEnd` is the step's last vertex: reveal the line in full.
|
|
1454
1013
|
this.applyReveal(instance, this.fractionAlongStep(instance, instance.conditions.coordinatesIndex + 1, 0));
|
|
1455
1014
|
onFinish === null || onFinish === void 0 ? void 0 : onFinish(timestamp);
|
|
1456
1015
|
return;
|
|
1457
1016
|
}
|
|
1458
|
-
// Charge the clock exactly what this segment cost instead of
|
|
1459
|
-
// restarting it, so no time is lost at a vertex.
|
|
1460
1017
|
const segmentMs = (segmentDistance / speed) * 1000;
|
|
1461
1018
|
startTime += segmentMs;
|
|
1462
1019
|
progress -= segmentMs;
|
|
@@ -1467,20 +1024,9 @@ export class RouteController {
|
|
|
1467
1024
|
const next = step.coordinates[instance.conditions.coordinatesIndex + 1];
|
|
1468
1025
|
if (!compareLatLng(segmentEnd, next)) {
|
|
1469
1026
|
if (instance.conditions.isStepByStep) {
|
|
1470
|
-
// Step-by-step mode animates the turn itself, on the rotation
|
|
1471
|
-
// branch of the next frame. Stop consuming segments and let it.
|
|
1472
|
-
//
|
|
1473
|
-
// The clock restarts here because the rotation branch measures its
|
|
1474
|
-
// own progress from `startTime`, and every other transition into it
|
|
1475
|
-
// resets too (see `prepareForNextStep` and the floor-change hand-off).
|
|
1476
|
-
// Carrying this frame's leftover sub-segment time over instead
|
|
1477
|
-
// started the turn already part-way through — or skipped it outright
|
|
1478
|
-
// once the remainder exceeded `iconRotationTime`. Before the segment
|
|
1479
|
-
// loop existed the per-vertex path reset it as well.
|
|
1480
1027
|
instance.conditions.rotatingIcon = true;
|
|
1481
1028
|
instance.conditions.startTime = timestamp;
|
|
1482
1029
|
instance.conditions.progress = 0;
|
|
1483
|
-
// The marker stops on the vertex it turns about, so the line does too.
|
|
1484
1030
|
this.applyReveal(instance, this.fractionAlongStep(instance, instance.conditions.coordinatesIndex, 0));
|
|
1485
1031
|
instance.conditions.animationId = requestAnimationFrame((time) => this.animateStep(time, instance));
|
|
1486
1032
|
return;
|
|
@@ -1497,25 +1043,8 @@ export class RouteController {
|
|
|
1497
1043
|
const point = segmentDistance === 0
|
|
1498
1044
|
? segmentEnd
|
|
1499
1045
|
: NavFunctions.intermediatePointBetween(segmentStart, segmentEnd, traveled / segmentDistance);
|
|
1500
|
-
// The same distance drives the reveal cut-off and the marker, and the
|
|
1501
|
-
// reveal is a synchronous paint update rather than a `setData` that lands
|
|
1502
|
-
// several frames later, so the two cannot drift apart.
|
|
1503
1046
|
this.applyReveal(instance, this.fractionAlongStep(instance, instance.conditions.coordinatesIndex, traveled));
|
|
1504
1047
|
this.setMarkerLngLat(instance, point);
|
|
1505
|
-
// Only when it has genuinely left the DOM. maplibre's `Marker.addTo`
|
|
1506
|
-
// opens with `remove()`, so re-attaching an attached marker tears down
|
|
1507
|
-
// and rebuilds 13 map listeners and detaches and re-appends the element.
|
|
1508
|
-
// Unconditionally, that ran every frame — and quietly undid
|
|
1509
|
-
// `updateRouteMarkerVisibility` hiding the arrow, which is the bug it was
|
|
1510
|
-
// really covering for.
|
|
1511
|
-
//
|
|
1512
|
-
// `isConnected` alone cannot express that: `hide()` detaches the element
|
|
1513
|
-
// through maplibre's `Marker.remove()`, so a marker hidden by a floor
|
|
1514
|
-
// change reads as disconnected and was re-attached on the very next
|
|
1515
|
-
// frame — the arrow reappeared on the wrong floor. Hidden-ness is an
|
|
1516
|
-
// intent, so it is read from the flag `hide()`/`show()` maintain, and
|
|
1517
|
-
// `isConnected` is left to answer only what it can: whether a marker
|
|
1518
|
-
// nobody hid has fallen out of the DOM (a step transition removing it).
|
|
1519
1048
|
if (instance.routeMarker != null &&
|
|
1520
1049
|
!instance.routeMarker.hiddenOnPurpose &&
|
|
1521
1050
|
!instance.routeMarker.getElement().isConnected) {
|
|
@@ -1559,4 +1088,3 @@ export class RouteController {
|
|
|
1559
1088
|
this.mapvxMap.updateCamera(Object.assign({ center: point, animate: true, duration: (_c = instance.animationConfig) === null || _c === void 0 ? void 0 : _c.iconRotationTime }, (keepFixedBearing ? {} : { bearing: (_d = instance.routeMarker) === null || _d === void 0 ? void 0 : _d.getRotation() })));
|
|
1560
1089
|
}
|
|
1561
1090
|
}
|
|
1562
|
-
//# sourceMappingURL=routeController.js.map
|