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,100 +0,0 @@
|
|
|
1
|
-
import createRealtimeFilters from './createRealtimeFilters';
|
|
2
|
-
|
|
3
|
-
const u1 = {
|
|
4
|
-
properties: {
|
|
5
|
-
route_identifier: '001.000827.004:7',
|
|
6
|
-
operator: 'FoO',
|
|
7
|
-
line: {
|
|
8
|
-
name: 'U1',
|
|
9
|
-
},
|
|
10
|
-
},
|
|
11
|
-
};
|
|
12
|
-
const ireta = {
|
|
13
|
-
properties: {
|
|
14
|
-
routeIdentifier: '0022.000827.004:7',
|
|
15
|
-
tenant: 'BAR',
|
|
16
|
-
line: {
|
|
17
|
-
name: 'IRETA',
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
const arb = {
|
|
22
|
-
properties: {
|
|
23
|
-
route_identifier: '00333.000827.004:7',
|
|
24
|
-
operator: 'qux',
|
|
25
|
-
line: {
|
|
26
|
-
name: 'ARB',
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const trajectories = [u1, ireta, arb];
|
|
32
|
-
|
|
33
|
-
describe('#createTrackerFilter()', () => {
|
|
34
|
-
test('returns null', () => {
|
|
35
|
-
const filterFunc = createRealtimeFilters();
|
|
36
|
-
expect(filterFunc).toBe(null);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
describe('using line', () => {
|
|
40
|
-
test('as string', () => {
|
|
41
|
-
const filterFunc = createRealtimeFilters('u1,foo');
|
|
42
|
-
expect(trajectories.filter(filterFunc)).toEqual([u1]);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
test('as array of string', () => {
|
|
46
|
-
const filterFunc = createRealtimeFilters(['u1', 'foo', 'IRETA']);
|
|
47
|
-
expect(trajectories.filter(filterFunc)).toEqual([u1, ireta]);
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
describe('using route identifier (snake_case and camelCase (only tralis)', () => {
|
|
52
|
-
test('as string', () => {
|
|
53
|
-
const filterFunc = createRealtimeFilters(null, '1,foo');
|
|
54
|
-
expect(trajectories.filter(filterFunc)).toEqual([u1]);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
test('as array of string', () => {
|
|
58
|
-
const filterFunc = createRealtimeFilters(null, ['22', 'foo', '1']);
|
|
59
|
-
expect(trajectories.filter(filterFunc)).toEqual([u1, ireta]);
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
describe('using operator', () => {
|
|
64
|
-
test('as string (using operator deprecated property)', () => {
|
|
65
|
-
const filterFunc = createRealtimeFilters(null, null, 'foo');
|
|
66
|
-
expect(trajectories.filter(filterFunc)).toEqual([u1]);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
test('as string (using tenant property)', () => {
|
|
70
|
-
const filterFunc = createRealtimeFilters(null, null, 'bar');
|
|
71
|
-
expect(trajectories.filter(filterFunc)).toEqual([ireta]);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
test('as array of string', () => {
|
|
75
|
-
const filterFunc = createRealtimeFilters(null, null, ['bar', 'foo', '1']);
|
|
76
|
-
expect(trajectories.filter(filterFunc)).toEqual([u1, ireta]);
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
describe('using regexLine', () => {
|
|
81
|
-
test('as string', () => {
|
|
82
|
-
const filterFunc = createRealtimeFilters(
|
|
83
|
-
null,
|
|
84
|
-
null,
|
|
85
|
-
null,
|
|
86
|
-
'^(S|R$|RE|PE|D|IRE|RB|TER)',
|
|
87
|
-
);
|
|
88
|
-
expect(trajectories.filter(filterFunc)).toEqual([ireta]);
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
test('as array of string', () => {
|
|
92
|
-
const filterFunc = createRealtimeFilters(null, null, null, [
|
|
93
|
-
'^IR',
|
|
94
|
-
'^ARB$',
|
|
95
|
-
'foo',
|
|
96
|
-
]);
|
|
97
|
-
expect(trajectories.filter(filterFunc)).toEqual([ireta, arb]);
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
});
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { RealtimeTrajectory } from '../../types';
|
|
2
|
-
/**
|
|
3
|
-
* Return a filter functions based on some parameters of a vehicle.
|
|
4
|
-
*
|
|
5
|
-
* @param {string|Array<string>} line - A list of vehicle's name to filter. Names can be separated by a comma. Ex: 'S1,S2,S3'
|
|
6
|
-
* @param {string|Array<string} route - A list of vehicle's route (contained in route_identifier property) to filter. Indentifiers can be separated by a comma. Ex: 'id1,id2,id3'
|
|
7
|
-
* @param {string|Array<string} operator A list of vehicle's operator to filter. Operators can be separated by a comma. Ex: 'SBB,DB'
|
|
8
|
-
* @param {Regexp} regexLine - A regex aplly of vehcile's name.
|
|
9
|
-
* @private
|
|
10
|
-
*/
|
|
11
|
-
const createRealtimeFilters = (
|
|
12
|
-
line: string | string[],
|
|
13
|
-
route: string | string[],
|
|
14
|
-
operator: string | string[],
|
|
15
|
-
regexLine: string | string[],
|
|
16
|
-
): ((trajectory: RealtimeTrajectory) => boolean) | null => {
|
|
17
|
-
const filterList: ((trajectory: RealtimeTrajectory) => boolean)[] = [];
|
|
18
|
-
|
|
19
|
-
if (!line && !route && !operator && !regexLine) {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (regexLine) {
|
|
24
|
-
const regexLineList: string[] =
|
|
25
|
-
typeof regexLine === 'string' ? [regexLine] : regexLine;
|
|
26
|
-
const lineFilter = (item: RealtimeTrajectory) => {
|
|
27
|
-
const name =
|
|
28
|
-
item.properties.name ||
|
|
29
|
-
(item.properties.line && item.properties.line.name) ||
|
|
30
|
-
'';
|
|
31
|
-
if (!name) {
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
return regexLineList.some((regexStr) =>
|
|
35
|
-
new RegExp(regexStr, 'i').test(name),
|
|
36
|
-
);
|
|
37
|
-
};
|
|
38
|
-
filterList.push(lineFilter);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (line) {
|
|
42
|
-
const lineFiltersList = typeof line === 'string' ? line.split(',') : line;
|
|
43
|
-
const lineList = lineFiltersList.map((l) =>
|
|
44
|
-
l.replace(/\s+/g, '').toUpperCase(),
|
|
45
|
-
);
|
|
46
|
-
const lineFilter = (item: RealtimeTrajectory) => {
|
|
47
|
-
const { line: linee, name } = item.properties;
|
|
48
|
-
const lineName = (name || (linee && linee.name) || '').toUpperCase();
|
|
49
|
-
if (!lineName) {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
return lineList.includes(lineName);
|
|
53
|
-
};
|
|
54
|
-
filterList.push(lineFilter);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (route) {
|
|
58
|
-
const routes = typeof route === 'string' ? route.split(',') : route;
|
|
59
|
-
const routeList = routes.map((item) => parseInt(item, 10));
|
|
60
|
-
const routeFilter = (item: RealtimeTrajectory) => {
|
|
61
|
-
const routeIdentifier =
|
|
62
|
-
item.properties.route_identifier ||
|
|
63
|
-
item.properties.routeIdentifier ||
|
|
64
|
-
'';
|
|
65
|
-
const routeId = parseInt(routeIdentifier.split('.')[0], 10);
|
|
66
|
-
return routeList.includes(routeId);
|
|
67
|
-
};
|
|
68
|
-
filterList.push(routeFilter);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (operator) {
|
|
72
|
-
const operatorList = typeof operator === 'string' ? [operator] : operator;
|
|
73
|
-
const operatorFilter = (item: RealtimeTrajectory) =>
|
|
74
|
-
operatorList.some((op) => {
|
|
75
|
-
// operaotr is the old property tenant is the new one
|
|
76
|
-
const tenant = item.properties.operator || item.properties.tenant || '';
|
|
77
|
-
return new RegExp(op, 'i').test(tenant);
|
|
78
|
-
});
|
|
79
|
-
filterList.push(operatorFilter);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (!filterList.length) {
|
|
83
|
-
return null;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return (item: RealtimeTrajectory) => {
|
|
87
|
-
for (let i = 0; i < filterList.length; i += 1) {
|
|
88
|
-
if (!filterList[i](item)) {
|
|
89
|
-
return false;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return true;
|
|
93
|
-
};
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
export default createRealtimeFilters;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { RealtimeAPIDeparturesById } from '../../api/RealtimeAPI';
|
|
2
|
-
import type { RealtimeDeparture, RealtimeDepartureExtended } from '../../types';
|
|
3
|
-
import type {
|
|
4
|
-
WebSocketAPIMessageCallback,
|
|
5
|
-
WebSocketAPIMessageEventData,
|
|
6
|
-
} from '../api/WebSocketAPI';
|
|
7
|
-
import sortAndFilterDepartures from './sortAndFilterDepartures';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* This function returns a WebSocket api callback, and call the onDeparturesUpdate function with the list of current departures to display.
|
|
11
|
-
* @param {function(departures: RealtimeDeparture[])} onDeparturesUpdate callback when list of departures changes, called after 100 ms
|
|
12
|
-
* @param {boolean} [sortByMinArrivalTime = true] Sort departures by arrival time
|
|
13
|
-
* @param {number} [maxDepartureAge = 30] max departure age of departures in minutes
|
|
14
|
-
* @param {number} [timeout = 100] debounce timeout in ms
|
|
15
|
-
* @private
|
|
16
|
-
*/
|
|
17
|
-
const debounceDeparturesMessages = (
|
|
18
|
-
onDeparturesUpdate: (departures: RealtimeDepartureExtended[]) => {},
|
|
19
|
-
sortByMinArrivalTime = false,
|
|
20
|
-
maxDepartureAge = 30,
|
|
21
|
-
timeout = 100,
|
|
22
|
-
): WebSocketAPIMessageCallback<RealtimeDeparture> => {
|
|
23
|
-
const departureUpdateTimeout: {
|
|
24
|
-
[key: string]: number;
|
|
25
|
-
} = {};
|
|
26
|
-
|
|
27
|
-
const departureObject: RealtimeAPIDeparturesById = {};
|
|
28
|
-
|
|
29
|
-
return (data: WebSocketAPIMessageEventData<RealtimeDeparture>) => {
|
|
30
|
-
const { source, content: departure } = data;
|
|
31
|
-
if (departureUpdateTimeout[source]) {
|
|
32
|
-
window.clearTimeout(departureUpdateTimeout[source]);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (!departure) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
departureObject[departure.call_id] = departure;
|
|
40
|
-
|
|
41
|
-
departureUpdateTimeout[source] = window.setTimeout(() => {
|
|
42
|
-
const departures = sortAndFilterDepartures(
|
|
43
|
-
departureObject,
|
|
44
|
-
sortByMinArrivalTime || false,
|
|
45
|
-
maxDepartureAge,
|
|
46
|
-
);
|
|
47
|
-
onDeparturesUpdate(departures);
|
|
48
|
-
}, timeout);
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export default debounceDeparturesMessages;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
WebSocketAPIMessageCallback,
|
|
3
|
-
WebSocketAPIMessageEventData,
|
|
4
|
-
} from '../api/WebSocketAPI';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* This function returns a WebSocket api callback, and call the onUpdate function with the list of of subscribed objects changes.
|
|
8
|
-
*
|
|
9
|
-
* @param {function(objects: any[])} onUpdate callback when list of subscribed objects changes, called after 100 ms
|
|
10
|
-
* @param {function(object: any)} [getObjectId = true] function returning the id of an object
|
|
11
|
-
* @param {number} [timeout = 100] debounce timeout in ms
|
|
12
|
-
* @private
|
|
13
|
-
*/
|
|
14
|
-
const debounceWebsocketMessages = (
|
|
15
|
-
onUpdate: (objects: any[]) => void,
|
|
16
|
-
getObjectId?: (object: any) => string,
|
|
17
|
-
timeout = 100,
|
|
18
|
-
): WebSocketAPIMessageCallback<any> => {
|
|
19
|
-
const updateTimeout: {
|
|
20
|
-
[key: string]: number;
|
|
21
|
-
} = {};
|
|
22
|
-
|
|
23
|
-
const objectsById: {
|
|
24
|
-
[key: string]: any;
|
|
25
|
-
} = {};
|
|
26
|
-
const objects: any[] = [];
|
|
27
|
-
|
|
28
|
-
return (data: WebSocketAPIMessageEventData<any>) => {
|
|
29
|
-
const { source, content } = data;
|
|
30
|
-
if (updateTimeout[source]) {
|
|
31
|
-
window.clearTimeout(updateTimeout[source]);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (getObjectId) {
|
|
35
|
-
objectsById[getObjectId(content)] = content;
|
|
36
|
-
} else {
|
|
37
|
-
objects.push(content);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
updateTimeout[source] = window.setTimeout(() => {
|
|
41
|
-
const objectToReturn = getObjectId ? Object.values(objectsById) : objects;
|
|
42
|
-
onUpdate(objectToReturn);
|
|
43
|
-
}, timeout);
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export default debounceWebsocketMessages;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// TODO: I use any to avoid circular dependency with common/layers/layer
|
|
2
|
-
/** @private */
|
|
3
|
-
const getLayersAsFlatArray = (layersOrLayer: any | any[]): any[] => {
|
|
4
|
-
let layers = layersOrLayer;
|
|
5
|
-
if (!Array.isArray(layers)) {
|
|
6
|
-
layers = [layersOrLayer as any];
|
|
7
|
-
}
|
|
8
|
-
let flatLayers: any[] = [];
|
|
9
|
-
layers.forEach((layer: any) => {
|
|
10
|
-
flatLayers.push(layer);
|
|
11
|
-
const { children } = layer;
|
|
12
|
-
flatLayers = flatLayers.concat(getLayersAsFlatArray(children || []));
|
|
13
|
-
});
|
|
14
|
-
return flatLayers;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export default getLayersAsFlatArray;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import getMapboxMapCopyrights from './getMapboxMapCopyrights';
|
|
2
|
-
|
|
3
|
-
describe('getMapboxMapCopyrights()', () => {
|
|
4
|
-
test('returns an empty array if map is not defined', () => {
|
|
5
|
-
expect(getMapboxMapCopyrights().length).toBe(0);
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
test('returns an empty array if map.style is not defined', () => {
|
|
9
|
-
expect(getMapboxMapCopyrights({}).length).toBe(0);
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
test('returns non depluicated copyrights in an array', () => {
|
|
13
|
-
expect(
|
|
14
|
-
getMapboxMapCopyrights({
|
|
15
|
-
style: {
|
|
16
|
-
sourceCaches: {
|
|
17
|
-
used: {
|
|
18
|
-
used: true,
|
|
19
|
-
getSource() {
|
|
20
|
-
return {
|
|
21
|
-
attribution:
|
|
22
|
-
'<a href="https://www.openmaptiles.org/" target="_blank">© OpenMapTiles</a> <a href="https://www.openstreetmap.org/about/" target="_blank">© OpenStreetMap contributors</a>',
|
|
23
|
-
};
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
'not used': {
|
|
27
|
-
used: false,
|
|
28
|
-
},
|
|
29
|
-
'also used': {
|
|
30
|
-
used: true,
|
|
31
|
-
getSource() {
|
|
32
|
-
return {
|
|
33
|
-
attribution:
|
|
34
|
-
'<a href="https://www.openmaptiles.org/" target="_blank">© OpenMapTiles</a> <a href="https://www.imagico.de/" target="_blank">© imagico</a>',
|
|
35
|
-
};
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
}),
|
|
41
|
-
).toEqual([
|
|
42
|
-
'<a href="https://www.openmaptiles.org/" target="_blank">© OpenMapTiles</a>',
|
|
43
|
-
'<a href="https://www.openstreetmap.org/about/" target="_blank">© OpenStreetMap contributors</a>',
|
|
44
|
-
'<a href="https://www.imagico.de/" target="_blank">© imagico</a>',
|
|
45
|
-
]);
|
|
46
|
-
});
|
|
47
|
-
});
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import removeDuplicate from './removeDuplicate';
|
|
2
|
-
|
|
3
|
-
export interface Source {
|
|
4
|
-
attribution: string;
|
|
5
|
-
options: {
|
|
6
|
-
attribution: string;
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface SourceCache {
|
|
11
|
-
used: boolean;
|
|
12
|
-
getSource: () => Source;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Return the copyright a Mapbox map.
|
|
17
|
-
* @param {mapboxgl.Map | maplibregl.Map} map A Mapbox map
|
|
18
|
-
* @private
|
|
19
|
-
*/
|
|
20
|
-
const getMapboxMapCopyrights = (map: mapboxgl.Map | maplibregl.Map) => {
|
|
21
|
-
if (!map) {
|
|
22
|
-
return [];
|
|
23
|
-
}
|
|
24
|
-
// @ts-ignore
|
|
25
|
-
const { style } = map;
|
|
26
|
-
if (!style) {
|
|
27
|
-
return [];
|
|
28
|
-
}
|
|
29
|
-
const { sourceCaches } = style;
|
|
30
|
-
let copyrights: string[] = [];
|
|
31
|
-
|
|
32
|
-
Object.values(sourceCaches as SourceCache[]).forEach(
|
|
33
|
-
(sourceCache: SourceCache) => {
|
|
34
|
-
if (sourceCache.used as boolean) {
|
|
35
|
-
const source = sourceCache.getSource();
|
|
36
|
-
|
|
37
|
-
const attribution = // @ts-ignore
|
|
38
|
-
source.attribution || (source.options && source.options.attribution);
|
|
39
|
-
|
|
40
|
-
if (attribution) {
|
|
41
|
-
copyrights = copyrights.concat(
|
|
42
|
-
attribution.replace(/©/g, '©').split(/(<a.*?<\/a>)/),
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
return removeDuplicate(copyrights);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export default getMapboxMapCopyrights;
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-underscore-dangle */
|
|
2
|
-
import { RenderFunction } from 'ol/layer/Layer';
|
|
3
|
-
import type { FrameState } from 'ol/Map';
|
|
4
|
-
import { toLonLat } from 'ol/proj';
|
|
5
|
-
import type { MapboxLayer } from '../../ol';
|
|
6
|
-
/**
|
|
7
|
-
* Return the render function fo the olLayer of a MaplibreLayer
|
|
8
|
-
* @private
|
|
9
|
-
*/
|
|
10
|
-
export default function getMapboxRender(
|
|
11
|
-
mapoxLayer: MapboxLayer,
|
|
12
|
-
): RenderFunction {
|
|
13
|
-
// We cretae emptyDiv only in render finction to work with serverside rendering
|
|
14
|
-
let emptyDiv: HTMLElement;
|
|
15
|
-
return (frameState: FrameState) => {
|
|
16
|
-
const { map, mbMap, renderState, olLayer } = mapoxLayer;
|
|
17
|
-
if (!map || !mbMap) {
|
|
18
|
-
if (!emptyDiv) {
|
|
19
|
-
emptyDiv = document.createElement('div');
|
|
20
|
-
}
|
|
21
|
-
return emptyDiv;
|
|
22
|
-
}
|
|
23
|
-
let changed = false;
|
|
24
|
-
const canvas = mbMap.getCanvas();
|
|
25
|
-
const { viewState } = frameState;
|
|
26
|
-
|
|
27
|
-
const visible = olLayer?.getVisible();
|
|
28
|
-
if (renderState && renderState?.visible !== visible) {
|
|
29
|
-
canvas.style.display = visible ? 'block' : 'none';
|
|
30
|
-
renderState.visible = visible;
|
|
31
|
-
// Needed since mapbox-gl 1.9.0.
|
|
32
|
-
// Without you don't see others ol layers on top.
|
|
33
|
-
canvas.style.position = 'absolute';
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const opacity = olLayer?.getOpacity();
|
|
37
|
-
if (canvas && renderState && renderState.opacity !== opacity) {
|
|
38
|
-
// @ts-ignore
|
|
39
|
-
canvas.style.opacity = opacity;
|
|
40
|
-
renderState.opacity = opacity;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// adjust view parameters in mapbox
|
|
44
|
-
const { rotation } = viewState;
|
|
45
|
-
if (renderState && renderState.rotation !== rotation) {
|
|
46
|
-
mbMap.rotateTo((-(rotation || 0) * 180) / Math.PI, {
|
|
47
|
-
animate: false,
|
|
48
|
-
});
|
|
49
|
-
changed = true;
|
|
50
|
-
renderState.rotation = rotation;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (
|
|
54
|
-
renderState &&
|
|
55
|
-
renderState.center &&
|
|
56
|
-
(renderState.zoom !== viewState.zoom ||
|
|
57
|
-
renderState.center[0] !== viewState.center[0] ||
|
|
58
|
-
renderState.center[1] !== viewState.center[1])
|
|
59
|
-
) {
|
|
60
|
-
mbMap.jumpTo({
|
|
61
|
-
center: toLonLat(viewState.center) as [number, number],
|
|
62
|
-
zoom: viewState.zoom - 1,
|
|
63
|
-
});
|
|
64
|
-
changed = true;
|
|
65
|
-
renderState.zoom = viewState.zoom;
|
|
66
|
-
renderState.center = viewState.center;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const size = map.getSize() || [0, 0];
|
|
70
|
-
if (
|
|
71
|
-
renderState &&
|
|
72
|
-
renderState.size &&
|
|
73
|
-
(renderState.size[0] !== size[0] || renderState.size[1] !== size[1])
|
|
74
|
-
) {
|
|
75
|
-
changed = true;
|
|
76
|
-
renderState.size = size;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// cancel the scheduled update & trigger synchronous redraw
|
|
80
|
-
// see https://github.com/mapbox/mapbox-gl-js/issues/7893#issue-408992184
|
|
81
|
-
// NOTE: THIS MIGHT BREAK WHEN UPDATING MAPBOX
|
|
82
|
-
// @ts-ignore
|
|
83
|
-
if (mbMap && mbMap.style && mbMap.isStyleLoaded() && changed) {
|
|
84
|
-
try {
|
|
85
|
-
// @ts-ignore
|
|
86
|
-
if (mbMap._frame) {
|
|
87
|
-
// @ts-ignore
|
|
88
|
-
mbMap._frame.cancel();
|
|
89
|
-
// @ts-ignore
|
|
90
|
-
mbMap._frame = null;
|
|
91
|
-
}
|
|
92
|
-
// @ts-ignore
|
|
93
|
-
mbMap._render();
|
|
94
|
-
} catch (err) {
|
|
95
|
-
// ignore render errors because it's probably related to
|
|
96
|
-
// a render during an update of the style.
|
|
97
|
-
// eslint-disable-next-line no-console
|
|
98
|
-
console.warn(err);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return mbMap.getContainer();
|
|
103
|
-
};
|
|
104
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { toLonLat } from 'ol/proj';
|
|
2
|
-
import { toDegrees } from 'ol/math';
|
|
3
|
-
import type { FrameState } from 'ol/Map';
|
|
4
|
-
import type { RenderFunction } from 'ol/layer/Layer';
|
|
5
|
-
import type { MaplibreLayer } from '../../ol';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Return the render function fo the olLayer of a MaplibreLayer
|
|
9
|
-
* @private
|
|
10
|
-
*
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
export default function getMaplibreRender(
|
|
14
|
-
maplibreLayer: MaplibreLayer,
|
|
15
|
-
): RenderFunction {
|
|
16
|
-
let emptyDiv: HTMLElement;
|
|
17
|
-
return (frameState: FrameState) => {
|
|
18
|
-
const { map, mbMap, olLayer } = maplibreLayer;
|
|
19
|
-
if (!map || !mbMap) {
|
|
20
|
-
if (!emptyDiv) {
|
|
21
|
-
emptyDiv = document.createElement('div');
|
|
22
|
-
}
|
|
23
|
-
return emptyDiv;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const canvas = mbMap.getCanvas();
|
|
27
|
-
const { viewState } = frameState;
|
|
28
|
-
|
|
29
|
-
const opacity = olLayer?.getOpacity() || 1;
|
|
30
|
-
canvas.style.opacity = `${opacity}`;
|
|
31
|
-
|
|
32
|
-
// adjust view parameters in mapbox
|
|
33
|
-
mbMap.jumpTo({
|
|
34
|
-
center: toLonLat(viewState.center) as [number, number],
|
|
35
|
-
zoom: viewState.zoom - 1,
|
|
36
|
-
bearing: toDegrees(-viewState.rotation),
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
if (!canvas.isConnected) {
|
|
40
|
-
// The canvas is not connected to the DOM, request a map rendering at the next animation frame
|
|
41
|
-
// to set the canvas size.
|
|
42
|
-
map.render();
|
|
43
|
-
} else if (
|
|
44
|
-
canvas.width !== frameState.size[0] ||
|
|
45
|
-
canvas.height !== frameState.size[1]
|
|
46
|
-
) {
|
|
47
|
-
mbMap.resize();
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
mbMap.redraw();
|
|
51
|
-
|
|
52
|
-
return mbMap.getContainer();
|
|
53
|
-
};
|
|
54
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Return the styleUrl with apiKey parameters set.
|
|
3
|
-
* @param {string} url a url.
|
|
4
|
-
* @param {Object<String,String>} params a list of key/value pair to add to the url.
|
|
5
|
-
* @private
|
|
6
|
-
*/
|
|
7
|
-
const getUrlWithParams = (url: string, params: Object): URL => {
|
|
8
|
-
// Clean requets parameters, removing undefined and null values.
|
|
9
|
-
const newUrl = new URL(url);
|
|
10
|
-
|
|
11
|
-
const searchParams = params || {};
|
|
12
|
-
Object.entries(searchParams).forEach(([key, value]) => {
|
|
13
|
-
if (value !== undefined && value !== null) {
|
|
14
|
-
newUrl.searchParams.set(key, value);
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
return newUrl;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export default getUrlWithParams;
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { Coordinate } from 'ol/coordinate';
|
|
2
|
-
import { LineString } from 'ol/geom';
|
|
3
|
-
import type { RealtimeTrajectory } from '../../api/typedefs';
|
|
4
|
-
|
|
5
|
-
export type VehiclePosition = {
|
|
6
|
-
coord: Coordinate;
|
|
7
|
-
rotation: number;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Interpolate or not the vehicle position from a trajectory at a specific date.
|
|
12
|
-
*
|
|
13
|
-
* @param {number} now Current date to interpolate a position with. In ms.
|
|
14
|
-
* @param {RealtimeTrajectory} trajectory The trajectory to interpolate.
|
|
15
|
-
* @param {boolean} noInterpolate If true, the vehicle position is not interpolated on each render but only once.
|
|
16
|
-
* @returns {VehiclePosition}
|
|
17
|
-
*/
|
|
18
|
-
const getVehiclePosition = (
|
|
19
|
-
now: number,
|
|
20
|
-
trajectory: RealtimeTrajectory,
|
|
21
|
-
noInterpolate: boolean,
|
|
22
|
-
): VehiclePosition => {
|
|
23
|
-
const {
|
|
24
|
-
time_intervals: timeIntervals,
|
|
25
|
-
olGeometry,
|
|
26
|
-
coordinate,
|
|
27
|
-
} = trajectory.properties;
|
|
28
|
-
const { coordinates } = trajectory.geometry;
|
|
29
|
-
let { type } = trajectory.geometry;
|
|
30
|
-
let geometry = olGeometry;
|
|
31
|
-
let coord;
|
|
32
|
-
let rotation;
|
|
33
|
-
|
|
34
|
-
if (olGeometry) {
|
|
35
|
-
type = geometry.getType();
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (noInterpolate && coordinate) {
|
|
39
|
-
coord = coordinate;
|
|
40
|
-
} else if (type === 'Point') {
|
|
41
|
-
coord = coordinates;
|
|
42
|
-
} else if (type === 'LineString') {
|
|
43
|
-
if (!geometry) {
|
|
44
|
-
geometry = new LineString(coordinates);
|
|
45
|
-
}
|
|
46
|
-
const intervals = timeIntervals || [[]];
|
|
47
|
-
const firstInterval = intervals[0];
|
|
48
|
-
const lastInterval = intervals[intervals.length - 1];
|
|
49
|
-
|
|
50
|
-
// Between the last time interval of a trajectory event and the beginning
|
|
51
|
-
// of the new trajectory event, there is few seconds, can be 6 to 30
|
|
52
|
-
// seconds (that's why the vehicle jumps sometimes).
|
|
53
|
-
// So we make the choice here to display the last (or the first) position
|
|
54
|
-
// of an trajectory event instead of removing them, if the current date is
|
|
55
|
-
// outside the time intervals we display the vehicle at the last (or first) position known.
|
|
56
|
-
if (now < firstInterval[0]) {
|
|
57
|
-
// Display first position known.
|
|
58
|
-
[, , rotation] = firstInterval;
|
|
59
|
-
coord = geometry.getFirstCoordinate();
|
|
60
|
-
} else if (now > lastInterval[0]) {
|
|
61
|
-
// Display last position known.
|
|
62
|
-
[, , rotation] = lastInterval;
|
|
63
|
-
coord = geometry.getLastCoordinate();
|
|
64
|
-
} else {
|
|
65
|
-
// Interpolate position using time intervals.
|
|
66
|
-
for (let j = 0; j < intervals.length - 1; j += 1) {
|
|
67
|
-
// Rotation only available in realtime layer.
|
|
68
|
-
const [start, startFrac] = intervals[j];
|
|
69
|
-
const [end, endFrac] = intervals[j + 1];
|
|
70
|
-
|
|
71
|
-
if (start <= now && now <= end) {
|
|
72
|
-
// interpolate position inside the time interval.
|
|
73
|
-
const timeFrac = Math.min((now - start) / (end - start), 1);
|
|
74
|
-
const geomFrac = timeFrac * (endFrac - startFrac) + startFrac;
|
|
75
|
-
coord = geometry.getCoordinateAt(geomFrac);
|
|
76
|
-
[, , rotation] = intervals[j];
|
|
77
|
-
break;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
} else {
|
|
82
|
-
// eslint-disable-next-line no-console
|
|
83
|
-
console.error(
|
|
84
|
-
'This geometry type is not supported. Only Point or LineString are. Current geometry: ',
|
|
85
|
-
geometry,
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return { coord, rotation };
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
export default getVehiclePosition;
|