Format Locus voice hint, with additional hint data
This commit is contained in:
parent
a9d27b4674
commit
fd0ece0d31
5 changed files with 152 additions and 39 deletions
|
|
@ -31,7 +31,7 @@ function adoptGpx(gpx) {
|
|||
}
|
||||
|
||||
function read(fileName) {
|
||||
return adoptGpx(fs.readFileSync(path + fileName, 'utf8'));
|
||||
return BR.Gpx.pretty(adoptGpx(fs.readFileSync(path + fileName, 'utf8')));
|
||||
}
|
||||
|
||||
test('simple track', () => {
|
||||
|
|
@ -41,8 +41,18 @@ test('simple track', () => {
|
|||
});
|
||||
|
||||
describe('voice hints', () => {
|
||||
test('2-locus', () => {
|
||||
let brouterGpx = read('2-locus.gpx');
|
||||
brouterGpx = brouterGpx.replace(/<(\/?)locus:/g, '<$1'); // TODO 'locus:' namespace
|
||||
brouterGpx = brouterGpx.replace(/.0<\/rteDistance/g, '</rteDistance'); // ignore .0 decimal
|
||||
brouterGpx = brouterGpx.replace(/\n\s*<\/extensions>\n\s*<extensions>/, ''); // ignore (invalid) double tag
|
||||
|
||||
const gpx = BR.Gpx.format(geoJson, 2);
|
||||
expect(gpx).toEqual(brouterGpx);
|
||||
});
|
||||
|
||||
test('5-gpsies', () => {
|
||||
const brouterGpx = BR.Gpx.pretty(read('5-gpsies.gpx'));
|
||||
const brouterGpx = read('5-gpsies.gpx');
|
||||
const gpx = BR.Gpx.format(geoJson, 5);
|
||||
expect(gpx).toEqual(brouterGpx);
|
||||
});
|
||||
|
|
|
|||
25
tests/format/data/2-locus.gpx
Normal file
25
tests/format/data/2-locus.gpx
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- track-length = 319 filtered ascend = 2 plain-ascend = -1 cost=533 energy=.0kwh time=44s -->
|
||||
<gpx
|
||||
xmlns="http://www.topografix.com/GPX/1/1"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:locus="http://www.locusmap.eu"
|
||||
xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"
|
||||
creator="BRouter-1.6.1" version="1.1">
|
||||
<wpt lon="8.468340" lat="49.488794"><ele>101.5</ele><name>right</name><extensions><locus:rteDistance>140.0</locus:rteDistance><locus:rteTime>24.90994644165039</locus:rteTime><locus:rteSpeed>5.620244922161478</locus:rteSpeed><locus:rtePointAction>7</locus:rtePointAction></extensions></wpt>
|
||||
<wpt lon="8.469971" lat="49.488151"><ele>103.5</ele><name>left</name><extensions><locus:rteDistance>90.0</locus:rteDistance><locus:rteTime>9.614852905273438</locus:rteTime><locus:rteSpeed>9.360517616513706</locus:rteSpeed><locus:rtePointAction>4</locus:rtePointAction></extensions></wpt>
|
||||
<trk>
|
||||
<name>2-locus</name>
|
||||
<extensions><locus:rteComputeType>5</locus:rteComputeType></extensions>
|
||||
<extensions><locus:rteSimpleRoundabouts>1</locus:rteSimpleRoundabouts></extensions>
|
||||
<trkseg>
|
||||
<trkpt lon="8.467714" lat="49.488115"><ele>101.5</ele></trkpt>
|
||||
<trkpt lon="8.468340" lat="49.488794"><ele>101.5</ele></trkpt>
|
||||
<trkpt lon="8.468586" lat="49.488698"><ele>101.5</ele></trkpt>
|
||||
<trkpt lon="8.468743" lat="49.488636"><ele>101.5</ele></trkpt>
|
||||
<trkpt lon="8.469161" lat="49.488473"><ele>101.75</ele></trkpt>
|
||||
<trkpt lon="8.469971" lat="49.488151"><ele>103.5</ele></trkpt>
|
||||
<trkpt lon="8.470610" lat="49.488842"><ele>99.75</ele></trkpt>
|
||||
</trkseg>
|
||||
</trk>
|
||||
</gpx>
|
||||
|
|
@ -13,8 +13,8 @@
|
|||
"total-energy": "4412",
|
||||
"cost": "533",
|
||||
"voicehints": [
|
||||
[1,5,0],
|
||||
[5,2,0]
|
||||
[1,5,0,140.0,24.90994644165039],
|
||||
[5,2,0,90.0,9.614852905273438]
|
||||
],
|
||||
"messages": [
|
||||
["Longitude", "Latitude", "Elevation", "Distance", "CostPerKm", "ElevCost", "TurnCost", "NodeCost", "InitialCost", "WayTags", "NodeTags"],
|
||||
|
|
@ -37,4 +37,3 @@
|
|||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue