Add sidebar tab with route analysis data
- adds a new analysis tab in the sidebar - the analysis tab shows length distribution for different way types, surface, and smoothness - table rows can be hovered/clicked to highlight the according segments on the map (similar behaviour as the detailed data table) - localization is implemented for `de` and `en` - the method for finding segment edges was extracted from `js/control/TrackMessages.js` into `js/util/TrackEdges.js` as it's used in the new analysis class too (the Gulp config was changed to reflect that) Notes: I had the idea to use the *DataTable* plugin for rendering the tables but decided against it. The only meaningful way to sort such a table is by the length column and that's already the case. So it's just three plain, old HTML tables, rendered by jQuery. For meaningful statistics the `processUnusedTags` setting has to be enabled in the routing profile. Only in this case the BRouter backend includes all needed tags (`highway`, `surface`, and `smoothness`) for *every* route segment in the response. I’ve enabled that setting for all profiles at my BRouter-web instance at <https://brouter.m11n.de/>.
This commit is contained in:
parent
b181649dff
commit
fc54c65e23
9 changed files with 682 additions and 53 deletions
79
js/util/TrackEdges.js
Normal file
79
js/util/TrackEdges.js
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
/**
|
||||
* The track messages and track analysis panels share some functionality
|
||||
* which is defined in this class to prevent code duplication.
|
||||
*
|
||||
* @type {L.Class}
|
||||
*/
|
||||
BR.TrackEdges = L.Class.extend({
|
||||
/**
|
||||
* List of indexes for the track array where
|
||||
* a segment with different features ends
|
||||
*
|
||||
* @type {number[]}
|
||||
* @see BR.TrackMessages
|
||||
*/
|
||||
edges: [],
|
||||
|
||||
/**
|
||||
* @param {Array} segments
|
||||
*/
|
||||
initialize: function(segments) {
|
||||
this.edges = this.getTrackEdges(segments);
|
||||
},
|
||||
|
||||
/**
|
||||
* Find the indexes where a track segment ends, i.e. where the waytags change.
|
||||
*
|
||||
* Used in TrackMessages and TrackAnalysis for highlighting track segments.
|
||||
*
|
||||
* @param {Array} segments
|
||||
*
|
||||
* @return {number[]}
|
||||
*/
|
||||
getTrackEdges: function(segments) {
|
||||
var messages,
|
||||
segLatLngs,
|
||||
length,
|
||||
si,
|
||||
mi,
|
||||
latLng,
|
||||
i,
|
||||
segIndex,
|
||||
baseIndex = 0,
|
||||
edges = [];
|
||||
|
||||
// track latLngs index for end node of edge
|
||||
for (si = 0; si < segments.length; si++) {
|
||||
messages = segments[si].feature.properties.messages;
|
||||
segLatLngs = segments[si].getLatLngs();
|
||||
length = segLatLngs.length;
|
||||
segIndex = 0;
|
||||
|
||||
for (mi = 1; mi < messages.length; mi++) {
|
||||
latLng = this.getMessageLatLng(messages[mi]);
|
||||
|
||||
for (i = segIndex; i < length; i++) {
|
||||
if (latLng.equals(segLatLngs[i])) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i === length) {
|
||||
i = length - 1;
|
||||
}
|
||||
|
||||
segIndex = i + 1;
|
||||
edges.push(baseIndex + i);
|
||||
}
|
||||
baseIndex += length;
|
||||
}
|
||||
|
||||
return edges;
|
||||
},
|
||||
|
||||
getMessageLatLng: function(message) {
|
||||
var lon = message[0] / 1000000,
|
||||
lat = message[1] / 1000000;
|
||||
|
||||
return L.latLng(lat, lon);
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue