Concatenate total track
+ handle server voicehint time removed, times with 3 digits
This commit is contained in:
parent
954812cf52
commit
25f8828ae7
10 changed files with 412 additions and 47 deletions
40
tests/control/Export.test.js
Normal file
40
tests/control/Export.test.js
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
BR = {};
|
||||
require('leaflet');
|
||||
turf = require('@turf/turf');
|
||||
require('../../js/control/Export.js');
|
||||
|
||||
// &lonlats=8.467712,49.488117;8.469354,49.488394;8.470556,49.488946;8.469982,49.489176 + turnInstructionMode=2
|
||||
const segments = require('./data/segments.json');
|
||||
const brouterTotal = require('./data/brouterTotal.json');
|
||||
|
||||
// resolve intended/accepted differences before comparing
|
||||
function adopt(total, brouterTotal) {
|
||||
// BRouter total aggregates messages over segments, client total does not,
|
||||
// but that's Ok, so just fix for the test comparison
|
||||
const messages = total.features[0].properties.messages;
|
||||
const message = messages[4].slice();
|
||||
messages[4] = message;
|
||||
message[3] = (+message[3] + +messages[2][3] + +messages[3][3]).toString();
|
||||
message[6] = (+message[6] + +messages[2][6] + +messages[3][6]).toString();
|
||||
messages.splice(2, 2);
|
||||
|
||||
// fix minor float rounding difference
|
||||
total.features[0].properties.times[6] = 28.833; // 28.832
|
||||
|
||||
total.features[0].properties.name = brouterTotal.features[0].properties.name;
|
||||
}
|
||||
|
||||
test('total track', () => {
|
||||
const segmentsString = JSON.stringify(segments, null, 2);
|
||||
let total = BR.Export._concatTotalTrack(segments);
|
||||
adopt(total, brouterTotal);
|
||||
expect(total).toEqual(brouterTotal);
|
||||
|
||||
// test original segments are not modified
|
||||
expect(JSON.stringify(segments, null, 2)).toEqual(segmentsString);
|
||||
|
||||
// should be repeatable
|
||||
total = BR.Export._concatTotalTrack(segments);
|
||||
adopt(total, brouterTotal);
|
||||
expect(total).toEqual(brouterTotal);
|
||||
});
|
||||
45
tests/control/data/brouterTotal.json
Normal file
45
tests/control/data/brouterTotal.json
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
{
|
||||
"type": "FeatureCollection",
|
||||
"features": [
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {
|
||||
"creator": "BRouter-1.1",
|
||||
"name": "brouter_1615489279610_0",
|
||||
"track-length": "388",
|
||||
"filtered ascend": "1",
|
||||
"plain-ascend": "0",
|
||||
"total-time": "44",
|
||||
"total-energy": "4420",
|
||||
"cost": "703",
|
||||
"voicehints": [
|
||||
[1,5,0,88.0,89],
|
||||
[6,2,0,99.0,-90],
|
||||
[7,2,0,10.0,-90]
|
||||
],
|
||||
"messages": [
|
||||
["Longitude", "Latitude", "Elevation", "Distance", "CostPerKm", "ElevCost", "TurnCost", "NodeCost", "InitialCost", "WayTags", "NodeTags"],
|
||||
["8468340", "49488794", "101", "89", "1000", "0", "0", "0", "0", "highway=residential surface=asphalt cycleway=lane oneway=yes lcn=yes smoothness=good route_bicycle_icn=yes route_bicycle_ncn=yes route_bicycle_rcn=yes", ""],
|
||||
["8469852", "49489230", "100", "299", "1150", "0", "270", "0", "0", "highway=residential surface=asphalt oneway=yes smoothness=good", ""]
|
||||
],
|
||||
"times": [0,9.592,12.271,14.13,19.406,22.134,28.833,37.817,38.938,44.217]
|
||||
},
|
||||
"geometry": {
|
||||
"type": "LineString",
|
||||
"coordinates": [
|
||||
[8.467714, 49.488115, 101.5],
|
||||
[8.468340, 49.488794, 101.5],
|
||||
[8.468586, 49.488698, 101.5],
|
||||
[8.468743, 49.488636, 101.5],
|
||||
[8.469161, 49.488473, 101.75],
|
||||
[8.469355, 49.488395, 102.0],
|
||||
[8.469971, 49.488151, 103.5],
|
||||
[8.470671, 49.488909, 99.5],
|
||||
[8.470561, 49.488951, 99.5],
|
||||
[8.469984, 49.489178, 100.0]
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
97
tests/control/data/segments.json
Normal file
97
tests/control/data/segments.json
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
[{
|
||||
"feature": {
|
||||
"type": "Feature",
|
||||
"properties": {
|
||||
"creator": "BRouter-1.1",
|
||||
"name": "brouter_1615393581719_0",
|
||||
"track-length": "177",
|
||||
"filtered ascend": "0",
|
||||
"plain-ascend": "1",
|
||||
"total-time": "22",
|
||||
"total-energy": "2213",
|
||||
"cost": "280",
|
||||
"voicehints": [
|
||||
[1,5,0,88.0,89]
|
||||
],
|
||||
"messages": [
|
||||
["Longitude", "Latitude", "Elevation", "Distance", "CostPerKm", "ElevCost", "TurnCost", "NodeCost", "InitialCost", "WayTags", "NodeTags"],
|
||||
["8468340", "49488794", "101", "89", "1000", "0", "0", "0", "0", "highway=residential surface=asphalt cycleway=lane oneway=yes lcn=yes smoothness=good route_bicycle_icn=yes route_bicycle_ncn=yes route_bicycle_rcn=yes", ""],
|
||||
["8469971", "49488151", "102", "88", "1150", "0", "90", "0", "0", "highway=residential surface=asphalt oneway=yes smoothness=good", ""]
|
||||
],
|
||||
"times": [0,9.592,12.271,14.13,19.406,22.134]
|
||||
},
|
||||
"geometry": {
|
||||
"type": "LineString",
|
||||
"coordinates": [
|
||||
[8.467714, 49.488115, 101.5],
|
||||
[8.468340, 49.488794, 101.5],
|
||||
[8.468586, 49.488698, 101.5],
|
||||
[8.468743, 49.488636, 101.5],
|
||||
[8.469161, 49.488473, 101.75],
|
||||
[8.469355, 49.488395, 102.0]
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"feature": {
|
||||
"type": "Feature",
|
||||
"properties": {
|
||||
"creator": "BRouter-1.1",
|
||||
"name": "brouter_1615393581719_0",
|
||||
"track-length": "162",
|
||||
"filtered ascend": "1",
|
||||
"plain-ascend": "-2",
|
||||
"total-time": "17",
|
||||
"total-energy": "1680",
|
||||
"cost": "367",
|
||||
"voicehints": [
|
||||
[1,2,0,99.0,-90],
|
||||
[2,2,0,10.0,-90]
|
||||
],
|
||||
"messages": [
|
||||
["Longitude", "Latitude", "Elevation", "Distance", "CostPerKm", "ElevCost", "TurnCost", "NodeCost", "InitialCost", "WayTags", "NodeTags"],
|
||||
["8469852", "49489230", "99", "162", "1150", "0", "180", "0", "0", "highway=residential surface=asphalt oneway=yes smoothness=good", ""]
|
||||
],
|
||||
"times": [0,6.698,15.683,16.804]
|
||||
},
|
||||
"geometry": {
|
||||
"type": "LineString",
|
||||
"coordinates": [
|
||||
[8.469355, 49.488395, 102.0],
|
||||
[8.469971, 49.488151, 103.5],
|
||||
[8.470671, 49.488909, 99.5],
|
||||
[8.470561, 49.488951, 99.5]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
{
|
||||
"feature": {
|
||||
"type": "Feature",
|
||||
"properties": {
|
||||
"creator": "BRouter-1.1",
|
||||
"name": "brouter_1615393581719_0",
|
||||
"track-length": "49",
|
||||
"filtered ascend": "0",
|
||||
"plain-ascend": "1",
|
||||
"total-time": "5",
|
||||
"total-energy": "527",
|
||||
"cost": "56",
|
||||
"messages": [
|
||||
["Longitude", "Latitude", "Elevation", "Distance", "CostPerKm", "ElevCost", "TurnCost", "NodeCost", "InitialCost", "WayTags", "NodeTags"],
|
||||
["8469852", "49489230", "100", "49", "1150", "0", "0", "0", "0", "highway=residential surface=asphalt oneway=yes smoothness=good", ""]
|
||||
],
|
||||
"times": [0,5.279]
|
||||
},
|
||||
"geometry": {
|
||||
"type": "LineString",
|
||||
"coordinates": [
|
||||
[8.470561, 49.488951, 99.5],
|
||||
[8.469984, 49.489178, 100.0]
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue