handle files with missing timestamps
This commit is contained in:
parent
0b457f9a1e
commit
52984d4b70
1 changed files with 5 additions and 0 deletions
|
@ -2006,6 +2006,8 @@ function withTimestamps(
|
||||||
if (last === undefined) {
|
if (last === undefined) {
|
||||||
last = points[0].clone();
|
last = points[0].clone();
|
||||||
last.time = startTime;
|
last.time = startTime;
|
||||||
|
} else if (last.time === undefined) {
|
||||||
|
last.time = startTime;
|
||||||
}
|
}
|
||||||
return points.map((point) => {
|
return points.map((point) => {
|
||||||
let time = getTimestamp(last, point, speed);
|
let time = getTimestamp(last, point, speed);
|
||||||
|
@ -2070,6 +2072,9 @@ function withArtificialTimestamps(
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTimestamp(a: TrackPoint, b: TrackPoint, speed: number): Date {
|
function getTimestamp(a: TrackPoint, b: TrackPoint, speed: number): Date {
|
||||||
|
if (a.time === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
let dist = distance(a.getCoordinates(), b.getCoordinates()) / 1000;
|
let dist = distance(a.getCoordinates(), b.getCoordinates()) / 1000;
|
||||||
return new Date(a.time.getTime() + (1000 * 3600 * dist) / speed);
|
return new Date(a.time.getTime() + (1000 * 3600 * dist) / speed);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue