routing controls class

This commit is contained in:
vcoppe
2024-04-25 16:41:06 +02:00
parent 22de36d426
commit 7ef19adf53
9 changed files with 343 additions and 298 deletions

View File

@@ -22,6 +22,7 @@ abstract class GPXTreeElement<T extends GPXTreeElement<any>> {
abstract getStatistics(): GPXStatistics;
abstract getTrackPoints(): TrackPoint[];
abstract getTrackPointsAndStatistics(): { points: TrackPoint[], point_statistics: TrackPointStatistics, statistics: GPXStatistics };
abstract getSegments(): TrackSegment[];
abstract toGeoJSON(): GeoJSON.Feature | GeoJSON.Feature[] | GeoJSON.FeatureCollection | GeoJSON.FeatureCollection[];
}
@@ -115,6 +116,10 @@ abstract class GPXTreeNode<T extends GPXTreeElement<any>> extends GPXTreeElement
return { points, point_statistics, statistics };
}
getSegments(): TrackSegment[] {
return this.getChildren().flatMap((child) => child.getSegments());
}
}
// An abstract class that TrackSegment extends to implement the GPXTreeElement interface
@@ -280,6 +285,7 @@ export class TrackSegment extends GPXTreeLeaf {
const points = this.trkpt;
for (let i = 0; i < points.length; i++) {
points[i]._data['index'] = i;
// distance
let dist = 0;
@@ -408,6 +414,10 @@ export class TrackSegment extends GPXTreeLeaf {
};
}
getSegments(): TrackSegment[] {
return [this];
}
toGeoJSON(): GeoJSON.Feature {
return {
type: "Feature",