mobility-toolbox-js 2.0.0-beta.1 → 2.0.0-beta.6
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/.babelrc +6 -0
- package/.esdoc.json +17 -0
- package/.eslintignore +1 -0
- package/.github/workflows/conventional-pr-title.yml +21 -0
- package/.github/workflows/cypress.yml +29 -0
- package/.github/workflows/nodejs.yml +28 -0
- package/.husky/commit-msg +4 -0
- package/.husky/post-checkout +4 -0
- package/.husky/post-merge +4 -0
- package/.husky/post-rebase +4 -0
- package/.husky/pre-commit +4 -0
- package/.neutrinorc.js +176 -0
- package/.nvmrc +1 -0
- package/CHANGELOG.md +10 -0
- package/LICENSE +21 -0
- package/Layer.js +2 -0
- package/Layer.js.map +7 -0
- package/README.md +7 -4
- package/__mocks__/mapbox-gl.js +81 -0
- package/__mocks__/maplibre-gl.js +81 -0
- package/commitlint.config.js +1 -0
- package/cypress/fixtures/example.json +5 -0
- package/cypress/integration/examples/api.spec.js +7 -0
- package/cypress/integration/examples/examples.spec.js +7 -0
- package/cypress/integration/examples/navigation.spec.js +29 -0
- package/cypress/plugins/index.js +21 -0
- package/cypress/support/commands.js +25 -0
- package/cypress/support/index.js +20 -0
- package/cypress.json +4 -0
- package/data/fetchRoute.json +292 -0
- package/data/fetchTrajectories.json +18 -0
- package/data/fetchTrajectoryById.json +3 -0
- package/data/fetchTrajectoryStations.json +18 -0
- package/data/stopsSearch.json +15 -0
- package/documentation.yml +4 -0
- package/esdoc/README.md +27 -0
- package/esdoc/plugins/MyPlugin.js +69 -0
- package/esdoc/plugins/dynamic-property-plugin/Plugin.js +50 -0
- package/esdoc/plugins/externals-plugin/Plugin.js +45 -0
- package/esdoc/plugins/externals-plugin/externals.js +96 -0
- package/global-setup.js +3 -0
- package/{ol/README.md → index.html} +0 -0
- package/indexweb.html +49 -0
- package/jest.config.js +5 -0
- package/package.json +34 -13
- package/pull_request_template.md +17 -0
- package/renovate.json +4 -0
- package/scripts/read-pkg-json.js +22 -0
- package/{api → src/api}/index.js +0 -1
- package/{api → src/api}/routing/RoutingAPI.js +0 -0
- package/{api → src/api}/routing/RoutingAPI.test.js +0 -0
- package/{api → src/api}/stops/StopsAPI.js +0 -0
- package/{api → src/api}/stops/StopsAPI.test.js +0 -0
- package/{api → src/api}/tralis/TralisAPI.js +1 -1
- package/{api → src/api}/tralis/TralisAPI.test.js +0 -0
- package/{api → src/api}/tralis/TralisAPIUtils.js +0 -0
- package/{api → src/api}/tralis/WebSocketConnector.js +0 -0
- package/{api → src/api}/tralis/WebSocketConnector.test.js +0 -0
- package/{api → src/api}/tralis/typedefs.js +0 -0
- 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 +93 -0
- package/{common → src/common}/Tracker.js +0 -0
- package/{common → src/common}/api/api.js +0 -0
- package/{common → src/common}/api/api.test.js +0 -0
- package/{common → src/common}/controls/Control.js +4 -1
- package/{common → src/common}/controls/Control.test.js +0 -0
- package/{common → src/common}/layers/Layer.js +18 -49
- package/{common → src/common}/layers/Layer.test.js +2 -106
- package/{common → src/common}/mixins/CopyrightMixin.js +0 -0
- package/{common → src/common}/mixins/SearchMixin.js +1 -1
- package/{common/mixins/TrackerLayerMixin.js → src/common/mixins/TralisLayerMixin.js} +380 -195
- package/src/common/styles/index.js +4 -0
- package/{common/utils/delayTrackerStyle.js → src/common/styles/trackerDefaultStyle.js} +8 -8
- package/src/common/styles/trackerDelayStyle.js +17 -0
- package/src/common/styles/trackerSimpleStyle.js +22 -0
- package/{common → src/common}/trackerConfig.js +0 -0
- package/{common → src/common}/trackerConfig.test.js +0 -13
- package/{common → src/common}/typedefs.js +0 -0
- package/{common → src/common}/utils/createTrackerFilters.js +0 -0
- package/{common → src/common}/utils/createTrackerFilters.test.js +0 -0
- package/{common → src/common}/utils/getMapboxMapCopyrights.js +1 -0
- package/{common → src/common}/utils/getMapboxMapCopyrights.test.js +0 -0
- package/{common → src/common}/utils/getMapboxStyleUrl.js +0 -0
- package/{common → src/common}/utils/getVehiclePosition.js +0 -0
- package/{common → src/common}/utils/index.js +2 -3
- package/{common → src/common}/utils/removeDuplicate.js +0 -0
- package/{common → src/common}/utils/removeDuplicate.test.js +0 -0
- package/src/common/utils/sortByDelay.js +23 -0
- package/{common → src/common}/utils/timeUtils.js +0 -0
- package/{common → src/common}/utils/timeUtils.test.js +0 -0
- package/src/doc/App.js +116 -0
- package/src/doc/App.scss +51 -0
- package/src/doc/_redirects +2 -0
- package/src/doc/components/CodeSandboxButton.js +103 -0
- package/src/doc/components/Documentation.js +40 -0
- package/src/doc/components/Esdoc/Anchor.js +57 -0
- package/src/doc/components/Esdoc/ClassDoc.js +272 -0
- package/src/doc/components/Esdoc/DeprecatedHTML.js +16 -0
- package/src/doc/components/Esdoc/DetailDocs.js +281 -0
- package/src/doc/components/Esdoc/DetailHTML.js +33 -0
- package/src/doc/components/Esdoc/DirectSubclassHTML.js +30 -0
- package/src/doc/components/Esdoc/DocBuilderUtils.js +694 -0
- package/src/doc/components/Esdoc/DocLinkHTML.js +62 -0
- package/src/doc/components/Esdoc/DocsLinkHTML.js +38 -0
- package/src/doc/components/Esdoc/Esdoc.js +63 -0
- package/src/doc/components/Esdoc/EsdocContent.js +51 -0
- package/src/doc/components/Esdoc/EsdocNavigation.js +13 -0
- package/src/doc/components/Esdoc/EsdocSearch.js +81 -0
- package/src/doc/components/Esdoc/ExperimentalHTML.js +17 -0
- package/src/doc/components/Esdoc/ExtendsChainHTML.js +32 -0
- package/src/doc/components/Esdoc/FileDocLinkHTML.js +60 -0
- package/src/doc/components/Esdoc/IdentifiersDoc.js +113 -0
- package/src/doc/components/Esdoc/IndirectSubclassHTML.js +30 -0
- package/src/doc/components/Esdoc/InheritedSummaryDoc.js +70 -0
- package/src/doc/components/Esdoc/InheritedSummaryHTML.js +38 -0
- package/src/doc/components/Esdoc/MixinClassesHTML.js +29 -0
- package/src/doc/components/Esdoc/NavDoc.js +112 -0
- package/src/doc/components/Esdoc/OverrideMethod.js +44 -0
- package/src/doc/components/Esdoc/OverrideMethodDescription.js +35 -0
- package/src/doc/components/Esdoc/Properties.js +89 -0
- package/src/doc/components/Esdoc/README.md +45 -0
- package/src/doc/components/Esdoc/SignatureHTML.js +123 -0
- package/src/doc/components/Esdoc/SingleDoc.js +31 -0
- package/src/doc/components/Esdoc/SummaryDoc.js +160 -0
- package/src/doc/components/Esdoc/SummaryHTML.js +96 -0
- package/src/doc/components/Esdoc/TypeDocLinkHTML.js +249 -0
- package/src/doc/components/Esdoc/css/identifiers.css +38 -0
- package/src/doc/components/Esdoc/css/search.css +76 -0
- package/src/doc/components/Esdoc/css/style.css +603 -0
- package/src/doc/components/Esdoc/index.js +7 -0
- package/src/doc/components/Example.js +153 -0
- package/src/doc/components/Examples.js +183 -0
- package/src/doc/components/Home.js +106 -0
- package/src/doc/components/TrackerExample.js +38 -0
- package/src/doc/components/esm.min.js +2 -0
- package/src/doc/components/examples/assets/tralis-live-map/index.js +11 -0
- package/src/doc/components/examples/assets/tralis-live-map/s1kreis.svg +105 -0
- package/src/doc/components/examples/assets/tralis-live-map/s20kreis.svg +101 -0
- package/src/doc/components/examples/assets/tralis-live-map/s2kreis.svg +95 -0
- package/src/doc/components/examples/assets/tralis-live-map/s3kreis.svg +95 -0
- package/src/doc/components/examples/assets/tralis-live-map/s4kreis.svg +95 -0
- package/src/doc/components/examples/assets/tralis-live-map/s6kreis.svg +95 -0
- package/src/doc/components/examples/assets/tralis-live-map/s7kreis.svg +95 -0
- package/src/doc/components/examples/assets/tralis-live-map/s8kreis.svg +93 -0
- package/src/doc/components/examples/assets/tralis-live-map/unknown.svg +107 -0
- package/src/doc/components/examples/mb-copyright.html +26 -0
- package/src/doc/components/examples/mb-copyright.js +37 -0
- package/src/doc/components/examples/mb-tracker.html +1 -0
- package/src/doc/components/examples/mb-tracker.js +39 -0
- package/src/doc/components/examples/mb-tracker.md +1 -0
- package/src/doc/components/examples/mb-tralis.html +1 -0
- package/src/doc/components/examples/mb-tralis.js +34 -0
- package/src/doc/components/examples/ol-copyright.html +26 -0
- package/src/doc/components/examples/ol-copyright.js +43 -0
- package/src/doc/components/examples/ol-mapbox-layer.html +1 -0
- package/src/doc/components/examples/ol-mapbox-layer.js +28 -0
- package/src/doc/components/examples/ol-mapbox-layer.md +0 -0
- package/src/doc/components/examples/ol-mapbox-style-layer.html +12 -0
- package/src/doc/components/examples/ol-mapbox-style-layer.js +44 -0
- package/src/doc/components/examples/ol-query.html +32 -0
- package/src/doc/components/examples/ol-query.js +83 -0
- package/src/doc/components/examples/ol-routing.html +26 -0
- package/src/doc/components/examples/ol-routing.js +59 -0
- package/src/doc/components/examples/ol-routing.md +1 -0
- package/src/doc/components/examples/ol-stop-finder.html +15 -0
- package/src/doc/components/examples/ol-stop-finder.js +31 -0
- package/src/doc/components/examples/ol-stop-finder.md +1 -0
- package/src/doc/components/examples/ol-tracker.html +1 -0
- package/src/doc/components/examples/ol-tracker.js +44 -0
- package/src/doc/components/examples/ol-tracker.md +1 -0
- package/src/doc/components/examples/ol-tralis.html +5 -0
- package/src/doc/components/examples/ol-tralis.js +57 -0
- package/src/doc/components/examples/tralis-live-map.html +1 -0
- package/src/doc/components/examples/tralis-live-map.js +51 -0
- package/src/doc/components/examples/tralis-live-map.md +3 -0
- package/src/doc/examples/assets/tralis-live-map/index.js +11 -0
- package/src/doc/examples/assets/tralis-live-map/s1kreis.svg +105 -0
- package/src/doc/examples/assets/tralis-live-map/s20kreis.svg +101 -0
- package/src/doc/examples/assets/tralis-live-map/s2kreis.svg +95 -0
- package/src/doc/examples/assets/tralis-live-map/s3kreis.svg +95 -0
- package/src/doc/examples/assets/tralis-live-map/s4kreis.svg +95 -0
- package/src/doc/examples/assets/tralis-live-map/s6kreis.svg +95 -0
- package/src/doc/examples/assets/tralis-live-map/s7kreis.svg +95 -0
- package/src/doc/examples/assets/tralis-live-map/s8kreis.svg +93 -0
- package/src/doc/examples/assets/tralis-live-map/unknown.svg +107 -0
- package/src/doc/examples/mb-copyright.html +26 -0
- package/src/doc/examples/mb-copyright.js +37 -0
- package/src/doc/examples/mb-tracker.html +1 -0
- package/src/doc/examples/mb-tracker.js +39 -0
- package/src/doc/examples/mb-tracker.md +1 -0
- package/src/doc/examples/mb-tralis.html +1 -0
- package/src/doc/examples/mb-tralis.js +34 -0
- package/src/doc/examples/ol-copyright.html +26 -0
- package/src/doc/examples/ol-copyright.js +43 -0
- package/src/doc/examples/ol-mapbox-layer.html +1 -0
- package/src/doc/examples/ol-mapbox-layer.js +28 -0
- package/src/doc/examples/ol-mapbox-layer.md +0 -0
- package/src/doc/examples/ol-mapbox-style-layer.html +12 -0
- package/src/doc/examples/ol-mapbox-style-layer.js +44 -0
- package/src/doc/examples/ol-query.html +32 -0
- package/src/doc/examples/ol-query.js +83 -0
- package/src/doc/examples/ol-routing.html +26 -0
- package/src/doc/examples/ol-routing.js +59 -0
- package/src/doc/examples/ol-routing.md +1 -0
- package/src/doc/examples/ol-stop-finder.html +15 -0
- package/src/doc/examples/ol-stop-finder.js +31 -0
- package/src/doc/examples/ol-stop-finder.md +1 -0
- package/src/doc/examples/ol-tracker.html +1 -0
- package/src/doc/examples/ol-tracker.js +44 -0
- package/src/doc/examples/ol-tracker.md +1 -0
- package/src/doc/examples/ol-tralis.html +5 -0
- package/src/doc/examples/ol-tralis.js +57 -0
- package/src/doc/examples/tralis-live-map.html +1 -0
- package/src/doc/examples/tralis-live-map.js +51 -0
- package/src/doc/examples/tralis-live-map.md +3 -0
- package/src/doc/examples.js +107 -0
- 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 +21 -0
- package/src/iife.js +7 -0
- package/{module.js → src/index.js} +3 -9
- package/{mapbox → src/mapbox}/controls/CopyrightControl.js +5 -1
- package/{mapbox → src/mapbox}/index.js +0 -2
- package/{mapbox → src/mapbox}/layers/Layer.js +0 -0
- package/{mapbox → src/mapbox}/layers/Layer.test.js +2 -2
- package/{mapbox/layers/TrackerLayer.js → src/mapbox/layers/TralisLayer.js} +71 -24
- package/src/mapbox/layers/TralisLayer.test.js +40 -0
- package/{mapbox → src/mapbox}/utils.js +0 -0
- package/src/ol/README.md +0 -0
- package/{ol → src/ol}/controls/CopyrightControl.js +4 -4
- package/{ol → src/ol}/controls/CopyrightControl.test.js +16 -16
- package/{ol → src/ol}/controls/RoutingControl.js +9 -7
- package/{ol → src/ol}/controls/RoutingControl.test.js +1 -1
- package/{ol → src/ol}/controls/StopFinderControl.js +8 -6
- package/{ol → src/ol}/controls/StopFinderControl.test.js +1 -1
- package/{ol → src/ol}/controls/snapshots/RoutingControlRouteGen10.json +0 -0
- package/{ol → src/ol}/controls/snapshots/RoutingControlRouteGen100.json +0 -0
- package/{ol → src/ol}/controls/snapshots/RoutingControlRouteGen30.json +0 -0
- package/{ol → src/ol}/controls/snapshots/RoutingControlRouteGen5.json +0 -0
- package/{ol → src/ol}/controls/snapshots/RoutingControlRouteOSM.json +0 -0
- package/{ol → src/ol}/controls/snapshots/RoutingControlStation1.json +0 -0
- package/{ol → src/ol}/controls/snapshots/RoutingControlStation2.json +0 -0
- package/{ol → src/ol}/index.js +3 -3
- package/{ol → src/ol}/layers/Layer.js +9 -0
- package/{ol → src/ol}/layers/Layer.test.js +22 -7
- package/{ol → src/ol}/layers/MapboxLayer.js +39 -44
- package/{ol → src/ol}/layers/MapboxLayer.test.js +5 -5
- package/{ol → src/ol}/layers/MapboxStyleLayer.js +0 -6
- package/{ol → src/ol}/layers/MapboxStyleLayer.test.js +22 -6
- package/src/ol/layers/MaplibreLayer.js +280 -0
- package/{ol → src/ol}/layers/RoutingLayer.js +0 -0
- package/{ol → src/ol}/layers/RoutingLayer.test.js +1 -1
- package/{ol/layers/TrackerLayer.js → src/ol/layers/TralisLayer.js} +96 -33
- package/{ol → src/ol}/layers/TralisLayer.test.js +1 -49
- package/{ol → src/ol}/layers/VectorLayer.js +0 -0
- package/{ol → src/ol}/layers/VectorLayer.test.js +1 -1
- package/{ol → src/ol}/layers/WMSLayer.js +0 -0
- package/{ol → src/ol}/layers/WMSLayer.test.js +6 -2
- package/src/ol/styles/fullTrajectoryDelayStyle.js +35 -0
- package/src/ol/styles/fullTrajectoryStyle.js +51 -0
- package/src/ol/styles/index.js +2 -0
- package/src/setupTests.js +15 -0
- package/webpack.config.js +6 -0
- package/api/trajserv/TrajservAPI.js +0 -71
- package/api/trajserv/TrajservAPI.test.js +0 -171
- package/api/trajserv/TrajservAPIUtils.js +0 -191
- package/api/trajserv/TrajservAPIUtils.test.js +0 -40
- package/api/trajserv/typedefs.js +0 -44
- package/common/mixins/MapMixin.js +0 -103
- package/common/mixins/TrajservLayerMixin.js +0 -544
- package/common/mixins/TralisLayerMixin.js +0 -402
- package/common/utils/simpleTrackerStyle.js +0 -18
- package/index.js +0 -2
- package/index.js.map +0 -1
- package/mapbox/Map.js +0 -87
- package/mapbox/layers/TrackerLayer.test.js +0 -68
- package/mapbox/layers/TrajservLayer.js +0 -114
- package/mapbox/layers/TrajservLayer.test.js +0 -90
- package/mapbox/layers/TralisLayer.js +0 -64
- package/ol/Map.js +0 -109
- package/ol/Map.test.js +0 -34
- package/ol/layers/TrackerLayer.test.js +0 -70
- package/ol/layers/TrajservLayer.js +0 -190
- package/ol/layers/TrajservLayer.test.js +0 -113
- package/ol/layers/TralisLayer.js +0 -177
|
@@ -158,24 +158,24 @@ const style = (trajectory, viewState, options) => {
|
|
|
158
158
|
} = options;
|
|
159
159
|
|
|
160
160
|
const { zoom, pixelRatio } = viewState;
|
|
161
|
-
let {
|
|
161
|
+
let { type, cancelled } = trajectory.properties;
|
|
162
162
|
const {
|
|
163
163
|
train_id: id,
|
|
164
|
+
line,
|
|
164
165
|
delay,
|
|
165
|
-
|
|
166
|
+
state,
|
|
166
167
|
operator_provides_realtime_journey: operatorProvidesRealtime,
|
|
167
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';
|
|
168
174
|
|
|
169
175
|
if (!type) {
|
|
170
176
|
type = 'Rail';
|
|
171
177
|
}
|
|
172
178
|
|
|
173
|
-
if (!line) {
|
|
174
|
-
line = {};
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
let { name, text_color: textColor, color } = line;
|
|
178
|
-
|
|
179
179
|
if (!name) {
|
|
180
180
|
name = 'I';
|
|
181
181
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import trackerDefaultStyle from './trackerDefaultStyle';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A tracker style that display the delay as backgroundColor.
|
|
5
|
+
*
|
|
6
|
+
* @param {*} trajectory The trajectory to render.
|
|
7
|
+
* @param {*} viewState The view state of the map.
|
|
8
|
+
* @param {*} options Some options to change the rendering
|
|
9
|
+
* @return a canvas
|
|
10
|
+
*/
|
|
11
|
+
const style = (trajectory, viewState, options) => {
|
|
12
|
+
return trackerDefaultStyle(trajectory, viewState, {
|
|
13
|
+
...options,
|
|
14
|
+
useDelayStyle: true,
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
export default style;
|
|
@@ -0,0 +1,22 @@
|
|
|
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;
|
|
File without changes
|
|
@@ -10,19 +10,6 @@ describe('trackerConfig', () => {
|
|
|
10
10
|
expect(getTypeIndex(undefined)).toBe(undefined);
|
|
11
11
|
});
|
|
12
12
|
|
|
13
|
-
test('find good index for old trajserv values', () => {
|
|
14
|
-
expect(getTypeIndex('Tram')).toBe(0);
|
|
15
|
-
expect(getTypeIndex('Subway / Metro / S-Bahn')).toBe(1);
|
|
16
|
-
expect(getTypeIndex('Train')).toBe(2);
|
|
17
|
-
expect(getTypeIndex('Bus')).toBe(3);
|
|
18
|
-
expect(getTypeIndex('Ferry')).toBe(4);
|
|
19
|
-
expect(getTypeIndex('Cable Car')).toBe(5);
|
|
20
|
-
expect(getTypeIndex('Gondola')).toBe(6);
|
|
21
|
-
expect(getTypeIndex('Funicular')).toBe(7);
|
|
22
|
-
expect(getTypeIndex('Long distance bus')).toBe(8);
|
|
23
|
-
expect(getTypeIndex('Rail')).toBe(9);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
13
|
test('find good index for new tracker values', () => {
|
|
27
14
|
expect(getTypeIndex('tram')).toBe(0);
|
|
28
15
|
expect(getTypeIndex('subway')).toBe(1);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export { default as getMapboxStyleUrl } from './getMapboxStyleUrl';
|
|
2
2
|
export { default as getMapboxMapCopyrights } from './getMapboxMapCopyrights';
|
|
3
3
|
export { default as removeDuplicate } from './removeDuplicate';
|
|
4
|
-
export { default as delayTrackerStyle } from './delayTrackerStyle';
|
|
5
|
-
export * from './delayTrackerStyle';
|
|
6
|
-
export { default as simpleTrackerStyle } from './simpleTrackerStyle';
|
|
7
4
|
export * from './timeUtils';
|
|
5
|
+
export * from '../styles';
|
|
6
|
+
export { default as sortByDelay } from './sortByDelay';
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const sortByDelay = (traj1, traj2) => {
|
|
2
|
+
const props1 = traj1.properties;
|
|
3
|
+
const props2 = traj2.properties;
|
|
4
|
+
|
|
5
|
+
if (props1.delay === null && props2.delay !== null) {
|
|
6
|
+
return 1;
|
|
7
|
+
}
|
|
8
|
+
if (props2.delay === null && props1.delay !== null) {
|
|
9
|
+
return -1;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// We put cancelled train inbetween green and yellow trains
|
|
13
|
+
// >=180000ms corresponds to yellow train
|
|
14
|
+
if (props1.cancelled && !props2.cancelled) {
|
|
15
|
+
return props2.delay < 180000 ? -1 : 1;
|
|
16
|
+
}
|
|
17
|
+
if (props2.cancelled && !props1.cancelled) {
|
|
18
|
+
return props1.delay < 180000 ? 1 : -1;
|
|
19
|
+
}
|
|
20
|
+
return props2.delay - props1.delay;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default sortByDelay;
|
|
File without changes
|
|
File without changes
|
package/src/doc/App.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ThemeProvider, makeStyles } from '@material-ui/core/styles';
|
|
3
|
+
import Container from '@material-ui/core/Container';
|
|
4
|
+
import { Outlet, Routes, Route, Navigate, Link } from 'react-router-dom';
|
|
5
|
+
import { geopsTheme, Header, Footer } from '@geops/geops-ui';
|
|
6
|
+
import Examples from './components/Examples';
|
|
7
|
+
import Example from './components/Example';
|
|
8
|
+
import Documentation from './components/Documentation';
|
|
9
|
+
import Home from './components/Home';
|
|
10
|
+
|
|
11
|
+
import 'typeface-lato';
|
|
12
|
+
import './App.scss';
|
|
13
|
+
|
|
14
|
+
const useStyles = makeStyles({
|
|
15
|
+
content: {
|
|
16
|
+
flexGrow: 1,
|
|
17
|
+
overflowY: 'auto',
|
|
18
|
+
paddingBottom: 115,
|
|
19
|
+
margin: 'auto',
|
|
20
|
+
marginTop: 30,
|
|
21
|
+
},
|
|
22
|
+
documentation: {
|
|
23
|
+
flexGrow: 1,
|
|
24
|
+
overflowY: 'auto',
|
|
25
|
+
padding: 0,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const tabs = [
|
|
30
|
+
{
|
|
31
|
+
label: 'Home',
|
|
32
|
+
component: Link,
|
|
33
|
+
to: '/home',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
label: 'API',
|
|
37
|
+
component: Link,
|
|
38
|
+
to: '/api',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
label: 'Examples',
|
|
42
|
+
component: Link,
|
|
43
|
+
to: '/examples',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
label: 'Code',
|
|
47
|
+
href: 'https://github.com/geops/mobility-toolbox-js',
|
|
48
|
+
},
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
function Main() {
|
|
52
|
+
return (
|
|
53
|
+
<ThemeProvider theme={geopsTheme}>
|
|
54
|
+
<Header title="mobility-toolbox-js" tabs={tabs} />
|
|
55
|
+
<Outlet />
|
|
56
|
+
<Footer />
|
|
57
|
+
</ThemeProvider>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function App() {
|
|
62
|
+
const classes = useStyles();
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<Routes>
|
|
66
|
+
<Route path="/" element={<Main />}>
|
|
67
|
+
<Route index element={<Navigate to="/home" />} />
|
|
68
|
+
<Route
|
|
69
|
+
index
|
|
70
|
+
path="/home"
|
|
71
|
+
element={
|
|
72
|
+
<Container className={classes.content}>
|
|
73
|
+
<Home />
|
|
74
|
+
</Container>
|
|
75
|
+
}
|
|
76
|
+
/>
|
|
77
|
+
<Route
|
|
78
|
+
path="/examples"
|
|
79
|
+
element={
|
|
80
|
+
<Container className={classes.content}>
|
|
81
|
+
<Examples />
|
|
82
|
+
</Container>
|
|
83
|
+
}
|
|
84
|
+
/>
|
|
85
|
+
<Route
|
|
86
|
+
path="/example/:exampleKey"
|
|
87
|
+
element={
|
|
88
|
+
<Container className={classes.content}>
|
|
89
|
+
<Example />
|
|
90
|
+
</Container>
|
|
91
|
+
}
|
|
92
|
+
/>
|
|
93
|
+
<Route path="/api">
|
|
94
|
+
<Route
|
|
95
|
+
index
|
|
96
|
+
element={
|
|
97
|
+
<Container className={classes.documentation} maxWidth={false}>
|
|
98
|
+
<Documentation />
|
|
99
|
+
</Container>
|
|
100
|
+
}
|
|
101
|
+
/>
|
|
102
|
+
<Route
|
|
103
|
+
path="*"
|
|
104
|
+
element={
|
|
105
|
+
<Container className={classes.documentation} maxWidth={false}>
|
|
106
|
+
<Documentation />
|
|
107
|
+
</Container>
|
|
108
|
+
}
|
|
109
|
+
/>
|
|
110
|
+
</Route>
|
|
111
|
+
</Route>
|
|
112
|
+
</Routes>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export default App;
|
package/src/doc/App.scss
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
html {
|
|
2
|
+
height: 100%;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
body {
|
|
6
|
+
margin: 0;
|
|
7
|
+
font-family: Lato, Arial, sans-serif;
|
|
8
|
+
color: #353535;
|
|
9
|
+
position: relative;
|
|
10
|
+
min-height: 100%;
|
|
11
|
+
overflow-y: scroll;
|
|
12
|
+
font-size: 18px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
a {
|
|
16
|
+
text-decoration: none;
|
|
17
|
+
color: #76b833;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
#map a {
|
|
21
|
+
color: initial;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/* geops ui css */
|
|
25
|
+
button.geops-ui {
|
|
26
|
+
color: #fff;
|
|
27
|
+
padding: 5px 15px;
|
|
28
|
+
font-size: 18px;
|
|
29
|
+
box-sizing: border-box;
|
|
30
|
+
transition:
|
|
31
|
+
background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,
|
|
32
|
+
box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,
|
|
33
|
+
border 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
|
|
34
|
+
font-weight: 700;
|
|
35
|
+
line-height: 24px;
|
|
36
|
+
border-radius: 5px;
|
|
37
|
+
text-transform: none;
|
|
38
|
+
background-color: #76b833;
|
|
39
|
+
border: 0;
|
|
40
|
+
outline: none;
|
|
41
|
+
|
|
42
|
+
&:not([disabled]) {
|
|
43
|
+
cursor: pointer;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
&:hover {
|
|
47
|
+
box-shadow: 0 5px 16px #35353540;
|
|
48
|
+
text-decoration: none;
|
|
49
|
+
background-color: #76b833;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { getParameters } from 'codesandbox/lib/api/define';
|
|
4
|
+
import { Button, SvgIcon } from '@material-ui/core';
|
|
5
|
+
import { makeStyles } from '@material-ui/core/styles';
|
|
6
|
+
|
|
7
|
+
const useStyles = makeStyles({
|
|
8
|
+
button: {
|
|
9
|
+
padding: '5px 15px',
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
function CodeSandboxButton({ html, js, extraFiles, ...props }) {
|
|
14
|
+
const classes = useStyles();
|
|
15
|
+
|
|
16
|
+
if (!html || !js) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const dataSB = {
|
|
21
|
+
files: {
|
|
22
|
+
'index.html': {
|
|
23
|
+
content: `${html}<script src="index.js"></script>`,
|
|
24
|
+
},
|
|
25
|
+
'index.js': {
|
|
26
|
+
content: js // eslint-disable-next-line no-template-curly-in-string
|
|
27
|
+
.replaceAll('${window.apiKey}', window.apiKey)
|
|
28
|
+
.replaceAll('window.apiKey', `'${window.apiKey}'`),
|
|
29
|
+
},
|
|
30
|
+
'package.json': {
|
|
31
|
+
content: {
|
|
32
|
+
name: 'vanilla',
|
|
33
|
+
version: '1.0.0',
|
|
34
|
+
description: 'Mobility example starter project',
|
|
35
|
+
main: 'index.html',
|
|
36
|
+
scripts: {
|
|
37
|
+
start: 'parcel index.html --open',
|
|
38
|
+
build: 'parcel build index.html',
|
|
39
|
+
},
|
|
40
|
+
dependencies: {
|
|
41
|
+
'mapbox-gl': '1',
|
|
42
|
+
'maplibre-gl': '2',
|
|
43
|
+
'mobility-toolbox-js': 'latest@beta',
|
|
44
|
+
ol: '6.3.1',
|
|
45
|
+
'query-string': '6.13.1',
|
|
46
|
+
},
|
|
47
|
+
devDependencies: {
|
|
48
|
+
'@babel/core': '7.2.0',
|
|
49
|
+
'parcel-bundler': '^1.6.1',
|
|
50
|
+
},
|
|
51
|
+
keywords: [
|
|
52
|
+
'javascript',
|
|
53
|
+
'starter',
|
|
54
|
+
'mobility-toolbox-js',
|
|
55
|
+
'mobility',
|
|
56
|
+
'toolbox',
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
...extraFiles,
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
const dataSBStr = getParameters(dataSB);
|
|
64
|
+
return (
|
|
65
|
+
<form
|
|
66
|
+
action="https://codesandbox.io/api/v1/sandboxes/define"
|
|
67
|
+
method="POST"
|
|
68
|
+
target="_blank"
|
|
69
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
70
|
+
{...props}
|
|
71
|
+
>
|
|
72
|
+
<input type="hidden" name="parameters" value={dataSBStr} />
|
|
73
|
+
<Button
|
|
74
|
+
type="submit"
|
|
75
|
+
className={classes.button}
|
|
76
|
+
startIcon={
|
|
77
|
+
<SvgIcon fontSize="large">
|
|
78
|
+
<path
|
|
79
|
+
d="M2 6l10.455-6L22.91 6L23 17.95L12.455 24L2 18V6zm2.088 2.481v4.757l3.345 1.86v3.516l3.972 2.296v-8.272L4.088 8.481zm16.739 0l-7.317 4.157v8.272l3.972-2.296V15.1l3.345-1.861V8.48zM5.134 6.601l7.303 4.144l7.32-4.18l-3.871-2.197l-3.41 1.945l-3.43-1.968L5.133 6.6z"
|
|
80
|
+
fill="currentColor"
|
|
81
|
+
/>
|
|
82
|
+
</SvgIcon>
|
|
83
|
+
}
|
|
84
|
+
>
|
|
85
|
+
Edit in Sandbox
|
|
86
|
+
</Button>
|
|
87
|
+
</form>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
CodeSandboxButton.propTypes = {
|
|
92
|
+
html: PropTypes.string,
|
|
93
|
+
js: PropTypes.string,
|
|
94
|
+
extraFiles: PropTypes.shape(),
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
CodeSandboxButton.defaultProps = {
|
|
98
|
+
html: null,
|
|
99
|
+
js: null,
|
|
100
|
+
extraFiles: {},
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export default React.memo(CodeSandboxButton);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { makeStyles } from '@material-ui/core/styles';
|
|
3
|
+
import { useParams, useLocation } from 'react-router-dom';
|
|
4
|
+
import Esdoc from './Esdoc/Esdoc';
|
|
5
|
+
|
|
6
|
+
const useStyles = makeStyles({
|
|
7
|
+
root: {
|
|
8
|
+
display: 'flex',
|
|
9
|
+
flexGrow: 1,
|
|
10
|
+
justifyContent: 'center',
|
|
11
|
+
height: '100%',
|
|
12
|
+
},
|
|
13
|
+
iframe: {
|
|
14
|
+
flexGrow: 1,
|
|
15
|
+
border: 0,
|
|
16
|
+
overflow: 'hidden',
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
function Documentation() {
|
|
21
|
+
const classes = useStyles();
|
|
22
|
+
const params = useParams();
|
|
23
|
+
const { hash } = useLocation();
|
|
24
|
+
const [path, setPath] = useState('identifiers%20html');
|
|
25
|
+
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
const matchPath = (params || {})['*'];
|
|
28
|
+
if (matchPath) {
|
|
29
|
+
setPath(matchPath.replace(/ /g, '.') + hash);
|
|
30
|
+
}
|
|
31
|
+
}, [params, hash]);
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<div className={classes.root}>
|
|
35
|
+
<Esdoc path={path} />
|
|
36
|
+
</div>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default React.memo(Documentation);
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/* eslint-disable react/prop-types */
|
|
2
|
+
/* eslint-disable no-underscore-dangle */
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import { Scrollchor } from 'react-scrollchor';
|
|
6
|
+
|
|
7
|
+
const propTypes = {
|
|
8
|
+
/**
|
|
9
|
+
* Path to the link, can include an anchor #
|
|
10
|
+
*/
|
|
11
|
+
path: PropTypes.string.isRequired,
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Children content of the link.
|
|
15
|
+
*/
|
|
16
|
+
children: PropTypes.node.isRequired,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Anchor which returns a Scrollchor element
|
|
21
|
+
* if the path contains an anchor (#), otherwise it returns a <a> element.
|
|
22
|
+
* @param {string} options.path Path to the link, can include an anchor #
|
|
23
|
+
* @param {node} options.children Children content of the link.
|
|
24
|
+
* @return {node} Scrollchor or <a> element
|
|
25
|
+
* @private
|
|
26
|
+
*/
|
|
27
|
+
function Anchor({ path, children, ...other }) {
|
|
28
|
+
const pathElements = path.split('#');
|
|
29
|
+
if (pathElements[0] === window.location.pathname) {
|
|
30
|
+
const anchor = pathElements[1];
|
|
31
|
+
const to = anchor ? `#${anchor}` : '';
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<Scrollchor
|
|
35
|
+
to={to}
|
|
36
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
37
|
+
{...other}
|
|
38
|
+
>
|
|
39
|
+
{children}
|
|
40
|
+
</Scrollchor>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<a
|
|
46
|
+
href={path}
|
|
47
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
48
|
+
{...other}
|
|
49
|
+
>
|
|
50
|
+
{children}
|
|
51
|
+
</a>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
Anchor.propTypes = propTypes;
|
|
56
|
+
|
|
57
|
+
export default Anchor;
|