mobility-toolbox-js 2.3.10 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/RealtimeAPI.d.ts +290 -0
- package/api/RealtimeAPI.d.ts.map +1 -0
- package/api/RealtimeAPI.js +483 -0
- package/api/RoutingAPI.d.ts +37 -0
- package/api/RoutingAPI.d.ts.map +1 -0
- package/api/RoutingAPI.js +35 -0
- package/api/StopsAPI.d.ts +38 -0
- package/api/StopsAPI.d.ts.map +1 -0
- package/api/StopsAPI.js +36 -0
- package/api/index.d.ts +4 -0
- package/api/index.d.ts.map +1 -0
- package/api/typedefs.d.ts +179 -0
- package/api/typedefs.d.ts.map +1 -0
- package/{src/api → api}/typedefs.js +1 -11
- package/common/api/HttpAPI.d.ts +31 -0
- package/common/api/HttpAPI.d.ts.map +1 -0
- package/common/api/HttpAPI.js +57 -0
- package/common/api/WebSocketAPI.d.ts +153 -0
- package/common/api/WebSocketAPI.d.ts.map +1 -0
- package/common/api/WebSocketAPI.js +341 -0
- package/common/controls/ControlCommon.d.ts +76 -0
- package/common/controls/ControlCommon.d.ts.map +1 -0
- package/common/controls/ControlCommon.js +150 -0
- package/common/controls/CopyrightControlCommon.d.ts +13 -0
- package/common/controls/CopyrightControlCommon.d.ts.map +1 -0
- package/common/controls/CopyrightControlCommon.js +34 -0
- package/common/controls/StopFinderControlCommon.d.ts +55 -0
- package/common/controls/StopFinderControlCommon.d.ts.map +1 -0
- package/common/controls/StopFinderControlCommon.js +144 -0
- package/common/index.d.ts +3 -0
- package/common/index.d.ts.map +1 -0
- package/common/layers/LayerCommon.d.ts +94 -0
- package/common/layers/LayerCommon.d.ts.map +1 -0
- package/common/layers/LayerCommon.js +244 -0
- package/common/mixins/RealtimeLayerMixin.d.ts +288 -0
- package/common/mixins/RealtimeLayerMixin.d.ts.map +1 -0
- package/common/mixins/RealtimeLayerMixin.js +779 -0
- package/common/mixins/UserInteractionsLayerMixin.d.ts +60 -0
- package/common/mixins/UserInteractionsLayerMixin.d.ts.map +1 -0
- package/common/mixins/UserInteractionsLayerMixin.js +241 -0
- package/common/styles/index.d.ts +5 -0
- package/common/styles/index.d.ts.map +1 -0
- package/common/styles/realtimeDefaultStyle.d.ts +36 -0
- package/common/styles/realtimeDefaultStyle.d.ts.map +1 -0
- package/common/styles/realtimeDefaultStyle.js +276 -0
- package/common/styles/realtimeDelayStyle.d.ts +12 -0
- package/common/styles/realtimeDelayStyle.d.ts.map +1 -0
- package/common/styles/realtimeDelayStyle.js +13 -0
- package/common/styles/realtimeHeadingStyle.d.ts +12 -0
- package/common/styles/realtimeHeadingStyle.d.ts.map +1 -0
- package/common/styles/realtimeHeadingStyle.js +87 -0
- package/common/styles/realtimeSimpleStyle.d.ts +4 -0
- package/common/styles/realtimeSimpleStyle.d.ts.map +1 -0
- package/common/styles/realtimeSimpleStyle.js +23 -0
- package/common/typedefs.d.ts +183 -0
- package/common/typedefs.d.ts.map +1 -0
- package/{src/common → common}/typedefs.js +1 -1
- package/common/utils/compareDepartures.d.ts +11 -0
- package/common/utils/compareDepartures.d.ts.map +1 -0
- package/common/utils/compareDepartures.js +35 -0
- package/common/utils/createCanvas.d.ts +11 -0
- package/common/utils/createCanvas.d.ts.map +1 -0
- package/common/utils/createCanvas.js +28 -0
- package/common/utils/createRealtimeFilters.d.ts +13 -0
- package/common/utils/createRealtimeFilters.d.ts.map +1 -0
- package/common/utils/createRealtimeFilters.js +74 -0
- package/common/utils/debounceDeparturesMessages.d.ts +13 -0
- package/common/utils/debounceDeparturesMessages.d.ts.map +1 -0
- package/common/utils/debounceDeparturesMessages.js +28 -0
- package/common/utils/debounceWebsocketMessages.d.ts +12 -0
- package/common/utils/debounceWebsocketMessages.d.ts.map +1 -0
- package/common/utils/debounceWebsocketMessages.js +30 -0
- package/common/utils/getLayersAsFlatArray.d.ts +4 -0
- package/common/utils/getLayersAsFlatArray.d.ts.map +1 -0
- package/common/utils/getLayersAsFlatArray.js +16 -0
- package/common/utils/getMapboxMapCopyrights.d.ts +18 -0
- package/common/utils/getMapboxMapCopyrights.d.ts.map +1 -0
- package/common/utils/getMapboxMapCopyrights.js +30 -0
- package/common/utils/getMapboxRender.d.ts +8 -0
- package/common/utils/getMapboxRender.d.ts.map +1 -0
- package/common/utils/getMapboxRender.js +88 -0
- package/common/utils/getMaplibreRender.d.ts +9 -0
- package/common/utils/getMaplibreRender.d.ts.map +1 -0
- package/common/utils/getMaplibreRender.js +40 -0
- package/{src/common/utils/getRealtimeModeSuffix.ts → common/utils/getRealtimeModeSuffix.d.ts} +2 -4
- package/common/utils/getRealtimeModeSuffix.d.ts.map +1 -0
- package/common/utils/getRealtimeModeSuffix.js +7 -0
- package/common/utils/getUrlWithParams.d.ts +9 -0
- package/common/utils/getUrlWithParams.d.ts.map +1 -0
- package/common/utils/getUrlWithParams.js +18 -0
- package/common/utils/getVehiclePosition.d.ts +16 -0
- package/common/utils/getVehiclePosition.d.ts.map +1 -0
- package/common/utils/getVehiclePosition.js +72 -0
- package/common/utils/index.d.ts +18 -0
- package/common/utils/index.d.ts.map +1 -0
- package/{src/common → common}/utils/index.js +2 -1
- package/common/utils/realtimeConfig.d.ts +53 -0
- package/common/utils/realtimeConfig.d.ts.map +1 -0
- package/common/utils/realtimeConfig.js +202 -0
- package/common/utils/removeDuplicate.d.ts +10 -0
- package/common/utils/removeDuplicate.d.ts.map +1 -0
- package/common/utils/removeDuplicate.js +15 -0
- package/common/utils/renderTrajectories.d.ts +17 -0
- package/common/utils/renderTrajectories.d.ts.map +1 -0
- package/common/utils/renderTrajectories.js +110 -0
- package/common/utils/sortAndFilterDepartures.d.ts +16 -0
- package/common/utils/sortAndFilterDepartures.d.ts.map +1 -0
- package/common/utils/sortAndFilterDepartures.js +58 -0
- package/common/utils/sortByDelay.d.ts +4 -0
- package/common/utils/sortByDelay.d.ts.map +1 -0
- package/common/utils/sortByDelay.js +21 -0
- package/common/utils/timeUtils.d.ts +24 -0
- package/common/utils/timeUtils.d.ts.map +1 -0
- package/common/utils/timeUtils.js +39 -0
- package/iife.d.ts +3 -0
- package/iife.d.ts.map +1 -0
- package/{src/iife.js → iife.js} +1 -3
- package/index.d.ts +10 -0
- package/index.d.ts.map +1 -0
- package/index.js +10 -0
- package/mapbox/controls/CopyrightControl.d.ts +29 -0
- package/mapbox/controls/CopyrightControl.d.ts.map +1 -0
- package/{src/mapbox/controls/CopyrightControl.ts → mapbox/controls/CopyrightControl.js} +21 -26
- package/mapbox/controls/index.d.ts +2 -0
- package/mapbox/controls/index.d.ts.map +1 -0
- package/mapbox/index.d.ts +6 -0
- package/mapbox/index.d.ts.map +1 -0
- package/mapbox/layers/Layer.d.ts +59 -0
- package/mapbox/layers/Layer.d.ts.map +1 -0
- package/mapbox/layers/Layer.js +101 -0
- package/mapbox/layers/RealtimeLayer.d.ts +180 -0
- package/mapbox/layers/RealtimeLayer.d.ts.map +1 -0
- package/mapbox/layers/RealtimeLayer.js +270 -0
- package/mapbox/layers/index.d.ts +3 -0
- package/mapbox/layers/index.d.ts.map +1 -0
- package/mapbox/utils/getMercatorResolution.d.ts +9 -0
- package/mapbox/utils/getMercatorResolution.d.ts.map +1 -0
- package/mapbox/utils/getMercatorResolution.js +18 -0
- package/mapbox/utils/getSourceCoordinates.d.ts +9 -0
- package/mapbox/utils/getSourceCoordinates.d.ts.map +1 -0
- package/mapbox/utils/getSourceCoordinates.js +27 -0
- package/mapbox/utils/index.d.ts +3 -0
- package/mapbox/utils/index.d.ts.map +1 -0
- package/mbt.js +64822 -0
- package/mbt.js.map +7 -0
- package/mbt.min.js +1090 -0
- package/mbt.min.js.map +7 -0
- package/ol/controls/CopyrightControl.d.ts +31 -0
- package/ol/controls/CopyrightControl.d.ts.map +1 -0
- package/ol/controls/CopyrightControl.js +68 -0
- package/ol/controls/RoutingControl.d.ts +193 -0
- package/ol/controls/RoutingControl.d.ts.map +1 -0
- package/ol/controls/RoutingControl.js +631 -0
- package/ol/controls/StopFinderControl.d.ts +30 -0
- package/ol/controls/StopFinderControl.d.ts.map +1 -0
- package/{src/ol/controls/StopFinderControl.ts → ol/controls/StopFinderControl.js} +7 -10
- package/ol/controls/index.d.ts +4 -0
- package/ol/controls/index.d.ts.map +1 -0
- package/ol/index.d.ts +6 -0
- package/ol/index.d.ts.map +1 -0
- package/ol/layers/Layer.d.ts +86 -0
- package/ol/layers/Layer.d.ts.map +1 -0
- package/ol/layers/Layer.js +174 -0
- package/ol/layers/MapGlLayer.d.ts +67 -0
- package/ol/layers/MapGlLayer.d.ts.map +1 -0
- package/ol/layers/MapGlLayer.js +218 -0
- package/ol/layers/MapboxLayer.d.ts +50 -0
- package/ol/layers/MapboxLayer.d.ts.map +1 -0
- package/ol/layers/MapboxLayer.js +109 -0
- package/ol/layers/MapboxStyleLayer.d.ts +131 -0
- package/ol/layers/MapboxStyleLayer.d.ts.map +1 -0
- package/ol/layers/MapboxStyleLayer.js +369 -0
- package/{src/ol/layers/MaplibreLayer.ts → ol/layers/MaplibreLayer.d.ts} +10 -21
- package/ol/layers/MaplibreLayer.d.ts.map +1 -0
- package/ol/layers/MaplibreLayer.js +34 -0
- package/ol/layers/RealtimeLayer.d.ts +202 -0
- package/ol/layers/RealtimeLayer.d.ts.map +1 -0
- package/ol/layers/RealtimeLayer.js +332 -0
- package/ol/layers/RoutingLayer.d.ts +35 -0
- package/ol/layers/RoutingLayer.d.ts.map +1 -0
- package/ol/layers/RoutingLayer.js +85 -0
- package/ol/layers/VectorLayer.d.ts +25 -0
- package/ol/layers/VectorLayer.d.ts.map +1 -0
- package/ol/layers/VectorLayer.js +38 -0
- package/ol/layers/WMSLayer.d.ts +42 -0
- package/ol/layers/WMSLayer.d.ts.map +1 -0
- package/ol/layers/WMSLayer.js +88 -0
- package/ol/layers/index.d.ts +9 -0
- package/ol/layers/index.d.ts.map +1 -0
- package/ol/styles/fullTrajectoryDelayStyle.d.ts +4 -0
- package/ol/styles/fullTrajectoryDelayStyle.d.ts.map +1 -0
- package/ol/styles/fullTrajectoryDelayStyle.js +33 -0
- package/ol/styles/fullTrajectoryStyle.d.ts +5 -0
- package/ol/styles/fullTrajectoryStyle.d.ts.map +1 -0
- package/ol/styles/fullTrajectoryStyle.js +44 -0
- package/ol/styles/index.d.ts +3 -0
- package/ol/styles/index.d.ts.map +1 -0
- package/package.json +1 -1
- package/setupTests.d.ts +2 -0
- package/setupTests.d.ts.map +1 -0
- package/{src/setupTests.js → setupTests.js} +7 -12
- package/.esdoc.js +0 -18
- package/.eslintignore +0 -1
- package/.eslintrc.js +0 -25
- package/.fixpackrc +0 -20
- package/.github/workflows/build.yml +0 -16
- package/.github/workflows/conventional-pr-title.yml +0 -16
- package/.github/workflows/cypress.yml +0 -101
- package/.github/workflows/test.yml +0 -17
- package/.husky/commit-msg +0 -4
- package/.husky/post-checkout +0 -4
- package/.husky/post-merge +0 -4
- package/.husky/post-rebase +0 -4
- package/.husky/pre-commit +0 -4
- package/.lintstagedrc.js +0 -10
- package/.nvmrc +0 -1
- package/.prettierrc.js +0 -5
- package/.stylelintrc.js +0 -4
- package/CHANGELOG.md +0 -132
- package/LICENSE +0 -21
- package/MIGRATION-V2.md +0 -248
- package/README.md +0 -42
- package/__mocks__/mapbox-gl.js +0 -81
- package/__mocks__/maplibre-gl.js +0 -81
- package/babel.config.js +0 -9
- package/commitlint.config.js +0 -1
- package/cypress/e2e/examples/api.cy.js +0 -7
- package/cypress/e2e/examples/examples.cy.js +0 -7
- package/cypress/e2e/examples/navigation.cy.js +0 -29
- package/cypress/fixtures/example.json +0 -5
- package/cypress/plugins/index.js +0 -21
- package/cypress/support/commands.js +0 -25
- package/cypress/support/e2e.js +0 -20
- package/cypress.config.ts +0 -15
- package/data/fetchRoute.json +0 -292
- package/data/fetchTrajectories.json +0 -18
- package/data/fetchTrajectoryById.json +0 -3
- package/data/fetchTrajectoryStations.json +0 -18
- package/data/stopsSearch.json +0 -15
- package/dependabot.yml +0 -15
- package/doc/.eslintrc.json +0 -1
- package/doc/README.md +0 -34
- package/doc/next.config.js +0 -16
- package/doc/package.json +0 -41
- package/doc/pages/404.js +0 -5
- package/doc/pages/_app.js +0 -61
- package/doc/pages/_document.js +0 -64
- package/doc/pages/doc/[...slug].js +0 -23
- package/doc/pages/doc.js +0 -23
- package/doc/pages/example/[example].js +0 -52
- package/doc/pages/examples.js +0 -34
- package/doc/pages/index.js +0 -25
- package/doc/public/README.md +0 -15
- package/doc/public/favicon.ico +0 -0
- package/doc/public/static/assets/Lato-Black.ttf +0 -0
- package/doc/public/static/assets/Lato-BlackItalic.ttf +0 -0
- package/doc/public/static/assets/Lato-Bold.ttf +0 -0
- package/doc/public/static/assets/Lato-BoldItalic.ttf +0 -0
- package/doc/public/static/assets/Lato-Italic.ttf +0 -0
- package/doc/public/static/assets/Lato-Light.ttf +0 -0
- package/doc/public/static/assets/Lato-LightItalic.ttf +0 -0
- package/doc/public/static/assets/Lato-Regular.ttf +0 -0
- package/doc/public/static/assets/Lato-Thin.ttf +0 -0
- package/doc/public/static/assets/Lato-ThinItalic.ttf +0 -0
- package/doc/public/static/assets/OFL.txt +0 -93
- package/doc/public/static/examples/assets/tralis-live-map/index.js +0 -11
- package/doc/public/static/examples/assets/tralis-live-map/s1kreis.svg +0 -105
- package/doc/public/static/examples/assets/tralis-live-map/s20kreis.svg +0 -101
- package/doc/public/static/examples/assets/tralis-live-map/s2kreis.svg +0 -95
- package/doc/public/static/examples/assets/tralis-live-map/s3kreis.svg +0 -95
- package/doc/public/static/examples/assets/tralis-live-map/s4kreis.svg +0 -95
- package/doc/public/static/examples/assets/tralis-live-map/s6kreis.svg +0 -95
- package/doc/public/static/examples/assets/tralis-live-map/s7kreis.svg +0 -95
- package/doc/public/static/examples/assets/tralis-live-map/s8kreis.svg +0 -93
- package/doc/public/static/examples/assets/tralis-live-map/unknown.svg +0 -107
- package/doc/public/static/examples/layers.html +0 -11
- package/doc/public/static/examples/layers.js +0 -97
- package/doc/public/static/examples/mb-copyright.html +0 -26
- package/doc/public/static/examples/mb-copyright.js +0 -37
- package/doc/public/static/examples/mb-tracker.html +0 -1
- package/doc/public/static/examples/mb-tracker.js +0 -40
- package/doc/public/static/examples/mb-tracker.md +0 -1
- package/doc/public/static/examples/mb-tralis.html +0 -1
- package/doc/public/static/examples/mb-tralis.js +0 -34
- package/doc/public/static/examples/ol-copyright.html +0 -26
- package/doc/public/static/examples/ol-copyright.js +0 -43
- package/doc/public/static/examples/ol-mapbox-layer.html +0 -1
- package/doc/public/static/examples/ol-mapbox-layer.js +0 -28
- package/doc/public/static/examples/ol-mapbox-style-layer.html +0 -12
- package/doc/public/static/examples/ol-mapbox-style-layer.js +0 -48
- package/doc/public/static/examples/ol-query.html +0 -32
- package/doc/public/static/examples/ol-query.js +0 -83
- package/doc/public/static/examples/ol-routing.html +0 -26
- package/doc/public/static/examples/ol-routing.js +0 -65
- package/doc/public/static/examples/ol-routing.md +0 -1
- package/doc/public/static/examples/ol-stop-finder.html +0 -15
- package/doc/public/static/examples/ol-stop-finder.js +0 -35
- package/doc/public/static/examples/ol-stop-finder.md +0 -1
- package/doc/public/static/examples/ol-tracker.html +0 -1
- package/doc/public/static/examples/ol-tracker.js +0 -41
- package/doc/public/static/examples/ol-tracker.md +0 -1
- package/doc/public/static/examples/ol-tralis.html +0 -5
- package/doc/public/static/examples/ol-tralis.js +0 -62
- package/doc/public/static/examples/tralis-live-map.html +0 -1
- package/doc/public/static/examples/tralis-live-map.js +0 -67
- package/doc/public/static/examples/tralis-live-map.md +0 -3
- package/doc/public/static/img/live_tracker_mb.jpg +0 -0
- package/doc/public/static/img/live_tracker_munich.jpg +0 -0
- package/doc/public/static/img/live_tracker_ol.jpg +0 -0
- package/doc/public/static/img/mapbox.jpg +0 -0
- package/doc/public/static/img/mapbox_style.jpg +0 -0
- package/doc/public/static/img/ol-copyright.png +0 -0
- package/doc/public/static/img/query_objects.jpg +0 -0
- package/doc/public/static/img/routing.jpg +0 -0
- package/doc/public/static/img/simple_map.jpg +0 -0
- package/doc/public/static/img/stops.jpg +0 -0
- package/doc/public/vercel.svg +0 -4
- package/doc/src/components/CodeSandboxButton.js +0 -102
- package/doc/src/components/Documentation.js +0 -42
- package/doc/src/components/Esdoc/Anchor.js +0 -57
- package/doc/src/components/Esdoc/ClassDoc.js +0 -272
- package/doc/src/components/Esdoc/DeprecatedHTML.js +0 -16
- package/doc/src/components/Esdoc/DetailDocs.js +0 -279
- package/doc/src/components/Esdoc/DetailHTML.js +0 -33
- package/doc/src/components/Esdoc/DirectSubclassHTML.js +0 -30
- package/doc/src/components/Esdoc/DocBuilderUtils.js +0 -697
- package/doc/src/components/Esdoc/DocLinkHTML.js +0 -63
- package/doc/src/components/Esdoc/DocsLinkHTML.js +0 -38
- package/doc/src/components/Esdoc/Esdoc.js +0 -63
- package/doc/src/components/Esdoc/EsdocContent.js +0 -56
- package/doc/src/components/Esdoc/EsdocNavigation.js +0 -13
- package/doc/src/components/Esdoc/EsdocSearch.js +0 -78
- package/doc/src/components/Esdoc/ExperimentalHTML.js +0 -17
- package/doc/src/components/Esdoc/ExtendsChainHTML.js +0 -32
- package/doc/src/components/Esdoc/FileDocLinkHTML.js +0 -62
- package/doc/src/components/Esdoc/IdentifiersDoc.js +0 -113
- package/doc/src/components/Esdoc/IndirectSubclassHTML.js +0 -30
- package/doc/src/components/Esdoc/InheritedSummaryDoc.js +0 -70
- package/doc/src/components/Esdoc/InheritedSummaryHTML.js +0 -38
- package/doc/src/components/Esdoc/MixinClassesHTML.js +0 -29
- package/doc/src/components/Esdoc/NavDoc.js +0 -112
- package/doc/src/components/Esdoc/OverrideMethod.js +0 -44
- package/doc/src/components/Esdoc/OverrideMethodDescription.js +0 -35
- package/doc/src/components/Esdoc/Properties.js +0 -89
- package/doc/src/components/Esdoc/README.md +0 -45
- package/doc/src/components/Esdoc/SignatureHTML.js +0 -123
- package/doc/src/components/Esdoc/SingleDoc.js +0 -31
- package/doc/src/components/Esdoc/SummaryDoc.js +0 -160
- package/doc/src/components/Esdoc/SummaryHTML.js +0 -96
- package/doc/src/components/Esdoc/TypeDocLinkHTML.js +0 -251
- package/doc/src/components/Esdoc/index.js +0 -7
- package/doc/src/components/Esdoc/taffydb.js +0 -2070
- package/doc/src/components/Example.js +0 -200
- package/doc/src/components/ExampleCard.js +0 -126
- package/doc/src/components/Examples.js +0 -78
- package/doc/src/components/Home.js +0 -121
- package/doc/src/components/TrackerExample.js +0 -39
- package/doc/src/examples.js +0 -117
- package/doc/styles/App.scss +0 -53
- package/doc/styles/identifiers.css +0 -38
- package/doc/styles/search.css +0 -76
- package/doc/styles/style.css +0 -603
- package/esdoc/README.md +0 -27
- package/esdoc/plugins/MyPlugin.js +0 -69
- package/esdoc/plugins/dynamic-property-plugin/Plugin.js +0 -50
- package/esdoc/plugins/externals-plugin/Plugin.js +0 -45
- package/esdoc/plugins/externals-plugin/externals.js +0 -93
- package/esdoc/plugins/optional-chaining-plugin/Plugin.js +0 -8
- package/global-setup.js +0 -3
- package/jest.config.js +0 -24
- package/pull_request_template.md +0 -17
- package/scripts/read-pkg-json.js +0 -22
- package/src/api/RealtimeAPI.test.js +0 -144
- package/src/api/RealtimeAPI.ts +0 -712
- package/src/api/RoutingAPI.test.js +0 -41
- package/src/api/RoutingAPI.ts +0 -47
- package/src/api/StopsAPI.test.js +0 -34
- package/src/api/StopsAPI.ts +0 -45
- package/src/common/api/HttpAPI.test.js +0 -68
- package/src/common/api/HttpAPI.ts +0 -77
- package/src/common/api/WebSocketAPI.test.js +0 -421
- package/src/common/api/WebSocketAPI.ts +0 -515
- package/src/common/controls/ControlCommon.test.js +0 -106
- package/src/common/controls/ControlCommon.ts +0 -194
- package/src/common/controls/CopyrightControlCommon.ts +0 -41
- package/src/common/controls/StopFinderControlCommon.ts +0 -192
- package/src/common/layers/LayerCommon.test.js +0 -158
- package/src/common/layers/LayerCommon.ts +0 -321
- package/src/common/mixins/RealtimeLayerMixin.ts +0 -1168
- package/src/common/mixins/UserInteractionsLayerMixin.test.js +0 -227
- package/src/common/mixins/UserInteractionsLayerMixin.ts +0 -352
- package/src/common/styles/realtimeDefaultStyle.ts +0 -436
- package/src/common/styles/realtimeDelayStyle.ts +0 -27
- package/src/common/styles/realtimeHeadingStyle.ts +0 -138
- package/src/common/styles/realtimeSimpleStyle.ts +0 -25
- package/src/common/utils/compareDepartures.ts +0 -46
- package/src/common/utils/createCanvas.ts +0 -33
- package/src/common/utils/createRealtimeFilters.test.js +0 -100
- package/src/common/utils/createRealtimeFilters.ts +0 -96
- package/src/common/utils/debounceDeparturesMessages.ts +0 -52
- package/src/common/utils/debounceWebsocketMessages.ts +0 -47
- package/src/common/utils/getLayersAsFlatArray.ts +0 -17
- package/src/common/utils/getMapboxMapCopyrights.test.js +0 -47
- package/src/common/utils/getMapboxMapCopyrights.ts +0 -52
- package/src/common/utils/getMapboxRender.ts +0 -104
- package/src/common/utils/getMaplibreRender.ts +0 -54
- package/src/common/utils/getUrlWithParams.ts +0 -21
- package/src/common/utils/getVehiclePosition.ts +0 -92
- package/src/common/utils/realtimeConfig.test.js +0 -57
- package/src/common/utils/realtimeConfig.ts +0 -228
- package/src/common/utils/removeDuplicate.test.js +0 -22
- package/src/common/utils/removeDuplicate.ts +0 -22
- package/src/common/utils/renderTrajectories.ts +0 -194
- package/src/common/utils/sortAndFilterDepartures.ts +0 -78
- package/src/common/utils/sortByDelay.ts +0 -29
- package/src/common/utils/timeUtils.test.js +0 -16
- package/src/common/utils/timeUtils.ts +0 -45
- package/src/index.js +0 -10
- package/src/mapbox/layers/Layer.test.js +0 -217
- package/src/mapbox/layers/Layer.ts +0 -144
- package/src/mapbox/layers/RealtimeLayer.test.js +0 -13
- package/src/mapbox/layers/RealtimeLayer.ts +0 -350
- package/src/mapbox/utils/getMercatorResolution.ts +0 -21
- package/src/mapbox/utils/getSourceCoordinates.ts +0 -34
- package/src/ol/README.md +0 -0
- package/src/ol/controls/CopyrightControl.test.js +0 -211
- package/src/ol/controls/CopyrightControl.ts +0 -82
- package/src/ol/controls/RoutingControl.test.js +0 -205
- package/src/ol/controls/RoutingControl.ts +0 -869
- package/src/ol/controls/StopFinderControl.test.js +0 -59
- package/src/ol/controls/snapshots/RoutingControlRouteGen10.json +0 -58
- package/src/ol/controls/snapshots/RoutingControlRouteGen100.json +0 -292
- package/src/ol/controls/snapshots/RoutingControlRouteGen30.json +0 -69
- package/src/ol/controls/snapshots/RoutingControlRouteGen5.json +0 -58
- package/src/ol/controls/snapshots/RoutingControlRouteOSM.json +0 -759
- package/src/ol/controls/snapshots/RoutingControlStation1.json +0 -60
- package/src/ol/controls/snapshots/RoutingControlStation2.json +0 -49
- package/src/ol/layers/Layer.test.js +0 -212
- package/src/ol/layers/Layer.ts +0 -252
- package/src/ol/layers/MapGlLayer.ts +0 -294
- package/src/ol/layers/MapboxLayer.test.js +0 -190
- package/src/ol/layers/MapboxLayer.ts +0 -136
- package/src/ol/layers/MapboxStyleLayer.test.js +0 -258
- package/src/ol/layers/MapboxStyleLayer.ts +0 -466
- package/src/ol/layers/RealtimeLayer.test.js +0 -84
- package/src/ol/layers/RealtimeLayer.ts +0 -465
- package/src/ol/layers/RoutingLayer.test.js +0 -48
- package/src/ol/layers/RoutingLayer.ts +0 -113
- package/src/ol/layers/VectorLayer.test.js +0 -87
- package/src/ol/layers/VectorLayer.ts +0 -48
- package/src/ol/layers/WMSLayer.test.js +0 -65
- package/src/ol/layers/WMSLayer.ts +0 -114
- package/src/ol/styles/fullTrajectoryDelayStyle.ts +0 -37
- package/src/ol/styles/fullTrajectoryStyle.ts +0 -56
- package/tsconfig.json +0 -23
- /package/{src/api → api}/index.js +0 -0
- /package/{src/common → common}/index.js +0 -0
- /package/{src/common → common}/styles/index.js +0 -0
- /package/{src/mapbox → mapbox}/controls/index.js +0 -0
- /package/{src/mapbox → mapbox}/index.js +0 -0
- /package/{src/mapbox → mapbox}/layers/index.js +0 -0
- /package/{src/mapbox → mapbox}/utils/index.js +0 -0
- /package/{src/ol → ol}/controls/index.js +0 -0
- /package/{src/ol → ol}/index.js +0 -0
- /package/{src/ol → ol}/layers/index.js +0 -0
- /package/{src/ol → ol}/styles/index.js +0 -0
- /package/{src/types → types}/common.d.ts +0 -0
- /package/{src/types → types}/index.d.ts +0 -0
- /package/{src/types → types}/realtime.d.ts +0 -0
- /package/{src/types → types}/routing.d.ts +0 -0
- /package/{src/types → types}/stops.d.ts +0 -0
|
@@ -0,0 +1,483 @@
|
|
|
1
|
+
import WebSocketAPI from '../common/api/WebSocketAPI';
|
|
2
|
+
import debounceWebsocketMessages from '../common/utils/debounceWebsocketMessages';
|
|
3
|
+
import getModeSuffix from '../common/utils/getRealtimeModeSuffix';
|
|
4
|
+
/**
|
|
5
|
+
* Enum for Realtime modes.
|
|
6
|
+
* @readonly
|
|
7
|
+
* @typedef {string} RealtimeMode
|
|
8
|
+
* @property {string} RAW "raw"
|
|
9
|
+
* @property {string} SCHEMATIC "schematic"
|
|
10
|
+
* @property {string} TOPOGRAPHIC "topographic"
|
|
11
|
+
* @enum {RealtimeMode}
|
|
12
|
+
*/
|
|
13
|
+
export const RealtimeModes = {
|
|
14
|
+
RAW: 'raw',
|
|
15
|
+
TOPOGRAPHIC: 'topographic',
|
|
16
|
+
SCHEMATIC: 'schematic',
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* This class provides convenience methods to access to the [geOps realtime api](https://developer.geops.io/apis/realtime/).
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* import { RealtimeAPI } from 'mobility-toolbox-js/api';
|
|
23
|
+
*
|
|
24
|
+
* const api = new RealtimeAPI({
|
|
25
|
+
* url: "yourUrl",
|
|
26
|
+
* apiKey: "yourApiKey"
|
|
27
|
+
* });
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* import { RealtimeAPI } from 'mobility-toolbox-js/api';
|
|
31
|
+
*
|
|
32
|
+
* const api = new RealtimeAPI("yourUrl");
|
|
33
|
+
*/
|
|
34
|
+
class RealtimeAPI {
|
|
35
|
+
/**
|
|
36
|
+
* Constructor
|
|
37
|
+
*
|
|
38
|
+
* @param {Object|string} options A string representing the url of the service or an object containing the url and the apiKey.
|
|
39
|
+
* @param {string} options.url Url to the [geOps realtime api](https://developer.geops.io/apis/realtime/).
|
|
40
|
+
* @param {string} options.apiKey Access key for [geOps apis](https://developer.geops.io/).
|
|
41
|
+
* @param {number[5]} [options.bbox=[minX, minY, maxX, maxY, zoom, tenant] The bounding box to receive data from.
|
|
42
|
+
*/
|
|
43
|
+
constructor(options = {}) {
|
|
44
|
+
this.version = '2';
|
|
45
|
+
this.defineProperties(options);
|
|
46
|
+
/** @private */
|
|
47
|
+
this.onOpen = this.onOpen.bind(this);
|
|
48
|
+
}
|
|
49
|
+
/* @private */
|
|
50
|
+
defineProperties(options = {}) {
|
|
51
|
+
let opt = options || {};
|
|
52
|
+
if (typeof options === 'string') {
|
|
53
|
+
opt = { url: options };
|
|
54
|
+
}
|
|
55
|
+
const { apiKey, version } = opt;
|
|
56
|
+
let { url, bbox, buffer = [100, 100] } = opt;
|
|
57
|
+
const wsApi = new WebSocketAPI();
|
|
58
|
+
if (!url) {
|
|
59
|
+
url = 'wss://api.geops.io/tracker-ws/v1/';
|
|
60
|
+
}
|
|
61
|
+
if (apiKey) {
|
|
62
|
+
url = `${url}?key=${apiKey}`;
|
|
63
|
+
}
|
|
64
|
+
Object.defineProperties(this, {
|
|
65
|
+
url: {
|
|
66
|
+
get: () => url,
|
|
67
|
+
set: (newUrl) => {
|
|
68
|
+
if (url !== newUrl) {
|
|
69
|
+
url = newUrl;
|
|
70
|
+
// Update the websocket only if the url has changed and the websocket is already open or is opening.
|
|
71
|
+
if (this.wsApi.open || this.wsApi.connecting) {
|
|
72
|
+
this.open();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
bbox: {
|
|
78
|
+
get: () => bbox,
|
|
79
|
+
set: (newBbox) => {
|
|
80
|
+
if (JSON.stringify(newBbox) !== JSON.stringify(bbox)) {
|
|
81
|
+
bbox = newBbox;
|
|
82
|
+
if (this.wsApi && bbox) {
|
|
83
|
+
this.wsApi.send(`BBOX ${bbox.join(' ')}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
buffer: {
|
|
89
|
+
get: () => buffer,
|
|
90
|
+
set: (newBuffer) => {
|
|
91
|
+
if (JSON.stringify(newBuffer) !== JSON.stringify(buffer)) {
|
|
92
|
+
buffer = newBuffer;
|
|
93
|
+
if (this.wsApi) {
|
|
94
|
+
this.wsApi.send(`BUFFER ${buffer.join(' ')}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
/**
|
|
100
|
+
* The RealtimeApi version
|
|
101
|
+
*/
|
|
102
|
+
version: {
|
|
103
|
+
value: version,
|
|
104
|
+
writable: true,
|
|
105
|
+
},
|
|
106
|
+
/**
|
|
107
|
+
* The websocket helper class to connect the websocket.
|
|
108
|
+
*
|
|
109
|
+
* @private
|
|
110
|
+
*/
|
|
111
|
+
wsApi: {
|
|
112
|
+
value: wsApi,
|
|
113
|
+
writable: true,
|
|
114
|
+
},
|
|
115
|
+
/**
|
|
116
|
+
* Interval between PING request in ms.
|
|
117
|
+
* If equal to 0, no PING request are sent.
|
|
118
|
+
* @type {number}
|
|
119
|
+
* @private
|
|
120
|
+
*/
|
|
121
|
+
pingIntervalMs: {
|
|
122
|
+
value: options.pingIntervalMs || 10000,
|
|
123
|
+
writable: true,
|
|
124
|
+
},
|
|
125
|
+
/**
|
|
126
|
+
* Timeout in ms after an automatic reconnection when the websoscket has been closed by the server.
|
|
127
|
+
* @type {number}
|
|
128
|
+
*/
|
|
129
|
+
reconnectTimeoutMs: {
|
|
130
|
+
value: options.pingIntervalMs || 100,
|
|
131
|
+
writable: true,
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
open() {
|
|
136
|
+
this.wsApi.connect(this.url, this.onOpen);
|
|
137
|
+
// Register reconnection on close.
|
|
138
|
+
if (this.wsApi.websocket) {
|
|
139
|
+
this.wsApi.websocket.onclose = () => {
|
|
140
|
+
this.onClose();
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Close the websocket connection without reconnection.
|
|
146
|
+
*/
|
|
147
|
+
close() {
|
|
148
|
+
this.wsApi.close();
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Unsubscribe trajectory and deleted_vehicles channels. To resubscribe you have to set a new BBOX.
|
|
152
|
+
*/
|
|
153
|
+
// eslint-disable-next-line class-methods-use-this
|
|
154
|
+
reset() {
|
|
155
|
+
this.wsApi.send('RESET');
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Callback when the websocket is opened and ready.
|
|
159
|
+
* It applies the bbox and the projection.
|
|
160
|
+
*/
|
|
161
|
+
onOpen() {
|
|
162
|
+
if (this.bbox) {
|
|
163
|
+
this.wsApi.send(`BBOX ${this.bbox.join(' ')}`);
|
|
164
|
+
}
|
|
165
|
+
if (this.buffer) {
|
|
166
|
+
this.wsApi.send(`BUFFER ${this.buffer.join(' ')}`);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Keep websocket alive
|
|
170
|
+
*/
|
|
171
|
+
if (this.pingIntervalMs) {
|
|
172
|
+
window.clearInterval(this.pingInterval);
|
|
173
|
+
/** @private */
|
|
174
|
+
this.pingInterval = window.setInterval(() => {
|
|
175
|
+
this.wsApi.send('PING');
|
|
176
|
+
}, this.pingIntervalMs);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Callback when the websocket is closed by the server.
|
|
181
|
+
* It auto reconnects after a timeout.
|
|
182
|
+
*/
|
|
183
|
+
onClose() {
|
|
184
|
+
window.clearTimeout(this.pingInterval);
|
|
185
|
+
window.clearTimeout(this.reconnectTimeout);
|
|
186
|
+
if (this.reconnectTimeoutMs) {
|
|
187
|
+
/** @private */
|
|
188
|
+
this.reconnectTimeout = window.setTimeout(() => this.open(), this.reconnectTimeoutMs);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Send GET to a channel.
|
|
193
|
+
*
|
|
194
|
+
* @param {string | WebSocketAPIParameters} channelOrParams Name of the websocket channel to send GET or an object representing parameters to send
|
|
195
|
+
* @return {Promise<WebSocketAPIMessageEventData<?>>} A websocket response.
|
|
196
|
+
*/
|
|
197
|
+
get(channelOrParams) {
|
|
198
|
+
let params = channelOrParams;
|
|
199
|
+
if (typeof channelOrParams === 'string') {
|
|
200
|
+
params = { channel: channelOrParams };
|
|
201
|
+
}
|
|
202
|
+
return new Promise((resolve, reject) => {
|
|
203
|
+
this.wsApi.get(params, resolve, reject);
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Subscribe to a channel.
|
|
208
|
+
*
|
|
209
|
+
* @param {string} channel Name of the websocket channel to subscribe.
|
|
210
|
+
* @param {function} onSuccess Callback when the subscription succeeds.
|
|
211
|
+
* @param {function} onError Callback when the subscription fails.
|
|
212
|
+
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
213
|
+
* @private
|
|
214
|
+
*/
|
|
215
|
+
subscribe(channel, onSuccess, onError = () => { }, quiet = false) {
|
|
216
|
+
if (!channel || !onSuccess) {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
this.wsApi.subscribe({ channel }, onSuccess, onError, quiet);
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Unsubscribe both modes of a channel.
|
|
223
|
+
*
|
|
224
|
+
* @param {string} channel Name of the websocket channel to unsubscribe.
|
|
225
|
+
* @param {string} suffix Suffix to add to the channel name.
|
|
226
|
+
* @param {function} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
227
|
+
* @private
|
|
228
|
+
*/
|
|
229
|
+
unsubscribe(channel, suffix = '', onMessage) {
|
|
230
|
+
const suffixSchenatic = getModeSuffix(RealtimeModes.SCHEMATIC, RealtimeModes);
|
|
231
|
+
const suffixTopographic = getModeSuffix(RealtimeModes.TOPOGRAPHIC, RealtimeModes);
|
|
232
|
+
this.wsApi.unsubscribe(`${channel}${suffixSchenatic}${suffix || ''}`, onMessage);
|
|
233
|
+
this.wsApi.unsubscribe(`${channel}${suffixTopographic}${suffix || ''}`, onMessage);
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Subscribe to departures channel of a given station.
|
|
237
|
+
*
|
|
238
|
+
* @param {number} stationId UIC of the station.
|
|
239
|
+
* @param {Boolean} sortByMinArrivalTime Sort by minimum arrival time
|
|
240
|
+
* @param {function(departures:Departure[])} onMessage Function called on each message of the channel.
|
|
241
|
+
* @param {function} onError Callback when the subscription fails.
|
|
242
|
+
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
243
|
+
*/
|
|
244
|
+
subscribeDepartures(stationId, onMessage, onError = () => { }, quiet = false) {
|
|
245
|
+
this.subscribe(`timetable_${stationId}`, onMessage, onError, quiet);
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Unsubscribe from current departures channel.
|
|
249
|
+
* @param {RealtimeStationId} id Station's id
|
|
250
|
+
* @param {function(data: { content: RealtimeDeparture[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
251
|
+
*/
|
|
252
|
+
unsubscribeDepartures(id, onMessage) {
|
|
253
|
+
this.unsubscribe(`timetable_${id}`, '', onMessage);
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Subscribe to the disruptions channel for tenant.
|
|
257
|
+
*
|
|
258
|
+
* @param {function(data: { content: RealtimeNews[] })} onMessage Function called on each message of the channel.
|
|
259
|
+
* @param {function} onError Callback when the subscription fails.
|
|
260
|
+
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
261
|
+
*/
|
|
262
|
+
subscribeDisruptions(tenant, onMessage, onError = () => { }, quiet = false) {
|
|
263
|
+
this.subscribe(`${tenant}_newsticker`, onMessage, onError, quiet);
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Unsubscribe disruptions.
|
|
267
|
+
*
|
|
268
|
+
* @param {function(data: { content: RealtimeNews[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
269
|
+
*/
|
|
270
|
+
unsubscribeDisruptions(tenant, onMessage) {
|
|
271
|
+
this.unsubscribe(`${tenant}_newsticker`, '', onMessage);
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Return a station with a given uic number and a mode.
|
|
275
|
+
*
|
|
276
|
+
* @param {number} uic UIC of the station.
|
|
277
|
+
* @param {RealtimeMode} mode Realtime mode.
|
|
278
|
+
* @return {Promise<{data: { content: RealtimeStation }}>} A station.
|
|
279
|
+
*/
|
|
280
|
+
getStation(uic, mode) {
|
|
281
|
+
const params = {
|
|
282
|
+
channel: `station${getModeSuffix(mode, RealtimeModes)}`,
|
|
283
|
+
args: uic,
|
|
284
|
+
};
|
|
285
|
+
return this.get(params);
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Get the list of ststions available for a specifc mode. The promise is resolved every 100ms
|
|
289
|
+
* @param {RealtimeMode} mode Realtime mode.
|
|
290
|
+
* @param {number} timeout = 100 Duration in ms between each promise resolve calls.
|
|
291
|
+
* @return {Promise<RealtimeStation[]>} An array of stations.
|
|
292
|
+
*/
|
|
293
|
+
getStations(mode, timeout = 100) {
|
|
294
|
+
return new Promise((resolve) => {
|
|
295
|
+
this.get(`station${getModeSuffix(mode, RealtimeModes)}`).then(debounceWebsocketMessages(resolve, undefined, timeout));
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Subscribe to stations channel.
|
|
300
|
+
* One message pro station.
|
|
301
|
+
*
|
|
302
|
+
* @param {RealtimeMode} mode Realtime mode.
|
|
303
|
+
* @param {function(data: { content: RealtimeStation })} onMessage Function called on each message of the channel.
|
|
304
|
+
* @param {function} onError Callback when the subscription fails.
|
|
305
|
+
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
306
|
+
*/
|
|
307
|
+
subscribeStations(mode, onMessage, onError = () => { }, quiet = false) {
|
|
308
|
+
this.subscribe(`station${getModeSuffix(mode, RealtimeModes)}`, onMessage, onError, quiet);
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Unsubscribe to stations channel.
|
|
312
|
+
* @param {function(data: { content: RealtimeStation })} onMessage The listener callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribe.
|
|
313
|
+
*/
|
|
314
|
+
unsubscribeStations(onMessage) {
|
|
315
|
+
this.unsubscribe('station', '', onMessage);
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Subscribe to extra_geoms channel.
|
|
319
|
+
*
|
|
320
|
+
* @param {function(data: { content: RealtimeExtraGeom })} onMessage Function called on each message of the channel.
|
|
321
|
+
* @param {function} onError Callback when the subscription fails.
|
|
322
|
+
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
323
|
+
*/
|
|
324
|
+
subscribeExtraGeoms(onMessage, onError = () => { }, quiet = false) {
|
|
325
|
+
this.subscribe('extra_geoms', onMessage, onError, quiet);
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Unsubscribe to extra_geoms channel.
|
|
329
|
+
* @param {function(data: { content: RealtimeExtraGeom })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
330
|
+
*/
|
|
331
|
+
unsubscribeExtraGeoms(onMessage) {
|
|
332
|
+
this.unsubscribe('extra_geoms', '', onMessage);
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Return a partial trajectory with a given id and a mode.
|
|
336
|
+
*
|
|
337
|
+
* @param {number} trainId The identifier of a trajectory.
|
|
338
|
+
* @param {RealtimeMode} mode Realtime mode.
|
|
339
|
+
* @return {Promise<{data: { content: RealtimeTrajectory }}>} A trajectory.
|
|
340
|
+
*/
|
|
341
|
+
getTrajectory(id, mode) {
|
|
342
|
+
return this.get(`partial_trajectory${getModeSuffix(mode, RealtimeModes)}_${id}`);
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Subscribe to trajectory channel.
|
|
346
|
+
*
|
|
347
|
+
* @param {RealtimeMode} mode Realtime mode.
|
|
348
|
+
* @param {function(data: { content: RealtimeTrajectoryResponse[] })} onMessage Function called on each message of the channel.
|
|
349
|
+
* @param {function} onError Callback when the subscription fails.
|
|
350
|
+
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
351
|
+
*/
|
|
352
|
+
subscribeTrajectory(mode, onMessage, onError = () => { }, quiet = false) {
|
|
353
|
+
this.unsubscribeTrajectory(onMessage);
|
|
354
|
+
let suffix = '';
|
|
355
|
+
if (this.version === '1') {
|
|
356
|
+
suffix = getModeSuffix(mode, RealtimeModes);
|
|
357
|
+
}
|
|
358
|
+
this.subscribe(`trajectory${suffix}`, onMessage, onError, quiet);
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Unsubscribe to trajectory channels.
|
|
362
|
+
* @param {function(data: { content: RealtimeTrajectoryResponse[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
363
|
+
*/
|
|
364
|
+
unsubscribeTrajectory(onMessage) {
|
|
365
|
+
this.unsubscribe(`trajectory`, '', onMessage);
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Subscribe to deleted_vhicles channel.
|
|
369
|
+
*
|
|
370
|
+
* @param {RealtimeMode} mode Realtime mode.
|
|
371
|
+
* @param {function(data: { content: RealtimeTrainId })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
372
|
+
* @param {function} onError Callback when the subscription fails.
|
|
373
|
+
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
374
|
+
*/
|
|
375
|
+
subscribeDeletedVehicles(mode, onMessage, onError = () => { }, quiet = false) {
|
|
376
|
+
this.unsubscribeDeletedVehicles(onMessage);
|
|
377
|
+
let suffix = '';
|
|
378
|
+
if (this.version === '1') {
|
|
379
|
+
suffix = getModeSuffix(mode, RealtimeModes);
|
|
380
|
+
}
|
|
381
|
+
this.subscribe(`deleted_vehicles${suffix}`, onMessage, onError, quiet);
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Unsubscribe to deleted_vhicles channels.
|
|
385
|
+
* @param {function(data: { content: RealtimeTrainId })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
386
|
+
*/
|
|
387
|
+
unsubscribeDeletedVehicles(onMessage) {
|
|
388
|
+
this.unsubscribe('deleted_vehicles', '', onMessage);
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Get a full trajectory of a vehicule .
|
|
392
|
+
*
|
|
393
|
+
* @param {string} id A vehicle id.
|
|
394
|
+
* @param {RealtimeMode} mode Realtime mode.
|
|
395
|
+
* @param {string} generalizationLevel The generalization level to request. Can be one of 5 (more generalized), 10, 30, 100, undefined (less generalized).
|
|
396
|
+
* @return {Promise<{ data: { content: RealtimeFullTrajectory } }>} Return a full trajectory.
|
|
397
|
+
*/
|
|
398
|
+
getFullTrajectory(id, mode, generalizationLevel) {
|
|
399
|
+
let suffix = '';
|
|
400
|
+
if (this.version === '1') {
|
|
401
|
+
suffix = getModeSuffix(mode, RealtimeModes);
|
|
402
|
+
}
|
|
403
|
+
const channel = [`full_trajectory${suffix}`];
|
|
404
|
+
if (id) {
|
|
405
|
+
channel.push(id);
|
|
406
|
+
}
|
|
407
|
+
if ((!mode || mode === RealtimeModes.TOPOGRAPHIC) && generalizationLevel) {
|
|
408
|
+
channel.push(`gen${generalizationLevel}`);
|
|
409
|
+
}
|
|
410
|
+
return this.get(channel.join('_'));
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* Subscribe to full_trajectory channel of a given vehicle.
|
|
414
|
+
*
|
|
415
|
+
* @param {string} id A vehicle id.
|
|
416
|
+
* @param {RealtimeMode} mode Realtime mode.
|
|
417
|
+
* @param {function(data: { content: RealtimeFullTrajectory })} onMessage Function called on each message of the channel.
|
|
418
|
+
* @param {function} onError Callback when the subscription fails.
|
|
419
|
+
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
420
|
+
*/
|
|
421
|
+
subscribeFullTrajectory(id, mode, onMessage, onError = () => { }, quiet = false) {
|
|
422
|
+
let suffix = '';
|
|
423
|
+
if (this.version === '1') {
|
|
424
|
+
suffix = getModeSuffix(mode, RealtimeModes);
|
|
425
|
+
}
|
|
426
|
+
this.subscribe(`full_trajectory${suffix}_${id}`, onMessage, onError, quiet);
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Unsubscribe from full_trajectory channel
|
|
430
|
+
*
|
|
431
|
+
* @param {string} id A vehicle id.
|
|
432
|
+
* @param {function(data: { content: RealtimeFullTrajectory })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
433
|
+
*/
|
|
434
|
+
unsubscribeFullTrajectory(id, onMessage) {
|
|
435
|
+
this.unsubscribe('full_trajectory', `_${id}`, onMessage);
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Get the list of stops for this vehicle.
|
|
439
|
+
*
|
|
440
|
+
* @param {string} id A vehicle id.
|
|
441
|
+
* @return {Promise<{ data: { content: StopSequence[] } }>} Returns a stop sequence object.
|
|
442
|
+
*/
|
|
443
|
+
getStopSequence(id) {
|
|
444
|
+
return this.get(`stopsequence_${id}`);
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Subscribe to stopsequence channel of a given vehicle.
|
|
448
|
+
*
|
|
449
|
+
* @param {string} id A vehicle id.
|
|
450
|
+
* @param {function(data: { content: StopSequence[] })} onMessage Function called on each message of the channel.
|
|
451
|
+
* @param {function} onError Callback when the subscription fails.
|
|
452
|
+
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
453
|
+
*/
|
|
454
|
+
subscribeStopSequence(id, onMessage, onError = () => { }, quiet = false) {
|
|
455
|
+
this.subscribe(`stopsequence_${id}`, onMessage, onError, quiet);
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* Unsubscribe from stopsequence channel
|
|
459
|
+
*
|
|
460
|
+
* @param {string} id A vehicle id.
|
|
461
|
+
* @param {function(data: { content: StopSequence[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
462
|
+
*/
|
|
463
|
+
unsubscribeStopSequence(id, onMessage) {
|
|
464
|
+
this.unsubscribe(`stopsequence`, `_${id}`, onMessage);
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* Subscribe to healthcheck channel.
|
|
468
|
+
* @param {function(data: { content: string })} onMessage Callback when the subscribe to healthcheck channel succeeds.
|
|
469
|
+
* @param {function} onError Callback when the subscription fails.
|
|
470
|
+
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
471
|
+
*/
|
|
472
|
+
subscribeHealthCheck(onMessage, onError = () => { }, quiet = false) {
|
|
473
|
+
this.subscribe('healthcheck', onMessage, onError, quiet);
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Unsubscribe to healthcheck channel.
|
|
477
|
+
* @param {function(data: { content: string })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
478
|
+
*/
|
|
479
|
+
unsubscribeHealthCheck(onMessage) {
|
|
480
|
+
this.unsubscribe('healthcheck', '', onMessage);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
export default RealtimeAPI;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import HttpAPI from '../common/api/HttpAPI';
|
|
2
|
+
import { RoutingParameters, RoutingResponse } from '../types';
|
|
3
|
+
export type RoutingAPIOptions = {
|
|
4
|
+
url?: string;
|
|
5
|
+
apiKey?: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Access to the [geOps Routing service](https://developer.geops.io/apis/routing).
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* import { RoutingAPI } from 'mobility-toolbox-js';
|
|
12
|
+
*
|
|
13
|
+
* const api = new RoutingAPI({
|
|
14
|
+
* apiKey: [yourApiKey]
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
declare class RoutingAPI extends HttpAPI {
|
|
19
|
+
/**
|
|
20
|
+
* Constructor
|
|
21
|
+
*
|
|
22
|
+
* @param {RoutingAPIOptions} options Options.
|
|
23
|
+
* @param {string} [options.url='https://api.geops.io/routing/v1/'] Service url.
|
|
24
|
+
* @param {string} options.apiKey Access key for [geOps services](https://developer.geops.io/).
|
|
25
|
+
*/
|
|
26
|
+
constructor(options?: RoutingAPIOptions);
|
|
27
|
+
/**
|
|
28
|
+
* Route.
|
|
29
|
+
*
|
|
30
|
+
* @param {RoutingParameters} params Request parameters. See [Routing service documentation](https://developer.geops.io/apis/routing/).
|
|
31
|
+
* @param {RequestInit} config Options for the fetch request.
|
|
32
|
+
* @return {Promise<RoutingResponse>} An GeoJSON feature collection with coordinates in [EPSG:4326](http://epsg.io/4326).
|
|
33
|
+
*/
|
|
34
|
+
route(params: RoutingParameters, config: RequestInit): Promise<RoutingResponse>;
|
|
35
|
+
}
|
|
36
|
+
export default RoutingAPI;
|
|
37
|
+
//# sourceMappingURL=RoutingAPI.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RoutingAPI.d.ts","sourceRoot":"","sources":["../../src/api/RoutingAPI.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE9D,MAAM,MAAM,iBAAiB,GAAG;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,cAAM,UAAW,SAAQ,OAAO;IAC9B;;;;;;OAMG;gBACS,OAAO,GAAE,iBAAsB;IAI3C;;;;;;OAMG;IACH,KAAK,CACH,MAAM,EAAE,iBAAiB,EACzB,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,eAAe,CAAC;CAG5B;AAED,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import HttpAPI from '../common/api/HttpAPI';
|
|
2
|
+
/**
|
|
3
|
+
* Access to the [geOps Routing service](https://developer.geops.io/apis/routing).
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* import { RoutingAPI } from 'mobility-toolbox-js';
|
|
7
|
+
*
|
|
8
|
+
* const api = new RoutingAPI({
|
|
9
|
+
* apiKey: [yourApiKey]
|
|
10
|
+
* });
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
class RoutingAPI extends HttpAPI {
|
|
14
|
+
/**
|
|
15
|
+
* Constructor
|
|
16
|
+
*
|
|
17
|
+
* @param {RoutingAPIOptions} options Options.
|
|
18
|
+
* @param {string} [options.url='https://api.geops.io/routing/v1/'] Service url.
|
|
19
|
+
* @param {string} options.apiKey Access key for [geOps services](https://developer.geops.io/).
|
|
20
|
+
*/
|
|
21
|
+
constructor(options = {}) {
|
|
22
|
+
super(Object.assign({ url: 'https://api.geops.io/routing/v1/' }, options));
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Route.
|
|
26
|
+
*
|
|
27
|
+
* @param {RoutingParameters} params Request parameters. See [Routing service documentation](https://developer.geops.io/apis/routing/).
|
|
28
|
+
* @param {RequestInit} config Options for the fetch request.
|
|
29
|
+
* @return {Promise<RoutingResponse>} An GeoJSON feature collection with coordinates in [EPSG:4326](http://epsg.io/4326).
|
|
30
|
+
*/
|
|
31
|
+
route(params, config) {
|
|
32
|
+
return this.fetch('', params, config);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export default RoutingAPI;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import HttpAPI from '../common/api/HttpAPI';
|
|
2
|
+
import { StopsParameters, StopsResponse } from '../types';
|
|
3
|
+
export type StopsAPIOptions = {
|
|
4
|
+
url?: string;
|
|
5
|
+
apiKey?: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Access to the [Stops service](https://developer.geops.io/apis/5dcbd702a256d90001cf1361/).
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* import { StopsAPI } from 'mobility-toolbox-js/api';
|
|
12
|
+
*
|
|
13
|
+
* const api = new StopsAPI({
|
|
14
|
+
* url: 'https://api.geops.io/stops/v1/',
|
|
15
|
+
* apiKey: [yourApiKey]
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
declare class StopsAPI extends HttpAPI {
|
|
20
|
+
/**
|
|
21
|
+
* Constructor
|
|
22
|
+
*
|
|
23
|
+
* @param {StopsAPIOptions} options Options.
|
|
24
|
+
* @param {string} [options.url='https://api.geops.io/stops/v1/'] Service url.
|
|
25
|
+
* @param {string} options.apiKey Access key for [geOps services](https://developer.geops.io/).
|
|
26
|
+
*/
|
|
27
|
+
constructor(options?: StopsAPIOptions);
|
|
28
|
+
/**
|
|
29
|
+
* Search fo stops.
|
|
30
|
+
*
|
|
31
|
+
* @param {StopsParameters} params Request parameters. See [Stops service documentation](https://developer.geops.io/apis/stops).
|
|
32
|
+
* @param {RequestInit} config Options for the fetch request.
|
|
33
|
+
* @return {Promise<StopsResponse>} An GeoJSON feature collection with coordinates in [EPSG:4326](http://epsg.io/4326).
|
|
34
|
+
*/
|
|
35
|
+
search(params: StopsParameters, config: RequestInit): Promise<StopsResponse>;
|
|
36
|
+
}
|
|
37
|
+
export default StopsAPI;
|
|
38
|
+
//# sourceMappingURL=StopsAPI.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StopsAPI.d.ts","sourceRoot":"","sources":["../../src/api/StopsAPI.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE1D,MAAM,MAAM,eAAe,GAAG;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,cAAM,QAAS,SAAQ,OAAO;IAC5B;;;;;;OAMG;gBACS,OAAO,GAAE,eAAoB;IAIzC;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;CAG7E;AAED,eAAe,QAAQ,CAAC"}
|
package/api/StopsAPI.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import HttpAPI from '../common/api/HttpAPI';
|
|
2
|
+
/**
|
|
3
|
+
* Access to the [Stops service](https://developer.geops.io/apis/5dcbd702a256d90001cf1361/).
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* import { StopsAPI } from 'mobility-toolbox-js/api';
|
|
7
|
+
*
|
|
8
|
+
* const api = new StopsAPI({
|
|
9
|
+
* url: 'https://api.geops.io/stops/v1/',
|
|
10
|
+
* apiKey: [yourApiKey]
|
|
11
|
+
* });
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
14
|
+
class StopsAPI extends HttpAPI {
|
|
15
|
+
/**
|
|
16
|
+
* Constructor
|
|
17
|
+
*
|
|
18
|
+
* @param {StopsAPIOptions} options Options.
|
|
19
|
+
* @param {string} [options.url='https://api.geops.io/stops/v1/'] Service url.
|
|
20
|
+
* @param {string} options.apiKey Access key for [geOps services](https://developer.geops.io/).
|
|
21
|
+
*/
|
|
22
|
+
constructor(options = {}) {
|
|
23
|
+
super(Object.assign({ url: 'https://api.geops.io/stops/v1/' }, options));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Search fo stops.
|
|
27
|
+
*
|
|
28
|
+
* @param {StopsParameters} params Request parameters. See [Stops service documentation](https://developer.geops.io/apis/stops).
|
|
29
|
+
* @param {RequestInit} config Options for the fetch request.
|
|
30
|
+
* @return {Promise<StopsResponse>} An GeoJSON feature collection with coordinates in [EPSG:4326](http://epsg.io/4326).
|
|
31
|
+
*/
|
|
32
|
+
search(params, config) {
|
|
33
|
+
return this.fetch('', params, config);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export default StopsAPI;
|
package/api/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.js"],"names":[],"mappings":""}
|