mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2025-08-31 15:43:25 +00:00
routing controls class
This commit is contained in:
@@ -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",
|
||||
|
Reference in New Issue
Block a user