Handle missing voicehints and times
This commit is contained in:
parent
819d0fbf22
commit
4c27f5894c
1 changed files with 11 additions and 12 deletions
|
|
@ -56,14 +56,8 @@
|
||||||
this.turnInstructionMode = turnInstructionMode;
|
this.turnInstructionMode = turnInstructionMode;
|
||||||
this.transportMode = transportMode;
|
this.transportMode = transportMode;
|
||||||
|
|
||||||
for (const feature of geoJson.features) {
|
this.track = geoJson.features?.[0];
|
||||||
let voicehints = feature?.properties.voicehints;
|
this.voicehints = this.track?.properties?.voicehints;
|
||||||
if (voicehints) {
|
|
||||||
this.voicehints = voicehints;
|
|
||||||
this.track = feature;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getGpxTransform: function () {
|
getGpxTransform: function () {
|
||||||
|
|
@ -110,6 +104,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
_loopHints: function (hintCallback) {
|
_loopHints: function (hintCallback) {
|
||||||
|
if (!this.voicehints) return;
|
||||||
for (const [i, values] of this.voicehints.entries()) {
|
for (const [i, values] of this.voicehints.entries()) {
|
||||||
const [indexInTrack, commandId, exitNumber, distance, time, angle, geometry] = values;
|
const [indexInTrack, commandId, exitNumber, distance, time, angle, geometry] = values;
|
||||||
const hint = { indexInTrack, commandId, exitNumber, distance, time, angle, geometry };
|
const hint = { indexInTrack, commandId, exitNumber, distance, time, angle, geometry };
|
||||||
|
|
@ -330,13 +325,17 @@
|
||||||
|
|
||||||
const trkseg = gpx.trk[0].trkseg[0];
|
const trkseg = gpx.trk[0].trkseg[0];
|
||||||
let trkpt = trkseg.trkpt[0];
|
let trkpt = trkseg.trkpt[0];
|
||||||
const startTime = this.track.properties.times[this.voicehints[0][0]];
|
const startPt = {
|
||||||
rteptList.push({
|
|
||||||
'@lat': trkpt['@lat'],
|
'@lat': trkpt['@lat'],
|
||||||
'@lon': trkpt['@lon'],
|
'@lon': trkpt['@lon'],
|
||||||
desc: 'start',
|
desc: 'start',
|
||||||
extensions: { time: Math.round(startTime), offset: 0 },
|
};
|
||||||
});
|
const times = this.track?.properties?.times;
|
||||||
|
if (this.voicehints && times) {
|
||||||
|
const startTime = times[this.voicehints[0][0]];
|
||||||
|
startPt.extensions = { time: Math.round(startTime), offset: 0 };
|
||||||
|
}
|
||||||
|
rteptList.push(startPt);
|
||||||
|
|
||||||
this._loopHints((hint, cmd, coord) => {
|
this._loopHints((hint, cmd, coord) => {
|
||||||
const rtept = {
|
const rtept = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue