mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2025-08-31 15:43:25 +00:00
fix anchors for new files
This commit is contained in:
@@ -195,9 +195,9 @@ export class Track extends GPXTreeNode<TrackSegment> {
|
||||
this.link = track.link;
|
||||
this.type = track.type;
|
||||
this.trkseg = track.trkseg ? track.trkseg.map((seg) => new TrackSegment(seg)) : [];
|
||||
this.extensions = cloneJSON(track.extensions);
|
||||
this.extensions = track.extensions;
|
||||
if (track.hasOwnProperty('_data')) {
|
||||
this._data = cloneJSON(track._data);
|
||||
this._data = track._data;
|
||||
}
|
||||
} else {
|
||||
this.trkseg = [new TrackSegment()];
|
||||
@@ -263,7 +263,7 @@ export class TrackSegment extends GPXTreeLeaf {
|
||||
if (segment) {
|
||||
this.trkpt = segment.trkpt.map((point) => new TrackPoint(point));
|
||||
if (segment.hasOwnProperty('_data')) {
|
||||
this._data = cloneJSON(segment._data);
|
||||
this._data = segment._data;
|
||||
}
|
||||
} else {
|
||||
this.trkpt = [];
|
||||
|
@@ -65,22 +65,20 @@ export class RoutingControls {
|
||||
for (let segmentIndex = 0; segmentIndex < segments.length; segmentIndex++) {
|
||||
let segment = segments[segmentIndex];
|
||||
|
||||
if (segment.trkpt.length === 0) { // Empty segment, skip
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!segment._data.anchors) { // New segment, compute anchor points for it
|
||||
computeAnchorPoints(segment);
|
||||
}
|
||||
|
||||
if (!segment.trkpt[0]._data.anchor) { // First point is not an anchor, make it one
|
||||
segment.trkpt[0]._data.anchor = true;
|
||||
segment.trkpt[0]._data.zoom = 0;
|
||||
}
|
||||
if (segment.trkpt.length > 0) {
|
||||
if (!segment.trkpt[0]._data.anchor) { // First point is not an anchor, make it one
|
||||
segment.trkpt[0]._data.anchor = true;
|
||||
segment.trkpt[0]._data.zoom = 0;
|
||||
}
|
||||
|
||||
if (!segment.trkpt[segment.trkpt.length - 1]._data.anchor) { // Last point is not an anchor, make it one
|
||||
segment.trkpt[segment.trkpt.length - 1]._data.anchor = true;
|
||||
segment.trkpt[segment.trkpt.length - 1]._data.zoom = 0;
|
||||
if (!segment.trkpt[segment.trkpt.length - 1]._data.anchor) { // Last point is not an anchor, make it one
|
||||
segment.trkpt[segment.trkpt.length - 1]._data.anchor = true;
|
||||
segment.trkpt[segment.trkpt.length - 1]._data.zoom = 0;
|
||||
}
|
||||
}
|
||||
|
||||
for (let point of segment.trkpt) { // Update the existing anchors (could be improved by matching the existing anchors with the new ones?)
|
||||
|
Reference in New Issue
Block a user