mobility-toolbox-js 2.3.10 → 2.3.11
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 +64817 -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 +128 -0
- package/ol/layers/MapboxStyleLayer.d.ts.map +1 -0
- package/ol/layers/MapboxStyleLayer.js +362 -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,84 +0,0 @@
|
|
|
1
|
-
import fetch from 'jest-fetch-mock';
|
|
2
|
-
import Map from 'ol/Map';
|
|
3
|
-
import View from 'ol/View';
|
|
4
|
-
import WS from 'jest-websocket-mock';
|
|
5
|
-
import RealtimeLayer from './RealtimeLayer';
|
|
6
|
-
|
|
7
|
-
// create a WS instance, listening on port 1234 on localhost
|
|
8
|
-
let layer;
|
|
9
|
-
let onClick;
|
|
10
|
-
let olMap;
|
|
11
|
-
let server;
|
|
12
|
-
|
|
13
|
-
describe('RealtimeLayer', () => {
|
|
14
|
-
beforeEach(() => {
|
|
15
|
-
server = new WS('ws://localhost:1234');
|
|
16
|
-
global.fetch = fetch;
|
|
17
|
-
fetch.resetMocks();
|
|
18
|
-
|
|
19
|
-
onClick = jest.fn();
|
|
20
|
-
layer = new RealtimeLayer({
|
|
21
|
-
url: 'ws://localhost:1234',
|
|
22
|
-
apiKey: 'apiKey',
|
|
23
|
-
onClick,
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
olMap = new Map({
|
|
27
|
-
view: new View({
|
|
28
|
-
center: [831634, 5933959],
|
|
29
|
-
zoom: 9,
|
|
30
|
-
}),
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
afterEach(() => {
|
|
35
|
-
// ...or gracefully close the connection
|
|
36
|
-
server.close();
|
|
37
|
-
|
|
38
|
-
// The WS class also has a static "clean" method to gracefully close all open connections,
|
|
39
|
-
// particularly useful to reset the environment between test runs.
|
|
40
|
-
WS.clean();
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
test('should be instanced.', () => {
|
|
44
|
-
expect(layer).toBeInstanceOf(RealtimeLayer);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
test('should called terminate on initalization.', () => {
|
|
48
|
-
const spy = jest.spyOn(layer, 'detachFromMap');
|
|
49
|
-
|
|
50
|
-
fetch.mockResponseOnce(JSON.stringify(global.fetchTrajectoriesResponse));
|
|
51
|
-
|
|
52
|
-
layer.attachToMap(olMap);
|
|
53
|
-
expect(spy).toHaveBeenCalledTimes(1);
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
test('should clone', () => {
|
|
57
|
-
const clone = layer.clone({ name: 'clone' });
|
|
58
|
-
expect(clone).not.toBe(layer);
|
|
59
|
-
expect(clone.name).toBe('clone');
|
|
60
|
-
expect(clone).toBeInstanceOf(RealtimeLayer);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
test('should use the sort function.', () => {
|
|
64
|
-
const fn = () => true;
|
|
65
|
-
const laye = new RealtimeLayer({
|
|
66
|
-
url: 'ws://localhost:1234',
|
|
67
|
-
apiKey: 'apiKey',
|
|
68
|
-
sort: fn,
|
|
69
|
-
});
|
|
70
|
-
expect(laye).toBeInstanceOf(RealtimeLayer);
|
|
71
|
-
expect(laye.sort).toBe(fn);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
test('should use filter function.', () => {
|
|
75
|
-
const fn = () => true;
|
|
76
|
-
const laye = new RealtimeLayer({
|
|
77
|
-
url: 'ws://localhost:1234',
|
|
78
|
-
apiKey: 'apiKey',
|
|
79
|
-
filter: fn, // reverse the array
|
|
80
|
-
});
|
|
81
|
-
expect(laye).toBeInstanceOf(RealtimeLayer);
|
|
82
|
-
expect(laye.filter).toBe(fn);
|
|
83
|
-
});
|
|
84
|
-
});
|
|
@@ -1,465 +0,0 @@
|
|
|
1
|
-
import GeoJSON from 'ol/format/GeoJSON';
|
|
2
|
-
import { Layer as OLLayer, Group, Vector as VectorLayer } from 'ol/layer';
|
|
3
|
-
import Source from 'ol/source/Source';
|
|
4
|
-
import { composeCssTransform } from 'ol/transform';
|
|
5
|
-
import { Vector as VectorSource } from 'ol/source';
|
|
6
|
-
import Feature, { FeatureLike } from 'ol/Feature';
|
|
7
|
-
import { MapEvent } from 'ol';
|
|
8
|
-
import { Coordinate } from 'ol/coordinate';
|
|
9
|
-
import { ObjectEvent } from 'ol/Object';
|
|
10
|
-
import debounce from 'lodash.debounce';
|
|
11
|
-
import Layer from './Layer';
|
|
12
|
-
import mixin, {
|
|
13
|
-
RealtimeLayerMixinOptions,
|
|
14
|
-
} from '../../common/mixins/RealtimeLayerMixin';
|
|
15
|
-
import { fullTrajectoryStyle } from '../styles';
|
|
16
|
-
import {
|
|
17
|
-
AnyMap,
|
|
18
|
-
LayerGetFeatureInfoResponse,
|
|
19
|
-
RealtimeFullTrajectory,
|
|
20
|
-
RealtimeTrainId,
|
|
21
|
-
ViewState,
|
|
22
|
-
} from '../../types';
|
|
23
|
-
import { RealtimeTrajectory } from '../../api/typedefs';
|
|
24
|
-
import { WebSocketAPIMessageEventData } from '../../common/api/WebSocketAPI';
|
|
25
|
-
|
|
26
|
-
/** @private */
|
|
27
|
-
const format = new GeoJSON();
|
|
28
|
-
|
|
29
|
-
export type OlRealtimeLayerOptions = RealtimeLayerMixinOptions & {
|
|
30
|
-
fullTrajectoryStyle?: (
|
|
31
|
-
feature: FeatureLike,
|
|
32
|
-
resolution: number,
|
|
33
|
-
options: any,
|
|
34
|
-
) => void;
|
|
35
|
-
allowRenderWhenAnimating?: boolean;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Responsible for loading and display data from a Realtime service.
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* import { RealtimeLayer } from 'mobility-toolbox-js/ol';
|
|
43
|
-
*
|
|
44
|
-
* const layer = new RealtimeLayer({
|
|
45
|
-
* url: [yourUrl],
|
|
46
|
-
* apiKey: [yourApiKey],
|
|
47
|
-
* });
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* @see <a href="/api/class/src/api/RealtimeAPI%20js~RealtimeAPI%20html">RealtimeAPI</a>
|
|
51
|
-
*
|
|
52
|
-
* @extends {Layer}
|
|
53
|
-
* @implements {UserInteractionsLayerInterface}
|
|
54
|
-
* @implements {RealtimeLayerInterface}
|
|
55
|
-
*/
|
|
56
|
-
// @ts-ignore
|
|
57
|
-
class RealtimeLayer extends mixin(Layer) {
|
|
58
|
-
allowRenderWhenAnimating?: boolean = false;
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Constructor.
|
|
62
|
-
*
|
|
63
|
-
* @param {Object} options
|
|
64
|
-
* @private
|
|
65
|
-
*/
|
|
66
|
-
constructor(options: OlRealtimeLayerOptions) {
|
|
67
|
-
// We use a group to be able to add custom vector layer in extended class.
|
|
68
|
-
// For example TrajservLayer use a vectorLayer to display the complete trajectory.
|
|
69
|
-
super({
|
|
70
|
-
...options,
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
this.allowRenderWhenAnimating = !!options.allowRenderWhenAnimating;
|
|
74
|
-
|
|
75
|
-
/** @private */
|
|
76
|
-
this.olLayer =
|
|
77
|
-
options.olLayer ||
|
|
78
|
-
new Group({
|
|
79
|
-
layers: [
|
|
80
|
-
new VectorLayer({
|
|
81
|
-
updateWhileAnimating: true,
|
|
82
|
-
updateWhileInteracting: true,
|
|
83
|
-
source: new VectorSource({ features: [] }),
|
|
84
|
-
style: (feature, resolution) => {
|
|
85
|
-
return (options.fullTrajectoryStyle || fullTrajectoryStyle)(
|
|
86
|
-
feature,
|
|
87
|
-
resolution,
|
|
88
|
-
this.styleOptions,
|
|
89
|
-
);
|
|
90
|
-
},
|
|
91
|
-
}),
|
|
92
|
-
new OLLayer({
|
|
93
|
-
source: new Source({}),
|
|
94
|
-
render: (frameState) => {
|
|
95
|
-
if (!this.container) {
|
|
96
|
-
this.container = document.createElement('div');
|
|
97
|
-
this.container.style.position = 'absolute';
|
|
98
|
-
this.container.style.width = '100%';
|
|
99
|
-
this.container.style.height = '100%';
|
|
100
|
-
this.transformContainer = document.createElement('div');
|
|
101
|
-
this.transformContainer.style.position = 'absolute';
|
|
102
|
-
this.transformContainer.style.width = '100%';
|
|
103
|
-
this.transformContainer.style.height = '100%';
|
|
104
|
-
this.container.appendChild(this.transformContainer);
|
|
105
|
-
if (this.canvas) {
|
|
106
|
-
(this.canvas as HTMLCanvasElement).style.position =
|
|
107
|
-
'absolute';
|
|
108
|
-
(this.canvas as HTMLCanvasElement).style.top = '0';
|
|
109
|
-
(this.canvas as HTMLCanvasElement).style.left = '0';
|
|
110
|
-
(this.canvas as HTMLCanvasElement).style.transformOrigin =
|
|
111
|
-
'top left';
|
|
112
|
-
this.transformContainer.appendChild(this.canvas);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
if (this.renderedViewState) {
|
|
117
|
-
const { center, resolution, rotation } = frameState.viewState;
|
|
118
|
-
const {
|
|
119
|
-
center: renderedCenter,
|
|
120
|
-
resolution: renderedResolution,
|
|
121
|
-
rotation: renderedRotation,
|
|
122
|
-
} = this.renderedViewState;
|
|
123
|
-
|
|
124
|
-
if (renderedResolution / resolution >= 3) {
|
|
125
|
-
// Avoid having really big points when zooming fast.
|
|
126
|
-
const context = this.canvas?.getContext('2d');
|
|
127
|
-
context?.clearRect(
|
|
128
|
-
0,
|
|
129
|
-
0,
|
|
130
|
-
this.canvas?.width as number,
|
|
131
|
-
this.canvas?.height as number,
|
|
132
|
-
);
|
|
133
|
-
} else {
|
|
134
|
-
const pixelCenterRendered =
|
|
135
|
-
this.map.getPixelFromCoordinate(renderedCenter);
|
|
136
|
-
const pixelCenter = this.map.getPixelFromCoordinate(center);
|
|
137
|
-
this.transformContainer.style.transform = composeCssTransform(
|
|
138
|
-
pixelCenterRendered[0] - pixelCenter[0],
|
|
139
|
-
pixelCenterRendered[1] - pixelCenter[1],
|
|
140
|
-
renderedResolution / resolution,
|
|
141
|
-
renderedResolution / resolution,
|
|
142
|
-
rotation - renderedRotation,
|
|
143
|
-
0,
|
|
144
|
-
0,
|
|
145
|
-
);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
return this.container;
|
|
149
|
-
},
|
|
150
|
-
}),
|
|
151
|
-
],
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
// We store the layer used to highlight the full Trajectory
|
|
155
|
-
this.vectorLayer = this.olLayer.getLayers().item(0);
|
|
156
|
-
|
|
157
|
-
// Options the last render run did happen. If something changes
|
|
158
|
-
// we have to render again
|
|
159
|
-
/** @private */
|
|
160
|
-
this.renderState = {
|
|
161
|
-
center: [0, 0],
|
|
162
|
-
zoom: undefined,
|
|
163
|
-
rotation: 0,
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
this.onZoomEndDebounced = debounce(this.onZoomEnd, 100);
|
|
167
|
-
this.onMoveEndDebounced = debounce(this.onMoveEnd, 100);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
attachToMap(map: AnyMap) {
|
|
171
|
-
super.attachToMap(map);
|
|
172
|
-
if (this.map) {
|
|
173
|
-
this.olListenersKeys.push(
|
|
174
|
-
...this.map.on(
|
|
175
|
-
['moveend', 'change:target'],
|
|
176
|
-
(evt: MapEvent | ObjectEvent) => {
|
|
177
|
-
const view = (
|
|
178
|
-
(evt as MapEvent).map || (evt as ObjectEvent).target
|
|
179
|
-
).getView();
|
|
180
|
-
if (view.getAnimating() || view.getInteracting()) {
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
const zoom = view.getZoom();
|
|
184
|
-
|
|
185
|
-
// Update the interval between render updates
|
|
186
|
-
if (this.currentZoom !== zoom) {
|
|
187
|
-
this.onZoomEndDebounced(evt);
|
|
188
|
-
}
|
|
189
|
-
this.currentZoom = zoom;
|
|
190
|
-
|
|
191
|
-
this.onMoveEndDebounced(evt);
|
|
192
|
-
},
|
|
193
|
-
),
|
|
194
|
-
);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* Destroy the container of the tracker.
|
|
200
|
-
*/
|
|
201
|
-
detachFromMap() {
|
|
202
|
-
super.detachFromMap();
|
|
203
|
-
this.container = null;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Detect in the canvas if there is data to query at a specific coordinate.
|
|
208
|
-
* @param {ol/coordinate~Coordinate} coordinate The coordinate to test
|
|
209
|
-
* @returns
|
|
210
|
-
*/
|
|
211
|
-
hasFeatureInfoAtCoordinate(coordinate: Coordinate) {
|
|
212
|
-
if (this.map && this.canvas) {
|
|
213
|
-
const context = this.canvas.getContext('2d', {
|
|
214
|
-
willReadFrequently: true,
|
|
215
|
-
});
|
|
216
|
-
const pixel = this.map.getPixelFromCoordinate(coordinate);
|
|
217
|
-
return !!context?.getImageData(
|
|
218
|
-
pixel[0] * (this.pixelRatio || 1),
|
|
219
|
-
pixel[1] * (this.pixelRatio || 1),
|
|
220
|
-
1,
|
|
221
|
-
1,
|
|
222
|
-
).data[3];
|
|
223
|
-
}
|
|
224
|
-
return false;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* Render the trajectories using current map's size, resolution and rotation.
|
|
229
|
-
* @param {boolean} noInterpolate if true, renders the vehicles without interpolating theirs positions.
|
|
230
|
-
* @overrides
|
|
231
|
-
*/
|
|
232
|
-
// @ts-ignore
|
|
233
|
-
renderTrajectories(noInterpolate: boolean) {
|
|
234
|
-
if (!this.map) {
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
const view = this.map.getView();
|
|
239
|
-
|
|
240
|
-
// it could happen that the view is set but without center yet,
|
|
241
|
-
// so the calcualteExtent will trigger an error.
|
|
242
|
-
if (!view.getCenter()) {
|
|
243
|
-
return;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
super.renderTrajectories(
|
|
247
|
-
{
|
|
248
|
-
size: this.map.getSize(),
|
|
249
|
-
center: view.getCenter(),
|
|
250
|
-
extent: view.calculateExtent(),
|
|
251
|
-
resolution: view.getResolution(),
|
|
252
|
-
rotation: view.getRotation(),
|
|
253
|
-
zoom: view.getZoom(),
|
|
254
|
-
pixelRatio: this.pixelRatio,
|
|
255
|
-
},
|
|
256
|
-
noInterpolate,
|
|
257
|
-
);
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* Launch renderTrajectories. it avoids duplicating code in renderTrajectories methhod.
|
|
262
|
-
* @private
|
|
263
|
-
* @override
|
|
264
|
-
*/
|
|
265
|
-
renderTrajectoriesInternal(viewState: ViewState, noInterpolate: boolean) {
|
|
266
|
-
if (!this.map) {
|
|
267
|
-
return false;
|
|
268
|
-
}
|
|
269
|
-
let isRendered = false;
|
|
270
|
-
|
|
271
|
-
const blockRendering = this.allowRenderWhenAnimating
|
|
272
|
-
? false
|
|
273
|
-
: this.map.getView().getAnimating() ||
|
|
274
|
-
this.map.getView().getInteracting();
|
|
275
|
-
|
|
276
|
-
// Don't render the map when the map is animating or interacting.
|
|
277
|
-
isRendered = blockRendering
|
|
278
|
-
? false
|
|
279
|
-
: super.renderTrajectoriesInternal(viewState, noInterpolate);
|
|
280
|
-
|
|
281
|
-
// We update the current render state.
|
|
282
|
-
if (isRendered) {
|
|
283
|
-
this.renderedViewState = { ...viewState };
|
|
284
|
-
|
|
285
|
-
if (this.transformContainer) {
|
|
286
|
-
this.transformContainer.style.transform = '';
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
return isRendered;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
/**
|
|
293
|
-
* Return the delay in ms before the next rendering.
|
|
294
|
-
*/
|
|
295
|
-
getRefreshTimeInMs() {
|
|
296
|
-
return super.getRefreshTimeInMs(this.map.getView().getZoom());
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
getFeatureInfoAtCoordinate(
|
|
300
|
-
coordinate: Coordinate,
|
|
301
|
-
options = {},
|
|
302
|
-
): Promise<LayerGetFeatureInfoResponse> {
|
|
303
|
-
if (!this.map || !this.map.getView()) {
|
|
304
|
-
return Promise.resolve({
|
|
305
|
-
layer: this,
|
|
306
|
-
features: [],
|
|
307
|
-
coordinate,
|
|
308
|
-
});
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
const resolution = this.map.getView().getResolution();
|
|
312
|
-
return super.getFeatureInfoAtCoordinate(coordinate, {
|
|
313
|
-
resolution,
|
|
314
|
-
...options,
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
* On move end we update the websocket with the new bbox.
|
|
320
|
-
*
|
|
321
|
-
* @private
|
|
322
|
-
* @override
|
|
323
|
-
*/
|
|
324
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
325
|
-
onMoveEnd(evt: MapEvent | ObjectEvent) {
|
|
326
|
-
if (!this.isUpdateBboxOnMoveEnd || !this.visible) {
|
|
327
|
-
return;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
this.setBbox();
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
/**
|
|
334
|
-
* Function called on moveend event only when the zoom has changed.
|
|
335
|
-
*
|
|
336
|
-
* @param {ol/MapEvent~MapEvent} evt Moveend event.
|
|
337
|
-
* @private
|
|
338
|
-
* @override
|
|
339
|
-
*/
|
|
340
|
-
// eslint-disable-next-line no-unused-vars
|
|
341
|
-
onZoomEnd() {
|
|
342
|
-
super.onZoomEnd();
|
|
343
|
-
|
|
344
|
-
if (!this.isUpdateBboxOnMoveEnd || !this.visible) {
|
|
345
|
-
return;
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
if (this.userClickInteractions && this.selectedVehicleId) {
|
|
349
|
-
this.highlightTrajectory(this.selectedVehicleId);
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
/**
|
|
354
|
-
* Update the cursor style when hovering a vehicle.
|
|
355
|
-
*
|
|
356
|
-
* @private
|
|
357
|
-
* @override
|
|
358
|
-
*/
|
|
359
|
-
onFeatureHover(
|
|
360
|
-
features: Feature[],
|
|
361
|
-
layer: RealtimeLayer,
|
|
362
|
-
coordinate: Coordinate,
|
|
363
|
-
) {
|
|
364
|
-
super.onFeatureHover(features, layer, coordinate);
|
|
365
|
-
this.map.getTargetElement().style.cursor = features.length
|
|
366
|
-
? 'pointer'
|
|
367
|
-
: 'auto';
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
/**
|
|
371
|
-
* Display the complete trajectory of the vehicle.
|
|
372
|
-
*
|
|
373
|
-
* @private
|
|
374
|
-
* @override
|
|
375
|
-
*/
|
|
376
|
-
onFeatureClick(
|
|
377
|
-
features: Feature[],
|
|
378
|
-
layer: RealtimeLayer,
|
|
379
|
-
coordinate: Coordinate,
|
|
380
|
-
) {
|
|
381
|
-
super.onFeatureClick(features, layer, coordinate);
|
|
382
|
-
if (!features.length && this.vectorLayer) {
|
|
383
|
-
this.vectorLayer.getSource().clear();
|
|
384
|
-
}
|
|
385
|
-
if (this.selectedVehicleId) {
|
|
386
|
-
this.highlightTrajectory(this.selectedVehicleId);
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
/**
|
|
391
|
-
* Remove the trajectory form the list if necessary.
|
|
392
|
-
*
|
|
393
|
-
* @private
|
|
394
|
-
*/
|
|
395
|
-
purgeTrajectory(
|
|
396
|
-
trajectory: RealtimeTrajectory,
|
|
397
|
-
extent: [number, number, number, number],
|
|
398
|
-
zoom: number,
|
|
399
|
-
) {
|
|
400
|
-
const center = this.map.getView().getCenter();
|
|
401
|
-
if (!extent && !center) {
|
|
402
|
-
// In that case the view is not zoomed yet so we can't calculate the extent of the map,
|
|
403
|
-
// it will trigger a js error on calculateExtent function.
|
|
404
|
-
return false;
|
|
405
|
-
}
|
|
406
|
-
return super.purgeTrajectory(
|
|
407
|
-
trajectory,
|
|
408
|
-
extent || this.map.getView().calculateExtent(),
|
|
409
|
-
zoom || this.map.getView().getZoom(),
|
|
410
|
-
);
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
/**
|
|
414
|
-
* Send the current bbox to the websocket
|
|
415
|
-
*
|
|
416
|
-
* @private
|
|
417
|
-
*/
|
|
418
|
-
setBbox(extent?: [number, number, number, number], zoom?: number) {
|
|
419
|
-
super.setBbox(
|
|
420
|
-
extent || this.map.getView().calculateExtent(),
|
|
421
|
-
zoom || this.map.getView().getZoom(),
|
|
422
|
-
);
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
/**
|
|
426
|
-
* Highlight the trajectory of journey.
|
|
427
|
-
* @private
|
|
428
|
-
*/
|
|
429
|
-
highlightTrajectory(id: RealtimeTrainId): Promise<Feature[] | undefined> {
|
|
430
|
-
return this.api
|
|
431
|
-
.getFullTrajectory(
|
|
432
|
-
id,
|
|
433
|
-
this.mode,
|
|
434
|
-
this.getGeneralizationLevelByZoom(
|
|
435
|
-
Math.floor(this.map?.getView()?.getZoom() || 0),
|
|
436
|
-
),
|
|
437
|
-
)
|
|
438
|
-
.then((data: WebSocketAPIMessageEventData<RealtimeFullTrajectory>) => {
|
|
439
|
-
const fullTrajectory = data.content;
|
|
440
|
-
this.vectorLayer.getSource().clear();
|
|
441
|
-
|
|
442
|
-
if (
|
|
443
|
-
!fullTrajectory ||
|
|
444
|
-
!fullTrajectory.features ||
|
|
445
|
-
!fullTrajectory.features.length
|
|
446
|
-
) {
|
|
447
|
-
return undefined;
|
|
448
|
-
}
|
|
449
|
-
const features = format.readFeatures(fullTrajectory);
|
|
450
|
-
this.vectorLayer.getSource().addFeatures(features);
|
|
451
|
-
return features as Feature[];
|
|
452
|
-
});
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
/**
|
|
456
|
-
* Create a copy of the RealtimeLayer.
|
|
457
|
-
* @param {Object} newOptions Options to override
|
|
458
|
-
* @return {RealtimeLayer} A RealtimeLayer
|
|
459
|
-
*/
|
|
460
|
-
clone(newOptions: OlRealtimeLayerOptions) {
|
|
461
|
-
return new RealtimeLayer({ ...this.options, ...newOptions });
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
export default RealtimeLayer;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import fetch from 'jest-fetch-mock';
|
|
2
|
-
import Map from 'ol/Map';
|
|
3
|
-
import View from 'ol/View';
|
|
4
|
-
import RoutingLayer from './RoutingLayer';
|
|
5
|
-
|
|
6
|
-
let layer;
|
|
7
|
-
let onClick;
|
|
8
|
-
let olMap;
|
|
9
|
-
|
|
10
|
-
describe('RoutingLayer', () => {
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
global.fetch = fetch;
|
|
13
|
-
fetch.resetMocks();
|
|
14
|
-
|
|
15
|
-
onClick = jest.fn();
|
|
16
|
-
layer = new RoutingLayer({
|
|
17
|
-
onClick,
|
|
18
|
-
apiKey: 'apiKey',
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
olMap = new Map({
|
|
22
|
-
view: new View({
|
|
23
|
-
center: [831634, 5933959],
|
|
24
|
-
zoom: 9,
|
|
25
|
-
}),
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
test('should be instanced.', () => {
|
|
30
|
-
expect(layer).toBeInstanceOf(RoutingLayer);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
test('should called terminate on initalization.', () => {
|
|
34
|
-
const spy = jest.spyOn(layer, 'detachFromMap');
|
|
35
|
-
|
|
36
|
-
fetch.mockResponseOnce(JSON.stringify(global.fetchTrajectoriesResponse));
|
|
37
|
-
|
|
38
|
-
layer.attachToMap(olMap);
|
|
39
|
-
expect(spy).toHaveBeenCalledTimes(1);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
test('should clone', () => {
|
|
43
|
-
const clone = layer.clone({ name: 'clone' });
|
|
44
|
-
expect(clone).not.toBe(layer);
|
|
45
|
-
expect(clone.name).toBe('clone');
|
|
46
|
-
expect(clone).toBeInstanceOf(RoutingLayer);
|
|
47
|
-
});
|
|
48
|
-
});
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { Circle, Fill, Stroke, Style } from 'ol/style';
|
|
2
|
-
import { Vector as VectorSource } from 'ol/source';
|
|
3
|
-
import { Vector } from 'ol/layer';
|
|
4
|
-
import type { StyleFunction, StyleLike } from 'ol/style/Style';
|
|
5
|
-
import type { FeatureLike } from 'ol/Feature';
|
|
6
|
-
import { Geometry } from 'ol/geom';
|
|
7
|
-
import Feature from 'ol/Feature';
|
|
8
|
-
import Layer from './Layer';
|
|
9
|
-
import type { OlLayerOptions } from './Layer';
|
|
10
|
-
|
|
11
|
-
export type OlRoutingLayerOptions = OlLayerOptions & {
|
|
12
|
-
olLayer?: Vector<VectorSource<Feature<Geometry>>>;
|
|
13
|
-
style?: StyleLike;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
/** @private */
|
|
17
|
-
const circleStyle = new Circle({
|
|
18
|
-
radius: 6,
|
|
19
|
-
fill: new Fill({
|
|
20
|
-
color: [255, 0, 0, 1],
|
|
21
|
-
}),
|
|
22
|
-
stroke: new Stroke({
|
|
23
|
-
color: [0, 0, 0, 1],
|
|
24
|
-
width: 1,
|
|
25
|
-
}),
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
/** @private */
|
|
29
|
-
const blackBorder = new Style({
|
|
30
|
-
stroke: new Stroke({
|
|
31
|
-
color: [0, 0, 0, 1],
|
|
32
|
-
width: 5,
|
|
33
|
-
}),
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
/** @private */
|
|
37
|
-
const redLine = new Style({
|
|
38
|
-
image: circleStyle,
|
|
39
|
-
stroke: new Stroke({
|
|
40
|
-
color: [255, 0, 0, 1],
|
|
41
|
-
width: 3,
|
|
42
|
-
}),
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
/** @private */
|
|
46
|
-
const dashedRedLine = new Style({
|
|
47
|
-
image: circleStyle,
|
|
48
|
-
stroke: new Stroke({
|
|
49
|
-
color: [255, 0, 0, 1],
|
|
50
|
-
width: 3,
|
|
51
|
-
lineDash: [1, 10],
|
|
52
|
-
}),
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
/** @private */
|
|
56
|
-
const defaultStyleFunction: StyleFunction = (
|
|
57
|
-
feature: FeatureLike,
|
|
58
|
-
resolution: number,
|
|
59
|
-
) => {
|
|
60
|
-
const minResolution = feature.get('minResolution');
|
|
61
|
-
const maxResolution = feature.get('maxResolution');
|
|
62
|
-
const inRange = resolution <= minResolution && resolution > maxResolution;
|
|
63
|
-
|
|
64
|
-
if (minResolution && maxResolution && !inRange) {
|
|
65
|
-
return [];
|
|
66
|
-
}
|
|
67
|
-
const mot = feature.get('mot');
|
|
68
|
-
|
|
69
|
-
if (mot !== 'foot') {
|
|
70
|
-
return [blackBorder, redLine];
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return [dashedRedLine];
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* A class use to display vector data.
|
|
78
|
-
*
|
|
79
|
-
* @classproperty {ol/Map~Map} map - The map where the layer is displayed.
|
|
80
|
-
* @extends {Layer}
|
|
81
|
-
*/
|
|
82
|
-
class RoutingLayer extends Layer {
|
|
83
|
-
olLayer?: Vector<VectorSource<Feature<Geometry>>>;
|
|
84
|
-
|
|
85
|
-
options: OlRoutingLayerOptions = {};
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Constructor.
|
|
89
|
-
* @param {Object} [options]
|
|
90
|
-
* @param {ol/style/Style~StyleLike} [options.style] Style to be used for routes, uses (ol/StyleLike) [https://openlayers.org/en/latest/apidoc/module-ol_style_Style.html#~StyleLike] instances
|
|
91
|
-
*/
|
|
92
|
-
constructor(options: OlRoutingLayerOptions) {
|
|
93
|
-
super(options);
|
|
94
|
-
|
|
95
|
-
this.olLayer =
|
|
96
|
-
options.olLayer ||
|
|
97
|
-
new Vector({
|
|
98
|
-
source: new VectorSource(),
|
|
99
|
-
style: options.style || defaultStyleFunction,
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Create a copy of the RoutingLayer.
|
|
105
|
-
* @param {Object} newOptions Options to override
|
|
106
|
-
* @return {RoutingLayer} A RoutingLayer
|
|
107
|
-
*/
|
|
108
|
-
clone(newOptions: OlRoutingLayerOptions) {
|
|
109
|
-
return new RoutingLayer({ ...this.options, ...newOptions });
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export default RoutingLayer;
|