mobility-toolbox-js 2.3.10 → 2.4.0
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/api/RealtimeAPI.d.ts +290 -0
- package/api/RealtimeAPI.d.ts.map +1 -0
- package/api/RealtimeAPI.js +483 -0
- package/api/RoutingAPI.d.ts +37 -0
- package/api/RoutingAPI.d.ts.map +1 -0
- package/api/RoutingAPI.js +35 -0
- package/api/StopsAPI.d.ts +38 -0
- package/api/StopsAPI.d.ts.map +1 -0
- package/api/StopsAPI.js +36 -0
- package/api/index.d.ts +4 -0
- package/api/index.d.ts.map +1 -0
- package/api/typedefs.d.ts +179 -0
- package/api/typedefs.d.ts.map +1 -0
- package/{src/api → api}/typedefs.js +1 -11
- package/common/api/HttpAPI.d.ts +31 -0
- package/common/api/HttpAPI.d.ts.map +1 -0
- package/common/api/HttpAPI.js +57 -0
- package/common/api/WebSocketAPI.d.ts +153 -0
- package/common/api/WebSocketAPI.d.ts.map +1 -0
- package/common/api/WebSocketAPI.js +341 -0
- package/common/controls/ControlCommon.d.ts +76 -0
- package/common/controls/ControlCommon.d.ts.map +1 -0
- package/common/controls/ControlCommon.js +150 -0
- package/common/controls/CopyrightControlCommon.d.ts +13 -0
- package/common/controls/CopyrightControlCommon.d.ts.map +1 -0
- package/common/controls/CopyrightControlCommon.js +34 -0
- package/common/controls/StopFinderControlCommon.d.ts +55 -0
- package/common/controls/StopFinderControlCommon.d.ts.map +1 -0
- package/common/controls/StopFinderControlCommon.js +144 -0
- package/common/index.d.ts +3 -0
- package/common/index.d.ts.map +1 -0
- package/common/layers/LayerCommon.d.ts +94 -0
- package/common/layers/LayerCommon.d.ts.map +1 -0
- package/common/layers/LayerCommon.js +244 -0
- package/common/mixins/RealtimeLayerMixin.d.ts +288 -0
- package/common/mixins/RealtimeLayerMixin.d.ts.map +1 -0
- package/common/mixins/RealtimeLayerMixin.js +779 -0
- package/common/mixins/UserInteractionsLayerMixin.d.ts +60 -0
- package/common/mixins/UserInteractionsLayerMixin.d.ts.map +1 -0
- package/common/mixins/UserInteractionsLayerMixin.js +241 -0
- package/common/styles/index.d.ts +5 -0
- package/common/styles/index.d.ts.map +1 -0
- package/common/styles/realtimeDefaultStyle.d.ts +36 -0
- package/common/styles/realtimeDefaultStyle.d.ts.map +1 -0
- package/common/styles/realtimeDefaultStyle.js +276 -0
- package/common/styles/realtimeDelayStyle.d.ts +12 -0
- package/common/styles/realtimeDelayStyle.d.ts.map +1 -0
- package/common/styles/realtimeDelayStyle.js +13 -0
- package/common/styles/realtimeHeadingStyle.d.ts +12 -0
- package/common/styles/realtimeHeadingStyle.d.ts.map +1 -0
- package/common/styles/realtimeHeadingStyle.js +87 -0
- package/common/styles/realtimeSimpleStyle.d.ts +4 -0
- package/common/styles/realtimeSimpleStyle.d.ts.map +1 -0
- package/common/styles/realtimeSimpleStyle.js +23 -0
- package/common/typedefs.d.ts +183 -0
- package/common/typedefs.d.ts.map +1 -0
- package/{src/common → common}/typedefs.js +1 -1
- package/common/utils/compareDepartures.d.ts +11 -0
- package/common/utils/compareDepartures.d.ts.map +1 -0
- package/common/utils/compareDepartures.js +35 -0
- package/common/utils/createCanvas.d.ts +11 -0
- package/common/utils/createCanvas.d.ts.map +1 -0
- package/common/utils/createCanvas.js +28 -0
- package/common/utils/createRealtimeFilters.d.ts +13 -0
- package/common/utils/createRealtimeFilters.d.ts.map +1 -0
- package/common/utils/createRealtimeFilters.js +74 -0
- package/common/utils/debounceDeparturesMessages.d.ts +13 -0
- package/common/utils/debounceDeparturesMessages.d.ts.map +1 -0
- package/common/utils/debounceDeparturesMessages.js +28 -0
- package/common/utils/debounceWebsocketMessages.d.ts +12 -0
- package/common/utils/debounceWebsocketMessages.d.ts.map +1 -0
- package/common/utils/debounceWebsocketMessages.js +30 -0
- package/common/utils/getLayersAsFlatArray.d.ts +4 -0
- package/common/utils/getLayersAsFlatArray.d.ts.map +1 -0
- package/common/utils/getLayersAsFlatArray.js +16 -0
- package/common/utils/getMapboxMapCopyrights.d.ts +18 -0
- package/common/utils/getMapboxMapCopyrights.d.ts.map +1 -0
- package/common/utils/getMapboxMapCopyrights.js +30 -0
- package/common/utils/getMapboxRender.d.ts +8 -0
- package/common/utils/getMapboxRender.d.ts.map +1 -0
- package/common/utils/getMapboxRender.js +88 -0
- package/common/utils/getMaplibreRender.d.ts +9 -0
- package/common/utils/getMaplibreRender.d.ts.map +1 -0
- package/common/utils/getMaplibreRender.js +40 -0
- package/{src/common/utils/getRealtimeModeSuffix.ts → common/utils/getRealtimeModeSuffix.d.ts} +2 -4
- package/common/utils/getRealtimeModeSuffix.d.ts.map +1 -0
- package/common/utils/getRealtimeModeSuffix.js +7 -0
- package/common/utils/getUrlWithParams.d.ts +9 -0
- package/common/utils/getUrlWithParams.d.ts.map +1 -0
- package/common/utils/getUrlWithParams.js +18 -0
- package/common/utils/getVehiclePosition.d.ts +16 -0
- package/common/utils/getVehiclePosition.d.ts.map +1 -0
- package/common/utils/getVehiclePosition.js +72 -0
- package/common/utils/index.d.ts +18 -0
- package/common/utils/index.d.ts.map +1 -0
- package/{src/common → common}/utils/index.js +2 -1
- package/common/utils/realtimeConfig.d.ts +53 -0
- package/common/utils/realtimeConfig.d.ts.map +1 -0
- package/common/utils/realtimeConfig.js +202 -0
- package/common/utils/removeDuplicate.d.ts +10 -0
- package/common/utils/removeDuplicate.d.ts.map +1 -0
- package/common/utils/removeDuplicate.js +15 -0
- package/common/utils/renderTrajectories.d.ts +17 -0
- package/common/utils/renderTrajectories.d.ts.map +1 -0
- package/common/utils/renderTrajectories.js +110 -0
- package/common/utils/sortAndFilterDepartures.d.ts +16 -0
- package/common/utils/sortAndFilterDepartures.d.ts.map +1 -0
- package/common/utils/sortAndFilterDepartures.js +58 -0
- package/common/utils/sortByDelay.d.ts +4 -0
- package/common/utils/sortByDelay.d.ts.map +1 -0
- package/common/utils/sortByDelay.js +21 -0
- package/common/utils/timeUtils.d.ts +24 -0
- package/common/utils/timeUtils.d.ts.map +1 -0
- package/common/utils/timeUtils.js +39 -0
- package/iife.d.ts +3 -0
- package/iife.d.ts.map +1 -0
- package/{src/iife.js → iife.js} +1 -3
- package/index.d.ts +10 -0
- package/index.d.ts.map +1 -0
- package/index.js +10 -0
- package/mapbox/controls/CopyrightControl.d.ts +29 -0
- package/mapbox/controls/CopyrightControl.d.ts.map +1 -0
- package/{src/mapbox/controls/CopyrightControl.ts → mapbox/controls/CopyrightControl.js} +21 -26
- package/mapbox/controls/index.d.ts +2 -0
- package/mapbox/controls/index.d.ts.map +1 -0
- package/mapbox/index.d.ts +6 -0
- package/mapbox/index.d.ts.map +1 -0
- package/mapbox/layers/Layer.d.ts +59 -0
- package/mapbox/layers/Layer.d.ts.map +1 -0
- package/mapbox/layers/Layer.js +101 -0
- package/mapbox/layers/RealtimeLayer.d.ts +180 -0
- package/mapbox/layers/RealtimeLayer.d.ts.map +1 -0
- package/mapbox/layers/RealtimeLayer.js +270 -0
- package/mapbox/layers/index.d.ts +3 -0
- package/mapbox/layers/index.d.ts.map +1 -0
- package/mapbox/utils/getMercatorResolution.d.ts +9 -0
- package/mapbox/utils/getMercatorResolution.d.ts.map +1 -0
- package/mapbox/utils/getMercatorResolution.js +18 -0
- package/mapbox/utils/getSourceCoordinates.d.ts +9 -0
- package/mapbox/utils/getSourceCoordinates.d.ts.map +1 -0
- package/mapbox/utils/getSourceCoordinates.js +27 -0
- package/mapbox/utils/index.d.ts +3 -0
- package/mapbox/utils/index.d.ts.map +1 -0
- package/mbt.js +64822 -0
- package/mbt.js.map +7 -0
- package/mbt.min.js +1090 -0
- package/mbt.min.js.map +7 -0
- package/ol/controls/CopyrightControl.d.ts +31 -0
- package/ol/controls/CopyrightControl.d.ts.map +1 -0
- package/ol/controls/CopyrightControl.js +68 -0
- package/ol/controls/RoutingControl.d.ts +193 -0
- package/ol/controls/RoutingControl.d.ts.map +1 -0
- package/ol/controls/RoutingControl.js +631 -0
- package/ol/controls/StopFinderControl.d.ts +30 -0
- package/ol/controls/StopFinderControl.d.ts.map +1 -0
- package/{src/ol/controls/StopFinderControl.ts → ol/controls/StopFinderControl.js} +7 -10
- package/ol/controls/index.d.ts +4 -0
- package/ol/controls/index.d.ts.map +1 -0
- package/ol/index.d.ts +6 -0
- package/ol/index.d.ts.map +1 -0
- package/ol/layers/Layer.d.ts +86 -0
- package/ol/layers/Layer.d.ts.map +1 -0
- package/ol/layers/Layer.js +174 -0
- package/ol/layers/MapGlLayer.d.ts +67 -0
- package/ol/layers/MapGlLayer.d.ts.map +1 -0
- package/ol/layers/MapGlLayer.js +218 -0
- package/ol/layers/MapboxLayer.d.ts +50 -0
- package/ol/layers/MapboxLayer.d.ts.map +1 -0
- package/ol/layers/MapboxLayer.js +109 -0
- package/ol/layers/MapboxStyleLayer.d.ts +131 -0
- package/ol/layers/MapboxStyleLayer.d.ts.map +1 -0
- package/ol/layers/MapboxStyleLayer.js +369 -0
- package/{src/ol/layers/MaplibreLayer.ts → ol/layers/MaplibreLayer.d.ts} +10 -21
- package/ol/layers/MaplibreLayer.d.ts.map +1 -0
- package/ol/layers/MaplibreLayer.js +34 -0
- package/ol/layers/RealtimeLayer.d.ts +202 -0
- package/ol/layers/RealtimeLayer.d.ts.map +1 -0
- package/ol/layers/RealtimeLayer.js +332 -0
- package/ol/layers/RoutingLayer.d.ts +35 -0
- package/ol/layers/RoutingLayer.d.ts.map +1 -0
- package/ol/layers/RoutingLayer.js +85 -0
- package/ol/layers/VectorLayer.d.ts +25 -0
- package/ol/layers/VectorLayer.d.ts.map +1 -0
- package/ol/layers/VectorLayer.js +38 -0
- package/ol/layers/WMSLayer.d.ts +42 -0
- package/ol/layers/WMSLayer.d.ts.map +1 -0
- package/ol/layers/WMSLayer.js +88 -0
- package/ol/layers/index.d.ts +9 -0
- package/ol/layers/index.d.ts.map +1 -0
- package/ol/styles/fullTrajectoryDelayStyle.d.ts +4 -0
- package/ol/styles/fullTrajectoryDelayStyle.d.ts.map +1 -0
- package/ol/styles/fullTrajectoryDelayStyle.js +33 -0
- package/ol/styles/fullTrajectoryStyle.d.ts +5 -0
- package/ol/styles/fullTrajectoryStyle.d.ts.map +1 -0
- package/ol/styles/fullTrajectoryStyle.js +44 -0
- package/ol/styles/index.d.ts +3 -0
- package/ol/styles/index.d.ts.map +1 -0
- package/package.json +1 -1
- package/setupTests.d.ts +2 -0
- package/setupTests.d.ts.map +1 -0
- package/{src/setupTests.js → setupTests.js} +7 -12
- package/.esdoc.js +0 -18
- package/.eslintignore +0 -1
- package/.eslintrc.js +0 -25
- package/.fixpackrc +0 -20
- package/.github/workflows/build.yml +0 -16
- package/.github/workflows/conventional-pr-title.yml +0 -16
- package/.github/workflows/cypress.yml +0 -101
- package/.github/workflows/test.yml +0 -17
- package/.husky/commit-msg +0 -4
- package/.husky/post-checkout +0 -4
- package/.husky/post-merge +0 -4
- package/.husky/post-rebase +0 -4
- package/.husky/pre-commit +0 -4
- package/.lintstagedrc.js +0 -10
- package/.nvmrc +0 -1
- package/.prettierrc.js +0 -5
- package/.stylelintrc.js +0 -4
- package/CHANGELOG.md +0 -132
- package/LICENSE +0 -21
- package/MIGRATION-V2.md +0 -248
- package/README.md +0 -42
- package/__mocks__/mapbox-gl.js +0 -81
- package/__mocks__/maplibre-gl.js +0 -81
- package/babel.config.js +0 -9
- package/commitlint.config.js +0 -1
- package/cypress/e2e/examples/api.cy.js +0 -7
- package/cypress/e2e/examples/examples.cy.js +0 -7
- package/cypress/e2e/examples/navigation.cy.js +0 -29
- package/cypress/fixtures/example.json +0 -5
- package/cypress/plugins/index.js +0 -21
- package/cypress/support/commands.js +0 -25
- package/cypress/support/e2e.js +0 -20
- package/cypress.config.ts +0 -15
- package/data/fetchRoute.json +0 -292
- package/data/fetchTrajectories.json +0 -18
- package/data/fetchTrajectoryById.json +0 -3
- package/data/fetchTrajectoryStations.json +0 -18
- package/data/stopsSearch.json +0 -15
- package/dependabot.yml +0 -15
- package/doc/.eslintrc.json +0 -1
- package/doc/README.md +0 -34
- package/doc/next.config.js +0 -16
- package/doc/package.json +0 -41
- package/doc/pages/404.js +0 -5
- package/doc/pages/_app.js +0 -61
- package/doc/pages/_document.js +0 -64
- package/doc/pages/doc/[...slug].js +0 -23
- package/doc/pages/doc.js +0 -23
- package/doc/pages/example/[example].js +0 -52
- package/doc/pages/examples.js +0 -34
- package/doc/pages/index.js +0 -25
- package/doc/public/README.md +0 -15
- package/doc/public/favicon.ico +0 -0
- package/doc/public/static/assets/Lato-Black.ttf +0 -0
- package/doc/public/static/assets/Lato-BlackItalic.ttf +0 -0
- package/doc/public/static/assets/Lato-Bold.ttf +0 -0
- package/doc/public/static/assets/Lato-BoldItalic.ttf +0 -0
- package/doc/public/static/assets/Lato-Italic.ttf +0 -0
- package/doc/public/static/assets/Lato-Light.ttf +0 -0
- package/doc/public/static/assets/Lato-LightItalic.ttf +0 -0
- package/doc/public/static/assets/Lato-Regular.ttf +0 -0
- package/doc/public/static/assets/Lato-Thin.ttf +0 -0
- package/doc/public/static/assets/Lato-ThinItalic.ttf +0 -0
- package/doc/public/static/assets/OFL.txt +0 -93
- package/doc/public/static/examples/assets/tralis-live-map/index.js +0 -11
- package/doc/public/static/examples/assets/tralis-live-map/s1kreis.svg +0 -105
- package/doc/public/static/examples/assets/tralis-live-map/s20kreis.svg +0 -101
- package/doc/public/static/examples/assets/tralis-live-map/s2kreis.svg +0 -95
- package/doc/public/static/examples/assets/tralis-live-map/s3kreis.svg +0 -95
- package/doc/public/static/examples/assets/tralis-live-map/s4kreis.svg +0 -95
- package/doc/public/static/examples/assets/tralis-live-map/s6kreis.svg +0 -95
- package/doc/public/static/examples/assets/tralis-live-map/s7kreis.svg +0 -95
- package/doc/public/static/examples/assets/tralis-live-map/s8kreis.svg +0 -93
- package/doc/public/static/examples/assets/tralis-live-map/unknown.svg +0 -107
- package/doc/public/static/examples/layers.html +0 -11
- package/doc/public/static/examples/layers.js +0 -97
- package/doc/public/static/examples/mb-copyright.html +0 -26
- package/doc/public/static/examples/mb-copyright.js +0 -37
- package/doc/public/static/examples/mb-tracker.html +0 -1
- package/doc/public/static/examples/mb-tracker.js +0 -40
- package/doc/public/static/examples/mb-tracker.md +0 -1
- package/doc/public/static/examples/mb-tralis.html +0 -1
- package/doc/public/static/examples/mb-tralis.js +0 -34
- package/doc/public/static/examples/ol-copyright.html +0 -26
- package/doc/public/static/examples/ol-copyright.js +0 -43
- package/doc/public/static/examples/ol-mapbox-layer.html +0 -1
- package/doc/public/static/examples/ol-mapbox-layer.js +0 -28
- package/doc/public/static/examples/ol-mapbox-style-layer.html +0 -12
- package/doc/public/static/examples/ol-mapbox-style-layer.js +0 -48
- package/doc/public/static/examples/ol-query.html +0 -32
- package/doc/public/static/examples/ol-query.js +0 -83
- package/doc/public/static/examples/ol-routing.html +0 -26
- package/doc/public/static/examples/ol-routing.js +0 -65
- package/doc/public/static/examples/ol-routing.md +0 -1
- package/doc/public/static/examples/ol-stop-finder.html +0 -15
- package/doc/public/static/examples/ol-stop-finder.js +0 -35
- package/doc/public/static/examples/ol-stop-finder.md +0 -1
- package/doc/public/static/examples/ol-tracker.html +0 -1
- package/doc/public/static/examples/ol-tracker.js +0 -41
- package/doc/public/static/examples/ol-tracker.md +0 -1
- package/doc/public/static/examples/ol-tralis.html +0 -5
- package/doc/public/static/examples/ol-tralis.js +0 -62
- package/doc/public/static/examples/tralis-live-map.html +0 -1
- package/doc/public/static/examples/tralis-live-map.js +0 -67
- package/doc/public/static/examples/tralis-live-map.md +0 -3
- package/doc/public/static/img/live_tracker_mb.jpg +0 -0
- package/doc/public/static/img/live_tracker_munich.jpg +0 -0
- package/doc/public/static/img/live_tracker_ol.jpg +0 -0
- package/doc/public/static/img/mapbox.jpg +0 -0
- package/doc/public/static/img/mapbox_style.jpg +0 -0
- package/doc/public/static/img/ol-copyright.png +0 -0
- package/doc/public/static/img/query_objects.jpg +0 -0
- package/doc/public/static/img/routing.jpg +0 -0
- package/doc/public/static/img/simple_map.jpg +0 -0
- package/doc/public/static/img/stops.jpg +0 -0
- package/doc/public/vercel.svg +0 -4
- package/doc/src/components/CodeSandboxButton.js +0 -102
- package/doc/src/components/Documentation.js +0 -42
- package/doc/src/components/Esdoc/Anchor.js +0 -57
- package/doc/src/components/Esdoc/ClassDoc.js +0 -272
- package/doc/src/components/Esdoc/DeprecatedHTML.js +0 -16
- package/doc/src/components/Esdoc/DetailDocs.js +0 -279
- package/doc/src/components/Esdoc/DetailHTML.js +0 -33
- package/doc/src/components/Esdoc/DirectSubclassHTML.js +0 -30
- package/doc/src/components/Esdoc/DocBuilderUtils.js +0 -697
- package/doc/src/components/Esdoc/DocLinkHTML.js +0 -63
- package/doc/src/components/Esdoc/DocsLinkHTML.js +0 -38
- package/doc/src/components/Esdoc/Esdoc.js +0 -63
- package/doc/src/components/Esdoc/EsdocContent.js +0 -56
- package/doc/src/components/Esdoc/EsdocNavigation.js +0 -13
- package/doc/src/components/Esdoc/EsdocSearch.js +0 -78
- package/doc/src/components/Esdoc/ExperimentalHTML.js +0 -17
- package/doc/src/components/Esdoc/ExtendsChainHTML.js +0 -32
- package/doc/src/components/Esdoc/FileDocLinkHTML.js +0 -62
- package/doc/src/components/Esdoc/IdentifiersDoc.js +0 -113
- package/doc/src/components/Esdoc/IndirectSubclassHTML.js +0 -30
- package/doc/src/components/Esdoc/InheritedSummaryDoc.js +0 -70
- package/doc/src/components/Esdoc/InheritedSummaryHTML.js +0 -38
- package/doc/src/components/Esdoc/MixinClassesHTML.js +0 -29
- package/doc/src/components/Esdoc/NavDoc.js +0 -112
- package/doc/src/components/Esdoc/OverrideMethod.js +0 -44
- package/doc/src/components/Esdoc/OverrideMethodDescription.js +0 -35
- package/doc/src/components/Esdoc/Properties.js +0 -89
- package/doc/src/components/Esdoc/README.md +0 -45
- package/doc/src/components/Esdoc/SignatureHTML.js +0 -123
- package/doc/src/components/Esdoc/SingleDoc.js +0 -31
- package/doc/src/components/Esdoc/SummaryDoc.js +0 -160
- package/doc/src/components/Esdoc/SummaryHTML.js +0 -96
- package/doc/src/components/Esdoc/TypeDocLinkHTML.js +0 -251
- package/doc/src/components/Esdoc/index.js +0 -7
- package/doc/src/components/Esdoc/taffydb.js +0 -2070
- package/doc/src/components/Example.js +0 -200
- package/doc/src/components/ExampleCard.js +0 -126
- package/doc/src/components/Examples.js +0 -78
- package/doc/src/components/Home.js +0 -121
- package/doc/src/components/TrackerExample.js +0 -39
- package/doc/src/examples.js +0 -117
- package/doc/styles/App.scss +0 -53
- package/doc/styles/identifiers.css +0 -38
- package/doc/styles/search.css +0 -76
- package/doc/styles/style.css +0 -603
- package/esdoc/README.md +0 -27
- package/esdoc/plugins/MyPlugin.js +0 -69
- package/esdoc/plugins/dynamic-property-plugin/Plugin.js +0 -50
- package/esdoc/plugins/externals-plugin/Plugin.js +0 -45
- package/esdoc/plugins/externals-plugin/externals.js +0 -93
- package/esdoc/plugins/optional-chaining-plugin/Plugin.js +0 -8
- package/global-setup.js +0 -3
- package/jest.config.js +0 -24
- package/pull_request_template.md +0 -17
- package/scripts/read-pkg-json.js +0 -22
- package/src/api/RealtimeAPI.test.js +0 -144
- package/src/api/RealtimeAPI.ts +0 -712
- package/src/api/RoutingAPI.test.js +0 -41
- package/src/api/RoutingAPI.ts +0 -47
- package/src/api/StopsAPI.test.js +0 -34
- package/src/api/StopsAPI.ts +0 -45
- package/src/common/api/HttpAPI.test.js +0 -68
- package/src/common/api/HttpAPI.ts +0 -77
- package/src/common/api/WebSocketAPI.test.js +0 -421
- package/src/common/api/WebSocketAPI.ts +0 -515
- package/src/common/controls/ControlCommon.test.js +0 -106
- package/src/common/controls/ControlCommon.ts +0 -194
- package/src/common/controls/CopyrightControlCommon.ts +0 -41
- package/src/common/controls/StopFinderControlCommon.ts +0 -192
- package/src/common/layers/LayerCommon.test.js +0 -158
- package/src/common/layers/LayerCommon.ts +0 -321
- package/src/common/mixins/RealtimeLayerMixin.ts +0 -1168
- package/src/common/mixins/UserInteractionsLayerMixin.test.js +0 -227
- package/src/common/mixins/UserInteractionsLayerMixin.ts +0 -352
- package/src/common/styles/realtimeDefaultStyle.ts +0 -436
- package/src/common/styles/realtimeDelayStyle.ts +0 -27
- package/src/common/styles/realtimeHeadingStyle.ts +0 -138
- package/src/common/styles/realtimeSimpleStyle.ts +0 -25
- package/src/common/utils/compareDepartures.ts +0 -46
- package/src/common/utils/createCanvas.ts +0 -33
- package/src/common/utils/createRealtimeFilters.test.js +0 -100
- package/src/common/utils/createRealtimeFilters.ts +0 -96
- package/src/common/utils/debounceDeparturesMessages.ts +0 -52
- package/src/common/utils/debounceWebsocketMessages.ts +0 -47
- package/src/common/utils/getLayersAsFlatArray.ts +0 -17
- package/src/common/utils/getMapboxMapCopyrights.test.js +0 -47
- package/src/common/utils/getMapboxMapCopyrights.ts +0 -52
- package/src/common/utils/getMapboxRender.ts +0 -104
- package/src/common/utils/getMaplibreRender.ts +0 -54
- package/src/common/utils/getUrlWithParams.ts +0 -21
- package/src/common/utils/getVehiclePosition.ts +0 -92
- package/src/common/utils/realtimeConfig.test.js +0 -57
- package/src/common/utils/realtimeConfig.ts +0 -228
- package/src/common/utils/removeDuplicate.test.js +0 -22
- package/src/common/utils/removeDuplicate.ts +0 -22
- package/src/common/utils/renderTrajectories.ts +0 -194
- package/src/common/utils/sortAndFilterDepartures.ts +0 -78
- package/src/common/utils/sortByDelay.ts +0 -29
- package/src/common/utils/timeUtils.test.js +0 -16
- package/src/common/utils/timeUtils.ts +0 -45
- package/src/index.js +0 -10
- package/src/mapbox/layers/Layer.test.js +0 -217
- package/src/mapbox/layers/Layer.ts +0 -144
- package/src/mapbox/layers/RealtimeLayer.test.js +0 -13
- package/src/mapbox/layers/RealtimeLayer.ts +0 -350
- package/src/mapbox/utils/getMercatorResolution.ts +0 -21
- package/src/mapbox/utils/getSourceCoordinates.ts +0 -34
- package/src/ol/README.md +0 -0
- package/src/ol/controls/CopyrightControl.test.js +0 -211
- package/src/ol/controls/CopyrightControl.ts +0 -82
- package/src/ol/controls/RoutingControl.test.js +0 -205
- package/src/ol/controls/RoutingControl.ts +0 -869
- package/src/ol/controls/StopFinderControl.test.js +0 -59
- package/src/ol/controls/snapshots/RoutingControlRouteGen10.json +0 -58
- package/src/ol/controls/snapshots/RoutingControlRouteGen100.json +0 -292
- package/src/ol/controls/snapshots/RoutingControlRouteGen30.json +0 -69
- package/src/ol/controls/snapshots/RoutingControlRouteGen5.json +0 -58
- package/src/ol/controls/snapshots/RoutingControlRouteOSM.json +0 -759
- package/src/ol/controls/snapshots/RoutingControlStation1.json +0 -60
- package/src/ol/controls/snapshots/RoutingControlStation2.json +0 -49
- package/src/ol/layers/Layer.test.js +0 -212
- package/src/ol/layers/Layer.ts +0 -252
- package/src/ol/layers/MapGlLayer.ts +0 -294
- package/src/ol/layers/MapboxLayer.test.js +0 -190
- package/src/ol/layers/MapboxLayer.ts +0 -136
- package/src/ol/layers/MapboxStyleLayer.test.js +0 -258
- package/src/ol/layers/MapboxStyleLayer.ts +0 -466
- package/src/ol/layers/RealtimeLayer.test.js +0 -84
- package/src/ol/layers/RealtimeLayer.ts +0 -465
- package/src/ol/layers/RoutingLayer.test.js +0 -48
- package/src/ol/layers/RoutingLayer.ts +0 -113
- package/src/ol/layers/VectorLayer.test.js +0 -87
- package/src/ol/layers/VectorLayer.ts +0 -48
- package/src/ol/layers/WMSLayer.test.js +0 -65
- package/src/ol/layers/WMSLayer.ts +0 -114
- package/src/ol/styles/fullTrajectoryDelayStyle.ts +0 -37
- package/src/ol/styles/fullTrajectoryStyle.ts +0 -56
- package/tsconfig.json +0 -23
- /package/{src/api → api}/index.js +0 -0
- /package/{src/common → common}/index.js +0 -0
- /package/{src/common → common}/styles/index.js +0 -0
- /package/{src/mapbox → mapbox}/controls/index.js +0 -0
- /package/{src/mapbox → mapbox}/index.js +0 -0
- /package/{src/mapbox → mapbox}/layers/index.js +0 -0
- /package/{src/mapbox → mapbox}/utils/index.js +0 -0
- /package/{src/ol → ol}/controls/index.js +0 -0
- /package/{src/ol → ol}/index.js +0 -0
- /package/{src/ol → ol}/layers/index.js +0 -0
- /package/{src/ol → ol}/styles/index.js +0 -0
- /package/{src/types → types}/common.d.ts +0 -0
- /package/{src/types → types}/index.d.ts +0 -0
- /package/{src/types → types}/realtime.d.ts +0 -0
- /package/{src/types → types}/routing.d.ts +0 -0
- /package/{src/types → types}/stops.d.ts +0 -0
|
@@ -1,869 +0,0 @@
|
|
|
1
|
-
import { Feature } from 'ol';
|
|
2
|
-
import type { Map, MapBrowserEvent } from 'ol';
|
|
3
|
-
import { Geometry, LineString, Point } from 'ol/geom';
|
|
4
|
-
import { Modify } from 'ol/interaction';
|
|
5
|
-
import { unByKey } from 'ol/Observable';
|
|
6
|
-
import { click } from 'ol/events/condition';
|
|
7
|
-
import { GeoJSON } from 'ol/format';
|
|
8
|
-
import { buffer } from 'ol/extent';
|
|
9
|
-
import { fromLonLat, toLonLat } from 'ol/proj';
|
|
10
|
-
import type { Coordinate } from 'ol/coordinate';
|
|
11
|
-
import type { StyleLike } from 'ol/style/Style';
|
|
12
|
-
import BaseEvent from 'ol/events/Event';
|
|
13
|
-
import { EventsKey } from 'ol/events';
|
|
14
|
-
import { ModifyEvent } from 'ol/interaction/Modify';
|
|
15
|
-
import { RoutingAPI } from '../../api';
|
|
16
|
-
import ControlCommon from '../../common/controls/ControlCommon';
|
|
17
|
-
import type { ControlCommonOptions } from '../../common/controls/ControlCommon';
|
|
18
|
-
import RoutingLayer from '../layers/RoutingLayer';
|
|
19
|
-
import type {
|
|
20
|
-
RoutingGraph,
|
|
21
|
-
RoutingMot,
|
|
22
|
-
RoutingParameters,
|
|
23
|
-
RoutingViaPoint,
|
|
24
|
-
} from '../../types';
|
|
25
|
-
|
|
26
|
-
export type RoutingControlOptions = ControlCommonOptions & {
|
|
27
|
-
apiKey?: string;
|
|
28
|
-
|
|
29
|
-
stopsApiKey?: string;
|
|
30
|
-
|
|
31
|
-
stopsApiUrl?: string;
|
|
32
|
-
|
|
33
|
-
routingLayer?: RoutingLayer;
|
|
34
|
-
|
|
35
|
-
graphs?: RoutingGraph[];
|
|
36
|
-
|
|
37
|
-
mot?: string;
|
|
38
|
-
|
|
39
|
-
modify?: boolean;
|
|
40
|
-
|
|
41
|
-
routingApiParams?: RoutingParameters;
|
|
42
|
-
|
|
43
|
-
useRawViaPoints?: boolean;
|
|
44
|
-
|
|
45
|
-
snapToClosestStation?: boolean;
|
|
46
|
-
|
|
47
|
-
style?: StyleLike;
|
|
48
|
-
|
|
49
|
-
onRouteError?: () => void;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export type AbotControllersByGraph = {
|
|
53
|
-
[key: string]: AbortController;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
// Examples for a single hop:
|
|
57
|
-
// basel sbb a station named "basel sbb"
|
|
58
|
-
// ZUE, station "Zürich HB" by its common abbreviation
|
|
59
|
-
// Zürich Hauptbahnhof or HBF Zürich are all valid synonyms für "Zürich HB"
|
|
60
|
-
// @47.37811,8.53935 a station at position 47.37811, 8.53935
|
|
61
|
-
// @47.37811,8.53935$4 track 4 in a station at position 47.37811, 8.53935
|
|
62
|
-
// zürich hb@47.37811,8.53935$8 track 8 in station "Zürich HB" at position 47.37811, 8.53935
|
|
63
|
-
/** @private */
|
|
64
|
-
const REGEX_VIA_POINT =
|
|
65
|
-
/^([^@$!\n]*)(@?([\d.]+),([\d.]+))?(\$?([a-zA-Z0-9]{0,2}))$/;
|
|
66
|
-
|
|
67
|
-
// Examples for a single hop:
|
|
68
|
-
//
|
|
69
|
-
// 47.37811,8.53935 a position 47.37811, 8.53935
|
|
70
|
-
/** @private */
|
|
71
|
-
const REGEX_VIA_POINT_COORD = /^([\d.]+),([\d.]+)$/;
|
|
72
|
-
|
|
73
|
-
// Examples for a single hop:
|
|
74
|
-
//
|
|
75
|
-
// !8596126 a station with id 8596126
|
|
76
|
-
// !8596126$4 a station with id 8596126
|
|
77
|
-
/** @private */
|
|
78
|
-
const REGEX_VIA_POINT_STATION_ID = /^!([^$]*)(\$?([a-zA-Z0-9]{0,2}))$/;
|
|
79
|
-
|
|
80
|
-
/** @private */
|
|
81
|
-
const STOP_FETCH_ABORT_CONTROLLER_KEY = 'stop-fetch';
|
|
82
|
-
|
|
83
|
-
/** @private */
|
|
84
|
-
const getFlatCoordinatesFromSegments = (
|
|
85
|
-
segmentArray: Feature[],
|
|
86
|
-
): Coordinate[] => {
|
|
87
|
-
const coords: Coordinate[] = [];
|
|
88
|
-
segmentArray.forEach((seg) => {
|
|
89
|
-
// @ts-ignore
|
|
90
|
-
const coordArr = seg.getGeometry()?.getCoordinates();
|
|
91
|
-
if (coordArr?.length) {
|
|
92
|
-
coords.push(...coordArr);
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
return coords;
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Display a route of a specified mean of transport.
|
|
100
|
-
*
|
|
101
|
-
* @example
|
|
102
|
-
* import { Map } from 'ol';
|
|
103
|
-
* import { RoutingControl } from 'mobility-toolbox-js/ol';
|
|
104
|
-
*
|
|
105
|
-
* const map = new Map({
|
|
106
|
-
* target: 'map'
|
|
107
|
-
* });
|
|
108
|
-
*
|
|
109
|
-
* const control = new RoutingControl();
|
|
110
|
-
*
|
|
111
|
-
* control.attachToMap(map)
|
|
112
|
-
*
|
|
113
|
-
* @classproperty {string} apiKey - Key used for RoutingApi requests.
|
|
114
|
-
* @classproperty {string} stopsApiKey - Key used for Stop lookup requests (defaults to apiKey).
|
|
115
|
-
* @classproperty {string} stopsApiUrl - Url used for Stop lookup requests (defaults to https://api.geops.io/stops/v1/lookup/).
|
|
116
|
-
* @classproperty {Array.<Array<graph="osm", minZoom=0, maxZoom=99>>} graphs - Array of routing graphs and min/max zoom levels. If you use the control in combination with the [geOps Maps API](https://developer.geops.io/apis/maps/), you may want to use the optimal level of generalizations: "[['gen4', 0, 8], ['gen3', 8, 9], ['gen2', 9, 11], ['gen1', 11, 13], ['osm', 13, 99]]"
|
|
117
|
-
* @classproperty {string} mot - Mean of transport to be used for routing.
|
|
118
|
-
* @classproperty {object} routingApiParams - object of additional parameters to pass to the routing api request.
|
|
119
|
-
* @classproperty {object} snapToClosestStation - If true, the routing will snap the coordinate to the closest station. Default to false.
|
|
120
|
-
* @classproperty {boolean} useRawViaPoints - Experimental property. Wen true, it allows the user to add via points using different kind of string. See "via" parameter defined by the [geOps Routing API](https://developer.geops.io/apis/routing/). Default to false, only array of coordinates and station's id are supported as via points.
|
|
121
|
-
* @classproperty {RoutingLayer|Layer} routingLayer - Layer for adding route features.
|
|
122
|
-
* @classproperty {function} onRouteError - Callback on error.
|
|
123
|
-
* @classproperty {boolean} loading - True if the control is requesting the backend.
|
|
124
|
-
* @see <a href="/example/ol-routing">Openlayers routing example</a>
|
|
125
|
-
*
|
|
126
|
-
* @extends {Control}
|
|
127
|
-
* @implements {RoutingInterface}
|
|
128
|
-
*/
|
|
129
|
-
class RoutingControl extends ControlCommon {
|
|
130
|
-
map?: Map;
|
|
131
|
-
|
|
132
|
-
viaPoints: RoutingViaPoint[] = [];
|
|
133
|
-
|
|
134
|
-
routingLayer?: RoutingLayer;
|
|
135
|
-
|
|
136
|
-
loading: boolean = false;
|
|
137
|
-
|
|
138
|
-
graphs: RoutingGraph[] = [];
|
|
139
|
-
|
|
140
|
-
mot?: RoutingMot;
|
|
141
|
-
|
|
142
|
-
modify: boolean = true;
|
|
143
|
-
|
|
144
|
-
routingApiParams?: RoutingParameters;
|
|
145
|
-
|
|
146
|
-
useRawViaPoints: boolean = false;
|
|
147
|
-
|
|
148
|
-
snapToClosestStation: boolean = false;
|
|
149
|
-
|
|
150
|
-
cacheStationData: {
|
|
151
|
-
[key: string]: Coordinate;
|
|
152
|
-
} = {};
|
|
153
|
-
|
|
154
|
-
abortControllers: {
|
|
155
|
-
[key: string]: AbortController;
|
|
156
|
-
} = {};
|
|
157
|
-
|
|
158
|
-
apiKey?: string;
|
|
159
|
-
|
|
160
|
-
stopsApiKey?: string;
|
|
161
|
-
|
|
162
|
-
segments: Feature<LineString>[] = [];
|
|
163
|
-
|
|
164
|
-
stopsApiUrl?: string;
|
|
165
|
-
|
|
166
|
-
api?: RoutingAPI;
|
|
167
|
-
|
|
168
|
-
format: GeoJSON = new GeoJSON({ featureProjection: 'EPSG:3857' });
|
|
169
|
-
|
|
170
|
-
graphsResolutions?: [number, number][];
|
|
171
|
-
|
|
172
|
-
onRouteError: (error?: Error, control?: RoutingControl) => void;
|
|
173
|
-
|
|
174
|
-
onMapClickKey?: EventsKey;
|
|
175
|
-
|
|
176
|
-
modifyInteraction?: Modify;
|
|
177
|
-
|
|
178
|
-
initialRouteDrag?: {
|
|
179
|
-
viaPoint?: Feature<Point>;
|
|
180
|
-
oldRoute?: Feature<LineString>;
|
|
181
|
-
segmentIndex?: number;
|
|
182
|
-
} = {};
|
|
183
|
-
|
|
184
|
-
constructor(options: RoutingControlOptions = {}) {
|
|
185
|
-
super(options);
|
|
186
|
-
|
|
187
|
-
Object.defineProperties(this, {
|
|
188
|
-
mot: {
|
|
189
|
-
get: () => this.get('mot'),
|
|
190
|
-
set: (newMot) => {
|
|
191
|
-
if (newMot) {
|
|
192
|
-
this.set('mot', newMot);
|
|
193
|
-
if (this.viaPoints) {
|
|
194
|
-
this.drawRoute();
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
},
|
|
198
|
-
},
|
|
199
|
-
loading: {
|
|
200
|
-
get: () => this.get('loading'),
|
|
201
|
-
set: (newLoading) => {
|
|
202
|
-
this.set('loading', newLoading);
|
|
203
|
-
},
|
|
204
|
-
},
|
|
205
|
-
modify: {
|
|
206
|
-
get: () => this.get('modify'),
|
|
207
|
-
set: (modify) => {
|
|
208
|
-
this.set('modify', modify);
|
|
209
|
-
},
|
|
210
|
-
},
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
/** True if the control is requesting the backend. */
|
|
214
|
-
this.loading = false;
|
|
215
|
-
|
|
216
|
-
/** @private */
|
|
217
|
-
this.graphs = options.graphs || [['osm', 0, 99]];
|
|
218
|
-
|
|
219
|
-
/** @private */
|
|
220
|
-
this.mot = options.mot || 'bus';
|
|
221
|
-
|
|
222
|
-
/** @private */
|
|
223
|
-
this.modify = options.modify !== false;
|
|
224
|
-
|
|
225
|
-
/** @private */
|
|
226
|
-
this.routingApiParams = options.routingApiParams;
|
|
227
|
-
|
|
228
|
-
/** @private */
|
|
229
|
-
this.useRawViaPoints = options.useRawViaPoints || false;
|
|
230
|
-
|
|
231
|
-
/** @private */
|
|
232
|
-
this.snapToClosestStation = options.snapToClosestStation || false;
|
|
233
|
-
|
|
234
|
-
/** @private */
|
|
235
|
-
this.apiKey = options.apiKey;
|
|
236
|
-
|
|
237
|
-
/** @private */
|
|
238
|
-
this.stopsApiKey = options.stopsApiKey || this.apiKey;
|
|
239
|
-
|
|
240
|
-
/** @private */
|
|
241
|
-
this.stopsApiUrl = options.stopsApiUrl || 'https://api.geops.io/stops/v1/';
|
|
242
|
-
|
|
243
|
-
/** @private */
|
|
244
|
-
this.api = new RoutingAPI({
|
|
245
|
-
...options,
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
/** @private */
|
|
249
|
-
this.routingLayer =
|
|
250
|
-
options.routingLayer ||
|
|
251
|
-
new RoutingLayer({
|
|
252
|
-
name: 'routing-layer',
|
|
253
|
-
style: options.style,
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
/** @private */
|
|
257
|
-
this.onRouteError =
|
|
258
|
-
options.onRouteError ||
|
|
259
|
-
((error) => {
|
|
260
|
-
this.dispatchEvent(new BaseEvent('change:route'));
|
|
261
|
-
this.reset();
|
|
262
|
-
// eslint-disable-next-line no-console
|
|
263
|
-
console.error(error);
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
/** @private */
|
|
267
|
-
this.onMapClick = this.onMapClick.bind(this);
|
|
268
|
-
|
|
269
|
-
/** @private */
|
|
270
|
-
this.onModifyEnd = this.onModifyEnd.bind(this);
|
|
271
|
-
|
|
272
|
-
/** @private */
|
|
273
|
-
this.onModifyStart = this.onModifyStart.bind(this);
|
|
274
|
-
|
|
275
|
-
/** @private */
|
|
276
|
-
this.createModifyInteraction();
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
* Calculate at which resolutions corresponds each generalizations.
|
|
281
|
-
*
|
|
282
|
-
* @private
|
|
283
|
-
*/
|
|
284
|
-
static getGraphsResolutions(
|
|
285
|
-
graphs: RoutingGraph[],
|
|
286
|
-
map: Map,
|
|
287
|
-
): [number, number][] {
|
|
288
|
-
const view = map.getView();
|
|
289
|
-
return graphs.map(([, minZoom, maxZoom]) => [
|
|
290
|
-
view.getResolutionForZoom(minZoom),
|
|
291
|
-
view.getResolutionForZoom(maxZoom || minZoom + 1),
|
|
292
|
-
]);
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
* Adds/Replaces a viaPoint to the viaPoints array and redraws route:
|
|
297
|
-
* Adds a viaPoint at end of array by default.
|
|
298
|
-
* If an index is passed a viaPoint is added at the specified index.
|
|
299
|
-
* If an index is passed and overwrite x is > 0, x viaPoints at the specified
|
|
300
|
-
* index are replaced with a single new viaPoint.
|
|
301
|
-
* @param {number[]|string} coordinates Array of coordinates
|
|
302
|
-
* @param {number} [index=-1] Integer representing the index of the added viaPoint. If not specified, the viaPoint is added at the end of the array.
|
|
303
|
-
* @param {number} [overwrite=0] Marks the number of viaPoints that are removed at the specified index on add.
|
|
304
|
-
*/
|
|
305
|
-
addViaPoint(
|
|
306
|
-
coordinatesOrString: RoutingViaPoint,
|
|
307
|
-
index: number = -1,
|
|
308
|
-
overwrite: number = 0,
|
|
309
|
-
) {
|
|
310
|
-
/* Add/Insert/Overwrite viapoint and redraw route */
|
|
311
|
-
this.viaPoints.splice(
|
|
312
|
-
index === -1 ? this.viaPoints.length : index,
|
|
313
|
-
overwrite,
|
|
314
|
-
coordinatesOrString,
|
|
315
|
-
);
|
|
316
|
-
this.drawRoute();
|
|
317
|
-
this.dispatchEvent(new BaseEvent('change:route'));
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
/**
|
|
321
|
-
* Removes a viaPoint at the passed array index and redraws route
|
|
322
|
-
* By default the last viaPoint is removed.
|
|
323
|
-
* @param {number} index Integer representing the index of the viaPoint to delete.
|
|
324
|
-
*/
|
|
325
|
-
removeViaPoint(index = (this.viaPoints || []).length - 1) {
|
|
326
|
-
/* Remove viapoint and redraw route */
|
|
327
|
-
if (this.viaPoints.length && this.viaPoints[index]) {
|
|
328
|
-
this.viaPoints.splice(index, 1);
|
|
329
|
-
}
|
|
330
|
-
this.drawRoute();
|
|
331
|
-
this.dispatchEvent(new BaseEvent('change:route'));
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
/**
|
|
335
|
-
* Replaces the current viaPoints with a new coordinate array.
|
|
336
|
-
* @param {Array<Array<number>>} coordinateArray Array of nested coordinates
|
|
337
|
-
*/
|
|
338
|
-
setViaPoints(coordinateArray: Coordinate[]) {
|
|
339
|
-
this.viaPoints = [...coordinateArray];
|
|
340
|
-
this.drawRoute();
|
|
341
|
-
this.dispatchEvent(new BaseEvent('change:route'));
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
/**
|
|
345
|
-
* Removes all viaPoints, clears the source and triggers a change event
|
|
346
|
-
*/
|
|
347
|
-
reset() {
|
|
348
|
-
// Clear viaPoints and source
|
|
349
|
-
this.abortRequests();
|
|
350
|
-
this.viaPoints = [];
|
|
351
|
-
this.routingLayer?.olLayer?.getSource()?.clear();
|
|
352
|
-
this.dispatchEvent(new BaseEvent('change:route'));
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
/**
|
|
356
|
-
* Aborts viapoint and route requests
|
|
357
|
-
* @private
|
|
358
|
-
*/
|
|
359
|
-
abortRequests() {
|
|
360
|
-
// Abort Routing API requests
|
|
361
|
-
this.graphs.forEach((graph) => {
|
|
362
|
-
const graphName = graph[0];
|
|
363
|
-
if (this.abortControllers[graphName]) {
|
|
364
|
-
this.abortControllers[graphName].abort();
|
|
365
|
-
}
|
|
366
|
-
this.abortControllers[graphName] = new AbortController();
|
|
367
|
-
});
|
|
368
|
-
|
|
369
|
-
// Abort Stops API requests
|
|
370
|
-
this.abortControllers[STOP_FETCH_ABORT_CONTROLLER_KEY]?.abort();
|
|
371
|
-
this.abortControllers[STOP_FETCH_ABORT_CONTROLLER_KEY] =
|
|
372
|
-
new AbortController();
|
|
373
|
-
|
|
374
|
-
this.loading = false;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
/**
|
|
378
|
-
* Draws route on map using an array of coordinates:
|
|
379
|
-
* If a single coordinate is passed a single point feature is added to map.
|
|
380
|
-
* If two or more coordinates are passed a request to the RoutingAPI fetches
|
|
381
|
-
* the route using the passed coordinates and the current mot.
|
|
382
|
-
* @private
|
|
383
|
-
*/
|
|
384
|
-
drawRoute() {
|
|
385
|
-
/* Calls RoutingAPI to draw a route using the viaPoints array */
|
|
386
|
-
this.abortRequests();
|
|
387
|
-
this.routingLayer?.olLayer?.getSource()?.clear();
|
|
388
|
-
|
|
389
|
-
if (!this.viaPoints.length) {
|
|
390
|
-
return null;
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
if (this.viaPoints.length === 1) {
|
|
394
|
-
// Add point for first node
|
|
395
|
-
return this.drawViaPoint(
|
|
396
|
-
this.viaPoints[0],
|
|
397
|
-
0,
|
|
398
|
-
this.abortControllers[STOP_FETCH_ABORT_CONTROLLER_KEY],
|
|
399
|
-
);
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
const formattedViaPoints = this.viaPoints.map((viaPoint) => {
|
|
403
|
-
if (Array.isArray(viaPoint)) {
|
|
404
|
-
const projection = this.map?.getView().getProjection();
|
|
405
|
-
// viaPoint is a coordinate
|
|
406
|
-
// Coordinates need to be reversed as required by the backend RoutingAPI
|
|
407
|
-
const [lon, lat] = toLonLat(viaPoint, projection);
|
|
408
|
-
return this.snapToClosestStation ? [`@${lat}`, lon] : [lat, lon];
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
// viaPoint is a string to use as it is
|
|
412
|
-
return this.useRawViaPoints ? viaPoint : `!${viaPoint}`;
|
|
413
|
-
});
|
|
414
|
-
|
|
415
|
-
this.loading = true;
|
|
416
|
-
|
|
417
|
-
// Clear source
|
|
418
|
-
this.routingLayer?.olLayer?.getSource()?.clear();
|
|
419
|
-
|
|
420
|
-
// Create point features for the viaPoints
|
|
421
|
-
this.viaPoints.forEach((viaPoint, idx) =>
|
|
422
|
-
this.drawViaPoint(
|
|
423
|
-
viaPoint,
|
|
424
|
-
idx,
|
|
425
|
-
this.abortControllers[STOP_FETCH_ABORT_CONTROLLER_KEY],
|
|
426
|
-
),
|
|
427
|
-
);
|
|
428
|
-
|
|
429
|
-
return Promise.all(
|
|
430
|
-
this.graphs.map(([graph], index) => {
|
|
431
|
-
const { signal } = this.abortControllers[graph];
|
|
432
|
-
if (!this.api) {
|
|
433
|
-
return Promise.resolve([]);
|
|
434
|
-
}
|
|
435
|
-
return this.api
|
|
436
|
-
.route(
|
|
437
|
-
{
|
|
438
|
-
graph,
|
|
439
|
-
via: `${formattedViaPoints.join('|')}`,
|
|
440
|
-
mot: this.mot,
|
|
441
|
-
// @ts-ignore missing property in swagger
|
|
442
|
-
'resolve-hops': false,
|
|
443
|
-
elevation: false,
|
|
444
|
-
'coord-radius': 100.0,
|
|
445
|
-
'coord-punish': 1000.0,
|
|
446
|
-
...(this.routingApiParams || {}),
|
|
447
|
-
},
|
|
448
|
-
{ signal },
|
|
449
|
-
)
|
|
450
|
-
.then((featureCollection) => {
|
|
451
|
-
this.segments = this.format.readFeatures(
|
|
452
|
-
featureCollection,
|
|
453
|
-
) as Feature<LineString>[];
|
|
454
|
-
|
|
455
|
-
if (this.mot === 'foot') {
|
|
456
|
-
// Extract unique values from viaPoint target value
|
|
457
|
-
const uniqueVias = this.segments.reduce(
|
|
458
|
-
(resultVias: Coordinate[], currentFeat: Feature) => {
|
|
459
|
-
const segTrg = currentFeat.get('trg');
|
|
460
|
-
return resultVias.find(
|
|
461
|
-
(via) => via[0] === segTrg[0] && via[1] === segTrg[1],
|
|
462
|
-
)
|
|
463
|
-
? resultVias
|
|
464
|
-
: [...resultVias, segTrg];
|
|
465
|
-
},
|
|
466
|
-
[],
|
|
467
|
-
);
|
|
468
|
-
|
|
469
|
-
// Create LineString features from segments with same unique value
|
|
470
|
-
this.segments = uniqueVias.map((via) => {
|
|
471
|
-
const viaSegments = this.segments.filter((seg) => {
|
|
472
|
-
const segTrg = seg.get('trg');
|
|
473
|
-
return segTrg[0] === via[0] && segTrg[1] === via[1];
|
|
474
|
-
});
|
|
475
|
-
|
|
476
|
-
const coords = getFlatCoordinatesFromSegments(viaSegments);
|
|
477
|
-
return new Feature({
|
|
478
|
-
geometry: new LineString(coords),
|
|
479
|
-
});
|
|
480
|
-
});
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
// Create the new route. This route will be modifiable by the Modifiy interaction.
|
|
484
|
-
const coords = getFlatCoordinatesFromSegments(this.segments);
|
|
485
|
-
|
|
486
|
-
const routeFeature = new Feature({
|
|
487
|
-
geometry: new LineString(coords),
|
|
488
|
-
});
|
|
489
|
-
routeFeature.set('graph', graph);
|
|
490
|
-
routeFeature.set('mot', this.mot);
|
|
491
|
-
|
|
492
|
-
if (
|
|
493
|
-
this.graphsResolutions &&
|
|
494
|
-
this.graphsResolutions[index]?.length >= 2
|
|
495
|
-
) {
|
|
496
|
-
routeFeature.set(
|
|
497
|
-
'minResolution',
|
|
498
|
-
this.graphsResolutions[index][0],
|
|
499
|
-
);
|
|
500
|
-
routeFeature.set(
|
|
501
|
-
'maxResolution',
|
|
502
|
-
this.graphsResolutions[index][1],
|
|
503
|
-
);
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
this.routingLayer?.olLayer?.getSource()?.addFeature(routeFeature);
|
|
507
|
-
this.loading = false;
|
|
508
|
-
})
|
|
509
|
-
.catch((error) => {
|
|
510
|
-
if (error.name === 'AbortError') {
|
|
511
|
-
// Ignore abort error
|
|
512
|
-
return;
|
|
513
|
-
}
|
|
514
|
-
this.segments = [];
|
|
515
|
-
// Dispatch error event and execute error function
|
|
516
|
-
this.dispatchEvent(new BaseEvent('error'));
|
|
517
|
-
this.onRouteError(error, this);
|
|
518
|
-
this.loading = false;
|
|
519
|
-
});
|
|
520
|
-
}),
|
|
521
|
-
);
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
/**
|
|
525
|
-
* Draw a via point. This function can parse all the possibilitiies
|
|
526
|
-
*
|
|
527
|
-
* @private
|
|
528
|
-
*/
|
|
529
|
-
drawViaPoint(
|
|
530
|
-
viaPoint: RoutingViaPoint,
|
|
531
|
-
idx: number,
|
|
532
|
-
abortController: AbortController,
|
|
533
|
-
) {
|
|
534
|
-
const pointFeature = new Feature();
|
|
535
|
-
pointFeature.set('viaPointIdx', idx);
|
|
536
|
-
|
|
537
|
-
// The via point is a coordinate using the current map's projection
|
|
538
|
-
if (Array.isArray(viaPoint)) {
|
|
539
|
-
pointFeature.setGeometry(new Point(viaPoint));
|
|
540
|
-
this.routingLayer?.olLayer?.getSource()?.addFeature(pointFeature);
|
|
541
|
-
return Promise.resolve(pointFeature);
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
// Possibility to parse:
|
|
545
|
-
//
|
|
546
|
-
// !8596126 a station with id 8596126
|
|
547
|
-
// !8596126$4 a station with id 8596126
|
|
548
|
-
if (!this.useRawViaPoints || REGEX_VIA_POINT_STATION_ID.test(viaPoint)) {
|
|
549
|
-
let stationId: string;
|
|
550
|
-
let track: string;
|
|
551
|
-
if (this.useRawViaPoints) {
|
|
552
|
-
[, stationId, , track] =
|
|
553
|
-
REGEX_VIA_POINT_STATION_ID.exec(viaPoint) || [];
|
|
554
|
-
} else {
|
|
555
|
-
[stationId, track] = viaPoint.split('$');
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
return fetch(
|
|
559
|
-
`${this.stopsApiUrl}lookup/${stationId}?key=${this.stopsApiKey}`,
|
|
560
|
-
{ signal: abortController.signal },
|
|
561
|
-
)
|
|
562
|
-
.then((res) => res.json())
|
|
563
|
-
.then((stationData) => {
|
|
564
|
-
const { coordinates } = stationData.features[0].geometry;
|
|
565
|
-
this.cacheStationData[viaPoint] = fromLonLat(coordinates);
|
|
566
|
-
pointFeature.set('viaPointTrack', track);
|
|
567
|
-
pointFeature.setGeometry(new Point(fromLonLat(coordinates)));
|
|
568
|
-
this.routingLayer?.olLayer?.getSource()?.addFeature(pointFeature);
|
|
569
|
-
return pointFeature;
|
|
570
|
-
})
|
|
571
|
-
.catch((error) => {
|
|
572
|
-
if (error.name === 'AbortError') {
|
|
573
|
-
// Ignore abort error
|
|
574
|
-
return;
|
|
575
|
-
}
|
|
576
|
-
// Dispatch error event and execute error function
|
|
577
|
-
this.dispatchEvent(new BaseEvent('error'));
|
|
578
|
-
this.onRouteError(error, this);
|
|
579
|
-
this.loading = false;
|
|
580
|
-
});
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
// Only when this.useRawViaPoints is true.
|
|
584
|
-
// Possibility to parse:
|
|
585
|
-
//
|
|
586
|
-
// 47.37811,8.53935 a position 47.37811, 8.53935
|
|
587
|
-
if (this.useRawViaPoints && REGEX_VIA_POINT_COORD.test(viaPoint)) {
|
|
588
|
-
const [lat, lon] = REGEX_VIA_POINT_COORD.exec(viaPoint) || [];
|
|
589
|
-
if (lon && lat) {
|
|
590
|
-
const floatLon = parseFloat(lon);
|
|
591
|
-
const floatLat = parseFloat(lat);
|
|
592
|
-
const coordinates = fromLonLat(
|
|
593
|
-
[floatLon, floatLat],
|
|
594
|
-
this.map?.getView().getProjection(),
|
|
595
|
-
);
|
|
596
|
-
pointFeature.setGeometry(new Point(coordinates));
|
|
597
|
-
this.routingLayer?.olLayer?.getSource()?.addFeature(pointFeature);
|
|
598
|
-
return Promise.resolve(pointFeature);
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
// Only when this.useRawViaPoints is true.
|
|
603
|
-
// It will parse the via point to find some name, id, track coordinates.
|
|
604
|
-
//
|
|
605
|
-
// Possibility to parse:
|
|
606
|
-
//
|
|
607
|
-
// @47.37811,8.53935 a station at position 47.37811, 8.53935
|
|
608
|
-
// @47.37811,8.53935$4 track 4 in a station at position 47.37811, 8.53935
|
|
609
|
-
// zürich hb@47.37811,8.53935$8 track 8 in station "Zürich HB" at position 47.37811, 8.53935
|
|
610
|
-
const [, stationName, , lat, lon, , track] =
|
|
611
|
-
REGEX_VIA_POINT.exec(viaPoint) || [];
|
|
612
|
-
|
|
613
|
-
if (lon && lat) {
|
|
614
|
-
const coordinates = fromLonLat(
|
|
615
|
-
[parseFloat(lon), parseFloat(lat)],
|
|
616
|
-
this.map?.getView().getProjection(),
|
|
617
|
-
);
|
|
618
|
-
pointFeature.set('viaPointTrack', track);
|
|
619
|
-
pointFeature.setGeometry(new Point(coordinates));
|
|
620
|
-
this.routingLayer?.olLayer?.getSource()?.addFeature(pointFeature);
|
|
621
|
-
return Promise.resolve(pointFeature);
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
if (stationName) {
|
|
625
|
-
return fetch(
|
|
626
|
-
`${this.stopsApiUrl}?key=${this.stopsApiKey}&q=${stationName}&limit=1`,
|
|
627
|
-
{ signal: abortController.signal },
|
|
628
|
-
)
|
|
629
|
-
.then((res) => res.json())
|
|
630
|
-
.then((stationData) => {
|
|
631
|
-
const { coordinates } = stationData.features[0].geometry;
|
|
632
|
-
this.cacheStationData[viaPoint] = fromLonLat(coordinates);
|
|
633
|
-
pointFeature.set('viaPointTrack', track);
|
|
634
|
-
pointFeature.setGeometry(new Point(fromLonLat(coordinates)));
|
|
635
|
-
this.routingLayer?.olLayer?.getSource()?.addFeature(pointFeature);
|
|
636
|
-
return pointFeature;
|
|
637
|
-
})
|
|
638
|
-
.catch((error) => {
|
|
639
|
-
// Dispatch error event and execute error function
|
|
640
|
-
this.dispatchEvent(new BaseEvent('error'));
|
|
641
|
-
this.onRouteError(error, this);
|
|
642
|
-
this.loading = false;
|
|
643
|
-
return null;
|
|
644
|
-
});
|
|
645
|
-
}
|
|
646
|
-
return Promise.resolve(null);
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
/**
|
|
650
|
-
* Used on click on map while control is active:
|
|
651
|
-
* By default adds a viaPoint to the end of array.
|
|
652
|
-
* If an existing viaPoint is clicked removes the clicked viaPoint.
|
|
653
|
-
* @private
|
|
654
|
-
*/
|
|
655
|
-
onMapClick(evt: MapBrowserEvent<MouseEvent>) {
|
|
656
|
-
const feats = (evt.target as Map).getFeaturesAtPixel(
|
|
657
|
-
evt.pixel,
|
|
658
|
-
) as Feature<Geometry>[];
|
|
659
|
-
const viaPoint = feats.find(
|
|
660
|
-
(feat: Feature<Geometry>) =>
|
|
661
|
-
feat.getGeometry()?.getType() === 'Point' &&
|
|
662
|
-
feat.get('viaPointIdx') !== undefined,
|
|
663
|
-
);
|
|
664
|
-
|
|
665
|
-
if (viaPoint) {
|
|
666
|
-
// Remove existing viaPoint on click and abort viaPoint add
|
|
667
|
-
this.removeViaPoint(viaPoint.get('viaPointIdx'));
|
|
668
|
-
return;
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
this.addViaPoint(evt.coordinate);
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
/**
|
|
675
|
-
* Used on start of the modify interaction. Stores relevant data
|
|
676
|
-
* in this.initialRouteDrag object
|
|
677
|
-
* @private
|
|
678
|
-
*/
|
|
679
|
-
onModifyStart(evt: ModifyEvent) {
|
|
680
|
-
// When modify start, we search the index of the segment that is modifying.
|
|
681
|
-
let segmentIndex = -1;
|
|
682
|
-
const route: Feature<LineString> = evt.features
|
|
683
|
-
.getArray()
|
|
684
|
-
.find(
|
|
685
|
-
(feat) => feat.getGeometry()?.getType() === 'LineString',
|
|
686
|
-
) as unknown as Feature<LineString>;
|
|
687
|
-
|
|
688
|
-
// Find the segment index that is being modified
|
|
689
|
-
if (route && route.getGeometry() && evt.mapBrowserEvent.coordinate) {
|
|
690
|
-
// We use a buff extent to fix floating issues , see https://github.com/openlayers/openlayers/issues/7130#issuecomment-535856422
|
|
691
|
-
const closestExtent = buffer(
|
|
692
|
-
new Point(
|
|
693
|
-
// @ts-ignore
|
|
694
|
-
route.getGeometry()?.getClosestPoint(evt.mapBrowserEvent.coordinate),
|
|
695
|
-
).getExtent(),
|
|
696
|
-
0.001,
|
|
697
|
-
);
|
|
698
|
-
|
|
699
|
-
segmentIndex = this.segments.findIndex(
|
|
700
|
-
(segment) => segment.getGeometry()?.intersectsExtent(closestExtent),
|
|
701
|
-
);
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
// Find the viaPoint that is being modified
|
|
705
|
-
const viaPoint: Feature<Point> = (evt.features
|
|
706
|
-
.getArray()
|
|
707
|
-
.filter((feat) => feat.getGeometry()?.getType() === 'Point') ||
|
|
708
|
-
[])[0] as Feature<Point>;
|
|
709
|
-
|
|
710
|
-
// Write object with modify info
|
|
711
|
-
/** @private */
|
|
712
|
-
this.initialRouteDrag = {
|
|
713
|
-
viaPoint,
|
|
714
|
-
oldRoute: route && route.clone(),
|
|
715
|
-
segmentIndex,
|
|
716
|
-
};
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
/**
|
|
720
|
-
* Used on end of the modify interaction. Resolves feature modification:
|
|
721
|
-
* Line drag creates new viaPoint at the final coordinate of drag.
|
|
722
|
-
* Point drag replaces old viaPoint.
|
|
723
|
-
* @private
|
|
724
|
-
*/
|
|
725
|
-
onModifyEnd(evt: ModifyEvent) {
|
|
726
|
-
const coord = evt.mapBrowserEvent.coordinate;
|
|
727
|
-
const { oldRoute, viaPoint, segmentIndex } = this.initialRouteDrag || {};
|
|
728
|
-
|
|
729
|
-
// If viaPoint is being relocated overwrite the old viaPoint
|
|
730
|
-
if (viaPoint) {
|
|
731
|
-
return this.addViaPoint(coord, viaPoint.get('viaPointIdx'), 1);
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
// In case there is no route overwrite first coordinate
|
|
735
|
-
if (!oldRoute) {
|
|
736
|
-
return this.addViaPoint(coord, 0, 1);
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
// We can't add a via point because we haven't found which segment has been modified.
|
|
740
|
-
if (segmentIndex === -1) {
|
|
741
|
-
return Promise.reject(new Error('No segment found'));
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
// Insert new viaPoint at the modified segment index + 1
|
|
745
|
-
return this.addViaPoint(coord, (segmentIndex || 0) + 1);
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
/**
|
|
749
|
-
* Define a default element.
|
|
750
|
-
*
|
|
751
|
-
* @private
|
|
752
|
-
*/
|
|
753
|
-
createDefaultElement() {
|
|
754
|
-
/** @private */
|
|
755
|
-
this.element = document.createElement('button');
|
|
756
|
-
this.element.id = 'ol-toggle-routing';
|
|
757
|
-
this.element.innerHTML = 'Toggle Route Control';
|
|
758
|
-
this.element.onclick = () =>
|
|
759
|
-
this.active ? this.deactivate() : this.activate();
|
|
760
|
-
Object.assign(this.element.style, {
|
|
761
|
-
position: 'absolute',
|
|
762
|
-
right: '10px',
|
|
763
|
-
top: '10px',
|
|
764
|
-
});
|
|
765
|
-
}
|
|
766
|
-
|
|
767
|
-
/**
|
|
768
|
-
* Create the interaction used to modify vertexes of features.
|
|
769
|
-
* @private
|
|
770
|
-
*/
|
|
771
|
-
createModifyInteraction() {
|
|
772
|
-
/**
|
|
773
|
-
* @type {ol.interaction.Modify}
|
|
774
|
-
* @private
|
|
775
|
-
*/
|
|
776
|
-
// Define and add modify interaction
|
|
777
|
-
this.modifyInteraction = new Modify({
|
|
778
|
-
source: this.routingLayer?.olLayer?.getSource() || undefined,
|
|
779
|
-
pixelTolerance: 4,
|
|
780
|
-
hitDetection: this.routingLayer?.olLayer,
|
|
781
|
-
deleteCondition: (e) => {
|
|
782
|
-
const feats = e.target.getFeaturesAtPixel(e.pixel, {
|
|
783
|
-
hitTolerance: 5,
|
|
784
|
-
}) as Feature<Geometry>[];
|
|
785
|
-
const viaPoint = feats.find(
|
|
786
|
-
(feat) =>
|
|
787
|
-
feat.getGeometry()?.getType() === 'Point' && feat.get('index'),
|
|
788
|
-
);
|
|
789
|
-
if (click(e) && viaPoint) {
|
|
790
|
-
// Remove node & viaPoint if an existing viaPoint was clicked
|
|
791
|
-
this.removeViaPoint(viaPoint.get('index'));
|
|
792
|
-
return true;
|
|
793
|
-
}
|
|
794
|
-
return false;
|
|
795
|
-
},
|
|
796
|
-
});
|
|
797
|
-
this.modifyInteraction.on('modifystart', this.onModifyStart);
|
|
798
|
-
this.modifyInteraction.on('modifyend', this.onModifyEnd);
|
|
799
|
-
this.modifyInteraction.setActive(false);
|
|
800
|
-
}
|
|
801
|
-
|
|
802
|
-
/**
|
|
803
|
-
* Add click listener to map.
|
|
804
|
-
* @private
|
|
805
|
-
*/
|
|
806
|
-
addListeners() {
|
|
807
|
-
if (!this.modify) {
|
|
808
|
-
return;
|
|
809
|
-
}
|
|
810
|
-
this.removeListeners();
|
|
811
|
-
/** @private */
|
|
812
|
-
this.onMapClickKey = this.map?.on('singleclick', this.onMapClick);
|
|
813
|
-
}
|
|
814
|
-
|
|
815
|
-
/**
|
|
816
|
-
* Remove click listener from map.
|
|
817
|
-
* @private
|
|
818
|
-
*/
|
|
819
|
-
removeListeners() {
|
|
820
|
-
if (this.onMapClickKey) {
|
|
821
|
-
unByKey(this.onMapClickKey);
|
|
822
|
-
}
|
|
823
|
-
}
|
|
824
|
-
|
|
825
|
-
activate() {
|
|
826
|
-
super.activate();
|
|
827
|
-
if (this.map) {
|
|
828
|
-
/** @private */
|
|
829
|
-
this.format = new GeoJSON({
|
|
830
|
-
featureProjection: this.map.getView().getProjection(),
|
|
831
|
-
});
|
|
832
|
-
|
|
833
|
-
/** @private */
|
|
834
|
-
this.graphsResolutions = RoutingControl.getGraphsResolutions(
|
|
835
|
-
this.graphs,
|
|
836
|
-
this.map,
|
|
837
|
-
);
|
|
838
|
-
|
|
839
|
-
// Clean the modifyInteraction if present
|
|
840
|
-
if (this.modifyInteraction) {
|
|
841
|
-
this.map.removeInteraction(this.modifyInteraction);
|
|
842
|
-
}
|
|
843
|
-
|
|
844
|
-
// Add modify interaction, RoutingLayer and listeners
|
|
845
|
-
this.routingLayer?.attachToMap(this.map);
|
|
846
|
-
if (this.modifyInteraction) {
|
|
847
|
-
this.map.addInteraction(this.modifyInteraction);
|
|
848
|
-
}
|
|
849
|
-
this.modifyInteraction?.setActive(this.modify);
|
|
850
|
-
this.addListeners();
|
|
851
|
-
}
|
|
852
|
-
}
|
|
853
|
-
|
|
854
|
-
deactivate() {
|
|
855
|
-
if (this.map) {
|
|
856
|
-
// Remove modify interaction, RoutingLayer, listeners and viaPoints
|
|
857
|
-
this.routingLayer?.detachFromMap();
|
|
858
|
-
if (this.modifyInteraction) {
|
|
859
|
-
this.map.removeInteraction(this.modifyInteraction);
|
|
860
|
-
}
|
|
861
|
-
this.removeListeners();
|
|
862
|
-
this.reset();
|
|
863
|
-
}
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
render() {}
|
|
867
|
-
}
|
|
868
|
-
|
|
869
|
-
export default RoutingControl;
|