mobility-toolbox-js 2.0.0-beta.8 → 2.0.0-beta.80
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 +279 -0
- package/api/RealtimeAPI.d.ts.map +1 -0
- package/api/RealtimeAPI.js +466 -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/index.js +3 -0
- package/api/typedefs.d.ts +179 -0
- package/api/typedefs.d.ts.map +1 -0
- package/{src/api/tralis → api}/typedefs.js +4 -10
- 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/index.js +2 -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 +286 -0
- package/common/mixins/RealtimeLayerMixin.d.ts.map +1 -0
- package/common/mixins/RealtimeLayerMixin.js +776 -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/index.js +4 -0
- package/common/styles/realtimeDefaultStyle.d.ts +36 -0
- package/common/styles/realtimeDefaultStyle.d.ts.map +1 -0
- package/common/styles/realtimeDefaultStyle.js +275 -0
- package/{src/common/styles/trackerDelayStyle.js → common/styles/realtimeDelayStyle.d.ts} +4 -9
- 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 +85 -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 +111 -0
- package/common/typedefs.d.ts.map +1 -0
- package/common/typedefs.js +52 -0
- 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 +10 -0
- package/common/utils/createCanvas.d.ts.map +1 -0
- package/common/utils/createCanvas.js +27 -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 +12 -0
- package/common/utils/debounceDeparturesMessages.d.ts.map +1 -0
- package/common/utils/debounceDeparturesMessages.js +24 -0
- package/common/utils/debounceWebsocketMessages.d.ts +11 -0
- package/common/utils/debounceWebsocketMessages.d.ts.map +1 -0
- package/common/utils/debounceWebsocketMessages.js +29 -0
- package/common/utils/getLayersAsFlatArray.d.ts +3 -0
- package/common/utils/getLayersAsFlatArray.d.ts.map +1 -0
- package/common/utils/getLayersAsFlatArray.js +15 -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 +7 -0
- package/common/utils/getMapboxRender.d.ts.map +1 -0
- package/common/utils/getMapboxRender.js +87 -0
- package/common/utils/getMaplibreRender.d.ts +7 -0
- package/common/utils/getMaplibreRender.d.ts.map +1 -0
- package/common/utils/getMaplibreRender.js +38 -0
- package/common/utils/getRealtimeModeSuffix.d.ts +10 -0
- 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 +17 -0
- package/common/utils/index.d.ts.map +1 -0
- package/common/utils/index.js +17 -0
- package/common/utils/realtimeConfig.d.ts +49 -0
- package/common/utils/realtimeConfig.d.ts.map +1 -0
- package/common/utils/realtimeConfig.js +173 -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 +3 -0
- package/common/utils/sortByDelay.d.ts.map +1 -0
- package/common/utils/sortByDelay.js +20 -0
- package/common/utils/timeUtils.d.ts +24 -0
- package/common/utils/timeUtils.d.ts.map +1 -0
- package/{src/common → common}/utils/timeUtils.js +13 -18
- 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/mapbox/controls/CopyrightControl.js +48 -0
- 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/{src/mapbox → mapbox}/index.js +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 +181 -0
- package/mapbox/layers/RealtimeLayer.d.ts.map +1 -0
- package/mapbox/layers/RealtimeLayer.js +276 -0
- package/mapbox/layers/index.d.ts +3 -0
- package/mapbox/layers/index.d.ts.map +1 -0
- package/mapbox/layers/index.js +2 -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/mapbox/utils/index.js +2 -0
- package/mbt.js +59981 -0
- package/mbt.js.map +7 -0
- package/mbt.min.js +1084 -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 → ol}/controls/StopFinderControl.js +10 -16
- 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 +160 -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 +129 -0
- package/ol/layers/MapboxStyleLayer.d.ts.map +1 -0
- package/ol/layers/MapboxStyleLayer.js +374 -0
- package/ol/layers/MaplibreLayer.d.ts +28 -0
- 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 +340 -0
- package/ol/layers/RoutingLayer.d.ts +34 -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/{src/ol → ol}/layers/index.js +1 -1
- 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 +96 -189
- package/setupTests.d.ts +2 -0
- package/setupTests.d.ts.map +1 -0
- package/{src/setupTests.js → setupTests.js} +13 -2
- package/types/common.d.ts +122 -0
- package/types/index.d.ts +11 -0
- package/types/realtime.d.ts +320 -0
- package/types/routing.d.ts +206 -0
- package/types/stops.d.ts +143 -0
- package/.babelrc +0 -6
- package/.esdoc.json +0 -17
- package/.eslintignore +0 -1
- package/.github/workflows/conventional-pr-title.yml +0 -21
- package/.github/workflows/cypress.yml +0 -29
- package/.github/workflows/nodejs.yml +0 -28
- 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/.neutrinorc.js +0 -176
- package/.nvmrc +0 -1
- package/CHANGELOG.md +0 -10
- package/LICENSE +0 -21
- package/README.md +0 -23
- package/__mocks__/mapbox-gl.js +0 -81
- package/__mocks__/maplibre-gl.js +0 -81
- package/commitlint.config.js +0 -1
- package/cypress/fixtures/example.json +0 -5
- package/cypress/integration/examples/api.spec.js +0 -7
- package/cypress/integration/examples/examples.spec.js +0 -7
- package/cypress/integration/examples/navigation.spec.js +0 -29
- package/cypress/plugins/index.js +0 -21
- package/cypress/support/commands.js +0 -25
- package/cypress/support/index.js +0 -20
- package/cypress.json +0 -4
- 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/documentation.yml +0 -4
- 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 -96
- package/global-setup.js +0 -3
- package/index.html +0 -0
- package/indexweb.html +0 -49
- package/jest.config.js +0 -5
- package/pull_request_template.md +0 -17
- package/renovate.json +0 -4
- package/scripts/read-pkg-json.js +0 -22
- package/src/api/index.js +0 -3
- package/src/api/routing/RoutingAPI.js +0 -44
- package/src/api/routing/RoutingAPI.test.js +0 -41
- package/src/api/stops/StopsAPI.js +0 -41
- package/src/api/stops/StopsAPI.test.js +0 -34
- package/src/api/tralis/TralisAPI.js +0 -731
- package/src/api/tralis/TralisAPI.test.js +0 -75
- package/src/api/tralis/TralisAPIUtils.js +0 -73
- package/src/api/tralis/WebSocketConnector.js +0 -338
- package/src/api/tralis/WebSocketConnector.test.js +0 -356
- package/src/assets/Lato-Black.ttf +0 -0
- package/src/assets/Lato-BlackItalic.ttf +0 -0
- package/src/assets/Lato-Bold.ttf +0 -0
- package/src/assets/Lato-BoldItalic.ttf +0 -0
- package/src/assets/Lato-Italic.ttf +0 -0
- package/src/assets/Lato-Light.ttf +0 -0
- package/src/assets/Lato-LightItalic.ttf +0 -0
- package/src/assets/Lato-Regular.ttf +0 -0
- package/src/assets/Lato-Thin.ttf +0 -0
- package/src/assets/Lato-ThinItalic.ttf +0 -0
- package/src/assets/OFL.txt +0 -93
- package/src/common/Tracker.js +0 -197
- package/src/common/api/api.js +0 -64
- package/src/common/api/api.test.js +0 -68
- package/src/common/controls/Control.js +0 -146
- package/src/common/controls/Control.test.js +0 -98
- package/src/common/index.js +0 -5
- package/src/common/layers/Layer.js +0 -404
- package/src/common/layers/Layer.test.js +0 -585
- package/src/common/mixins/CopyrightMixin.js +0 -48
- package/src/common/mixins/SearchMixin.js +0 -176
- package/src/common/mixins/TralisLayerMixin.js +0 -930
- package/src/common/styles/index.js +0 -4
- package/src/common/styles/trackerDefaultStyle.js +0 -333
- package/src/common/styles/trackerSimpleStyle.js +0 -22
- package/src/common/trackerConfig.js +0 -190
- package/src/common/trackerConfig.test.js +0 -25
- package/src/common/typedefs.js +0 -23
- package/src/common/utils/createTrackerFilters.js +0 -87
- package/src/common/utils/createTrackerFilters.test.js +0 -95
- package/src/common/utils/getMapboxMapCopyrights.js +0 -32
- package/src/common/utils/getMapboxMapCopyrights.test.js +0 -47
- package/src/common/utils/getMapboxStyleUrl.js +0 -32
- package/src/common/utils/getVehiclePosition.js +0 -72
- package/src/common/utils/index.js +0 -5
- package/src/common/utils/removeDuplicate.js +0 -22
- package/src/common/utils/removeDuplicate.test.js +0 -22
- package/src/common/utils/sortByDelay.js +0 -23
- package/src/common/utils/timeUtils.test.js +0 -16
- package/src/doc/App.js +0 -116
- package/src/doc/App.scss +0 -51
- package/src/doc/_redirects +0 -2
- package/src/doc/components/CodeSandboxButton.js +0 -103
- package/src/doc/components/Documentation.js +0 -40
- package/src/doc/components/Esdoc/Anchor.js +0 -57
- package/src/doc/components/Esdoc/ClassDoc.js +0 -272
- package/src/doc/components/Esdoc/DeprecatedHTML.js +0 -16
- package/src/doc/components/Esdoc/DetailDocs.js +0 -281
- package/src/doc/components/Esdoc/DetailHTML.js +0 -33
- package/src/doc/components/Esdoc/DirectSubclassHTML.js +0 -30
- package/src/doc/components/Esdoc/DocBuilderUtils.js +0 -694
- package/src/doc/components/Esdoc/DocLinkHTML.js +0 -62
- package/src/doc/components/Esdoc/DocsLinkHTML.js +0 -38
- package/src/doc/components/Esdoc/Esdoc.js +0 -63
- package/src/doc/components/Esdoc/EsdocContent.js +0 -51
- package/src/doc/components/Esdoc/EsdocNavigation.js +0 -13
- package/src/doc/components/Esdoc/EsdocSearch.js +0 -81
- package/src/doc/components/Esdoc/ExperimentalHTML.js +0 -17
- package/src/doc/components/Esdoc/ExtendsChainHTML.js +0 -32
- package/src/doc/components/Esdoc/FileDocLinkHTML.js +0 -60
- package/src/doc/components/Esdoc/IdentifiersDoc.js +0 -113
- package/src/doc/components/Esdoc/IndirectSubclassHTML.js +0 -30
- package/src/doc/components/Esdoc/InheritedSummaryDoc.js +0 -70
- package/src/doc/components/Esdoc/InheritedSummaryHTML.js +0 -38
- package/src/doc/components/Esdoc/MixinClassesHTML.js +0 -29
- package/src/doc/components/Esdoc/NavDoc.js +0 -112
- package/src/doc/components/Esdoc/OverrideMethod.js +0 -44
- package/src/doc/components/Esdoc/OverrideMethodDescription.js +0 -35
- package/src/doc/components/Esdoc/Properties.js +0 -89
- package/src/doc/components/Esdoc/README.md +0 -45
- package/src/doc/components/Esdoc/SignatureHTML.js +0 -123
- package/src/doc/components/Esdoc/SingleDoc.js +0 -31
- package/src/doc/components/Esdoc/SummaryDoc.js +0 -160
- package/src/doc/components/Esdoc/SummaryHTML.js +0 -96
- package/src/doc/components/Esdoc/TypeDocLinkHTML.js +0 -249
- package/src/doc/components/Esdoc/css/identifiers.css +0 -38
- package/src/doc/components/Esdoc/css/search.css +0 -76
- package/src/doc/components/Esdoc/css/style.css +0 -603
- package/src/doc/components/Esdoc/index.js +0 -7
- package/src/doc/components/Example.js +0 -153
- package/src/doc/components/Examples.js +0 -183
- package/src/doc/components/Home.js +0 -106
- package/src/doc/components/TrackerExample.js +0 -38
- package/src/doc/examples/assets/tralis-live-map/index.js +0 -11
- package/src/doc/examples/assets/tralis-live-map/s1kreis.svg +0 -105
- package/src/doc/examples/assets/tralis-live-map/s20kreis.svg +0 -101
- package/src/doc/examples/assets/tralis-live-map/s2kreis.svg +0 -95
- package/src/doc/examples/assets/tralis-live-map/s3kreis.svg +0 -95
- package/src/doc/examples/assets/tralis-live-map/s4kreis.svg +0 -95
- package/src/doc/examples/assets/tralis-live-map/s6kreis.svg +0 -95
- package/src/doc/examples/assets/tralis-live-map/s7kreis.svg +0 -95
- package/src/doc/examples/assets/tralis-live-map/s8kreis.svg +0 -93
- package/src/doc/examples/assets/tralis-live-map/unknown.svg +0 -107
- package/src/doc/examples/mb-copyright.html +0 -26
- package/src/doc/examples/mb-copyright.js +0 -37
- package/src/doc/examples/mb-tracker.html +0 -1
- package/src/doc/examples/mb-tracker.js +0 -39
- package/src/doc/examples/mb-tracker.md +0 -1
- package/src/doc/examples/mb-tralis.html +0 -1
- package/src/doc/examples/mb-tralis.js +0 -34
- package/src/doc/examples/ol-copyright.html +0 -26
- package/src/doc/examples/ol-copyright.js +0 -43
- package/src/doc/examples/ol-mapbox-layer.html +0 -1
- package/src/doc/examples/ol-mapbox-layer.js +0 -28
- package/src/doc/examples/ol-mapbox-layer.md +0 -0
- package/src/doc/examples/ol-mapbox-style-layer.html +0 -12
- package/src/doc/examples/ol-mapbox-style-layer.js +0 -44
- package/src/doc/examples/ol-query.html +0 -32
- package/src/doc/examples/ol-query.js +0 -83
- package/src/doc/examples/ol-routing.html +0 -26
- package/src/doc/examples/ol-routing.js +0 -59
- package/src/doc/examples/ol-routing.md +0 -1
- package/src/doc/examples/ol-stop-finder.html +0 -15
- package/src/doc/examples/ol-stop-finder.js +0 -31
- package/src/doc/examples/ol-stop-finder.md +0 -1
- package/src/doc/examples/ol-tracker.html +0 -1
- package/src/doc/examples/ol-tracker.js +0 -44
- package/src/doc/examples/ol-tracker.md +0 -1
- package/src/doc/examples/ol-tralis.html +0 -5
- package/src/doc/examples/ol-tralis.js +0 -57
- package/src/doc/examples/tralis-live-map.html +0 -1
- package/src/doc/examples/tralis-live-map.js +0 -51
- package/src/doc/examples/tralis-live-map.md +0 -3
- package/src/doc/examples.js +0 -107
- package/src/doc/img/examples/live_tracker_mb.jpg +0 -0
- package/src/doc/img/examples/live_tracker_munich.jpg +0 -0
- package/src/doc/img/examples/live_tracker_ol.jpg +0 -0
- package/src/doc/img/examples/mapbox.jpg +0 -0
- package/src/doc/img/examples/mapbox_style.jpg +0 -0
- package/src/doc/img/examples/ol-copyright.png +0 -0
- package/src/doc/img/examples/query_objects.jpg +0 -0
- package/src/doc/img/examples/routing.jpg +0 -0
- package/src/doc/img/examples/simple_map.jpg +0 -0
- package/src/doc/img/examples/stops.jpg +0 -0
- package/src/doc/img/favico.ico +0 -0
- package/src/doc/index.js +0 -21
- package/src/index.js +0 -10
- package/src/mapbox/controls/CopyrightControl.js +0 -58
- package/src/mapbox/layers/Layer.js +0 -118
- package/src/mapbox/layers/Layer.test.js +0 -202
- package/src/mapbox/layers/TralisLayer.js +0 -329
- package/src/mapbox/layers/TralisLayer.test.js +0 -40
- package/src/mapbox/layers/index.js +0 -2
- package/src/mapbox/utils.js +0 -46
- package/src/ol/README.md +0 -0
- package/src/ol/controls/CopyrightControl.js +0 -80
- package/src/ol/controls/CopyrightControl.test.js +0 -211
- package/src/ol/controls/RoutingControl.js +0 -752
- package/src/ol/controls/RoutingControl.test.js +0 -216
- 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.js +0 -193
- package/src/ol/layers/Layer.test.js +0 -197
- package/src/ol/layers/MapboxLayer.js +0 -378
- package/src/ol/layers/MapboxLayer.test.js +0 -186
- package/src/ol/layers/MapboxStyleLayer.js +0 -417
- package/src/ol/layers/MapboxStyleLayer.test.js +0 -262
- package/src/ol/layers/MaplibreLayer.js +0 -280
- package/src/ol/layers/RoutingLayer.js +0 -91
- package/src/ol/layers/RoutingLayer.test.js +0 -49
- package/src/ol/layers/TralisLayer.js +0 -359
- package/src/ol/layers/TralisLayer.test.js +0 -97
- package/src/ol/layers/VectorLayer.js +0 -43
- package/src/ol/layers/VectorLayer.test.js +0 -98
- package/src/ol/layers/WMSLayer.js +0 -80
- package/src/ol/layers/WMSLayer.test.js +0 -84
- package/src/ol/styles/fullTrajectoryDelayStyle.js +0 -35
- package/src/ol/styles/fullTrajectoryStyle.js +0 -51
- package/webpack.config.js +0 -6
- /package/{src/mapbox → mapbox}/controls/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}/styles/index.js +0 -0
|
@@ -1,333 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getRadius,
|
|
3
|
-
getBgColor,
|
|
4
|
-
getDelayColor,
|
|
5
|
-
getDelayText,
|
|
6
|
-
getTextColor,
|
|
7
|
-
getTextSize,
|
|
8
|
-
} from '../trackerConfig';
|
|
9
|
-
|
|
10
|
-
const createCanvas = (width, height) => {
|
|
11
|
-
const canvas = document.createElement('canvas');
|
|
12
|
-
canvas.width = width;
|
|
13
|
-
canvas.height = height;
|
|
14
|
-
return canvas;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
// Draw circle delay background
|
|
18
|
-
const cacheDelayBg = {};
|
|
19
|
-
export const getDelayBgCanvas = (origin, radius, color) => {
|
|
20
|
-
const key = `${origin}, ${radius}, ${color}`;
|
|
21
|
-
if (!cacheDelayBg[key]) {
|
|
22
|
-
const canvas = createCanvas(origin * 2, origin * 2);
|
|
23
|
-
const ctx = canvas.getContext('2d');
|
|
24
|
-
ctx.beginPath();
|
|
25
|
-
ctx.arc(origin, origin, radius, 0, 2 * Math.PI, false);
|
|
26
|
-
ctx.fillStyle = color;
|
|
27
|
-
ctx.filter = 'blur(1px)';
|
|
28
|
-
ctx.fill();
|
|
29
|
-
cacheDelayBg[key] = canvas;
|
|
30
|
-
}
|
|
31
|
-
return cacheDelayBg[key];
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
// Draw delay text
|
|
35
|
-
const cacheDelayText = {};
|
|
36
|
-
export const getDelayTextCanvas = (
|
|
37
|
-
width,
|
|
38
|
-
text,
|
|
39
|
-
fontSize,
|
|
40
|
-
font,
|
|
41
|
-
delayColor,
|
|
42
|
-
delayOutlineColor,
|
|
43
|
-
pixelRatio,
|
|
44
|
-
) => {
|
|
45
|
-
const key = `${width}, ${text}, ${font}, ${delayColor}, ${delayOutlineColor}, ${pixelRatio}`;
|
|
46
|
-
if (!cacheDelayText[key]) {
|
|
47
|
-
const canvas = createCanvas(width, fontSize + 8 * pixelRatio);
|
|
48
|
-
const ctx = canvas.getContext('2d');
|
|
49
|
-
ctx.textAlign = 'left';
|
|
50
|
-
ctx.textBaseline = 'middle';
|
|
51
|
-
ctx.font = font;
|
|
52
|
-
ctx.fillStyle = delayColor;
|
|
53
|
-
ctx.strokeStyle = delayOutlineColor;
|
|
54
|
-
ctx.lineWidth = 1.5 * pixelRatio;
|
|
55
|
-
const delayText = text;
|
|
56
|
-
ctx.strokeText(delayText, 0, fontSize);
|
|
57
|
-
ctx.fillText(delayText, 0, fontSize);
|
|
58
|
-
cacheDelayText[key] = canvas;
|
|
59
|
-
}
|
|
60
|
-
return cacheDelayText[key];
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
// Draw colored circle with black border
|
|
64
|
-
const cacheCircle = {};
|
|
65
|
-
export const getCircleCanvas = (
|
|
66
|
-
origin,
|
|
67
|
-
radius,
|
|
68
|
-
color,
|
|
69
|
-
hasStroke,
|
|
70
|
-
hasDash,
|
|
71
|
-
pixelRatio,
|
|
72
|
-
) => {
|
|
73
|
-
const key = `${origin}, ${radius}, ${color}, ${hasStroke}, ${hasDash}, ${pixelRatio}`;
|
|
74
|
-
if (!cacheCircle[key]) {
|
|
75
|
-
const canvas = createCanvas(origin * 2, origin * 2);
|
|
76
|
-
const ctx = canvas.getContext('2d');
|
|
77
|
-
ctx.fillStyle = color;
|
|
78
|
-
|
|
79
|
-
if (hasStroke) {
|
|
80
|
-
ctx.lineWidth = 1 * pixelRatio;
|
|
81
|
-
ctx.strokeStyle = '#000000';
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
ctx.beginPath();
|
|
85
|
-
ctx.arc(origin, origin, radius, 0, 2 * Math.PI, false);
|
|
86
|
-
ctx.fill();
|
|
87
|
-
|
|
88
|
-
if (hasDash) {
|
|
89
|
-
ctx.setLineDash([5, 3]);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (hasStroke) {
|
|
93
|
-
ctx.stroke();
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
cacheCircle[key] = canvas;
|
|
97
|
-
}
|
|
98
|
-
return cacheCircle[key];
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
// Draw text in the circle
|
|
102
|
-
const cacheText = {};
|
|
103
|
-
export const getTextCanvas = (
|
|
104
|
-
text,
|
|
105
|
-
origin,
|
|
106
|
-
textSize,
|
|
107
|
-
fillColor,
|
|
108
|
-
strokeColor,
|
|
109
|
-
hasStroke,
|
|
110
|
-
pixelRatio,
|
|
111
|
-
) => {
|
|
112
|
-
const key = `${text}, ${origin}, ${textSize}, ${fillColor},${strokeColor}, ${hasStroke}, ${pixelRatio}`;
|
|
113
|
-
if (!cacheText[key]) {
|
|
114
|
-
const canvas = createCanvas(origin * 2, origin * 2);
|
|
115
|
-
const ctx = canvas.getContext('2d');
|
|
116
|
-
|
|
117
|
-
// Draw a stroke to the text only if a provider provides realtime but we don't use it.
|
|
118
|
-
if (hasStroke) {
|
|
119
|
-
ctx.save();
|
|
120
|
-
ctx.textBaseline = 'middle';
|
|
121
|
-
ctx.textAlign = 'center';
|
|
122
|
-
ctx.font = `bold ${textSize + 2}px Arial`;
|
|
123
|
-
ctx.strokeStyle = strokeColor;
|
|
124
|
-
ctx.strokeText(text, origin, origin);
|
|
125
|
-
ctx.restore();
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// Draw a text
|
|
129
|
-
ctx.textBaseline = 'middle';
|
|
130
|
-
ctx.textAlign = 'center';
|
|
131
|
-
ctx.fillStyle = fillColor;
|
|
132
|
-
ctx.font = `bold ${textSize}px Arial`;
|
|
133
|
-
ctx.strokeStyle = strokeColor;
|
|
134
|
-
ctx.strokeText(text, origin, origin);
|
|
135
|
-
ctx.fillText(text, origin, origin);
|
|
136
|
-
|
|
137
|
-
cacheText[key] = canvas;
|
|
138
|
-
}
|
|
139
|
-
return cacheText[key];
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* A tracker style that take in account the delay.
|
|
144
|
-
*
|
|
145
|
-
* @param {*} trajectory The trajectory to render.
|
|
146
|
-
* @param {*} viewState The view state of the map.
|
|
147
|
-
* @param {*} options Some options to change the rendering
|
|
148
|
-
* @return a canvas
|
|
149
|
-
*/
|
|
150
|
-
const styleCache = {};
|
|
151
|
-
const style = (trajectory, viewState, options) => {
|
|
152
|
-
const {
|
|
153
|
-
hoverVehicleId,
|
|
154
|
-
selectedVehicleId,
|
|
155
|
-
useDelayStyle,
|
|
156
|
-
delayOutlineColor,
|
|
157
|
-
delayDisplay,
|
|
158
|
-
} = options;
|
|
159
|
-
|
|
160
|
-
const { zoom, pixelRatio } = viewState;
|
|
161
|
-
let { type, cancelled } = trajectory.properties;
|
|
162
|
-
const {
|
|
163
|
-
train_id: id,
|
|
164
|
-
line,
|
|
165
|
-
delay,
|
|
166
|
-
state,
|
|
167
|
-
operator_provides_realtime_journey: operatorProvidesRealtime,
|
|
168
|
-
} = trajectory.properties;
|
|
169
|
-
let { name, text_color: textColor, color } = line || {};
|
|
170
|
-
|
|
171
|
-
// In the future, the cancelled property will be removed we still managed it
|
|
172
|
-
// until the backend change is on prod.
|
|
173
|
-
cancelled = cancelled === true || state === 'JOURNEY_CANCELLED';
|
|
174
|
-
|
|
175
|
-
if (!type) {
|
|
176
|
-
type = 'Rail';
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
if (!name) {
|
|
180
|
-
name = 'I';
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
if (!textColor) {
|
|
184
|
-
textColor = '#000000';
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
if (color && color[0] !== '#') {
|
|
188
|
-
color = `#${color}`;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
if (textColor[0] !== '#') {
|
|
192
|
-
textColor = `#${textColor}`;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
const z = Math.min(Math.floor(zoom || 1), 16);
|
|
196
|
-
const hover = hoverVehicleId && hoverVehicleId === id;
|
|
197
|
-
const selected = selectedVehicleId && selectedVehicleId === id;
|
|
198
|
-
|
|
199
|
-
// Calcul the radius of the circle
|
|
200
|
-
let radius = getRadius(type, z) * pixelRatio;
|
|
201
|
-
const isDisplayStrokeAndDelay = radius >= 7 * pixelRatio;
|
|
202
|
-
if (hover || selected) {
|
|
203
|
-
radius = isDisplayStrokeAndDelay
|
|
204
|
-
? radius + 5 * pixelRatio
|
|
205
|
-
: 14 * pixelRatio;
|
|
206
|
-
}
|
|
207
|
-
const mustDrawText = radius > 10 * pixelRatio;
|
|
208
|
-
|
|
209
|
-
// Optimize the cache key, very important in high zoom level
|
|
210
|
-
let key = `${radius}${type}${color}${hover}${selected}${cancelled}${delay}`;
|
|
211
|
-
|
|
212
|
-
if (useDelayStyle) {
|
|
213
|
-
key += `${operatorProvidesRealtime}`;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
if (mustDrawText) {
|
|
217
|
-
key += `${name}${textColor}`;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
if (!styleCache[key]) {
|
|
221
|
-
if (radius === 0) {
|
|
222
|
-
styleCache[key] = null;
|
|
223
|
-
return null;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
const margin = 1 * pixelRatio;
|
|
227
|
-
const radiusDelay = radius + 2;
|
|
228
|
-
const markerSize = radius * 2;
|
|
229
|
-
const size = radiusDelay * 2 + margin * 2 + 100 * pixelRatio; // add space for delay information
|
|
230
|
-
const origin = size / 2;
|
|
231
|
-
|
|
232
|
-
// Create the canvas
|
|
233
|
-
const canvas = createCanvas(size, size);
|
|
234
|
-
const ctx = canvas.getContext('2d');
|
|
235
|
-
|
|
236
|
-
if (isDisplayStrokeAndDelay && delay !== null) {
|
|
237
|
-
// Draw circle delay background
|
|
238
|
-
const delayBg = getDelayBgCanvas(
|
|
239
|
-
origin,
|
|
240
|
-
radiusDelay,
|
|
241
|
-
getDelayColor(delay, cancelled),
|
|
242
|
-
);
|
|
243
|
-
ctx.drawImage(delayBg, 0, 0);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
// Show delay if feature is hovered or if delay is above 5mins.
|
|
247
|
-
if (
|
|
248
|
-
isDisplayStrokeAndDelay &&
|
|
249
|
-
(hover || delay >= delayDisplay || cancelled)
|
|
250
|
-
) {
|
|
251
|
-
// Draw delay text
|
|
252
|
-
const fontSize =
|
|
253
|
-
Math.max(
|
|
254
|
-
cancelled ? 19 : 14,
|
|
255
|
-
Math.min(cancelled ? 19 : 17, radius * 1.2),
|
|
256
|
-
) * pixelRatio;
|
|
257
|
-
const text = getDelayText(delay, cancelled);
|
|
258
|
-
|
|
259
|
-
if (text) {
|
|
260
|
-
const textWidth = text.length * fontSize;
|
|
261
|
-
const delayText = getDelayTextCanvas(
|
|
262
|
-
textWidth,
|
|
263
|
-
text,
|
|
264
|
-
fontSize,
|
|
265
|
-
`bold ${fontSize}px arial, sans-serif`,
|
|
266
|
-
getDelayColor(delay, cancelled, true),
|
|
267
|
-
delayOutlineColor,
|
|
268
|
-
pixelRatio,
|
|
269
|
-
);
|
|
270
|
-
ctx.drawImage(
|
|
271
|
-
delayText,
|
|
272
|
-
origin + radiusDelay + margin,
|
|
273
|
-
origin - fontSize,
|
|
274
|
-
);
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
// Draw colored circle with black border
|
|
279
|
-
let circleFillColor;
|
|
280
|
-
if (useDelayStyle) {
|
|
281
|
-
circleFillColor = getDelayColor(delay, cancelled);
|
|
282
|
-
} else {
|
|
283
|
-
circleFillColor = color || getBgColor(type);
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
const hasStroke = isDisplayStrokeAndDelay || hover || selected;
|
|
287
|
-
|
|
288
|
-
const hasDash =
|
|
289
|
-
isDisplayStrokeAndDelay &&
|
|
290
|
-
useDelayStyle &&
|
|
291
|
-
delay === null &&
|
|
292
|
-
operatorProvidesRealtime === 'yes';
|
|
293
|
-
|
|
294
|
-
const circle = getCircleCanvas(
|
|
295
|
-
origin,
|
|
296
|
-
radius,
|
|
297
|
-
circleFillColor,
|
|
298
|
-
hasStroke,
|
|
299
|
-
hasDash,
|
|
300
|
-
pixelRatio,
|
|
301
|
-
);
|
|
302
|
-
|
|
303
|
-
ctx.drawImage(circle, 0, 0);
|
|
304
|
-
|
|
305
|
-
// Draw text in the circle
|
|
306
|
-
if (mustDrawText) {
|
|
307
|
-
const fontSize = Math.max(radius, 10);
|
|
308
|
-
const textSize = getTextSize(ctx, markerSize, name, fontSize);
|
|
309
|
-
const textColor2 = !useDelayStyle
|
|
310
|
-
? textColor || getTextColor(type)
|
|
311
|
-
: '#000000';
|
|
312
|
-
const hasStroke2 =
|
|
313
|
-
useDelayStyle && delay === null && operatorProvidesRealtime === 'yes';
|
|
314
|
-
|
|
315
|
-
const text = getTextCanvas(
|
|
316
|
-
name,
|
|
317
|
-
origin,
|
|
318
|
-
textSize,
|
|
319
|
-
textColor2,
|
|
320
|
-
circleFillColor,
|
|
321
|
-
hasStroke2,
|
|
322
|
-
pixelRatio,
|
|
323
|
-
);
|
|
324
|
-
|
|
325
|
-
ctx.drawImage(text, 0, 0);
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
styleCache[key] = canvas;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
return styleCache[key];
|
|
332
|
-
};
|
|
333
|
-
export default style;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A very simple tracker style.
|
|
3
|
-
* Display blue point for each train.
|
|
4
|
-
*/
|
|
5
|
-
let canvas;
|
|
6
|
-
const style = () => {
|
|
7
|
-
if (!canvas) {
|
|
8
|
-
document.createElement('canvas');
|
|
9
|
-
canvas.width = 15;
|
|
10
|
-
canvas.height = 15;
|
|
11
|
-
const ctx = canvas.getContext('2d');
|
|
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
|
-
return canvas;
|
|
21
|
-
};
|
|
22
|
-
export default style;
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
const trackerRadiusMapping = {
|
|
2
|
-
0: [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
|
|
3
|
-
1: [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
|
|
4
|
-
2: [0, 0, 0, 0, 0, 2, 2, 3, 7, 7, 7, 12, 15, 15, 15, 15, 15],
|
|
5
|
-
3: [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
|
|
6
|
-
4: [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
|
|
7
|
-
5: [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
|
|
8
|
-
6: [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
|
|
9
|
-
7: [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
|
|
10
|
-
8: [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
|
|
11
|
-
9: [0, 0, 0, 0, 0, 2, 2, 3, 7, 7, 7, 12, 15, 15, 15, 15, 15],
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Trajserv value: 'Tram', 'Subway / Metro / S-Bahn', 'Train', 'Bus', 'Ferry', 'Cable Car', 'Gondola', 'Funicular', 'Long distance bus', 'Rail',
|
|
16
|
-
* New endpoint use Rail instead of Train.
|
|
17
|
-
* New tracker values: null, "tram", "subway", "rail", "bus", "ferry", "cablecar", "gondola", "funicular", "coach".
|
|
18
|
-
*
|
|
19
|
-
* @ignore
|
|
20
|
-
*/
|
|
21
|
-
export const types = [
|
|
22
|
-
/^Tram/i,
|
|
23
|
-
/^Subway( \/ Metro \/ S-Bahn)?/i,
|
|
24
|
-
/^Train/i,
|
|
25
|
-
/^Bus/i,
|
|
26
|
-
/^Ferry/i,
|
|
27
|
-
/^Cable ?Car/i,
|
|
28
|
-
/^Gondola/i,
|
|
29
|
-
/^Funicular/i,
|
|
30
|
-
/^(Long distance bus|coach)/i,
|
|
31
|
-
/^Rail/i, // New endpoint use Rail instead of Train.
|
|
32
|
-
];
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* @ignore
|
|
36
|
-
*/
|
|
37
|
-
export const bgColors = [
|
|
38
|
-
'#ffb400',
|
|
39
|
-
'#ff5400',
|
|
40
|
-
'#ff8080',
|
|
41
|
-
'#ea0000',
|
|
42
|
-
'#3000ff',
|
|
43
|
-
'#ffb400',
|
|
44
|
-
'#41a27b',
|
|
45
|
-
'#00d237',
|
|
46
|
-
'#b5b5b5',
|
|
47
|
-
'#ff8080',
|
|
48
|
-
];
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* @ignore
|
|
52
|
-
*/
|
|
53
|
-
export const textColors = [
|
|
54
|
-
'#000000',
|
|
55
|
-
'#ffffff',
|
|
56
|
-
'#000000',
|
|
57
|
-
'#ffffff',
|
|
58
|
-
'#ffffff',
|
|
59
|
-
'#000000',
|
|
60
|
-
'#ffffff',
|
|
61
|
-
'#000000',
|
|
62
|
-
'#000000',
|
|
63
|
-
'#000000',
|
|
64
|
-
];
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* @ignore
|
|
68
|
-
*/
|
|
69
|
-
export const timeSteps = [
|
|
70
|
-
100000, 50000, 40000, 30000, 20000, 15000, 10000, 5000, 2000, 1000, 400, 300,
|
|
71
|
-
250, 180, 90, 60, 50, 50, 50, 50, 50,
|
|
72
|
-
];
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* @ignore
|
|
76
|
-
*/
|
|
77
|
-
export const getTypeIndex = (type) => {
|
|
78
|
-
if (typeof type === 'string') {
|
|
79
|
-
return types.findIndex((t) => t.test(type));
|
|
80
|
-
}
|
|
81
|
-
return type;
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* @ignore
|
|
86
|
-
*/
|
|
87
|
-
export const getRadius = (type, zoom) => {
|
|
88
|
-
try {
|
|
89
|
-
const typeIdx = getTypeIndex(type || 0);
|
|
90
|
-
return trackerRadiusMapping[typeIdx][zoom];
|
|
91
|
-
} catch (e) {
|
|
92
|
-
return 1;
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* @ignore
|
|
98
|
-
*/
|
|
99
|
-
export const getBgColor = (type = 0) => {
|
|
100
|
-
try {
|
|
101
|
-
const typeIdx = getTypeIndex(type);
|
|
102
|
-
return bgColors[typeIdx];
|
|
103
|
-
} catch (e) {
|
|
104
|
-
return 1;
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* @ignore
|
|
110
|
-
*/
|
|
111
|
-
export const getTextColor = (type = 0) => {
|
|
112
|
-
try {
|
|
113
|
-
const typeIdx = getTypeIndex(type);
|
|
114
|
-
return textColors[typeIdx];
|
|
115
|
-
} catch (e) {
|
|
116
|
-
return 1;
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* @ignore
|
|
122
|
-
*/
|
|
123
|
-
export const getTextSize = (ctx, markerSize, text, fontSize) => {
|
|
124
|
-
ctx.font = `bold ${fontSize}px Arial`;
|
|
125
|
-
let newText = ctx.measureText(text);
|
|
126
|
-
|
|
127
|
-
const maxiter = 25;
|
|
128
|
-
let i = 0;
|
|
129
|
-
|
|
130
|
-
while (newText.width > markerSize - 6 && i < maxiter) {
|
|
131
|
-
// eslint-disable-next-line no-param-reassign
|
|
132
|
-
fontSize -= 0.5;
|
|
133
|
-
ctx.font = `bold ${fontSize}px arial, sans-serif`;
|
|
134
|
-
newText = ctx.measureText(text);
|
|
135
|
-
i += 1;
|
|
136
|
-
}
|
|
137
|
-
return fontSize;
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* @ignore
|
|
142
|
-
* @param {number} delayInMs Delay in milliseconds.
|
|
143
|
-
* @param {boolean} cancelled true if the journey is cancelled.
|
|
144
|
-
* @param {boolean} isDelayText true if the color is used for delay text of the symbol.
|
|
145
|
-
*/
|
|
146
|
-
export const getDelayColor = (delayInMs, cancelled, isDelayText) => {
|
|
147
|
-
if (cancelled) {
|
|
148
|
-
return isDelayText ? '#ff0000' : '#a0a0a0'; // red or gray
|
|
149
|
-
}
|
|
150
|
-
if (delayInMs >= 3600000) {
|
|
151
|
-
return '#ed004c'; // pink { r: 237, g: 0, b: 76, s: '237,0,76' };
|
|
152
|
-
}
|
|
153
|
-
if (delayInMs >= 500000) {
|
|
154
|
-
return '#e80000'; // red { r: 232, g: 0, b: 0, s: '232,0,0' };
|
|
155
|
-
}
|
|
156
|
-
if (delayInMs >= 300000) {
|
|
157
|
-
return '#ff4a00'; // orange { r: 255, g: 74, b: 0, s: '255,74,0' };
|
|
158
|
-
}
|
|
159
|
-
if (delayInMs >= 180000) {
|
|
160
|
-
return '#f7bf00'; // yellow { r: 247, g: 191, b: 0, s: '247,191,0' };
|
|
161
|
-
}
|
|
162
|
-
if (delayInMs === null) {
|
|
163
|
-
return '#a0a0a0'; // grey { r: 160, g: 160, b: 160, s: '160,160,160' };
|
|
164
|
-
}
|
|
165
|
-
return '#00a00c'; // green { r: 0, g: 160, b: 12, s: '0,160,12' };
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* @ignore
|
|
170
|
-
*/
|
|
171
|
-
export const getDelayText = (delayInMs, cancelled) => {
|
|
172
|
-
if (cancelled) {
|
|
173
|
-
return String.fromCodePoint(0x00d7);
|
|
174
|
-
}
|
|
175
|
-
if (delayInMs > 3600000) {
|
|
176
|
-
const rounded = Math.round(delayInMs / 3600000);
|
|
177
|
-
return `+${rounded}h`;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
if (delayInMs > 59000) {
|
|
181
|
-
const rounded = Math.round(delayInMs / 60000);
|
|
182
|
-
return `+${rounded}m`;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
if (delayInMs > 0) {
|
|
186
|
-
return `+${delayInMs}s`;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
return '';
|
|
190
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { getTypeIndex } from './trackerConfig';
|
|
2
|
-
|
|
3
|
-
describe('trackerConfig', () => {
|
|
4
|
-
describe('#getTypeIndex()', () => {
|
|
5
|
-
test("retrurn the type is it's not a string", () => {
|
|
6
|
-
const obj = { foo: 'foo' };
|
|
7
|
-
expect(getTypeIndex(obj)).toBe(obj);
|
|
8
|
-
expect(getTypeIndex(0)).toBe(0);
|
|
9
|
-
expect(getTypeIndex(null)).toBe(null);
|
|
10
|
-
expect(getTypeIndex(undefined)).toBe(undefined);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
test('find good index for new tracker values', () => {
|
|
14
|
-
expect(getTypeIndex('tram')).toBe(0);
|
|
15
|
-
expect(getTypeIndex('subway')).toBe(1);
|
|
16
|
-
expect(getTypeIndex('bus')).toBe(3);
|
|
17
|
-
expect(getTypeIndex('ferry')).toBe(4);
|
|
18
|
-
expect(getTypeIndex('cablecar')).toBe(5);
|
|
19
|
-
expect(getTypeIndex('gondola')).toBe(6);
|
|
20
|
-
expect(getTypeIndex('funicular')).toBe(7);
|
|
21
|
-
expect(getTypeIndex('coach')).toBe(8);
|
|
22
|
-
expect(getTypeIndex('rail')).toBe(9);
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
});
|
package/src/common/typedefs.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {function} FilterFunction
|
|
3
|
-
* @param {Object} vehicle Vehicle to filter.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @typedef {Object} ViewState
|
|
8
|
-
* @property {number} time A time in ms.
|
|
9
|
-
* @property {number[2]} center A center in mercator coordinate.
|
|
10
|
-
* @property {number[4]} extent An Extent in mercator coordinates.
|
|
11
|
-
* @property {number[2]} size A size ([width, height]).
|
|
12
|
-
* @property {number} rotation A rotation in radians.
|
|
13
|
-
* @property {number} resolution A resolution.
|
|
14
|
-
* @property {number} zoom A zoom level.
|
|
15
|
-
* @property {number} pixelRatio A pixel ratio.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @typedef {Object} FeatureInfo
|
|
20
|
-
* @property {Layer} layer A layer.
|
|
21
|
-
* @property {ol/Feature~Feature[]} features An array of features.
|
|
22
|
-
* @property {number[2]} coordinate The coordinate where to find the featue.
|
|
23
|
-
*/
|
|
@@ -1,87 +0,0 @@
|
|
|
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 routeIdentifier 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 createFilters = (line, route, operator, regexLine) => {
|
|
11
|
-
const filterList = [];
|
|
12
|
-
|
|
13
|
-
if (!line && !route && !operator && !regexLine) {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (regexLine) {
|
|
18
|
-
const regexLineList =
|
|
19
|
-
typeof regexLine === 'string' ? [regexLine] : regexLine;
|
|
20
|
-
const lineFilter = (item) => {
|
|
21
|
-
const name =
|
|
22
|
-
item.properties.name ||
|
|
23
|
-
(item.properties.line && item.properties.line.name) ||
|
|
24
|
-
'';
|
|
25
|
-
if (!name) {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
return regexLineList.some((regexStr) =>
|
|
29
|
-
new RegExp(regexStr, 'i').test(name),
|
|
30
|
-
);
|
|
31
|
-
};
|
|
32
|
-
filterList.push(lineFilter);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (line) {
|
|
36
|
-
const lineFiltersList = typeof line === 'string' ? line.split(',') : line;
|
|
37
|
-
const lineList = lineFiltersList.map((l) =>
|
|
38
|
-
l.replace(/\s+/g, '').toUpperCase(),
|
|
39
|
-
);
|
|
40
|
-
const lineFilter = (item) => {
|
|
41
|
-
const { line: linee, name } = item.properties;
|
|
42
|
-
const lineName = (name || (linee && linee.name) || '').toUpperCase();
|
|
43
|
-
if (!lineName) {
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
return lineList.includes(lineName);
|
|
47
|
-
};
|
|
48
|
-
filterList.push(lineFilter);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (route) {
|
|
52
|
-
const routes = typeof route === 'string' ? route.split(',') : route;
|
|
53
|
-
const routeList = routes.map((item) => parseInt(item, 10));
|
|
54
|
-
const routeFilter = (item) => {
|
|
55
|
-
const routeId = parseInt(
|
|
56
|
-
item.properties.routeIdentifier.split('.')[0],
|
|
57
|
-
10,
|
|
58
|
-
);
|
|
59
|
-
return routeList.includes(routeId);
|
|
60
|
-
};
|
|
61
|
-
filterList.push(routeFilter);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (operator) {
|
|
65
|
-
const operatorList = typeof operator === 'string' ? [operator] : operator;
|
|
66
|
-
const operatorFilter = (item) =>
|
|
67
|
-
operatorList.some((op) =>
|
|
68
|
-
new RegExp(op, 'i').test(item.properties.operator),
|
|
69
|
-
);
|
|
70
|
-
filterList.push(operatorFilter);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (!filterList.length) {
|
|
74
|
-
return null;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return (t) => {
|
|
78
|
-
for (let i = 0; i < filterList.length; i += 1) {
|
|
79
|
-
if (!filterList[i](t)) {
|
|
80
|
-
return false;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return true;
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
export default createFilters;
|