mobility-toolbox-js 2.3.10 → 2.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/RealtimeAPI.d.ts +290 -0
- package/api/RealtimeAPI.d.ts.map +1 -0
- package/api/RealtimeAPI.js +483 -0
- package/api/RoutingAPI.d.ts +37 -0
- package/api/RoutingAPI.d.ts.map +1 -0
- package/api/RoutingAPI.js +35 -0
- package/api/StopsAPI.d.ts +38 -0
- package/api/StopsAPI.d.ts.map +1 -0
- package/api/StopsAPI.js +36 -0
- package/api/index.d.ts +4 -0
- package/api/index.d.ts.map +1 -0
- package/api/typedefs.d.ts +179 -0
- package/api/typedefs.d.ts.map +1 -0
- package/{src/api → api}/typedefs.js +1 -11
- package/common/api/HttpAPI.d.ts +31 -0
- package/common/api/HttpAPI.d.ts.map +1 -0
- package/common/api/HttpAPI.js +57 -0
- package/common/api/WebSocketAPI.d.ts +153 -0
- package/common/api/WebSocketAPI.d.ts.map +1 -0
- package/common/api/WebSocketAPI.js +341 -0
- package/common/controls/ControlCommon.d.ts +76 -0
- package/common/controls/ControlCommon.d.ts.map +1 -0
- package/common/controls/ControlCommon.js +150 -0
- package/common/controls/CopyrightControlCommon.d.ts +13 -0
- package/common/controls/CopyrightControlCommon.d.ts.map +1 -0
- package/common/controls/CopyrightControlCommon.js +34 -0
- package/common/controls/StopFinderControlCommon.d.ts +55 -0
- package/common/controls/StopFinderControlCommon.d.ts.map +1 -0
- package/common/controls/StopFinderControlCommon.js +144 -0
- package/common/index.d.ts +3 -0
- package/common/index.d.ts.map +1 -0
- package/common/layers/LayerCommon.d.ts +94 -0
- package/common/layers/LayerCommon.d.ts.map +1 -0
- package/common/layers/LayerCommon.js +244 -0
- package/common/mixins/RealtimeLayerMixin.d.ts +288 -0
- package/common/mixins/RealtimeLayerMixin.d.ts.map +1 -0
- package/common/mixins/RealtimeLayerMixin.js +779 -0
- package/common/mixins/UserInteractionsLayerMixin.d.ts +60 -0
- package/common/mixins/UserInteractionsLayerMixin.d.ts.map +1 -0
- package/common/mixins/UserInteractionsLayerMixin.js +241 -0
- package/common/styles/index.d.ts +5 -0
- package/common/styles/index.d.ts.map +1 -0
- package/common/styles/realtimeDefaultStyle.d.ts +36 -0
- package/common/styles/realtimeDefaultStyle.d.ts.map +1 -0
- package/common/styles/realtimeDefaultStyle.js +276 -0
- package/common/styles/realtimeDelayStyle.d.ts +12 -0
- package/common/styles/realtimeDelayStyle.d.ts.map +1 -0
- package/common/styles/realtimeDelayStyle.js +13 -0
- package/common/styles/realtimeHeadingStyle.d.ts +12 -0
- package/common/styles/realtimeHeadingStyle.d.ts.map +1 -0
- package/common/styles/realtimeHeadingStyle.js +87 -0
- package/common/styles/realtimeSimpleStyle.d.ts +4 -0
- package/common/styles/realtimeSimpleStyle.d.ts.map +1 -0
- package/common/styles/realtimeSimpleStyle.js +23 -0
- package/common/typedefs.d.ts +183 -0
- package/common/typedefs.d.ts.map +1 -0
- package/{src/common → common}/typedefs.js +1 -1
- package/common/utils/compareDepartures.d.ts +11 -0
- package/common/utils/compareDepartures.d.ts.map +1 -0
- package/common/utils/compareDepartures.js +35 -0
- package/common/utils/createCanvas.d.ts +11 -0
- package/common/utils/createCanvas.d.ts.map +1 -0
- package/common/utils/createCanvas.js +28 -0
- package/common/utils/createRealtimeFilters.d.ts +13 -0
- package/common/utils/createRealtimeFilters.d.ts.map +1 -0
- package/common/utils/createRealtimeFilters.js +74 -0
- package/common/utils/debounceDeparturesMessages.d.ts +13 -0
- package/common/utils/debounceDeparturesMessages.d.ts.map +1 -0
- package/common/utils/debounceDeparturesMessages.js +28 -0
- package/common/utils/debounceWebsocketMessages.d.ts +12 -0
- package/common/utils/debounceWebsocketMessages.d.ts.map +1 -0
- package/common/utils/debounceWebsocketMessages.js +30 -0
- package/common/utils/getLayersAsFlatArray.d.ts +4 -0
- package/common/utils/getLayersAsFlatArray.d.ts.map +1 -0
- package/common/utils/getLayersAsFlatArray.js +16 -0
- package/common/utils/getMapboxMapCopyrights.d.ts +18 -0
- package/common/utils/getMapboxMapCopyrights.d.ts.map +1 -0
- package/common/utils/getMapboxMapCopyrights.js +30 -0
- package/common/utils/getMapboxRender.d.ts +8 -0
- package/common/utils/getMapboxRender.d.ts.map +1 -0
- package/common/utils/getMapboxRender.js +88 -0
- package/common/utils/getMaplibreRender.d.ts +9 -0
- package/common/utils/getMaplibreRender.d.ts.map +1 -0
- package/common/utils/getMaplibreRender.js +40 -0
- package/{src/common/utils/getRealtimeModeSuffix.ts → common/utils/getRealtimeModeSuffix.d.ts} +2 -4
- package/common/utils/getRealtimeModeSuffix.d.ts.map +1 -0
- package/common/utils/getRealtimeModeSuffix.js +7 -0
- package/common/utils/getUrlWithParams.d.ts +9 -0
- package/common/utils/getUrlWithParams.d.ts.map +1 -0
- package/common/utils/getUrlWithParams.js +18 -0
- package/common/utils/getVehiclePosition.d.ts +16 -0
- package/common/utils/getVehiclePosition.d.ts.map +1 -0
- package/common/utils/getVehiclePosition.js +72 -0
- package/common/utils/index.d.ts +18 -0
- package/common/utils/index.d.ts.map +1 -0
- package/{src/common → common}/utils/index.js +2 -1
- package/common/utils/realtimeConfig.d.ts +53 -0
- package/common/utils/realtimeConfig.d.ts.map +1 -0
- package/common/utils/realtimeConfig.js +202 -0
- package/common/utils/removeDuplicate.d.ts +10 -0
- package/common/utils/removeDuplicate.d.ts.map +1 -0
- package/common/utils/removeDuplicate.js +15 -0
- package/common/utils/renderTrajectories.d.ts +17 -0
- package/common/utils/renderTrajectories.d.ts.map +1 -0
- package/common/utils/renderTrajectories.js +110 -0
- package/common/utils/sortAndFilterDepartures.d.ts +16 -0
- package/common/utils/sortAndFilterDepartures.d.ts.map +1 -0
- package/common/utils/sortAndFilterDepartures.js +58 -0
- package/common/utils/sortByDelay.d.ts +4 -0
- package/common/utils/sortByDelay.d.ts.map +1 -0
- package/common/utils/sortByDelay.js +21 -0
- package/common/utils/timeUtils.d.ts +24 -0
- package/common/utils/timeUtils.d.ts.map +1 -0
- package/common/utils/timeUtils.js +39 -0
- package/iife.d.ts +3 -0
- package/iife.d.ts.map +1 -0
- package/{src/iife.js → iife.js} +1 -3
- package/index.d.ts +10 -0
- package/index.d.ts.map +1 -0
- package/index.js +10 -0
- package/mapbox/controls/CopyrightControl.d.ts +29 -0
- package/mapbox/controls/CopyrightControl.d.ts.map +1 -0
- package/{src/mapbox/controls/CopyrightControl.ts → mapbox/controls/CopyrightControl.js} +21 -26
- package/mapbox/controls/index.d.ts +2 -0
- package/mapbox/controls/index.d.ts.map +1 -0
- package/mapbox/index.d.ts +6 -0
- package/mapbox/index.d.ts.map +1 -0
- package/mapbox/layers/Layer.d.ts +59 -0
- package/mapbox/layers/Layer.d.ts.map +1 -0
- package/mapbox/layers/Layer.js +101 -0
- package/mapbox/layers/RealtimeLayer.d.ts +180 -0
- package/mapbox/layers/RealtimeLayer.d.ts.map +1 -0
- package/mapbox/layers/RealtimeLayer.js +270 -0
- package/mapbox/layers/index.d.ts +3 -0
- package/mapbox/layers/index.d.ts.map +1 -0
- package/mapbox/utils/getMercatorResolution.d.ts +9 -0
- package/mapbox/utils/getMercatorResolution.d.ts.map +1 -0
- package/mapbox/utils/getMercatorResolution.js +18 -0
- package/mapbox/utils/getSourceCoordinates.d.ts +9 -0
- package/mapbox/utils/getSourceCoordinates.d.ts.map +1 -0
- package/mapbox/utils/getSourceCoordinates.js +27 -0
- package/mapbox/utils/index.d.ts +3 -0
- package/mapbox/utils/index.d.ts.map +1 -0
- package/mbt.js +64817 -0
- package/mbt.js.map +7 -0
- package/mbt.min.js +1090 -0
- package/mbt.min.js.map +7 -0
- package/ol/controls/CopyrightControl.d.ts +31 -0
- package/ol/controls/CopyrightControl.d.ts.map +1 -0
- package/ol/controls/CopyrightControl.js +68 -0
- package/ol/controls/RoutingControl.d.ts +193 -0
- package/ol/controls/RoutingControl.d.ts.map +1 -0
- package/ol/controls/RoutingControl.js +631 -0
- package/ol/controls/StopFinderControl.d.ts +30 -0
- package/ol/controls/StopFinderControl.d.ts.map +1 -0
- package/{src/ol/controls/StopFinderControl.ts → ol/controls/StopFinderControl.js} +7 -10
- package/ol/controls/index.d.ts +4 -0
- package/ol/controls/index.d.ts.map +1 -0
- package/ol/index.d.ts +6 -0
- package/ol/index.d.ts.map +1 -0
- package/ol/layers/Layer.d.ts +86 -0
- package/ol/layers/Layer.d.ts.map +1 -0
- package/ol/layers/Layer.js +174 -0
- package/ol/layers/MapGlLayer.d.ts +67 -0
- package/ol/layers/MapGlLayer.d.ts.map +1 -0
- package/ol/layers/MapGlLayer.js +218 -0
- package/ol/layers/MapboxLayer.d.ts +50 -0
- package/ol/layers/MapboxLayer.d.ts.map +1 -0
- package/ol/layers/MapboxLayer.js +109 -0
- package/ol/layers/MapboxStyleLayer.d.ts +128 -0
- package/ol/layers/MapboxStyleLayer.d.ts.map +1 -0
- package/ol/layers/MapboxStyleLayer.js +362 -0
- package/{src/ol/layers/MaplibreLayer.ts → ol/layers/MaplibreLayer.d.ts} +10 -21
- package/ol/layers/MaplibreLayer.d.ts.map +1 -0
- package/ol/layers/MaplibreLayer.js +34 -0
- package/ol/layers/RealtimeLayer.d.ts +202 -0
- package/ol/layers/RealtimeLayer.d.ts.map +1 -0
- package/ol/layers/RealtimeLayer.js +332 -0
- package/ol/layers/RoutingLayer.d.ts +35 -0
- package/ol/layers/RoutingLayer.d.ts.map +1 -0
- package/ol/layers/RoutingLayer.js +85 -0
- package/ol/layers/VectorLayer.d.ts +25 -0
- package/ol/layers/VectorLayer.d.ts.map +1 -0
- package/ol/layers/VectorLayer.js +38 -0
- package/ol/layers/WMSLayer.d.ts +42 -0
- package/ol/layers/WMSLayer.d.ts.map +1 -0
- package/ol/layers/WMSLayer.js +88 -0
- package/ol/layers/index.d.ts +9 -0
- package/ol/layers/index.d.ts.map +1 -0
- package/ol/styles/fullTrajectoryDelayStyle.d.ts +4 -0
- package/ol/styles/fullTrajectoryDelayStyle.d.ts.map +1 -0
- package/ol/styles/fullTrajectoryDelayStyle.js +33 -0
- package/ol/styles/fullTrajectoryStyle.d.ts +5 -0
- package/ol/styles/fullTrajectoryStyle.d.ts.map +1 -0
- package/ol/styles/fullTrajectoryStyle.js +44 -0
- package/ol/styles/index.d.ts +3 -0
- package/ol/styles/index.d.ts.map +1 -0
- package/package.json +1 -1
- package/setupTests.d.ts +2 -0
- package/setupTests.d.ts.map +1 -0
- package/{src/setupTests.js → setupTests.js} +7 -12
- package/.esdoc.js +0 -18
- package/.eslintignore +0 -1
- package/.eslintrc.js +0 -25
- package/.fixpackrc +0 -20
- package/.github/workflows/build.yml +0 -16
- package/.github/workflows/conventional-pr-title.yml +0 -16
- package/.github/workflows/cypress.yml +0 -101
- package/.github/workflows/test.yml +0 -17
- package/.husky/commit-msg +0 -4
- package/.husky/post-checkout +0 -4
- package/.husky/post-merge +0 -4
- package/.husky/post-rebase +0 -4
- package/.husky/pre-commit +0 -4
- package/.lintstagedrc.js +0 -10
- package/.nvmrc +0 -1
- package/.prettierrc.js +0 -5
- package/.stylelintrc.js +0 -4
- package/CHANGELOG.md +0 -132
- package/LICENSE +0 -21
- package/MIGRATION-V2.md +0 -248
- package/README.md +0 -42
- package/__mocks__/mapbox-gl.js +0 -81
- package/__mocks__/maplibre-gl.js +0 -81
- package/babel.config.js +0 -9
- package/commitlint.config.js +0 -1
- package/cypress/e2e/examples/api.cy.js +0 -7
- package/cypress/e2e/examples/examples.cy.js +0 -7
- package/cypress/e2e/examples/navigation.cy.js +0 -29
- package/cypress/fixtures/example.json +0 -5
- package/cypress/plugins/index.js +0 -21
- package/cypress/support/commands.js +0 -25
- package/cypress/support/e2e.js +0 -20
- package/cypress.config.ts +0 -15
- package/data/fetchRoute.json +0 -292
- package/data/fetchTrajectories.json +0 -18
- package/data/fetchTrajectoryById.json +0 -3
- package/data/fetchTrajectoryStations.json +0 -18
- package/data/stopsSearch.json +0 -15
- package/dependabot.yml +0 -15
- package/doc/.eslintrc.json +0 -1
- package/doc/README.md +0 -34
- package/doc/next.config.js +0 -16
- package/doc/package.json +0 -41
- package/doc/pages/404.js +0 -5
- package/doc/pages/_app.js +0 -61
- package/doc/pages/_document.js +0 -64
- package/doc/pages/doc/[...slug].js +0 -23
- package/doc/pages/doc.js +0 -23
- package/doc/pages/example/[example].js +0 -52
- package/doc/pages/examples.js +0 -34
- package/doc/pages/index.js +0 -25
- package/doc/public/README.md +0 -15
- package/doc/public/favicon.ico +0 -0
- package/doc/public/static/assets/Lato-Black.ttf +0 -0
- package/doc/public/static/assets/Lato-BlackItalic.ttf +0 -0
- package/doc/public/static/assets/Lato-Bold.ttf +0 -0
- package/doc/public/static/assets/Lato-BoldItalic.ttf +0 -0
- package/doc/public/static/assets/Lato-Italic.ttf +0 -0
- package/doc/public/static/assets/Lato-Light.ttf +0 -0
- package/doc/public/static/assets/Lato-LightItalic.ttf +0 -0
- package/doc/public/static/assets/Lato-Regular.ttf +0 -0
- package/doc/public/static/assets/Lato-Thin.ttf +0 -0
- package/doc/public/static/assets/Lato-ThinItalic.ttf +0 -0
- package/doc/public/static/assets/OFL.txt +0 -93
- package/doc/public/static/examples/assets/tralis-live-map/index.js +0 -11
- package/doc/public/static/examples/assets/tralis-live-map/s1kreis.svg +0 -105
- package/doc/public/static/examples/assets/tralis-live-map/s20kreis.svg +0 -101
- package/doc/public/static/examples/assets/tralis-live-map/s2kreis.svg +0 -95
- package/doc/public/static/examples/assets/tralis-live-map/s3kreis.svg +0 -95
- package/doc/public/static/examples/assets/tralis-live-map/s4kreis.svg +0 -95
- package/doc/public/static/examples/assets/tralis-live-map/s6kreis.svg +0 -95
- package/doc/public/static/examples/assets/tralis-live-map/s7kreis.svg +0 -95
- package/doc/public/static/examples/assets/tralis-live-map/s8kreis.svg +0 -93
- package/doc/public/static/examples/assets/tralis-live-map/unknown.svg +0 -107
- package/doc/public/static/examples/layers.html +0 -11
- package/doc/public/static/examples/layers.js +0 -97
- package/doc/public/static/examples/mb-copyright.html +0 -26
- package/doc/public/static/examples/mb-copyright.js +0 -37
- package/doc/public/static/examples/mb-tracker.html +0 -1
- package/doc/public/static/examples/mb-tracker.js +0 -40
- package/doc/public/static/examples/mb-tracker.md +0 -1
- package/doc/public/static/examples/mb-tralis.html +0 -1
- package/doc/public/static/examples/mb-tralis.js +0 -34
- package/doc/public/static/examples/ol-copyright.html +0 -26
- package/doc/public/static/examples/ol-copyright.js +0 -43
- package/doc/public/static/examples/ol-mapbox-layer.html +0 -1
- package/doc/public/static/examples/ol-mapbox-layer.js +0 -28
- package/doc/public/static/examples/ol-mapbox-style-layer.html +0 -12
- package/doc/public/static/examples/ol-mapbox-style-layer.js +0 -48
- package/doc/public/static/examples/ol-query.html +0 -32
- package/doc/public/static/examples/ol-query.js +0 -83
- package/doc/public/static/examples/ol-routing.html +0 -26
- package/doc/public/static/examples/ol-routing.js +0 -65
- package/doc/public/static/examples/ol-routing.md +0 -1
- package/doc/public/static/examples/ol-stop-finder.html +0 -15
- package/doc/public/static/examples/ol-stop-finder.js +0 -35
- package/doc/public/static/examples/ol-stop-finder.md +0 -1
- package/doc/public/static/examples/ol-tracker.html +0 -1
- package/doc/public/static/examples/ol-tracker.js +0 -41
- package/doc/public/static/examples/ol-tracker.md +0 -1
- package/doc/public/static/examples/ol-tralis.html +0 -5
- package/doc/public/static/examples/ol-tralis.js +0 -62
- package/doc/public/static/examples/tralis-live-map.html +0 -1
- package/doc/public/static/examples/tralis-live-map.js +0 -67
- package/doc/public/static/examples/tralis-live-map.md +0 -3
- package/doc/public/static/img/live_tracker_mb.jpg +0 -0
- package/doc/public/static/img/live_tracker_munich.jpg +0 -0
- package/doc/public/static/img/live_tracker_ol.jpg +0 -0
- package/doc/public/static/img/mapbox.jpg +0 -0
- package/doc/public/static/img/mapbox_style.jpg +0 -0
- package/doc/public/static/img/ol-copyright.png +0 -0
- package/doc/public/static/img/query_objects.jpg +0 -0
- package/doc/public/static/img/routing.jpg +0 -0
- package/doc/public/static/img/simple_map.jpg +0 -0
- package/doc/public/static/img/stops.jpg +0 -0
- package/doc/public/vercel.svg +0 -4
- package/doc/src/components/CodeSandboxButton.js +0 -102
- package/doc/src/components/Documentation.js +0 -42
- package/doc/src/components/Esdoc/Anchor.js +0 -57
- package/doc/src/components/Esdoc/ClassDoc.js +0 -272
- package/doc/src/components/Esdoc/DeprecatedHTML.js +0 -16
- package/doc/src/components/Esdoc/DetailDocs.js +0 -279
- package/doc/src/components/Esdoc/DetailHTML.js +0 -33
- package/doc/src/components/Esdoc/DirectSubclassHTML.js +0 -30
- package/doc/src/components/Esdoc/DocBuilderUtils.js +0 -697
- package/doc/src/components/Esdoc/DocLinkHTML.js +0 -63
- package/doc/src/components/Esdoc/DocsLinkHTML.js +0 -38
- package/doc/src/components/Esdoc/Esdoc.js +0 -63
- package/doc/src/components/Esdoc/EsdocContent.js +0 -56
- package/doc/src/components/Esdoc/EsdocNavigation.js +0 -13
- package/doc/src/components/Esdoc/EsdocSearch.js +0 -78
- package/doc/src/components/Esdoc/ExperimentalHTML.js +0 -17
- package/doc/src/components/Esdoc/ExtendsChainHTML.js +0 -32
- package/doc/src/components/Esdoc/FileDocLinkHTML.js +0 -62
- package/doc/src/components/Esdoc/IdentifiersDoc.js +0 -113
- package/doc/src/components/Esdoc/IndirectSubclassHTML.js +0 -30
- package/doc/src/components/Esdoc/InheritedSummaryDoc.js +0 -70
- package/doc/src/components/Esdoc/InheritedSummaryHTML.js +0 -38
- package/doc/src/components/Esdoc/MixinClassesHTML.js +0 -29
- package/doc/src/components/Esdoc/NavDoc.js +0 -112
- package/doc/src/components/Esdoc/OverrideMethod.js +0 -44
- package/doc/src/components/Esdoc/OverrideMethodDescription.js +0 -35
- package/doc/src/components/Esdoc/Properties.js +0 -89
- package/doc/src/components/Esdoc/README.md +0 -45
- package/doc/src/components/Esdoc/SignatureHTML.js +0 -123
- package/doc/src/components/Esdoc/SingleDoc.js +0 -31
- package/doc/src/components/Esdoc/SummaryDoc.js +0 -160
- package/doc/src/components/Esdoc/SummaryHTML.js +0 -96
- package/doc/src/components/Esdoc/TypeDocLinkHTML.js +0 -251
- package/doc/src/components/Esdoc/index.js +0 -7
- package/doc/src/components/Esdoc/taffydb.js +0 -2070
- package/doc/src/components/Example.js +0 -200
- package/doc/src/components/ExampleCard.js +0 -126
- package/doc/src/components/Examples.js +0 -78
- package/doc/src/components/Home.js +0 -121
- package/doc/src/components/TrackerExample.js +0 -39
- package/doc/src/examples.js +0 -117
- package/doc/styles/App.scss +0 -53
- package/doc/styles/identifiers.css +0 -38
- package/doc/styles/search.css +0 -76
- package/doc/styles/style.css +0 -603
- package/esdoc/README.md +0 -27
- package/esdoc/plugins/MyPlugin.js +0 -69
- package/esdoc/plugins/dynamic-property-plugin/Plugin.js +0 -50
- package/esdoc/plugins/externals-plugin/Plugin.js +0 -45
- package/esdoc/plugins/externals-plugin/externals.js +0 -93
- package/esdoc/plugins/optional-chaining-plugin/Plugin.js +0 -8
- package/global-setup.js +0 -3
- package/jest.config.js +0 -24
- package/pull_request_template.md +0 -17
- package/scripts/read-pkg-json.js +0 -22
- package/src/api/RealtimeAPI.test.js +0 -144
- package/src/api/RealtimeAPI.ts +0 -712
- package/src/api/RoutingAPI.test.js +0 -41
- package/src/api/RoutingAPI.ts +0 -47
- package/src/api/StopsAPI.test.js +0 -34
- package/src/api/StopsAPI.ts +0 -45
- package/src/common/api/HttpAPI.test.js +0 -68
- package/src/common/api/HttpAPI.ts +0 -77
- package/src/common/api/WebSocketAPI.test.js +0 -421
- package/src/common/api/WebSocketAPI.ts +0 -515
- package/src/common/controls/ControlCommon.test.js +0 -106
- package/src/common/controls/ControlCommon.ts +0 -194
- package/src/common/controls/CopyrightControlCommon.ts +0 -41
- package/src/common/controls/StopFinderControlCommon.ts +0 -192
- package/src/common/layers/LayerCommon.test.js +0 -158
- package/src/common/layers/LayerCommon.ts +0 -321
- package/src/common/mixins/RealtimeLayerMixin.ts +0 -1168
- package/src/common/mixins/UserInteractionsLayerMixin.test.js +0 -227
- package/src/common/mixins/UserInteractionsLayerMixin.ts +0 -352
- package/src/common/styles/realtimeDefaultStyle.ts +0 -436
- package/src/common/styles/realtimeDelayStyle.ts +0 -27
- package/src/common/styles/realtimeHeadingStyle.ts +0 -138
- package/src/common/styles/realtimeSimpleStyle.ts +0 -25
- package/src/common/utils/compareDepartures.ts +0 -46
- package/src/common/utils/createCanvas.ts +0 -33
- package/src/common/utils/createRealtimeFilters.test.js +0 -100
- package/src/common/utils/createRealtimeFilters.ts +0 -96
- package/src/common/utils/debounceDeparturesMessages.ts +0 -52
- package/src/common/utils/debounceWebsocketMessages.ts +0 -47
- package/src/common/utils/getLayersAsFlatArray.ts +0 -17
- package/src/common/utils/getMapboxMapCopyrights.test.js +0 -47
- package/src/common/utils/getMapboxMapCopyrights.ts +0 -52
- package/src/common/utils/getMapboxRender.ts +0 -104
- package/src/common/utils/getMaplibreRender.ts +0 -54
- package/src/common/utils/getUrlWithParams.ts +0 -21
- package/src/common/utils/getVehiclePosition.ts +0 -92
- package/src/common/utils/realtimeConfig.test.js +0 -57
- package/src/common/utils/realtimeConfig.ts +0 -228
- package/src/common/utils/removeDuplicate.test.js +0 -22
- package/src/common/utils/removeDuplicate.ts +0 -22
- package/src/common/utils/renderTrajectories.ts +0 -194
- package/src/common/utils/sortAndFilterDepartures.ts +0 -78
- package/src/common/utils/sortByDelay.ts +0 -29
- package/src/common/utils/timeUtils.test.js +0 -16
- package/src/common/utils/timeUtils.ts +0 -45
- package/src/index.js +0 -10
- package/src/mapbox/layers/Layer.test.js +0 -217
- package/src/mapbox/layers/Layer.ts +0 -144
- package/src/mapbox/layers/RealtimeLayer.test.js +0 -13
- package/src/mapbox/layers/RealtimeLayer.ts +0 -350
- package/src/mapbox/utils/getMercatorResolution.ts +0 -21
- package/src/mapbox/utils/getSourceCoordinates.ts +0 -34
- package/src/ol/README.md +0 -0
- package/src/ol/controls/CopyrightControl.test.js +0 -211
- package/src/ol/controls/CopyrightControl.ts +0 -82
- package/src/ol/controls/RoutingControl.test.js +0 -205
- package/src/ol/controls/RoutingControl.ts +0 -869
- package/src/ol/controls/StopFinderControl.test.js +0 -59
- package/src/ol/controls/snapshots/RoutingControlRouteGen10.json +0 -58
- package/src/ol/controls/snapshots/RoutingControlRouteGen100.json +0 -292
- package/src/ol/controls/snapshots/RoutingControlRouteGen30.json +0 -69
- package/src/ol/controls/snapshots/RoutingControlRouteGen5.json +0 -58
- package/src/ol/controls/snapshots/RoutingControlRouteOSM.json +0 -759
- package/src/ol/controls/snapshots/RoutingControlStation1.json +0 -60
- package/src/ol/controls/snapshots/RoutingControlStation2.json +0 -49
- package/src/ol/layers/Layer.test.js +0 -212
- package/src/ol/layers/Layer.ts +0 -252
- package/src/ol/layers/MapGlLayer.ts +0 -294
- package/src/ol/layers/MapboxLayer.test.js +0 -190
- package/src/ol/layers/MapboxLayer.ts +0 -136
- package/src/ol/layers/MapboxStyleLayer.test.js +0 -258
- package/src/ol/layers/MapboxStyleLayer.ts +0 -466
- package/src/ol/layers/RealtimeLayer.test.js +0 -84
- package/src/ol/layers/RealtimeLayer.ts +0 -465
- package/src/ol/layers/RoutingLayer.test.js +0 -48
- package/src/ol/layers/RoutingLayer.ts +0 -113
- package/src/ol/layers/VectorLayer.test.js +0 -87
- package/src/ol/layers/VectorLayer.ts +0 -48
- package/src/ol/layers/WMSLayer.test.js +0 -65
- package/src/ol/layers/WMSLayer.ts +0 -114
- package/src/ol/styles/fullTrajectoryDelayStyle.ts +0 -37
- package/src/ol/styles/fullTrajectoryStyle.ts +0 -56
- package/tsconfig.json +0 -23
- /package/{src/api → api}/index.js +0 -0
- /package/{src/common → common}/index.js +0 -0
- /package/{src/common → common}/styles/index.js +0 -0
- /package/{src/mapbox → mapbox}/controls/index.js +0 -0
- /package/{src/mapbox → mapbox}/index.js +0 -0
- /package/{src/mapbox → mapbox}/layers/index.js +0 -0
- /package/{src/mapbox → mapbox}/utils/index.js +0 -0
- /package/{src/ol → ol}/controls/index.js +0 -0
- /package/{src/ol → ol}/index.js +0 -0
- /package/{src/ol → ol}/layers/index.js +0 -0
- /package/{src/ol → ol}/styles/index.js +0 -0
- /package/{src/types → types}/common.d.ts +0 -0
- /package/{src/types → types}/index.d.ts +0 -0
- /package/{src/types → types}/realtime.d.ts +0 -0
- /package/{src/types → types}/routing.d.ts +0 -0
- /package/{src/types → types}/stops.d.ts +0 -0
|
@@ -1,436 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
RealtimeTrajectory,
|
|
3
|
-
ViewState,
|
|
4
|
-
StyleCache,
|
|
5
|
-
RealtimeStyleOptions,
|
|
6
|
-
RealtimeStyleFunction,
|
|
7
|
-
} from '../../types';
|
|
8
|
-
import createCanvas from '../utils/createCanvas';
|
|
9
|
-
|
|
10
|
-
/** @private */
|
|
11
|
-
const cacheDelayBg: StyleCache = {};
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Draw circle delay background
|
|
15
|
-
*
|
|
16
|
-
* @private
|
|
17
|
-
*/
|
|
18
|
-
export const getDelayBgCanvas = (
|
|
19
|
-
origin: number,
|
|
20
|
-
radius: number,
|
|
21
|
-
color: string,
|
|
22
|
-
) => {
|
|
23
|
-
const key = `${origin}, ${radius}, ${color}`;
|
|
24
|
-
if (!cacheDelayBg[key]) {
|
|
25
|
-
const canvas = createCanvas(origin * 2, origin * 2);
|
|
26
|
-
if (canvas) {
|
|
27
|
-
const ctx = canvas.getContext('2d');
|
|
28
|
-
if (!ctx) {
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
ctx.beginPath();
|
|
32
|
-
ctx.arc(origin, origin, radius, 0, 2 * Math.PI, false);
|
|
33
|
-
ctx.fillStyle = color;
|
|
34
|
-
ctx.filter = 'blur(1px)';
|
|
35
|
-
ctx.fill();
|
|
36
|
-
cacheDelayBg[key] = canvas;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return cacheDelayBg[key];
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
/** @private */
|
|
43
|
-
const cacheDelayText: StyleCache = {};
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Draw delay text
|
|
47
|
-
*
|
|
48
|
-
* @private
|
|
49
|
-
*/
|
|
50
|
-
export const getDelayTextCanvas = (
|
|
51
|
-
text: string,
|
|
52
|
-
fontSize: number,
|
|
53
|
-
font: string,
|
|
54
|
-
delayColor: string,
|
|
55
|
-
delayOutlineColor: string = '#000',
|
|
56
|
-
pixelRatio: number = 1,
|
|
57
|
-
) => {
|
|
58
|
-
const key = `${text}, ${font}, ${delayColor}, ${delayOutlineColor}, ${pixelRatio}`;
|
|
59
|
-
if (!cacheDelayText[key]) {
|
|
60
|
-
const canvas = createCanvas(
|
|
61
|
-
Math.ceil(text.length * fontSize),
|
|
62
|
-
Math.ceil(fontSize + 8 * pixelRatio),
|
|
63
|
-
);
|
|
64
|
-
if (canvas) {
|
|
65
|
-
const ctx = canvas.getContext('2d') as CanvasRenderingContext2D;
|
|
66
|
-
if (!ctx) {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
ctx.font = font;
|
|
70
|
-
ctx.textAlign = 'left';
|
|
71
|
-
ctx.textBaseline = 'middle';
|
|
72
|
-
ctx.font = font;
|
|
73
|
-
ctx.fillStyle = delayColor;
|
|
74
|
-
ctx.strokeStyle = delayOutlineColor;
|
|
75
|
-
ctx.lineWidth = 1.5 * pixelRatio;
|
|
76
|
-
ctx.strokeText(text, 0, fontSize);
|
|
77
|
-
ctx.fillText(text, 0, fontSize);
|
|
78
|
-
cacheDelayText[key] = canvas;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return cacheDelayText[key];
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
/** @private */
|
|
85
|
-
const cacheCircle: StyleCache = {};
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Draw colored circle with black border
|
|
89
|
-
*
|
|
90
|
-
* @private
|
|
91
|
-
*/
|
|
92
|
-
export const getCircleCanvas = (
|
|
93
|
-
origin: number,
|
|
94
|
-
radius: number,
|
|
95
|
-
color: string,
|
|
96
|
-
hasStroke: boolean,
|
|
97
|
-
hasDash: boolean,
|
|
98
|
-
pixelRatio: number,
|
|
99
|
-
) => {
|
|
100
|
-
const key = `${origin}, ${radius}, ${color}, ${hasStroke}, ${hasDash}, ${pixelRatio}`;
|
|
101
|
-
if (!cacheCircle[key]) {
|
|
102
|
-
const canvas = createCanvas(origin * 2, origin * 2);
|
|
103
|
-
if (canvas) {
|
|
104
|
-
const ctx = canvas.getContext('2d');
|
|
105
|
-
if (!ctx) {
|
|
106
|
-
return null;
|
|
107
|
-
}
|
|
108
|
-
ctx.fillStyle = color;
|
|
109
|
-
|
|
110
|
-
if (hasStroke) {
|
|
111
|
-
ctx.lineWidth = 1 * pixelRatio;
|
|
112
|
-
ctx.strokeStyle = '#000000';
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
ctx.beginPath();
|
|
116
|
-
ctx.arc(origin, origin, radius, 0, 2 * Math.PI, false);
|
|
117
|
-
ctx.fill();
|
|
118
|
-
|
|
119
|
-
if (hasDash) {
|
|
120
|
-
ctx.setLineDash([5, 3]);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
if (hasStroke) {
|
|
124
|
-
ctx.stroke();
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
cacheCircle[key] = canvas;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
return cacheCircle[key];
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
/** @private */
|
|
134
|
-
const cacheText: StyleCache = {};
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Draw text in the circle
|
|
138
|
-
*
|
|
139
|
-
* @private
|
|
140
|
-
*/
|
|
141
|
-
export const getTextCanvas = (
|
|
142
|
-
text: string,
|
|
143
|
-
origin: number,
|
|
144
|
-
textSize: number,
|
|
145
|
-
fillColor: string,
|
|
146
|
-
strokeColor: string,
|
|
147
|
-
hasStroke: boolean,
|
|
148
|
-
pixelRatio: number,
|
|
149
|
-
getTextFont: (fontSize: number, text?: string) => string,
|
|
150
|
-
) => {
|
|
151
|
-
const key = `${text}, ${origin}, ${textSize}, ${fillColor},${strokeColor}, ${hasStroke}, ${pixelRatio}`;
|
|
152
|
-
if (!cacheText[key]) {
|
|
153
|
-
const canvas = createCanvas(origin * 2, origin * 2);
|
|
154
|
-
if (canvas) {
|
|
155
|
-
const ctx = canvas.getContext('2d');
|
|
156
|
-
if (!ctx) {
|
|
157
|
-
return null;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
// Draw a stroke to the text only if a provider provides realtime but we don't use it.
|
|
161
|
-
if (hasStroke) {
|
|
162
|
-
ctx.save();
|
|
163
|
-
ctx.textBaseline = 'middle';
|
|
164
|
-
ctx.textAlign = 'center';
|
|
165
|
-
ctx.font = getTextFont(textSize + 2, text);
|
|
166
|
-
ctx.strokeStyle = strokeColor;
|
|
167
|
-
ctx.strokeText(text, origin, origin);
|
|
168
|
-
ctx.restore();
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// Draw a text
|
|
172
|
-
ctx.textBaseline = 'middle';
|
|
173
|
-
ctx.textAlign = 'center';
|
|
174
|
-
ctx.fillStyle = fillColor;
|
|
175
|
-
ctx.font = getTextFont(textSize, text);
|
|
176
|
-
ctx.strokeStyle = strokeColor;
|
|
177
|
-
ctx.strokeText(text, origin, origin);
|
|
178
|
-
ctx.fillText(text, origin, origin);
|
|
179
|
-
|
|
180
|
-
cacheText[key] = canvas;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
return cacheText[key];
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
/** @private */
|
|
187
|
-
const cache: StyleCache = {};
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* A tracker style that take in account the delay.
|
|
191
|
-
*
|
|
192
|
-
* @param {RealtimeTrajectory} trajectory The trajectory to render.
|
|
193
|
-
* @param {ViewState} viewState The view state of the map.
|
|
194
|
-
* @param {RealtimeStyleOptions} options Some options to change the rendering
|
|
195
|
-
* @return a canvas
|
|
196
|
-
*/
|
|
197
|
-
const realtimeDefaultStyle: RealtimeStyleFunction = (
|
|
198
|
-
trajectory: RealtimeTrajectory,
|
|
199
|
-
viewState: ViewState,
|
|
200
|
-
options: RealtimeStyleOptions,
|
|
201
|
-
) => {
|
|
202
|
-
const {
|
|
203
|
-
hoverVehicleId,
|
|
204
|
-
selectedVehicleId,
|
|
205
|
-
useDelayStyle,
|
|
206
|
-
delayOutlineColor = '#000',
|
|
207
|
-
delayDisplay = 300000,
|
|
208
|
-
getRadius = () => 0,
|
|
209
|
-
getBgColor = () => '#000',
|
|
210
|
-
getDelayColor = () => '#000',
|
|
211
|
-
getDelayText = () => null,
|
|
212
|
-
getDelayFont = (fontSize: number) => `bold ${fontSize}px arial, sans-serif`,
|
|
213
|
-
getText = (text?: string) => text,
|
|
214
|
-
getTextFont = (fontSize: number) => `bold ${fontSize}px arial, sans-serif`,
|
|
215
|
-
getTextColor = () => '#000',
|
|
216
|
-
getTextSize = () => 14,
|
|
217
|
-
getMaxRadiusForText = () => 10,
|
|
218
|
-
getMaxRadiusForStrokeAndDelay = () => 7,
|
|
219
|
-
} = options;
|
|
220
|
-
|
|
221
|
-
const { zoom, pixelRatio = 1 } = viewState;
|
|
222
|
-
let { type } = trajectory.properties;
|
|
223
|
-
const {
|
|
224
|
-
train_id: id,
|
|
225
|
-
line,
|
|
226
|
-
delay,
|
|
227
|
-
state,
|
|
228
|
-
operator_provides_realtime_journey: operatorProvidesRealtime,
|
|
229
|
-
} = trajectory.properties;
|
|
230
|
-
let { name, text_color: textColor, color } = line || {};
|
|
231
|
-
|
|
232
|
-
name = getText(name);
|
|
233
|
-
|
|
234
|
-
const cancelled = state === 'JOURNEY_CANCELLED';
|
|
235
|
-
|
|
236
|
-
if (!type) {
|
|
237
|
-
type = 'Rail';
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
if (!name) {
|
|
241
|
-
name = 'I';
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
if (!textColor) {
|
|
245
|
-
textColor = '#000000';
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
if (color && color[0] !== '#') {
|
|
249
|
-
color = `#${color}`;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
if (textColor[0] !== '#') {
|
|
253
|
-
textColor = `#${textColor}`;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
const z = Math.min(Math.floor(zoom || 1), 16);
|
|
257
|
-
const hover = !!(hoverVehicleId && hoverVehicleId === id);
|
|
258
|
-
const selected = !!(selectedVehicleId && selectedVehicleId === id);
|
|
259
|
-
|
|
260
|
-
// Calcul the radius of the circle
|
|
261
|
-
let radius = getRadius(type, z) * pixelRatio;
|
|
262
|
-
const isDisplayStrokeAndDelay =
|
|
263
|
-
radius >= getMaxRadiusForStrokeAndDelay() * pixelRatio;
|
|
264
|
-
|
|
265
|
-
if (hover || selected) {
|
|
266
|
-
radius = isDisplayStrokeAndDelay
|
|
267
|
-
? radius + 5 * pixelRatio
|
|
268
|
-
: 14 * pixelRatio;
|
|
269
|
-
}
|
|
270
|
-
const isDisplayText = radius > getMaxRadiusForText() * pixelRatio;
|
|
271
|
-
|
|
272
|
-
// Optimize the cache key, very important in high zoom level
|
|
273
|
-
let key = `${radius}${hover || selected}`;
|
|
274
|
-
|
|
275
|
-
if (useDelayStyle) {
|
|
276
|
-
key += `${operatorProvidesRealtime}${delay}`;
|
|
277
|
-
|
|
278
|
-
if (isDisplayStrokeAndDelay) {
|
|
279
|
-
key += `${cancelled}`;
|
|
280
|
-
}
|
|
281
|
-
} else {
|
|
282
|
-
key += `${color || type}`;
|
|
283
|
-
|
|
284
|
-
if (isDisplayStrokeAndDelay) {
|
|
285
|
-
key += `${cancelled}${delay}`;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
if (isDisplayText) {
|
|
290
|
-
key += `${name}${textColor}`;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
if (!cache[key]) {
|
|
294
|
-
if (radius === 0) {
|
|
295
|
-
return null;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
const margin = 1 * pixelRatio;
|
|
299
|
-
const radiusDelay = radius + 2 * pixelRatio;
|
|
300
|
-
const markerSize = radius * 2;
|
|
301
|
-
const size = radiusDelay * 2 + margin * 2;
|
|
302
|
-
const origin = size / 2;
|
|
303
|
-
|
|
304
|
-
// Draw circle delay background
|
|
305
|
-
let delayBg = null;
|
|
306
|
-
if (isDisplayStrokeAndDelay && delay !== null) {
|
|
307
|
-
delayBg = getDelayBgCanvas(
|
|
308
|
-
origin,
|
|
309
|
-
radiusDelay,
|
|
310
|
-
getDelayColor(delay, cancelled),
|
|
311
|
-
);
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
// Show delay if feature is hovered or if delay is above 5mins.
|
|
315
|
-
let delayText = null;
|
|
316
|
-
let fontSize = 0;
|
|
317
|
-
if (
|
|
318
|
-
isDisplayStrokeAndDelay &&
|
|
319
|
-
(hover || (delay || 0) >= delayDisplay || cancelled)
|
|
320
|
-
) {
|
|
321
|
-
// Draw delay text
|
|
322
|
-
fontSize =
|
|
323
|
-
Math.max(
|
|
324
|
-
cancelled ? 19 : 14,
|
|
325
|
-
Math.min(cancelled ? 19 : 17, radius * 1.2),
|
|
326
|
-
) * pixelRatio;
|
|
327
|
-
const text = getDelayText(delay, cancelled);
|
|
328
|
-
|
|
329
|
-
if (text) {
|
|
330
|
-
delayText = getDelayTextCanvas(
|
|
331
|
-
text,
|
|
332
|
-
fontSize,
|
|
333
|
-
getDelayFont(fontSize, text),
|
|
334
|
-
getDelayColor(delay, cancelled, true),
|
|
335
|
-
delayOutlineColor,
|
|
336
|
-
pixelRatio,
|
|
337
|
-
);
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
// Draw colored circle with black border
|
|
342
|
-
let circleFillColor;
|
|
343
|
-
if (useDelayStyle) {
|
|
344
|
-
circleFillColor = getDelayColor(delay, cancelled);
|
|
345
|
-
} else {
|
|
346
|
-
circleFillColor = color || getBgColor(type);
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
const hasStroke = isDisplayStrokeAndDelay || hover || selected;
|
|
350
|
-
|
|
351
|
-
const hasDash =
|
|
352
|
-
!!isDisplayStrokeAndDelay &&
|
|
353
|
-
!!useDelayStyle &&
|
|
354
|
-
delay === null &&
|
|
355
|
-
operatorProvidesRealtime === 'yes';
|
|
356
|
-
|
|
357
|
-
const circle = getCircleCanvas(
|
|
358
|
-
origin,
|
|
359
|
-
radius,
|
|
360
|
-
circleFillColor,
|
|
361
|
-
hasStroke,
|
|
362
|
-
hasDash,
|
|
363
|
-
pixelRatio,
|
|
364
|
-
);
|
|
365
|
-
|
|
366
|
-
// Create the canvas
|
|
367
|
-
const width = size + (delayText?.width || 0) * 2;
|
|
368
|
-
const height = size;
|
|
369
|
-
const canvas = createCanvas(width, height);
|
|
370
|
-
if (canvas) {
|
|
371
|
-
const ctx = canvas.getContext('2d') as CanvasRenderingContext2D;
|
|
372
|
-
if (!ctx) {
|
|
373
|
-
return null;
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
// The renderTrajectories will center the image on the vehicle positions.
|
|
377
|
-
const originX = delayText?.width || 0;
|
|
378
|
-
|
|
379
|
-
if (delayBg) {
|
|
380
|
-
ctx.drawImage(delayBg, originX, 0);
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
if (circle) {
|
|
384
|
-
ctx.drawImage(circle, originX, 0);
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
// Draw text in the circle
|
|
388
|
-
let circleText = null;
|
|
389
|
-
if (isDisplayText) {
|
|
390
|
-
const fontSize2 = Math.max(radius, 10);
|
|
391
|
-
const textSize = getTextSize(
|
|
392
|
-
ctx,
|
|
393
|
-
markerSize,
|
|
394
|
-
name,
|
|
395
|
-
fontSize2,
|
|
396
|
-
getTextFont,
|
|
397
|
-
);
|
|
398
|
-
const textColor2 = !useDelayStyle
|
|
399
|
-
? textColor || getTextColor(type)
|
|
400
|
-
: '#000000';
|
|
401
|
-
const hasStroke2 =
|
|
402
|
-
!!useDelayStyle &&
|
|
403
|
-
delay === null &&
|
|
404
|
-
operatorProvidesRealtime === 'yes';
|
|
405
|
-
|
|
406
|
-
circleText = getTextCanvas(
|
|
407
|
-
name,
|
|
408
|
-
origin,
|
|
409
|
-
textSize,
|
|
410
|
-
textColor2,
|
|
411
|
-
circleFillColor,
|
|
412
|
-
hasStroke2,
|
|
413
|
-
pixelRatio,
|
|
414
|
-
getTextFont,
|
|
415
|
-
);
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
if (circleText) {
|
|
419
|
-
ctx.drawImage(circleText, originX, 0);
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
if (delayText) {
|
|
423
|
-
ctx.drawImage(
|
|
424
|
-
delayText,
|
|
425
|
-
originX + Math.ceil(origin + radiusDelay) + margin,
|
|
426
|
-
Math.ceil(origin - fontSize),
|
|
427
|
-
);
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
cache[key] = canvas;
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
return cache[key];
|
|
435
|
-
};
|
|
436
|
-
export default realtimeDefaultStyle;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import realtimeDefaultStyle from './realtimeDefaultStyle';
|
|
2
|
-
|
|
3
|
-
import type {
|
|
4
|
-
RealtimeTrajectory,
|
|
5
|
-
ViewState,
|
|
6
|
-
RealtimeStyleOptions,
|
|
7
|
-
RealtimeStyleFunction,
|
|
8
|
-
} from '../../types';
|
|
9
|
-
/**
|
|
10
|
-
* A tracker style that display the delay as backgroundColor.
|
|
11
|
-
*
|
|
12
|
-
* @param {*} trajectory The trajectory to render.
|
|
13
|
-
* @param {*} viewState The view state of the map.
|
|
14
|
-
* @param {*} options Some options to change the rendering
|
|
15
|
-
* @return a canvas
|
|
16
|
-
*/
|
|
17
|
-
const realtimeDelayStyle: RealtimeStyleFunction = (
|
|
18
|
-
trajectory: RealtimeTrajectory,
|
|
19
|
-
viewState: ViewState,
|
|
20
|
-
options: RealtimeStyleOptions,
|
|
21
|
-
) => {
|
|
22
|
-
return realtimeDefaultStyle(trajectory, viewState, {
|
|
23
|
-
...options,
|
|
24
|
-
useDelayStyle: true,
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
export default realtimeDelayStyle;
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
RealtimeTrajectory,
|
|
3
|
-
ViewState,
|
|
4
|
-
RealtimeStyleOptions,
|
|
5
|
-
RealtimeStyleFunction,
|
|
6
|
-
AnyCanvas,
|
|
7
|
-
} from '../../types';
|
|
8
|
-
import createCanvas from '../utils/createCanvas';
|
|
9
|
-
import { getBgColor } from '../utils/realtimeConfig';
|
|
10
|
-
import realtimeDefaultStyle from './realtimeDefaultStyle';
|
|
11
|
-
|
|
12
|
-
/** @private */
|
|
13
|
-
const rotateCanvas = (canvas: AnyCanvas, rotation: number) => {
|
|
14
|
-
const ctx = canvas.getContext('2d');
|
|
15
|
-
ctx?.translate(canvas.width / 2, canvas.height / 2);
|
|
16
|
-
ctx?.rotate(rotation);
|
|
17
|
-
ctx?.translate(-canvas.width / 2, -canvas.height / 2);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
/** @private */
|
|
21
|
-
const arrowCache: {
|
|
22
|
-
[key: string]: AnyCanvas | null;
|
|
23
|
-
} = {};
|
|
24
|
-
|
|
25
|
-
/** @private */
|
|
26
|
-
const getArrowCanvas = (fillColor: string): AnyCanvas | null => {
|
|
27
|
-
const key = `${fillColor}`;
|
|
28
|
-
if (!arrowCache[key]) {
|
|
29
|
-
// Create the arrow canvas
|
|
30
|
-
const arrowCanvas = createCanvas(20, 20);
|
|
31
|
-
const ctx = arrowCanvas?.getContext('2d');
|
|
32
|
-
if (ctx) {
|
|
33
|
-
ctx.fillStyle = fillColor;
|
|
34
|
-
ctx.beginPath();
|
|
35
|
-
ctx.moveTo(5, 5);
|
|
36
|
-
ctx.lineTo(10, 10);
|
|
37
|
-
ctx.lineTo(5, 15);
|
|
38
|
-
ctx.fill();
|
|
39
|
-
ctx.beginPath();
|
|
40
|
-
ctx.moveTo(5, 5);
|
|
41
|
-
ctx.lineTo(10, 10);
|
|
42
|
-
ctx.lineTo(5, 15);
|
|
43
|
-
ctx.lineTo(5, 5);
|
|
44
|
-
ctx.stroke();
|
|
45
|
-
}
|
|
46
|
-
arrowCache[key] = arrowCanvas;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return arrowCache[key];
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
/** @private */
|
|
53
|
-
const bufferArrowCache: {
|
|
54
|
-
[key: string]: AnyCanvas | null;
|
|
55
|
-
} = {};
|
|
56
|
-
|
|
57
|
-
/** @private */
|
|
58
|
-
const getBufferArrowCanvas = (
|
|
59
|
-
canvas: AnyCanvas,
|
|
60
|
-
fillColor: string,
|
|
61
|
-
rotation: number,
|
|
62
|
-
): AnyCanvas | null => {
|
|
63
|
-
const margin = 20;
|
|
64
|
-
const bufferKey = `${fillColor},${canvas.width},${canvas.height},${rotation}`;
|
|
65
|
-
if (!bufferArrowCache[bufferKey]) {
|
|
66
|
-
// Create a buffer canvas around the current vehicle to display properly the arrow
|
|
67
|
-
const buffer = createCanvas(
|
|
68
|
-
canvas.width + margin * 2,
|
|
69
|
-
canvas.height + margin * 2,
|
|
70
|
-
);
|
|
71
|
-
const arrowCanvas = getArrowCanvas(fillColor);
|
|
72
|
-
if (arrowCanvas && buffer) {
|
|
73
|
-
const bufferCtx = buffer.getContext('2d');
|
|
74
|
-
bufferCtx?.drawImage(
|
|
75
|
-
arrowCanvas,
|
|
76
|
-
buffer.width - margin,
|
|
77
|
-
buffer.height / 2 - arrowCanvas.height / 2,
|
|
78
|
-
arrowCanvas.width,
|
|
79
|
-
arrowCanvas.height,
|
|
80
|
-
);
|
|
81
|
-
bufferCtx?.save();
|
|
82
|
-
const rot = rotation + (90 * Math.PI) / 180;
|
|
83
|
-
rotateCanvas(buffer, -rot);
|
|
84
|
-
bufferCtx?.restore();
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
bufferArrowCache[bufferKey] = buffer;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return bufferArrowCache[bufferKey];
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* A tracker style that take in account the delay.
|
|
95
|
-
*
|
|
96
|
-
* @param {RealtimeTrajectory} trajectory The trajectory to render.
|
|
97
|
-
* @param {ViewState} viewState The view state of the map.
|
|
98
|
-
* @param {RealtimeStyleOptions} options Some options to change the rendering
|
|
99
|
-
* @return a canvas
|
|
100
|
-
*/
|
|
101
|
-
const realtimeHeadingStyle: RealtimeStyleFunction = (
|
|
102
|
-
trajectory: RealtimeTrajectory,
|
|
103
|
-
viewState: ViewState,
|
|
104
|
-
options: RealtimeStyleOptions,
|
|
105
|
-
) => {
|
|
106
|
-
// @ts-ignore
|
|
107
|
-
const { rotation, type, line } = trajectory.properties;
|
|
108
|
-
const { color } = line || {};
|
|
109
|
-
|
|
110
|
-
const canvas = realtimeDefaultStyle(trajectory, viewState, options);
|
|
111
|
-
|
|
112
|
-
if (canvas && rotation !== null) {
|
|
113
|
-
const circleFillColor = color || getBgColor(type);
|
|
114
|
-
const bufferArrow = getBufferArrowCanvas(canvas, circleFillColor, rotation);
|
|
115
|
-
if (bufferArrow) {
|
|
116
|
-
const bufferSize = (bufferArrow.width - canvas.width) / 2;
|
|
117
|
-
const vehicleWithArrow = createCanvas(
|
|
118
|
-
bufferArrow.width,
|
|
119
|
-
bufferArrow.height,
|
|
120
|
-
);
|
|
121
|
-
vehicleWithArrow
|
|
122
|
-
?.getContext('2d')
|
|
123
|
-
?.drawImage(bufferArrow, 0, 0, bufferArrow.width, bufferArrow.height);
|
|
124
|
-
vehicleWithArrow
|
|
125
|
-
?.getContext('2d')
|
|
126
|
-
?.drawImage(
|
|
127
|
-
canvas,
|
|
128
|
-
bufferSize,
|
|
129
|
-
bufferSize,
|
|
130
|
-
canvas.width,
|
|
131
|
-
canvas.height,
|
|
132
|
-
);
|
|
133
|
-
return vehicleWithArrow;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
return canvas;
|
|
137
|
-
};
|
|
138
|
-
export default realtimeHeadingStyle;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { AnyCanvas, RealtimeStyleFunction } from '../../types';
|
|
2
|
-
import createCanvas from '../utils/createCanvas';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* A very simple tracker style.
|
|
6
|
-
* Display blue point for each train.
|
|
7
|
-
*/
|
|
8
|
-
let canvas: AnyCanvas | null;
|
|
9
|
-
const realtimeSimpleStyle: RealtimeStyleFunction = () => {
|
|
10
|
-
if (!canvas) {
|
|
11
|
-
canvas = createCanvas(15, 15);
|
|
12
|
-
const ctx = canvas?.getContext('2d');
|
|
13
|
-
if (ctx) {
|
|
14
|
-
ctx.arc(8, 8, 5, 0, 2 * Math.PI, false);
|
|
15
|
-
ctx.fillStyle = '#8ED6FF';
|
|
16
|
-
ctx.fill();
|
|
17
|
-
ctx.lineWidth = 3;
|
|
18
|
-
ctx.strokeStyle = 'black';
|
|
19
|
-
ctx.stroke();
|
|
20
|
-
ctx.lineWidth = 3;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return canvas;
|
|
24
|
-
};
|
|
25
|
-
export default realtimeSimpleStyle;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { RealtimeDeparture } from '../../types';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Compare two given departures for sort alogithm,
|
|
5
|
-
* @param {Departure} a First departure.
|
|
6
|
-
* @param {Departure} b Second departure.
|
|
7
|
-
* @param {boolean} [sortByMinArrivalTime=false] Sort departures by arrival time.
|
|
8
|
-
* @private
|
|
9
|
-
*/
|
|
10
|
-
const compareDepartures = (
|
|
11
|
-
a: RealtimeDeparture,
|
|
12
|
-
b: RealtimeDeparture,
|
|
13
|
-
sortByMinArrivalTime: boolean = false,
|
|
14
|
-
): number => {
|
|
15
|
-
// First LEAVING and HIDDEN, then BOARDING and then sorted by time.
|
|
16
|
-
const topStates = ['HIDDEN', 'LEAVING', 'BOARDING'];
|
|
17
|
-
const aTop = a.has_fzo && topStates.indexOf(a.state) > -1;
|
|
18
|
-
const bTop = b.has_fzo && topStates.indexOf(b.state) > -1;
|
|
19
|
-
|
|
20
|
-
if (aTop || bTop) {
|
|
21
|
-
if (aTop !== bTop) {
|
|
22
|
-
return aTop ? -1 : 1;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (a.state !== b.state) {
|
|
26
|
-
// one is leaving
|
|
27
|
-
return topStates.indexOf(a.state) - topStates.indexOf(b.state);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
let aDuration = null;
|
|
32
|
-
let bDuration = null;
|
|
33
|
-
const now = Date.now();
|
|
34
|
-
|
|
35
|
-
if (sortByMinArrivalTime) {
|
|
36
|
-
aDuration = new Date(a.min_arrival_time || a.time).getTime() - now;
|
|
37
|
-
bDuration = new Date(b.min_arrival_time || b.time).getTime() - now;
|
|
38
|
-
} else {
|
|
39
|
-
aDuration = new Date(a.time).getTime() - now;
|
|
40
|
-
bDuration = new Date(b.time).getTime() - now;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return aDuration - bDuration;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export default compareDepartures;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { AnyCanvas } from '../../types';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* This function try to create a canvas element and return it.
|
|
5
|
-
* it uses document.createElement('canvas') if document is available
|
|
6
|
-
* or new OffscreenCanvas(width, height) if OffscreenCanvas is avalaible (for web worker)
|
|
7
|
-
* or it returns null if neither is available.
|
|
8
|
-
* @private
|
|
9
|
-
*/
|
|
10
|
-
const createCanvas = (width: number, height: number): AnyCanvas | null => {
|
|
11
|
-
let canvas = null;
|
|
12
|
-
|
|
13
|
-
// Prevent SSR errors
|
|
14
|
-
if (typeof window === 'undefined') {
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if (typeof document !== 'undefined' && document?.createElement) {
|
|
19
|
-
canvas = document.createElement('canvas');
|
|
20
|
-
canvas.width = width;
|
|
21
|
-
canvas.height = height;
|
|
22
|
-
} else if (OffscreenCanvas) {
|
|
23
|
-
canvas = new OffscreenCanvas(width, height);
|
|
24
|
-
} else {
|
|
25
|
-
// eslint-disable-next-line no-console
|
|
26
|
-
console.error(
|
|
27
|
-
"We didn't find a way to create a canvas element, document.createElement('canvas') and new OffscrenCanvas() are not supported",
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
return canvas;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export default createCanvas;
|