do not compute stats on draft object

This commit is contained in:
vcoppe
2024-05-03 17:37:34 +02:00
parent 28a50dd46e
commit e9cf49f51b
5 changed files with 13 additions and 28 deletions

View File

@@ -309,14 +309,8 @@ export class TrackSegment extends GPXTreeLeaf {
if (segment) {
if (segment instanceof TrackSegment) {
this.trkpt = segment.trkpt;
this.statistics = segment.statistics;
this.trkptStatistics = segment.trkptStatistics;
} else {
this.trkpt = segment.trkpt.map((point) => new TrackPoint(point));
if (segment.hasOwnProperty('statistics') && segment.hasOwnProperty('trkptStatistics')) {
this.statistics = segment.statistics;
this.trkptStatistics = segment.trkptStatistics;
}
}
if (segment.hasOwnProperty('_data')) {
this._data = cloneJSON(segment._data);
@@ -325,9 +319,7 @@ export class TrackSegment extends GPXTreeLeaf {
this.trkpt = [];
}
if (!this.statistics) {
this._computeStatistics();
}
this._computeStatistics();
}
_computeStatistics(): void {
@@ -431,12 +423,10 @@ export class TrackSegment extends GPXTreeLeaf {
append(points: TrackPoint[]): void {
this.trkpt = this.trkpt.concat(points);
this._computeStatistics();
}
replace(start: number, end: number, points: TrackPoint[]): void {
this.trkpt.splice(start, end - start + 1, ...points);
this._computeStatistics();
}
reverse(originalNextTimestamp: Date | undefined, newPreviousTimestamp: Date | undefined): void {
@@ -456,7 +446,6 @@ export class TrackSegment extends GPXTreeLeaf {
} else {
this.trkpt.reverse();
}
this._computeStatistics();
}
getStartTimestamp(): Date {