Format OsmAnd voice hints
This commit is contained in:
parent
ea564006e9
commit
8f2261037c
5 changed files with 169 additions and 13 deletions
|
|
@ -11,14 +11,16 @@ const geoJson = require('./data/track.json');
|
|||
const path = 'tests/format/data/';
|
||||
|
||||
// resolve intended/accepted differences before comparing
|
||||
function adoptGpx(gpx) {
|
||||
function adoptGpx(gpx, replaceCreator = true) {
|
||||
const creator = 'togpx';
|
||||
const name = 'Track';
|
||||
const newline = '\n';
|
||||
|
||||
gpx = gpx.replace('=.0', '=0.0');
|
||||
gpx = gpx.replace(/creator="[^"]*"/, `creator="${creator}"`);
|
||||
gpx = gpx.replace(`creator="${creator}" version="1.1"`, `version="1.1" \n creator="${creator}"`);
|
||||
if (replaceCreator) {
|
||||
gpx = gpx.replace(/creator="[^"]*"/, `creator="${creator}"`);
|
||||
}
|
||||
gpx = gpx.replace(/creator="([^"]*)" version="1.1"/, 'version="1.1" \n creator="$1"');
|
||||
gpx = gpx.replace(/<trk>\n <name>[^<]*<\/name>/, `<trk>\n <name>${name}</name>`);
|
||||
gpx = gpx
|
||||
.split(newline)
|
||||
|
|
@ -30,8 +32,8 @@ function adoptGpx(gpx) {
|
|||
return gpx;
|
||||
}
|
||||
|
||||
function read(fileName) {
|
||||
return BR.Gpx.pretty(adoptGpx(fs.readFileSync(path + fileName, 'utf8')));
|
||||
function read(fileName, replaceCreator) {
|
||||
return BR.Gpx.pretty(adoptGpx(fs.readFileSync(path + fileName, 'utf8'), replaceCreator));
|
||||
}
|
||||
|
||||
test('simple track', () => {
|
||||
|
|
@ -51,6 +53,12 @@ describe('voice hints', () => {
|
|||
expect(gpx).toEqual(brouterGpx);
|
||||
});
|
||||
|
||||
test('3-osmand', () => {
|
||||
const brouterGpx = read('3-osmand.gpx', false);
|
||||
const gpx = BR.Gpx.format(geoJson, 3);
|
||||
expect(gpx).toEqual(brouterGpx);
|
||||
});
|
||||
|
||||
test('4-comment', () => {
|
||||
let brouterGpx = read('4-comment.gpx');
|
||||
brouterGpx = brouterGpx.replace(/;\s*([-0-9]+.[0-9]+?)0+;/g, (match, p1) => `;${p1.padStart(10)};`); // remove trailing zeros
|
||||
|
|
|
|||
54
tests/format/data/3-osmand.gpx
Normal file
54
tests/format/data/3-osmand.gpx
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
<?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"
|
||||
xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"
|
||||
creator="OsmAndRouter" version="1.1">
|
||||
<rte>
|
||||
<rtept lat="49.488115" lon="8.467714">
|
||||
<desc>start</desc>
|
||||
<extensions>
|
||||
<time>10</time>
|
||||
<offset>0</offset>
|
||||
</extensions>
|
||||
</rtept>
|
||||
<rtept lat="49.488794" lon="8.468340">
|
||||
<desc>right</desc>
|
||||
<extensions>
|
||||
<time>25</time>
|
||||
<turn>TR</turn>
|
||||
<turn-angle>89</turn-angle>
|
||||
<offset>1</offset>
|
||||
</extensions>
|
||||
</rtept>
|
||||
<rtept lat="49.488151" lon="8.469971">
|
||||
<desc>left</desc>
|
||||
<extensions>
|
||||
<time>10</time>
|
||||
<turn>TL</turn>
|
||||
<turn-angle>-90</turn-angle>
|
||||
<offset>5</offset>
|
||||
</extensions>
|
||||
</rtept>
|
||||
<rtept lat="49.488842" lon="8.470610">
|
||||
<desc>destination</desc>
|
||||
<extensions>
|
||||
<time>0</time>
|
||||
<offset>6</offset>
|
||||
</extensions>
|
||||
</rtept>
|
||||
</rte>
|
||||
<trk>
|
||||
<name>3-osmand</name>
|
||||
<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,14 +13,15 @@
|
|||
"total-energy": "4412",
|
||||
"cost": "533",
|
||||
"voicehints": [
|
||||
[1,5,0,140.0,24.90994644165039," 6(90)6 (0)6 (-89)2"],
|
||||
[5,2,0,90.0,9.614852905273438," 6(-89)6 (0)6 (89)6"]
|
||||
[1,5,0,140.0,24.90994644165039,89," 6(90)6 (0)6 (-89)2"],
|
||||
[5,2,0,90.0,9.614852905273438,-90," 6(-89)6 (0)6 (89)6"]
|
||||
],
|
||||
"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", ""],
|
||||
["8470671", "49488909", "99", "230", "1150", "0", "180", "0", "0", "highway=residential surface=asphalt oneway=yes smoothness=good", ""]
|
||||
]
|
||||
],
|
||||
"times": [0.0,9.592433,12.270765,14.129882,19.406338,34.50238,44.117233]
|
||||
},
|
||||
"geometry": {
|
||||
"type": "LineString",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue