Format basic voice hint
Use togpx fork for now (outdated), see PR: https://github.com/tyrasd/togpx/pull/11
This commit is contained in:
parent
74af851687
commit
a9d27b4674
6 changed files with 169 additions and 13 deletions
|
|
@ -1,5 +1,8 @@
|
|||
BR = {};
|
||||
turf = require('@turf/turf');
|
||||
togpx = require('togpx');
|
||||
require('leaflet');
|
||||
require('../../js/format/VoiceHints.js');
|
||||
require('../../js/format/Gpx.js');
|
||||
|
||||
const fs = require('fs');
|
||||
|
|
@ -21,7 +24,7 @@ function adoptGpx(gpx) {
|
|||
.split(newline)
|
||||
.map((line) => line.replace(/lon="([^"]*)" lat="([^"]*)"/, 'lat="$2" lon="$1"'))
|
||||
.join(newline);
|
||||
gpx = gpx.replace(/0"><ele>/g, '"><ele>');
|
||||
gpx = gpx.replace(/(lon|lat)="([-0-9]+.[0-9]+?)0+"/g, '$1="$2"'); // remove trailing zeros
|
||||
gpx = gpx.replace('</gpx>\n', '</gpx>');
|
||||
|
||||
return gpx;
|
||||
|
|
@ -36,3 +39,11 @@ test('simple track', () => {
|
|||
const gpx = BR.Gpx.format(geoJson);
|
||||
expect(gpx).toEqual(brouterGpx);
|
||||
});
|
||||
|
||||
describe('voice hints', () => {
|
||||
test('5-gpsies', () => {
|
||||
const brouterGpx = BR.Gpx.pretty(read('5-gpsies.gpx'));
|
||||
const gpx = BR.Gpx.format(geoJson, 5);
|
||||
expect(gpx).toEqual(brouterGpx);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
22
tests/format/data/5-gpsies.gpx
Normal file
22
tests/format/data/5-gpsies.gpx
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<?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="BRouter-1.6.1" version="1.1">
|
||||
<wpt lon="8.468340" lat="49.488794"><name>right</name><sym>right</sym><type>Right</type></wpt>
|
||||
<wpt lon="8.469971" lat="49.488151"><name>left</name><sym>left</sym><type>Left</type></wpt>
|
||||
<trk>
|
||||
<name>5-gpsies</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>
|
||||
Loading…
Add table
Add a link
Reference in a new issue