mobility-toolbox-js 2.0.0-beta.8 → 2.0.1-beta.13
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/RoutingAPI.js +15 -0
- package/api/RoutingAPI.test.js +25 -0
- package/api/StopsAPI.js +12 -0
- package/api/StopsAPI.test.js +22 -0
- package/api/TralisAPI.js +359 -0
- package/api/TralisAPI.test.js +67 -0
- package/{src/api/tralis → api}/TralisAPIUtils.js +2 -32
- package/api/index.js +3 -0
- package/{index.html → api/typedefs.js} +0 -0
- package/common/Tracker.js +93 -0
- package/common/api/HttpAPI.js +30 -0
- package/common/api/HttpAPI.test.js +50 -0
- package/common/api/WebSocketAPI.js +175 -0
- package/{src/api/tralis/WebSocketConnector.test.js → common/api/WebSocketAPI.test.js} +100 -145
- package/common/controls/Control.js +81 -0
- package/{src/common → common}/controls/Control.test.js +32 -43
- package/common/index.js +4 -0
- package/common/layers/Layer.js +213 -0
- package/{src/common → common}/layers/Layer.test.js +185 -244
- package/common/mixins/CopyrightMixin.js +24 -0
- package/common/mixins/SearchMixin.js +110 -0
- package/common/mixins/TralisLayerMixin.js +479 -0
- package/common/styles/index.js +4 -0
- package/{src/common → common}/styles/trackerDefaultStyle.js +39 -175
- package/common/styles/trackerDelayStyle.js +8 -0
- package/{src/common → common}/styles/trackerSimpleStyle.js +4 -8
- package/{src/common → common}/trackerConfig.js +61 -99
- package/common/trackerConfig.test.js +23 -0
- package/{src/doc/examples/ol-mapbox-layer.md → common/typedefs.js} +0 -0
- package/common/utils/createTrackerFilters.js +56 -0
- package/common/utils/createTrackerFilters.test.js +79 -0
- package/{src/common → common}/utils/getMapboxMapCopyrights.js +3 -16
- package/common/utils/getMapboxMapCopyrights.test.js +40 -0
- package/{src/common → common}/utils/getMapboxStyleUrl.js +3 -13
- package/{src/common → common}/utils/getVehiclePosition.js +3 -33
- package/common/utils/index.js +5 -0
- package/common/utils/removeDuplicate.js +8 -0
- package/common/utils/removeDuplicate.test.js +19 -0
- package/{src/common → common}/utils/sortByDelay.js +2 -7
- package/common/utils/timeUtils.js +20 -0
- package/common/utils/timeUtils.test.js +10 -0
- package/index.js +8 -0
- package/mapbox/controls/CopyrightControl.js +29 -0
- package/mapbox/controls/index.js +1 -0
- package/mapbox/index.js +4 -0
- package/mapbox/layers/Layer.js +57 -0
- package/mapbox/layers/Layer.test.js +182 -0
- package/mapbox/layers/TralisLayer.js +182 -0
- package/{src/mapbox → mapbox}/layers/TralisLayer.test.js +12 -14
- package/mapbox/layers/index.js +2 -0
- package/{src/mapbox → mapbox}/utils.js +7 -21
- package/mbt.js +50444 -0
- package/mbt.js.map +7 -0
- package/mbt.min.js +1005 -0
- package/mbt.min.js.map +7 -0
- package/ol/controls/CopyrightControl.js +42 -0
- package/ol/controls/CopyrightControl.test.js +165 -0
- package/ol/controls/RoutingControl.js +387 -0
- package/ol/controls/RoutingControl.test.js +151 -0
- package/ol/controls/StopFinderControl.js +10 -0
- package/ol/controls/StopFinderControl.test.js +48 -0
- package/ol/controls/index.js +3 -0
- package/ol/index.js +5 -0
- package/ol/layers/Layer.js +88 -0
- package/ol/layers/Layer.test.js +174 -0
- package/ol/layers/MapboxLayer.js +203 -0
- package/{src/ol → ol}/layers/MapboxLayer.test.js +58 -84
- package/ol/layers/MapboxStyleLayer.js +187 -0
- package/{src/ol → ol}/layers/MapboxStyleLayer.test.js +97 -128
- package/ol/layers/MaplibreLayer.js +139 -0
- package/ol/layers/RoutingLayer.js +61 -0
- package/{src/ol → ol}/layers/RoutingLayer.test.js +15 -24
- package/ol/layers/TralisLayer.js +185 -0
- package/ol/layers/TralisLayer.test.js +79 -0
- package/ol/layers/VectorLayer.js +22 -0
- package/{src/ol → ol}/layers/VectorLayer.test.js +34 -45
- package/ol/layers/WMSLayer.js +38 -0
- package/ol/layers/WMSLayer.test.js +76 -0
- package/ol/layers/index.js +8 -0
- package/{src/ol → ol}/styles/fullTrajectoryDelayStyle.js +11 -15
- package/ol/styles/fullTrajectoryStyle.js +43 -0
- package/ol/styles/index.js +2 -0
- package/package.json +34 -74
- 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/__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/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/WebSocketConnector.js +0 -338
- package/src/api/tralis/typedefs.js +0 -81
- 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/index.js +0 -5
- package/src/common/layers/Layer.js +0 -404
- 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/trackerDelayStyle.js +0 -17
- 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.test.js +0 -47
- 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/timeUtils.js +0 -44
- 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-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/iife.js +0 -7
- package/src/index.js +0 -10
- package/src/mapbox/controls/CopyrightControl.js +0 -58
- package/src/mapbox/controls/index.js +0 -2
- package/src/mapbox/index.js +0 -4
- 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/index.js +0 -2
- 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.js +0 -38
- package/src/ol/controls/StopFinderControl.test.js +0 -59
- package/src/ol/controls/index.js +0 -3
- 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/index.js +0 -5
- 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/MapboxStyleLayer.js +0 -417
- package/src/ol/layers/MaplibreLayer.js +0 -280
- package/src/ol/layers/RoutingLayer.js +0 -91
- 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/WMSLayer.js +0 -80
- package/src/ol/layers/WMSLayer.test.js +0 -84
- package/src/ol/layers/index.js +0 -8
- package/src/ol/styles/fullTrajectoryStyle.js +0 -51
- package/src/ol/styles/index.js +0 -2
- package/src/setupTests.js +0 -15
- package/webpack.config.js +0 -6
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export class CopyrightInterface {
|
|
2
|
+
getCopyrights() {
|
|
3
|
+
}
|
|
4
|
+
}
|
|
5
|
+
const CopyrightMixin = (Base) => class extends Base {
|
|
6
|
+
render() {
|
|
7
|
+
if (!this.element) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
this.element.innerHTML = this.active ? this.getCopyrights().join(" | ") : "";
|
|
11
|
+
}
|
|
12
|
+
createDefaultElement() {
|
|
13
|
+
this.element = document.createElement("div");
|
|
14
|
+
this.element.id = "mbt-copyright";
|
|
15
|
+
Object.assign(this.element.style, {
|
|
16
|
+
position: "absolute",
|
|
17
|
+
bottom: 0,
|
|
18
|
+
right: 0,
|
|
19
|
+
fontSize: ".8rem",
|
|
20
|
+
padding: "0 10px"
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
export default CopyrightMixin;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { StopsAPI } from "../../api";
|
|
2
|
+
export class SearchInterface {
|
|
3
|
+
constructor(options = {}) {
|
|
4
|
+
}
|
|
5
|
+
search(query, abortController) {
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
const SearchMixin = (Base) => class extends Base {
|
|
9
|
+
constructor(options = {}) {
|
|
10
|
+
super(options);
|
|
11
|
+
const { apiParams, apiKey, url } = options;
|
|
12
|
+
this.apiParams = { limit: 20, ...apiParams || {} };
|
|
13
|
+
this.placeholder = options.placeholder || "Search for a stop...";
|
|
14
|
+
const apiOptions = { apiKey };
|
|
15
|
+
if (url) {
|
|
16
|
+
apiOptions.url = url;
|
|
17
|
+
}
|
|
18
|
+
this.api = new StopsAPI(apiOptions);
|
|
19
|
+
this.abortController = new AbortController();
|
|
20
|
+
}
|
|
21
|
+
render(featureCollection) {
|
|
22
|
+
const suggestions = featureCollection?.features || [];
|
|
23
|
+
if (!this.suggestionsElt) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
this.suggestionsElt.style.display = suggestions.length ? "block" : "none";
|
|
27
|
+
this.suggestionsElt.innerHTML = "";
|
|
28
|
+
suggestions.forEach((suggestion) => {
|
|
29
|
+
const { properties } = suggestion;
|
|
30
|
+
const suggElt = document.createElement("div");
|
|
31
|
+
suggElt.innerHTML = properties.name;
|
|
32
|
+
suggElt.onclick = () => {
|
|
33
|
+
this.onSuggestionClick(suggestion);
|
|
34
|
+
};
|
|
35
|
+
Object.assign(suggElt.style, {
|
|
36
|
+
padding: "5px 12px"
|
|
37
|
+
});
|
|
38
|
+
this.suggestionsElt.appendChild(suggElt);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
createDefaultElement() {
|
|
42
|
+
this.element = document.createElement("div");
|
|
43
|
+
this.element.id = "mbt-search";
|
|
44
|
+
Object.assign(this.element.style, {
|
|
45
|
+
position: "absolute",
|
|
46
|
+
top: 0,
|
|
47
|
+
left: "50px",
|
|
48
|
+
margin: "10px",
|
|
49
|
+
display: "flex",
|
|
50
|
+
flexDirection: "column",
|
|
51
|
+
width: "320px"
|
|
52
|
+
});
|
|
53
|
+
this.inputElt = document.createElement("input");
|
|
54
|
+
this.inputElt.type = "text";
|
|
55
|
+
this.inputElt.placeholder = this.placeholder;
|
|
56
|
+
this.inputElt.autoComplete = "off";
|
|
57
|
+
this.inputElt.onkeyup = (evt) => {
|
|
58
|
+
this.abortController.abort();
|
|
59
|
+
this.abortController = new AbortController();
|
|
60
|
+
this.search(evt.target.value, this.abortController);
|
|
61
|
+
};
|
|
62
|
+
Object.assign(this.inputElt.style, {
|
|
63
|
+
padding: "10px 30px 10px 10px"
|
|
64
|
+
});
|
|
65
|
+
this.element.appendChild(this.inputElt);
|
|
66
|
+
this.suggestionsElt = document.createElement("div");
|
|
67
|
+
Object.assign(this.suggestionsElt.style, {
|
|
68
|
+
backgroundColor: "white",
|
|
69
|
+
overflowY: "auto",
|
|
70
|
+
cursor: "pointer"
|
|
71
|
+
});
|
|
72
|
+
this.element.appendChild(this.suggestionsElt);
|
|
73
|
+
this.clearElt = document.createElement("div");
|
|
74
|
+
Object.assign(this.clearElt.style, {
|
|
75
|
+
display: "none",
|
|
76
|
+
position: "absolute",
|
|
77
|
+
right: "0",
|
|
78
|
+
padding: "0 10px",
|
|
79
|
+
fontSize: "200%",
|
|
80
|
+
cursor: "pointer"
|
|
81
|
+
});
|
|
82
|
+
this.clearElt.innerHTML = "\xD7";
|
|
83
|
+
this.clearElt.onclick = () => this.clear();
|
|
84
|
+
this.element.appendChild(this.clearElt);
|
|
85
|
+
}
|
|
86
|
+
search(q, abortController) {
|
|
87
|
+
if (q !== void 0 || q !== null) {
|
|
88
|
+
this.apiParams.q = q;
|
|
89
|
+
}
|
|
90
|
+
if (this.clearElt) {
|
|
91
|
+
this.clearElt.style.display = "block";
|
|
92
|
+
}
|
|
93
|
+
return this.api.search(this.apiParams, abortController).then((data) => {
|
|
94
|
+
this.render(data);
|
|
95
|
+
}).catch(() => {
|
|
96
|
+
this.render();
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
onSuggestionClick(suggestion) {
|
|
100
|
+
}
|
|
101
|
+
clear() {
|
|
102
|
+
if (!this.suggestionsElt) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
this.inputElt.value = "";
|
|
106
|
+
this.suggestionsElt.innerHTML = "";
|
|
107
|
+
this.clearElt.style.display = "none";
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
export default SearchMixin;
|
|
@@ -0,0 +1,479 @@
|
|
|
1
|
+
import qs from "query-string";
|
|
2
|
+
import { buffer, containsCoordinate, intersects } from "ol/extent";
|
|
3
|
+
import { unByKey } from "ol/Observable";
|
|
4
|
+
import GeoJSON from "ol/format/GeoJSON";
|
|
5
|
+
import Point from "ol/geom/Point";
|
|
6
|
+
import debounce from "lodash.debounce";
|
|
7
|
+
import throttle from "lodash.throttle";
|
|
8
|
+
import { fromLonLat } from "ol/proj";
|
|
9
|
+
import Tracker from "../Tracker";
|
|
10
|
+
import { timeSteps } from "../trackerConfig";
|
|
11
|
+
import createFilters from "../utils/createTrackerFilters";
|
|
12
|
+
import trackerDefaultStyle from "../styles/trackerDefaultStyle";
|
|
13
|
+
import { TralisAPI, TralisModes } from "../../api";
|
|
14
|
+
const LINE_FILTER = "publishedlinename";
|
|
15
|
+
const ROUTE_FILTER = "tripnumber";
|
|
16
|
+
const OPERATOR_FILTER = "operator";
|
|
17
|
+
export class TralisLayerInterface {
|
|
18
|
+
constructor(options = {}) {
|
|
19
|
+
}
|
|
20
|
+
attachToMap(map) {
|
|
21
|
+
}
|
|
22
|
+
detachFromMap() {
|
|
23
|
+
}
|
|
24
|
+
start() {
|
|
25
|
+
}
|
|
26
|
+
stop() {
|
|
27
|
+
}
|
|
28
|
+
setBbox(extent, zoom) {
|
|
29
|
+
}
|
|
30
|
+
setMode(mode) {
|
|
31
|
+
}
|
|
32
|
+
getTrajectoryInfos(id, mode) {
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const TralisLayerMixin = (Base) => class extends Base {
|
|
36
|
+
constructor(options = {}) {
|
|
37
|
+
super({ hitTolerance: 10, ...options });
|
|
38
|
+
this.debug = options.debug;
|
|
39
|
+
this.mode = options.mode || TralisModes.TOPOGRAPHIC;
|
|
40
|
+
this.api = options.api || new TralisAPI(options);
|
|
41
|
+
this.tenant = options.tenant || "";
|
|
42
|
+
this.minZoomNonTrain = options.minZoomNonTrain || 9;
|
|
43
|
+
this.minZoomInterpolation = options.minZoomInterpolation || 8;
|
|
44
|
+
this.format = new GeoJSON();
|
|
45
|
+
this.generalizationLevelByZoom = options.generalizationLevelByZoom || {
|
|
46
|
+
0: 5,
|
|
47
|
+
1: 5,
|
|
48
|
+
2: 5,
|
|
49
|
+
3: 5,
|
|
50
|
+
4: 5,
|
|
51
|
+
5: 5,
|
|
52
|
+
6: 5,
|
|
53
|
+
7: 5,
|
|
54
|
+
8: 10,
|
|
55
|
+
9: 30,
|
|
56
|
+
10: 30,
|
|
57
|
+
11: 100,
|
|
58
|
+
12: 100,
|
|
59
|
+
13: 100
|
|
60
|
+
};
|
|
61
|
+
this.isUpdateBboxOnMoveEnd = options.isUpdateBboxOnMoveEnd !== false;
|
|
62
|
+
this.throttleRenderTrajectories = throttle(this.renderTrajectoriesInternal, 50, { leading: false, trailing: true });
|
|
63
|
+
this.debounceRenderTrajectories = debounce(this.renderTrajectoriesInternal, 50, { leading: true, trailing: true, maxWait: 5e3 });
|
|
64
|
+
this.onFeatureHover = this.onFeatureHover.bind(this);
|
|
65
|
+
this.onFeatureClick = this.onFeatureClick.bind(this);
|
|
66
|
+
this.renderTrajectoriesInternal = this.renderTrajectoriesInternal.bind(this);
|
|
67
|
+
this.onTrajectoryMessage = this.onTrajectoryMessage.bind(this);
|
|
68
|
+
this.onDeleteTrajectoryMessage = this.onDeleteTrajectoryMessage.bind(this);
|
|
69
|
+
this.onDocumentVisibilityChange = this.onDocumentVisibilityChange.bind(this);
|
|
70
|
+
}
|
|
71
|
+
defineProperties(options) {
|
|
72
|
+
let { regexPublishedLineName, publishedLineName, tripNumber, operator } = options;
|
|
73
|
+
const {
|
|
74
|
+
style,
|
|
75
|
+
speed,
|
|
76
|
+
pixelRatio,
|
|
77
|
+
hoverVehicleId,
|
|
78
|
+
selectedVehicleId,
|
|
79
|
+
filter,
|
|
80
|
+
sort,
|
|
81
|
+
time,
|
|
82
|
+
live
|
|
83
|
+
} = options;
|
|
84
|
+
const initTrackerOptions = {
|
|
85
|
+
style
|
|
86
|
+
};
|
|
87
|
+
Object.keys(initTrackerOptions).forEach((key) => initTrackerOptions[key] === void 0 && delete initTrackerOptions[key]);
|
|
88
|
+
let currSpeed = speed || 1;
|
|
89
|
+
let currTime = time || new Date();
|
|
90
|
+
super.defineProperties(options);
|
|
91
|
+
Object.defineProperties(this, {
|
|
92
|
+
isTrackerLayer: { value: true },
|
|
93
|
+
style: {
|
|
94
|
+
value: (trajectory, viewState) => (style || trackerDefaultStyle)(trajectory, viewState, this)
|
|
95
|
+
},
|
|
96
|
+
speed: {
|
|
97
|
+
get: () => currSpeed,
|
|
98
|
+
set: (newSpeed) => {
|
|
99
|
+
currSpeed = newSpeed;
|
|
100
|
+
this.start();
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
filter: {
|
|
104
|
+
value: filter,
|
|
105
|
+
writable: true
|
|
106
|
+
},
|
|
107
|
+
sort: {
|
|
108
|
+
value: sort,
|
|
109
|
+
writable: true
|
|
110
|
+
},
|
|
111
|
+
tracker: { value: null, writable: true },
|
|
112
|
+
styleCache: { value: {} },
|
|
113
|
+
live: {
|
|
114
|
+
value: live === false ? live : true,
|
|
115
|
+
writable: true
|
|
116
|
+
},
|
|
117
|
+
time: {
|
|
118
|
+
get: () => currTime,
|
|
119
|
+
set: (newTime) => {
|
|
120
|
+
currTime = newTime && newTime.getTime ? newTime : new Date(newTime);
|
|
121
|
+
this.renderTrajectories();
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
trajectories: {
|
|
125
|
+
value: {},
|
|
126
|
+
writable: true
|
|
127
|
+
},
|
|
128
|
+
renderedTrajectories: {
|
|
129
|
+
get: () => this.tracker && this.tracker.renderedTrajectories || []
|
|
130
|
+
},
|
|
131
|
+
hoverVehicleId: {
|
|
132
|
+
value: hoverVehicleId,
|
|
133
|
+
writable: true
|
|
134
|
+
},
|
|
135
|
+
selectedVehicleId: {
|
|
136
|
+
value: selectedVehicleId,
|
|
137
|
+
writable: true
|
|
138
|
+
},
|
|
139
|
+
pixelRatio: {
|
|
140
|
+
value: pixelRatio || (typeof window !== "undefined" ? window.devicePixelRatio : 1),
|
|
141
|
+
writable: true
|
|
142
|
+
},
|
|
143
|
+
initTrackerOptions: {
|
|
144
|
+
value: initTrackerOptions,
|
|
145
|
+
writable: false
|
|
146
|
+
},
|
|
147
|
+
useRequestAnimationFrame: {
|
|
148
|
+
value: options.useRequestAnimationFrame || false,
|
|
149
|
+
writable: true
|
|
150
|
+
},
|
|
151
|
+
useThrottle: {
|
|
152
|
+
value: options.useThrottle || true,
|
|
153
|
+
writable: true
|
|
154
|
+
},
|
|
155
|
+
useDebounce: {
|
|
156
|
+
value: options.useDebounce || false,
|
|
157
|
+
writable: true
|
|
158
|
+
},
|
|
159
|
+
publishedLineName: {
|
|
160
|
+
get: () => publishedLineName,
|
|
161
|
+
set: (newPublishedLineName) => {
|
|
162
|
+
publishedLineName = newPublishedLineName;
|
|
163
|
+
this.updateFilters();
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
tripNumber: {
|
|
167
|
+
get: () => tripNumber,
|
|
168
|
+
set: (newTripNumber) => {
|
|
169
|
+
tripNumber = newTripNumber;
|
|
170
|
+
this.updateFilters();
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
operator: {
|
|
174
|
+
get: () => operator,
|
|
175
|
+
set: (newOperator) => {
|
|
176
|
+
operator = newOperator;
|
|
177
|
+
this.updateFilters();
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
regexPublishedLineName: {
|
|
181
|
+
get: () => regexPublishedLineName,
|
|
182
|
+
set: (newRegex) => {
|
|
183
|
+
regexPublishedLineName = newRegex;
|
|
184
|
+
this.updateFilters();
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
delayDisplay: {
|
|
188
|
+
value: options.delayDisplay || 3e5,
|
|
189
|
+
writable: true
|
|
190
|
+
},
|
|
191
|
+
delayOutlineColor: {
|
|
192
|
+
value: options.delayOutlineColor || "#000000",
|
|
193
|
+
writable: true
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
this.updateFilters();
|
|
197
|
+
}
|
|
198
|
+
attachToMap(map) {
|
|
199
|
+
super.attachToMap(map);
|
|
200
|
+
this.tracker = new Tracker({
|
|
201
|
+
style: (...args) => this.style(...args),
|
|
202
|
+
...this.initTrackerOptions
|
|
203
|
+
});
|
|
204
|
+
if (this.visible) {
|
|
205
|
+
this.start();
|
|
206
|
+
}
|
|
207
|
+
this.visibilityRef = this.on("change:visible", (evt) => {
|
|
208
|
+
if (evt.target.visible) {
|
|
209
|
+
this.start();
|
|
210
|
+
} else {
|
|
211
|
+
this.stop();
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
document.addEventListener("visibilitychange", this.onDocumentVisibilityChange);
|
|
215
|
+
}
|
|
216
|
+
detachFromMap() {
|
|
217
|
+
document.removeEventListener("visibilitychange", this.onDocumentVisibilityChange);
|
|
218
|
+
this.stop();
|
|
219
|
+
unByKey(this.visibilityRef);
|
|
220
|
+
if (this.tracker) {
|
|
221
|
+
const { canvas } = this.tracker;
|
|
222
|
+
const context = canvas.getContext("2d");
|
|
223
|
+
context.clearRect(0, 0, canvas.width, canvas.height);
|
|
224
|
+
this.tracker = null;
|
|
225
|
+
}
|
|
226
|
+
super.detachFromMap();
|
|
227
|
+
}
|
|
228
|
+
start() {
|
|
229
|
+
this.stop();
|
|
230
|
+
this.renderTrajectories();
|
|
231
|
+
this.startUpdateTime();
|
|
232
|
+
if (this.isClickActive) {
|
|
233
|
+
this.onClick(this.onFeatureClick);
|
|
234
|
+
}
|
|
235
|
+
if (this.isHoverActive) {
|
|
236
|
+
this.onHover(this.onFeatureHover);
|
|
237
|
+
}
|
|
238
|
+
this.api.open();
|
|
239
|
+
this.api.subscribeTrajectory(this.mode, this.onTrajectoryMessage, this.isUpdateBboxOnMoveEnd);
|
|
240
|
+
this.api.subscribeDeletedVehicles(this.mode, this.onDeleteTrajectoryMessage, this.isUpdateBboxOnMoveEnd);
|
|
241
|
+
if (this.isUpdateBboxOnMoveEnd) {
|
|
242
|
+
this.setBbox();
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
startUpdateTime() {
|
|
246
|
+
this.stopUpdateTime();
|
|
247
|
+
this.updateTimeDelay = this.getRefreshTimeInMs();
|
|
248
|
+
this.updateTimeInterval = setInterval(() => {
|
|
249
|
+
this.time = this.live ? new Date() : this.time.getTime() + this.updateTimeDelay * this.speed;
|
|
250
|
+
}, this.updateTimeDelay);
|
|
251
|
+
}
|
|
252
|
+
stop() {
|
|
253
|
+
this.api.unsubscribeTrajectory(this.onTrajectoryMessage);
|
|
254
|
+
this.api.unsubscribeDeletedVehicles(this.onDeleteTrajectoryMessage);
|
|
255
|
+
this.api.close();
|
|
256
|
+
}
|
|
257
|
+
stopUpdateTime() {
|
|
258
|
+
if (this.updateTimeInterval) {
|
|
259
|
+
clearInterval(this.updateTimeInterval);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
renderTrajectoriesInternal(viewState, noInterpolate) {
|
|
263
|
+
if (!this.tracker) {
|
|
264
|
+
return false;
|
|
265
|
+
}
|
|
266
|
+
const time = this.live ? Date.now() : this.time;
|
|
267
|
+
const trajectories = Object.values(this.trajectories);
|
|
268
|
+
if (this.sort) {
|
|
269
|
+
trajectories.sort(this.sort);
|
|
270
|
+
}
|
|
271
|
+
this.renderState = this.tracker.renderTrajectories(trajectories, { ...viewState, pixelRatio: this.pixelRatio, time }, {
|
|
272
|
+
noInterpolate: viewState.zoom < this.minZoomInterpolation ? true : noInterpolate,
|
|
273
|
+
hoverVehicleId: this.hoverVehicleId,
|
|
274
|
+
selectedVehicleId: this.selectedVehicleId,
|
|
275
|
+
iconScale: this.iconScale,
|
|
276
|
+
delayDisplay: this.delayDisplay,
|
|
277
|
+
delayOutlineColor: this.delayOutlineColor
|
|
278
|
+
});
|
|
279
|
+
return true;
|
|
280
|
+
}
|
|
281
|
+
renderTrajectories(viewState, noInterpolate) {
|
|
282
|
+
if (this.requestId) {
|
|
283
|
+
cancelAnimationFrame(this.requestId);
|
|
284
|
+
this.requestId = null;
|
|
285
|
+
}
|
|
286
|
+
if (!noInterpolate && this.useRequestAnimationFrame) {
|
|
287
|
+
this.requestId = requestAnimationFrame(() => {
|
|
288
|
+
this.renderTrajectoriesInternal(viewState, noInterpolate);
|
|
289
|
+
});
|
|
290
|
+
} else if (!noInterpolate && this.useDebounce) {
|
|
291
|
+
this.debounceRenderTrajectories(viewState, noInterpolate);
|
|
292
|
+
} else if (!noInterpolate && this.useThrottle) {
|
|
293
|
+
this.throttleRenderTrajectories(viewState, noInterpolate);
|
|
294
|
+
} else {
|
|
295
|
+
this.renderTrajectoriesInternal(viewState, noInterpolate);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
setBbox(extent, zoom) {
|
|
299
|
+
const keys = Object.keys(this.trajectories);
|
|
300
|
+
for (let i = keys.length - 1; i >= 0; i -= 1) {
|
|
301
|
+
this.purgeTrajectory(this.trajectories[keys[i]], extent, zoom);
|
|
302
|
+
}
|
|
303
|
+
const bbox = [...extent];
|
|
304
|
+
if (this.isUpdateBboxOnMoveEnd) {
|
|
305
|
+
bbox.push(zoom);
|
|
306
|
+
if (this.tenant) {
|
|
307
|
+
bbox.push(`tenant=${this.tenant}`);
|
|
308
|
+
}
|
|
309
|
+
this.generalizationLevel = this.generalizationLevelByZoom[zoom];
|
|
310
|
+
if (this.generalizationLevel) {
|
|
311
|
+
bbox.push(`gen=${this.generalizationLevel}`);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
this.api.bbox = bbox;
|
|
315
|
+
}
|
|
316
|
+
setMode(mode) {
|
|
317
|
+
if (this.mode === mode) {
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
this.mode = mode;
|
|
321
|
+
this.api.subscribeTrajectory(this.mode, this.onTrajectoryMessage, this.isUpdateBboxOnMoveEnd);
|
|
322
|
+
this.api.subscribeDeletedVehicles(this.mode, this.onDeleteTrajectoryMessage, this.isUpdateBboxOnMoveEnd);
|
|
323
|
+
}
|
|
324
|
+
getRefreshTimeInMs(zoom) {
|
|
325
|
+
const roundedZoom = Math.round(zoom);
|
|
326
|
+
const timeStep = timeSteps[roundedZoom] || 25;
|
|
327
|
+
const nextTick = Math.max(25, timeStep / this.speed);
|
|
328
|
+
const nextThrottleTick = Math.min(nextTick, 500);
|
|
329
|
+
if (this.useThrottle) {
|
|
330
|
+
this.throttleRenderTrajectories = throttle(this.renderTrajectoriesInternal, nextThrottleTick, { leading: true, trailing: true });
|
|
331
|
+
} else if (this.useDebounce) {
|
|
332
|
+
this.debounceRenderTrajectories = debounce(this.renderTrajectoriesInternal, nextThrottleTick, { leading: true, trailing: true, maxWait: 5e3 });
|
|
333
|
+
}
|
|
334
|
+
if (this.api?.buffer) {
|
|
335
|
+
const [, size] = this.api.buffer;
|
|
336
|
+
this.api.buffer = [nextThrottleTick, size];
|
|
337
|
+
}
|
|
338
|
+
return nextTick;
|
|
339
|
+
}
|
|
340
|
+
getVehicle(filterFc) {
|
|
341
|
+
return Object.values(this.trajectories).filter(filterFc);
|
|
342
|
+
}
|
|
343
|
+
getFeatureInfoAtCoordinate(coordinate, options = {}) {
|
|
344
|
+
const { resolution, nb } = options;
|
|
345
|
+
const ext = buffer([...coordinate, ...coordinate], this.hitTolerance * resolution);
|
|
346
|
+
let trajectories = Object.values(this.trajectories);
|
|
347
|
+
if (this.sort) {
|
|
348
|
+
trajectories = trajectories.sort(this.sort);
|
|
349
|
+
}
|
|
350
|
+
const vehicles = [];
|
|
351
|
+
for (let i = 0; i < trajectories.length; i += 1) {
|
|
352
|
+
if (trajectories[i].properties.coordinate && containsCoordinate(ext, trajectories[i].properties.coordinate)) {
|
|
353
|
+
vehicles.push(trajectories[i]);
|
|
354
|
+
}
|
|
355
|
+
if (vehicles.length === nb) {
|
|
356
|
+
break;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
return Promise.resolve({
|
|
360
|
+
layer: this,
|
|
361
|
+
features: vehicles.map((vehicle) => this.format.readFeature(vehicle)),
|
|
362
|
+
coordinate
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
getTrajectoryInfos(id) {
|
|
366
|
+
const promises = [
|
|
367
|
+
this.api.getStopSequence(id, this.mode),
|
|
368
|
+
this.api.getFullTrajectory(id, this.mode, this.generalizationLevel)
|
|
369
|
+
];
|
|
370
|
+
return Promise.all(promises).then(([stopSequence, fullTrajectory]) => {
|
|
371
|
+
const response = {
|
|
372
|
+
stopSequence,
|
|
373
|
+
fullTrajectory
|
|
374
|
+
};
|
|
375
|
+
return response;
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
purgeTrajectory(trajectory, extent, zoom) {
|
|
379
|
+
const { type, bounds, train_id: id } = trajectory.properties;
|
|
380
|
+
if (!intersects(extent, bounds) || type !== "rail" && zoom < (this.minZoomNonTrain || 9)) {
|
|
381
|
+
this.removeTrajectory(id);
|
|
382
|
+
return true;
|
|
383
|
+
}
|
|
384
|
+
return false;
|
|
385
|
+
}
|
|
386
|
+
addTrajectory(trajectory) {
|
|
387
|
+
if (this.filter && !this.filter(trajectory)) {
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
this.trajectories[trajectory.properties.train_id] = trajectory;
|
|
391
|
+
this.renderTrajectories();
|
|
392
|
+
}
|
|
393
|
+
removeTrajectory(id) {
|
|
394
|
+
delete this.trajectories[id];
|
|
395
|
+
}
|
|
396
|
+
onZoomEnd(evt) {
|
|
397
|
+
this.startUpdateTime();
|
|
398
|
+
}
|
|
399
|
+
onDocumentVisibilityChange() {
|
|
400
|
+
if (!this.visible) {
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
if (document.hidden) {
|
|
404
|
+
this.stop();
|
|
405
|
+
} else {
|
|
406
|
+
this.start();
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
onTrajectoryMessage(data) {
|
|
410
|
+
if (!data.content) {
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
const trajectory = data.content;
|
|
414
|
+
const {
|
|
415
|
+
geometry,
|
|
416
|
+
properties: {
|
|
417
|
+
train_id: id,
|
|
418
|
+
time_since_update: timeSinceUpdate,
|
|
419
|
+
raw_coordinates: rawCoordinates
|
|
420
|
+
}
|
|
421
|
+
} = trajectory;
|
|
422
|
+
if (timeSinceUpdate < 0) {
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
if (this.purgeTrajectory(trajectory)) {
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
if (this.debug && this.mode === TralisModes.TOPOGRAPHIC && rawCoordinates) {
|
|
429
|
+
trajectory.properties.olGeometry = {
|
|
430
|
+
type: "Point",
|
|
431
|
+
coordinates: fromLonLat(rawCoordinates, this.map.getView().getProjection())
|
|
432
|
+
};
|
|
433
|
+
} else {
|
|
434
|
+
trajectory.properties.olGeometry = this.format.readGeometry(geometry);
|
|
435
|
+
}
|
|
436
|
+
trajectory.properties.timeOffset = Date.now() - data.timestamp;
|
|
437
|
+
this.addTrajectory(trajectory);
|
|
438
|
+
}
|
|
439
|
+
onDeleteTrajectoryMessage(data) {
|
|
440
|
+
if (!data.content) {
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
this.removeTrajectory(data.content);
|
|
444
|
+
}
|
|
445
|
+
onFeatureHover(features, layer, coordinate) {
|
|
446
|
+
const [feature] = features;
|
|
447
|
+
let id = null;
|
|
448
|
+
if (feature) {
|
|
449
|
+
id = feature.get("train_id");
|
|
450
|
+
}
|
|
451
|
+
if (this.hoverVehicleId !== id) {
|
|
452
|
+
this.hoverVehicleId = id;
|
|
453
|
+
this.renderTrajectories(true);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
onFeatureClick(features, layer, coordinate) {
|
|
457
|
+
const [feature] = features;
|
|
458
|
+
let id = null;
|
|
459
|
+
if (feature) {
|
|
460
|
+
id = feature.get("train_id");
|
|
461
|
+
}
|
|
462
|
+
if (this.selectedVehicleId !== id) {
|
|
463
|
+
this.selectedVehicleId = id;
|
|
464
|
+
this.selectedVehicle = feature;
|
|
465
|
+
this.renderTrajectories(true);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
updateFilters() {
|
|
469
|
+
const parameters = qs.parse(window.location.search.toLowerCase());
|
|
470
|
+
const publishedName = this.publishedLineName || parameters[LINE_FILTER];
|
|
471
|
+
const tripNumber = this.tripNumber || parameters[ROUTE_FILTER];
|
|
472
|
+
const operator = this.operator || parameters[OPERATOR_FILTER];
|
|
473
|
+
const { regexPublishedLineName } = this;
|
|
474
|
+
if (publishedName || tripNumber || operator || regexPublishedLineName) {
|
|
475
|
+
this.filter = createFilters(publishedName, tripNumber, operator, regexPublishedLineName);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
export default TralisLayerMixin;
|