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
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import createCanvas from '../utils/createCanvas';
|
|
2
|
+
import { getBgColor } from '../utils/realtimeConfig';
|
|
3
|
+
import realtimeDefaultStyle from './realtimeDefaultStyle';
|
|
4
|
+
/** @private */
|
|
5
|
+
const rotateCanvas = (canvas, rotation) => {
|
|
6
|
+
const ctx = canvas.getContext('2d');
|
|
7
|
+
ctx === null || ctx === void 0 ? void 0 : ctx.translate(canvas.width / 2, canvas.height / 2);
|
|
8
|
+
ctx === null || ctx === void 0 ? void 0 : ctx.rotate(rotation);
|
|
9
|
+
ctx === null || ctx === void 0 ? void 0 : ctx.translate(-canvas.width / 2, -canvas.height / 2);
|
|
10
|
+
};
|
|
11
|
+
/** @private */
|
|
12
|
+
const arrowCache = {};
|
|
13
|
+
/** @private */
|
|
14
|
+
const getArrowCanvas = (fillColor) => {
|
|
15
|
+
const key = `${fillColor}`;
|
|
16
|
+
if (!arrowCache[key]) {
|
|
17
|
+
// Create the arrow canvas
|
|
18
|
+
const arrowCanvas = createCanvas(20, 20);
|
|
19
|
+
const ctx = arrowCanvas === null || arrowCanvas === void 0 ? void 0 : arrowCanvas.getContext('2d');
|
|
20
|
+
if (ctx) {
|
|
21
|
+
ctx.fillStyle = fillColor;
|
|
22
|
+
ctx.beginPath();
|
|
23
|
+
ctx.moveTo(5, 5);
|
|
24
|
+
ctx.lineTo(10, 10);
|
|
25
|
+
ctx.lineTo(5, 15);
|
|
26
|
+
ctx.fill();
|
|
27
|
+
ctx.beginPath();
|
|
28
|
+
ctx.moveTo(5, 5);
|
|
29
|
+
ctx.lineTo(10, 10);
|
|
30
|
+
ctx.lineTo(5, 15);
|
|
31
|
+
ctx.lineTo(5, 5);
|
|
32
|
+
ctx.stroke();
|
|
33
|
+
}
|
|
34
|
+
arrowCache[key] = arrowCanvas;
|
|
35
|
+
}
|
|
36
|
+
return arrowCache[key];
|
|
37
|
+
};
|
|
38
|
+
/** @private */
|
|
39
|
+
const bufferArrowCache = {};
|
|
40
|
+
/** @private */
|
|
41
|
+
const getBufferArrowCanvas = (canvas, fillColor, rotation) => {
|
|
42
|
+
const margin = 20;
|
|
43
|
+
const bufferKey = `${fillColor},${canvas.width},${canvas.height},${rotation}`;
|
|
44
|
+
if (!bufferArrowCache[bufferKey]) {
|
|
45
|
+
// Create a buffer canvas around the current vehicle to display properly the arrow
|
|
46
|
+
const buffer = createCanvas(canvas.width + margin * 2, canvas.height + margin * 2);
|
|
47
|
+
const arrowCanvas = getArrowCanvas(fillColor);
|
|
48
|
+
if (arrowCanvas && buffer) {
|
|
49
|
+
const bufferCtx = buffer.getContext('2d');
|
|
50
|
+
bufferCtx === null || bufferCtx === void 0 ? void 0 : bufferCtx.drawImage(arrowCanvas, buffer.width - margin, buffer.height / 2 - arrowCanvas.height / 2, arrowCanvas.width, arrowCanvas.height);
|
|
51
|
+
bufferCtx === null || bufferCtx === void 0 ? void 0 : bufferCtx.save();
|
|
52
|
+
const rot = rotation + (90 * Math.PI) / 180;
|
|
53
|
+
rotateCanvas(buffer, -rot);
|
|
54
|
+
bufferCtx === null || bufferCtx === void 0 ? void 0 : bufferCtx.restore();
|
|
55
|
+
}
|
|
56
|
+
bufferArrowCache[bufferKey] = buffer;
|
|
57
|
+
}
|
|
58
|
+
return bufferArrowCache[bufferKey];
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* A tracker style that take in account the delay.
|
|
62
|
+
*
|
|
63
|
+
* @param {RealtimeTrajectory} trajectory The trajectory to render.
|
|
64
|
+
* @param {ViewState} viewState The view state of the map.
|
|
65
|
+
* @param {RealtimeStyleOptions} options Some options to change the rendering
|
|
66
|
+
* @return a canvas
|
|
67
|
+
*/
|
|
68
|
+
const realtimeHeadingStyle = (trajectory, viewState, options) => {
|
|
69
|
+
var _a, _b;
|
|
70
|
+
// @ts-ignore
|
|
71
|
+
const { rotation, type, line } = trajectory.properties;
|
|
72
|
+
const { color } = line || {};
|
|
73
|
+
const canvas = realtimeDefaultStyle(trajectory, viewState, options);
|
|
74
|
+
if (canvas && rotation !== null) {
|
|
75
|
+
const circleFillColor = color || getBgColor(type);
|
|
76
|
+
const bufferArrow = getBufferArrowCanvas(canvas, circleFillColor, rotation);
|
|
77
|
+
if (bufferArrow) {
|
|
78
|
+
const bufferSize = (bufferArrow.width - canvas.width) / 2;
|
|
79
|
+
const vehicleWithArrow = createCanvas(bufferArrow.width, bufferArrow.height);
|
|
80
|
+
(_a = vehicleWithArrow === null || vehicleWithArrow === void 0 ? void 0 : vehicleWithArrow.getContext('2d')) === null || _a === void 0 ? void 0 : _a.drawImage(bufferArrow, 0, 0, bufferArrow.width, bufferArrow.height);
|
|
81
|
+
(_b = vehicleWithArrow === null || vehicleWithArrow === void 0 ? void 0 : vehicleWithArrow.getContext('2d')) === null || _b === void 0 ? void 0 : _b.drawImage(canvas, bufferSize, bufferSize, canvas.width, canvas.height);
|
|
82
|
+
return vehicleWithArrow;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return canvas;
|
|
86
|
+
};
|
|
87
|
+
export default realtimeHeadingStyle;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"realtimeSimpleStyle.d.ts","sourceRoot":"","sources":["../../../src/common/styles/realtimeSimpleStyle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAQpE,QAAA,MAAM,mBAAmB,EAAE,qBAe1B,CAAC;AACF,eAAe,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import createCanvas from '../utils/createCanvas';
|
|
2
|
+
/**
|
|
3
|
+
* A very simple tracker style.
|
|
4
|
+
* Display blue point for each train.
|
|
5
|
+
*/
|
|
6
|
+
let canvas;
|
|
7
|
+
const realtimeSimpleStyle = () => {
|
|
8
|
+
if (!canvas) {
|
|
9
|
+
canvas = createCanvas(15, 15);
|
|
10
|
+
const ctx = canvas === null || canvas === void 0 ? void 0 : canvas.getContext('2d');
|
|
11
|
+
if (ctx) {
|
|
12
|
+
ctx.arc(8, 8, 5, 0, 2 * Math.PI, false);
|
|
13
|
+
ctx.fillStyle = '#8ED6FF';
|
|
14
|
+
ctx.fill();
|
|
15
|
+
ctx.lineWidth = 3;
|
|
16
|
+
ctx.strokeStyle = 'black';
|
|
17
|
+
ctx.stroke();
|
|
18
|
+
ctx.lineWidth = 3;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return canvas;
|
|
22
|
+
};
|
|
23
|
+
export default realtimeSimpleStyle;
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
export default dummy;
|
|
2
|
+
export type FilterFunction = Function;
|
|
3
|
+
export type SortFunction = Function;
|
|
4
|
+
export type ViewState = {
|
|
5
|
+
/**
|
|
6
|
+
* A time in ms.
|
|
7
|
+
*/
|
|
8
|
+
time: number | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* A center in mercator coordinate.
|
|
11
|
+
*/
|
|
12
|
+
center: number[2] | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* An Extent in mercator coordinates.
|
|
15
|
+
*/
|
|
16
|
+
extent: any;
|
|
17
|
+
/**
|
|
18
|
+
* A size ([width, height]).
|
|
19
|
+
*/
|
|
20
|
+
size: any;
|
|
21
|
+
/**
|
|
22
|
+
* A rotation in radians.
|
|
23
|
+
*/
|
|
24
|
+
rotation: number;
|
|
25
|
+
/**
|
|
26
|
+
* A resolution.
|
|
27
|
+
*/
|
|
28
|
+
resolution: number;
|
|
29
|
+
/**
|
|
30
|
+
* A zoom level.
|
|
31
|
+
*/
|
|
32
|
+
zoom: number;
|
|
33
|
+
/**
|
|
34
|
+
* A pixel ratio.
|
|
35
|
+
*/
|
|
36
|
+
pixelRatio: number | undefined;
|
|
37
|
+
};
|
|
38
|
+
export type FeatureInfo = {
|
|
39
|
+
/**
|
|
40
|
+
* A layer.
|
|
41
|
+
*/
|
|
42
|
+
layer: Layer;
|
|
43
|
+
/**
|
|
44
|
+
* /Feature~Feature[]} features An array of features.
|
|
45
|
+
*/
|
|
46
|
+
"": ol;
|
|
47
|
+
/**
|
|
48
|
+
* The coordinate where to find the featue.
|
|
49
|
+
*/
|
|
50
|
+
coordinate: any;
|
|
51
|
+
};
|
|
52
|
+
export type ControlCommonOptions = {
|
|
53
|
+
/**
|
|
54
|
+
* Whether the control is active or not.
|
|
55
|
+
*/
|
|
56
|
+
active?: boolean | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* The HTML element used to render the control.
|
|
59
|
+
*/
|
|
60
|
+
element: HTMLElement;
|
|
61
|
+
/**
|
|
62
|
+
* The HTML element where to render the element property. Default is the map's element.
|
|
63
|
+
*/
|
|
64
|
+
target: HTMLElement;
|
|
65
|
+
/**
|
|
66
|
+
* Render function called whenever the control needs to be rerendered.
|
|
67
|
+
*/
|
|
68
|
+
render: Function;
|
|
69
|
+
};
|
|
70
|
+
export type LayerCommonOptions = {
|
|
71
|
+
/**
|
|
72
|
+
* Identifier of the layer. Must be unique.
|
|
73
|
+
*/
|
|
74
|
+
key: string;
|
|
75
|
+
/**
|
|
76
|
+
* Name of the layer.
|
|
77
|
+
*/
|
|
78
|
+
name: string;
|
|
79
|
+
/**
|
|
80
|
+
* Group of the layer.
|
|
81
|
+
*/
|
|
82
|
+
group: string;
|
|
83
|
+
/**
|
|
84
|
+
* List of copyrights.
|
|
85
|
+
*/
|
|
86
|
+
copyrights: string[];
|
|
87
|
+
/**
|
|
88
|
+
* List of children layers.
|
|
89
|
+
*/
|
|
90
|
+
children: Layer[];
|
|
91
|
+
/**
|
|
92
|
+
* Define if the layer is currently display on the map.
|
|
93
|
+
*/
|
|
94
|
+
visible: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Define if the layer is currently display on the map but can't be seen (extent, zoom ,data restrictions).
|
|
97
|
+
*/
|
|
98
|
+
disabled: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Hit-detection tolerance in css pixels. Pixels inside the radius around the given position will be checked for features.
|
|
101
|
+
*/
|
|
102
|
+
hittolerance: number;
|
|
103
|
+
/**
|
|
104
|
+
* - Custom properties.
|
|
105
|
+
*/
|
|
106
|
+
properties: Object;
|
|
107
|
+
/**
|
|
108
|
+
* - The map used to display the layer.
|
|
109
|
+
*/
|
|
110
|
+
map: AnyMap;
|
|
111
|
+
};
|
|
112
|
+
export type VehiclePosition = {
|
|
113
|
+
/**
|
|
114
|
+
* Coordinate of the vehicle position in Mercator .
|
|
115
|
+
*/
|
|
116
|
+
coord: any;
|
|
117
|
+
/**
|
|
118
|
+
* An angle in radians representing the direction (from the true north) towards which the vehicle is facing.
|
|
119
|
+
*/
|
|
120
|
+
rotation: number;
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* /Map~Map|mapboxgl.Map|maplibregl.Map} AnyMap
|
|
124
|
+
*/
|
|
125
|
+
type dummy = ol;
|
|
126
|
+
/**
|
|
127
|
+
* @typedef {function} FilterFunction
|
|
128
|
+
* @param {Vehicle} vehicle Vehicle to filter.
|
|
129
|
+
* @returns boolean
|
|
130
|
+
*/
|
|
131
|
+
/**
|
|
132
|
+
* @typedef {function} SortFunction
|
|
133
|
+
* @param {any} a Object a to compare.
|
|
134
|
+
* @param {any} b Object b to compare.
|
|
135
|
+
* @returns number
|
|
136
|
+
*/
|
|
137
|
+
/**
|
|
138
|
+
* @typedef {Object} ViewState
|
|
139
|
+
* @property {number|undefined} time A time in ms.
|
|
140
|
+
* @property {number[2]|undefined} center A center in mercator coordinate.
|
|
141
|
+
* @property {number[4]} extent An Extent in mercator coordinates.
|
|
142
|
+
* @property {number[2]} size A size ([width, height]).
|
|
143
|
+
* @property {number} rotation A rotation in radians.
|
|
144
|
+
* @property {number} resolution A resolution.
|
|
145
|
+
* @property {number} zoom A zoom level.
|
|
146
|
+
* @property {number|undefined} pixelRatio A pixel ratio.
|
|
147
|
+
*/
|
|
148
|
+
/**
|
|
149
|
+
* @typedef {Object} FeatureInfo
|
|
150
|
+
* @property {Layer} layer A layer.
|
|
151
|
+
* @property {ol/Feature~Feature[]} features An array of features.
|
|
152
|
+
* @property {number[2]} coordinate The coordinate where to find the featue.
|
|
153
|
+
*/
|
|
154
|
+
/**
|
|
155
|
+
* @typedef {ol/Map~Map|mapboxgl.Map|maplibregl.Map} AnyMap
|
|
156
|
+
*/
|
|
157
|
+
/**
|
|
158
|
+
* @typedef {Object} ControlCommonOptions
|
|
159
|
+
* @property {boolean} [active = true] Whether the control is active or not.
|
|
160
|
+
* @property {HTMLElement} element The HTML element used to render the control.
|
|
161
|
+
* @property {HTMLElement} target The HTML element where to render the element property. Default is the map's element.
|
|
162
|
+
* @property {function} render Render function called whenever the control needs to be rerendered.
|
|
163
|
+
*/
|
|
164
|
+
/**
|
|
165
|
+
* @typedef {Object} LayerCommonOptions
|
|
166
|
+
* @property {string!} key Identifier of the layer. Must be unique.
|
|
167
|
+
* @property {string!} name Name of the layer.
|
|
168
|
+
* @property {string!} group Group of the layer.
|
|
169
|
+
* @property {string[]!} copyrights List of copyrights.
|
|
170
|
+
* @property {Layer[]!} children List of children layers.
|
|
171
|
+
* @property {boolean!} visible Define if the layer is currently display on the map.
|
|
172
|
+
* @property {boolean!} disabled Define if the layer is currently display on the map but can't be seen (extent, zoom ,data restrictions).
|
|
173
|
+
* @property {number!} hittolerance Hit-detection tolerance in css pixels. Pixels inside the radius around the given position will be checked for features.
|
|
174
|
+
* @property {Object!} properties - Custom properties.
|
|
175
|
+
* @property {AnyMap!} map - The map used to display the layer.
|
|
176
|
+
*/
|
|
177
|
+
/**
|
|
178
|
+
* @typedef {Object} VehiclePosition
|
|
179
|
+
* @property {number[2]} coord Coordinate of the vehicle position in Mercator .
|
|
180
|
+
* @property {number!} rotation An angle in radians representing the direction (from the true north) towards which the vehicle is facing.
|
|
181
|
+
*/
|
|
182
|
+
declare function dummy(): void;
|
|
183
|
+
//# sourceMappingURL=typedefs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typedefs.d.ts","sourceRoot":"","sources":["../../src/common/typedefs.js"],"names":[],"mappings":";;;;;;;UAac,MAAM,GAAC,SAAS;;;;YAChB,MAAM,CAAC,CAAC,CAAC,GAAC,SAAS;;;;;;;;;;;;cAGnB,MAAM;;;;gBACN,MAAM;;;;UACN,MAAM;;;;gBACN,MAAM,GAAC,SAAS;;;;;;;;;;;;;;;;;;;;;;;;aAchB,WAAW;;;;YACX,WAAW;;;;;;;;;;SAKX,MAAM;;;;UACN,MAAM;;;;WACN,MAAM;;;;gBACN,MAAM,EAAE;;;;cACR,OAAO;;;;aACP,OAAO;;;;cACP,OAAO;;;;kBACP,MAAM;;;;gBACN,MAAM;;;;;;;;;;;;;;cAMN,MAAM;;;;;;AAtDpB;;;;GAIG;AACH;;;;;GAKG;AACH;;;;;;;;;;GAUG;AACH;;;;;GAKG;AACH;;GAEG;AACH;;;;;;GAMG;AACH;;;;;;;;;;;;GAYG;AACH;;;;GAIG;AAEH,+BAAsB"}
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
* @property {number!} rotation An angle in radians representing the direction (from the true north) towards which the vehicle is facing.
|
|
56
56
|
*/
|
|
57
57
|
// These lines is to block TypeScript to add "use strict;" in the outputed file.
|
|
58
|
-
const dummy = () => {};
|
|
58
|
+
const dummy = () => { };
|
|
59
59
|
export default dummy;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { RealtimeDeparture } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Compare two given departures for sort alogithm,
|
|
4
|
+
* @param {Departure} a First departure.
|
|
5
|
+
* @param {Departure} b Second departure.
|
|
6
|
+
* @param {boolean} [sortByMinArrivalTime=false] Sort departures by arrival time.
|
|
7
|
+
* @private
|
|
8
|
+
*/
|
|
9
|
+
declare const compareDepartures: (a: RealtimeDeparture, b: RealtimeDeparture, sortByMinArrivalTime?: boolean) => number;
|
|
10
|
+
export default compareDepartures;
|
|
11
|
+
//# sourceMappingURL=compareDepartures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compareDepartures.d.ts","sourceRoot":"","sources":["../../../src/common/utils/compareDepartures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD;;;;;;GAMG;AACH,QAAA,MAAM,iBAAiB,MAClB,iBAAiB,KACjB,iBAAiB,yBACE,OAAO,KAC5B,MA8BF,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compare two given departures for sort alogithm,
|
|
3
|
+
* @param {Departure} a First departure.
|
|
4
|
+
* @param {Departure} b Second departure.
|
|
5
|
+
* @param {boolean} [sortByMinArrivalTime=false] Sort departures by arrival time.
|
|
6
|
+
* @private
|
|
7
|
+
*/
|
|
8
|
+
const compareDepartures = (a, b, sortByMinArrivalTime = false) => {
|
|
9
|
+
// First LEAVING and HIDDEN, then BOARDING and then sorted by time.
|
|
10
|
+
const topStates = ['HIDDEN', 'LEAVING', 'BOARDING'];
|
|
11
|
+
const aTop = a.has_fzo && topStates.indexOf(a.state) > -1;
|
|
12
|
+
const bTop = b.has_fzo && topStates.indexOf(b.state) > -1;
|
|
13
|
+
if (aTop || bTop) {
|
|
14
|
+
if (aTop !== bTop) {
|
|
15
|
+
return aTop ? -1 : 1;
|
|
16
|
+
}
|
|
17
|
+
if (a.state !== b.state) {
|
|
18
|
+
// one is leaving
|
|
19
|
+
return topStates.indexOf(a.state) - topStates.indexOf(b.state);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
let aDuration = null;
|
|
23
|
+
let bDuration = null;
|
|
24
|
+
const now = Date.now();
|
|
25
|
+
if (sortByMinArrivalTime) {
|
|
26
|
+
aDuration = new Date(a.min_arrival_time || a.time).getTime() - now;
|
|
27
|
+
bDuration = new Date(b.min_arrival_time || b.time).getTime() - now;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
aDuration = new Date(a.time).getTime() - now;
|
|
31
|
+
bDuration = new Date(b.time).getTime() - now;
|
|
32
|
+
}
|
|
33
|
+
return aDuration - bDuration;
|
|
34
|
+
};
|
|
35
|
+
export default compareDepartures;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AnyCanvas } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* This function try to create a canvas element and return it.
|
|
4
|
+
* it uses document.createElement('canvas') if document is available
|
|
5
|
+
* or new OffscreenCanvas(width, height) if OffscreenCanvas is avalaible (for web worker)
|
|
6
|
+
* or it returns null if neither is available.
|
|
7
|
+
* @private
|
|
8
|
+
*/
|
|
9
|
+
declare const createCanvas: (width: number, height: number) => AnyCanvas | null;
|
|
10
|
+
export default createCanvas;
|
|
11
|
+
//# sourceMappingURL=createCanvas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createCanvas.d.ts","sourceRoot":"","sources":["../../../src/common/utils/createCanvas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;;;;GAMG;AACH,QAAA,MAAM,YAAY,UAAW,MAAM,UAAU,MAAM,KAAG,SAAS,GAAG,IAqBjE,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This function try to create a canvas element and return it.
|
|
3
|
+
* it uses document.createElement('canvas') if document is available
|
|
4
|
+
* or new OffscreenCanvas(width, height) if OffscreenCanvas is avalaible (for web worker)
|
|
5
|
+
* or it returns null if neither is available.
|
|
6
|
+
* @private
|
|
7
|
+
*/
|
|
8
|
+
const createCanvas = (width, height) => {
|
|
9
|
+
let canvas = null;
|
|
10
|
+
// Prevent SSR errors
|
|
11
|
+
if (typeof window === 'undefined') {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
if (typeof document !== 'undefined' && (document === null || document === void 0 ? void 0 : document.createElement)) {
|
|
15
|
+
canvas = document.createElement('canvas');
|
|
16
|
+
canvas.width = width;
|
|
17
|
+
canvas.height = height;
|
|
18
|
+
}
|
|
19
|
+
else if (OffscreenCanvas) {
|
|
20
|
+
canvas = new OffscreenCanvas(width, height);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
// eslint-disable-next-line no-console
|
|
24
|
+
console.error("We didn't find a way to create a canvas element, document.createElement('canvas') and new OffscrenCanvas() are not supported");
|
|
25
|
+
}
|
|
26
|
+
return canvas;
|
|
27
|
+
};
|
|
28
|
+
export default createCanvas;
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
declare const createRealtimeFilters: (line: string | string[], route: string | string[], operator: string | string[], regexLine: string | string[]) => ((trajectory: RealtimeTrajectory) => boolean) | null;
|
|
12
|
+
export default createRealtimeFilters;
|
|
13
|
+
//# sourceMappingURL=createRealtimeFilters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createRealtimeFilters.d.ts","sourceRoot":"","sources":["../../../src/common/utils/createRealtimeFilters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD;;;;;;;;GAQG;AACH,QAAA,MAAM,qBAAqB,SACnB,MAAM,GAAG,MAAM,EAAE,SAChB,MAAM,GAAG,MAAM,EAAE,YACd,MAAM,GAAG,MAAM,EAAE,aAChB,MAAM,GAAG,MAAM,EAAE,mBACb,kBAAkB,KAAK,OAAO,QA8E9C,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return a filter functions based on some parameters of a vehicle.
|
|
3
|
+
*
|
|
4
|
+
* @param {string|Array<string>} line - A list of vehicle's name to filter. Names can be separated by a comma. Ex: 'S1,S2,S3'
|
|
5
|
+
* @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'
|
|
6
|
+
* @param {string|Array<string} operator A list of vehicle's operator to filter. Operators can be separated by a comma. Ex: 'SBB,DB'
|
|
7
|
+
* @param {Regexp} regexLine - A regex aplly of vehcile's name.
|
|
8
|
+
* @private
|
|
9
|
+
*/
|
|
10
|
+
const createRealtimeFilters = (line, route, operator, regexLine) => {
|
|
11
|
+
const filterList = [];
|
|
12
|
+
if (!line && !route && !operator && !regexLine) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
if (regexLine) {
|
|
16
|
+
const regexLineList = typeof regexLine === 'string' ? [regexLine] : regexLine;
|
|
17
|
+
const lineFilter = (item) => {
|
|
18
|
+
const name = item.properties.name ||
|
|
19
|
+
(item.properties.line && item.properties.line.name) ||
|
|
20
|
+
'';
|
|
21
|
+
if (!name) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
return regexLineList.some((regexStr) => new RegExp(regexStr, 'i').test(name));
|
|
25
|
+
};
|
|
26
|
+
filterList.push(lineFilter);
|
|
27
|
+
}
|
|
28
|
+
if (line) {
|
|
29
|
+
const lineFiltersList = typeof line === 'string' ? line.split(',') : line;
|
|
30
|
+
const lineList = lineFiltersList.map((l) => l.replace(/\s+/g, '').toUpperCase());
|
|
31
|
+
const lineFilter = (item) => {
|
|
32
|
+
const { line: linee, name } = item.properties;
|
|
33
|
+
const lineName = (name || (linee && linee.name) || '').toUpperCase();
|
|
34
|
+
if (!lineName) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
return lineList.includes(lineName);
|
|
38
|
+
};
|
|
39
|
+
filterList.push(lineFilter);
|
|
40
|
+
}
|
|
41
|
+
if (route) {
|
|
42
|
+
const routes = typeof route === 'string' ? route.split(',') : route;
|
|
43
|
+
const routeList = routes.map((item) => parseInt(item, 10));
|
|
44
|
+
const routeFilter = (item) => {
|
|
45
|
+
const routeIdentifier = item.properties.route_identifier ||
|
|
46
|
+
item.properties.routeIdentifier ||
|
|
47
|
+
'';
|
|
48
|
+
const routeId = parseInt(routeIdentifier.split('.')[0], 10);
|
|
49
|
+
return routeList.includes(routeId);
|
|
50
|
+
};
|
|
51
|
+
filterList.push(routeFilter);
|
|
52
|
+
}
|
|
53
|
+
if (operator) {
|
|
54
|
+
const operatorList = typeof operator === 'string' ? [operator] : operator;
|
|
55
|
+
const operatorFilter = (item) => operatorList.some((op) => {
|
|
56
|
+
// operaotr is the old property tenant is the new one
|
|
57
|
+
const tenant = item.properties.operator || item.properties.tenant || '';
|
|
58
|
+
return new RegExp(op, 'i').test(tenant);
|
|
59
|
+
});
|
|
60
|
+
filterList.push(operatorFilter);
|
|
61
|
+
}
|
|
62
|
+
if (!filterList.length) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
return (item) => {
|
|
66
|
+
for (let i = 0; i < filterList.length; i += 1) {
|
|
67
|
+
if (!filterList[i](item)) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return true;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
export default createRealtimeFilters;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { RealtimeDeparture, RealtimeDepartureExtended } from '../../types';
|
|
2
|
+
import type { WebSocketAPIMessageCallback } from '../api/WebSocketAPI';
|
|
3
|
+
/**
|
|
4
|
+
* This function returns a WebSocket api callback, and call the onDeparturesUpdate function with the list of current departures to display.
|
|
5
|
+
* @param {function(departures: RealtimeDeparture[])} onDeparturesUpdate callback when list of departures changes, called after 100 ms
|
|
6
|
+
* @param {boolean} [sortByMinArrivalTime = true] Sort departures by arrival time
|
|
7
|
+
* @param {number} [maxDepartureAge = 30] max departure age of departures in minutes
|
|
8
|
+
* @param {number} [timeout = 100] debounce timeout in ms
|
|
9
|
+
* @private
|
|
10
|
+
*/
|
|
11
|
+
declare const debounceDeparturesMessages: (onDeparturesUpdate: (departures: RealtimeDepartureExtended[]) => {}, sortByMinArrivalTime?: boolean, maxDepartureAge?: number, timeout?: number) => WebSocketAPIMessageCallback<RealtimeDeparture>;
|
|
12
|
+
export default debounceDeparturesMessages;
|
|
13
|
+
//# sourceMappingURL=debounceDeparturesMessages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debounceDeparturesMessages.d.ts","sourceRoot":"","sources":["../../../src/common/utils/debounceDeparturesMessages.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAChF,OAAO,KAAK,EACV,2BAA2B,EAE5B,MAAM,qBAAqB,CAAC;AAG7B;;;;;;;GAOG;AACH,QAAA,MAAM,0BAA0B,oCACG,yBAAyB,EAAE,KAAK,EAAE,iFAIlE,4BAA4B,iBAAiB,CA4B/C,CAAC;AAEF,eAAe,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import sortAndFilterDepartures from './sortAndFilterDepartures';
|
|
2
|
+
/**
|
|
3
|
+
* This function returns a WebSocket api callback, and call the onDeparturesUpdate function with the list of current departures to display.
|
|
4
|
+
* @param {function(departures: RealtimeDeparture[])} onDeparturesUpdate callback when list of departures changes, called after 100 ms
|
|
5
|
+
* @param {boolean} [sortByMinArrivalTime = true] Sort departures by arrival time
|
|
6
|
+
* @param {number} [maxDepartureAge = 30] max departure age of departures in minutes
|
|
7
|
+
* @param {number} [timeout = 100] debounce timeout in ms
|
|
8
|
+
* @private
|
|
9
|
+
*/
|
|
10
|
+
const debounceDeparturesMessages = (onDeparturesUpdate, sortByMinArrivalTime = false, maxDepartureAge = 30, timeout = 100) => {
|
|
11
|
+
const departureUpdateTimeout = {};
|
|
12
|
+
const departureObject = {};
|
|
13
|
+
return (data) => {
|
|
14
|
+
const { source, content: departure } = data;
|
|
15
|
+
if (departureUpdateTimeout[source]) {
|
|
16
|
+
window.clearTimeout(departureUpdateTimeout[source]);
|
|
17
|
+
}
|
|
18
|
+
if (!departure) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
departureObject[departure.call_id] = departure;
|
|
22
|
+
departureUpdateTimeout[source] = window.setTimeout(() => {
|
|
23
|
+
const departures = sortAndFilterDepartures(departureObject, sortByMinArrivalTime || false, maxDepartureAge);
|
|
24
|
+
onDeparturesUpdate(departures);
|
|
25
|
+
}, timeout);
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export default debounceDeparturesMessages;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { WebSocketAPIMessageCallback } from '../api/WebSocketAPI';
|
|
2
|
+
/**
|
|
3
|
+
* This function returns a WebSocket api callback, and call the onUpdate function with the list of of subscribed objects changes.
|
|
4
|
+
*
|
|
5
|
+
* @param {function(objects: any[])} onUpdate callback when list of subscribed objects changes, called after 100 ms
|
|
6
|
+
* @param {function(object: any)} [getObjectId = true] function returning the id of an object
|
|
7
|
+
* @param {number} [timeout = 100] debounce timeout in ms
|
|
8
|
+
* @private
|
|
9
|
+
*/
|
|
10
|
+
declare const debounceWebsocketMessages: (onUpdate: (objects: any[]) => void, getObjectId?: ((object: any) => string) | undefined, timeout?: number) => WebSocketAPIMessageCallback<any>;
|
|
11
|
+
export default debounceWebsocketMessages;
|
|
12
|
+
//# sourceMappingURL=debounceWebsocketMessages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debounceWebsocketMessages.d.ts","sourceRoot":"","sources":["../../../src/common/utils/debounceWebsocketMessages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,2BAA2B,EAE5B,MAAM,qBAAqB,CAAC;AAE7B;;;;;;;GAOG;AACH,QAAA,MAAM,yBAAyB,uBACT,GAAG,EAAE,KAAK,IAAI,0BACX,GAAG,KAAK,MAAM,oCAEpC,4BAA4B,GAAG,CA2BjC,CAAC;AAEF,eAAe,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This function returns a WebSocket api callback, and call the onUpdate function with the list of of subscribed objects changes.
|
|
3
|
+
*
|
|
4
|
+
* @param {function(objects: any[])} onUpdate callback when list of subscribed objects changes, called after 100 ms
|
|
5
|
+
* @param {function(object: any)} [getObjectId = true] function returning the id of an object
|
|
6
|
+
* @param {number} [timeout = 100] debounce timeout in ms
|
|
7
|
+
* @private
|
|
8
|
+
*/
|
|
9
|
+
const debounceWebsocketMessages = (onUpdate, getObjectId, timeout = 100) => {
|
|
10
|
+
const updateTimeout = {};
|
|
11
|
+
const objectsById = {};
|
|
12
|
+
const objects = [];
|
|
13
|
+
return (data) => {
|
|
14
|
+
const { source, content } = data;
|
|
15
|
+
if (updateTimeout[source]) {
|
|
16
|
+
window.clearTimeout(updateTimeout[source]);
|
|
17
|
+
}
|
|
18
|
+
if (getObjectId) {
|
|
19
|
+
objectsById[getObjectId(content)] = content;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
objects.push(content);
|
|
23
|
+
}
|
|
24
|
+
updateTimeout[source] = window.setTimeout(() => {
|
|
25
|
+
const objectToReturn = getObjectId ? Object.values(objectsById) : objects;
|
|
26
|
+
onUpdate(objectToReturn);
|
|
27
|
+
}, timeout);
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export default debounceWebsocketMessages;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getLayersAsFlatArray.d.ts","sourceRoot":"","sources":["../../../src/common/utils/getLayersAsFlatArray.ts"],"names":[],"mappings":"AACA,eAAe;AACf,QAAA,MAAM,oBAAoB,kBAAmB,GAAG,GAAG,GAAG,EAAE,KAAG,GAAG,EAY7D,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// TODO: I use any to avoid circular dependency with common/layers/layer
|
|
2
|
+
/** @private */
|
|
3
|
+
const getLayersAsFlatArray = (layersOrLayer) => {
|
|
4
|
+
let layers = layersOrLayer;
|
|
5
|
+
if (!Array.isArray(layers)) {
|
|
6
|
+
layers = [layersOrLayer];
|
|
7
|
+
}
|
|
8
|
+
let flatLayers = [];
|
|
9
|
+
layers.forEach((layer) => {
|
|
10
|
+
flatLayers.push(layer);
|
|
11
|
+
const { children } = layer;
|
|
12
|
+
flatLayers = flatLayers.concat(getLayersAsFlatArray(children || []));
|
|
13
|
+
});
|
|
14
|
+
return flatLayers;
|
|
15
|
+
};
|
|
16
|
+
export default getLayersAsFlatArray;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface Source {
|
|
2
|
+
attribution: string;
|
|
3
|
+
options: {
|
|
4
|
+
attribution: string;
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
export interface SourceCache {
|
|
8
|
+
used: boolean;
|
|
9
|
+
getSource: () => Source;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Return the copyright a Mapbox map.
|
|
13
|
+
* @param {mapboxgl.Map | maplibregl.Map} map A Mapbox map
|
|
14
|
+
* @private
|
|
15
|
+
*/
|
|
16
|
+
declare const getMapboxMapCopyrights: (map: mapboxgl.Map | maplibregl.Map) => any[];
|
|
17
|
+
export default getMapboxMapCopyrights;
|
|
18
|
+
//# sourceMappingURL=getMapboxMapCopyrights.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getMapboxMapCopyrights.d.ts","sourceRoot":"","sources":["../../../src/common/utils/getMapboxMapCopyrights.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,MAAM;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE;QACP,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;CACH;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,EAAE,MAAM,MAAM,CAAC;CACzB;AAED;;;;GAIG;AACH,QAAA,MAAM,sBAAsB,QAAS,YAAY,GAAG,cAAc,UA8BjE,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
|