This commit is contained in:
vcoppe
2024-04-24 19:32:55 +02:00
parent e12a704c2e
commit 88c6681a78
8 changed files with 103 additions and 43 deletions

View File

@@ -16,6 +16,7 @@ abstract class GPXTreeElement<T extends GPXTreeElement<any>> {
abstract computeStatistics(): GPXStatistics;
abstract append(points: TrackPoint[]): void;
abstract reverse(originalNextTimestamp?: Date, newPreviousTimestamp?: Date): void;
abstract getStartTimestamp(): Date;
@@ -44,6 +45,16 @@ abstract class GPXTreeNode<T extends GPXTreeElement<any>> extends GPXTreeElement
return statistics;
}
append(points: TrackPoint[]): void {
let children = this.getChildren();
if (children.length === 0) {
return;
}
children[children.length - 1].append(points);
}
reverse(originalNextTimestamp?: Date, newPreviousTimestamp?: Date): void {
const children = this.getChildren();
@@ -130,7 +141,10 @@ export class GPXFiles extends GPXTreeNode<GPXFile> {
super();
this.files = files;
this.computeStatistics();
this.statistics = new GPXStatistics();
for (let file of files) {
this.statistics.mergeWith(file.statistics);
}
}
getChildren(): GPXFile[] {
@@ -357,6 +371,11 @@ export class TrackSegment extends GPXTreeLeaf {
return distanceWindowSmoothingWithDistanceAccumulator(points, 50, (accumulated, start, end) => 100 * (points[end].ele - points[start].ele) / accumulated);
}
append(points: TrackPoint[]): void {
this.trkpt = this.trkpt.concat(points);
//this.computeStatistics();
}
reverse(originalNextTimestamp: Date | undefined, newPreviousTimestamp: Date | undefined): void {
if (originalNextTimestamp !== undefined && newPreviousTimestamp !== undefined) {
let originalEndTimestamp = this.getEndTimestamp();