mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2025-12-27 13:39:59 +00:00
fix wpt to segment matching
This commit is contained in:
@@ -473,13 +473,11 @@ export const fileActions = {
|
|||||||
newFile.replaceWaypoints(
|
newFile.replaceWaypoints(
|
||||||
0,
|
0,
|
||||||
file.wpt.length - 1,
|
file.wpt.length - 1,
|
||||||
closest
|
file.wpt.filter((wpt, wptIndex) =>
|
||||||
.filter((c) =>
|
closest[wptIndex].some(
|
||||||
c.some(
|
([trackIndex, segmentIndex]) => trackIndex === index
|
||||||
([trackIndex, segmentIndex]) => trackIndex === index
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
.map((c, wptIndex) => file.wpt[wptIndex])
|
)
|
||||||
);
|
);
|
||||||
newFile._data.id = fileIds[index];
|
newFile._data.id = fileIds[index];
|
||||||
newFile.metadata.name =
|
newFile.metadata.name =
|
||||||
@@ -499,14 +497,11 @@ export const fileActions = {
|
|||||||
newFile.replaceWaypoints(
|
newFile.replaceWaypoints(
|
||||||
0,
|
0,
|
||||||
file.wpt.length - 1,
|
file.wpt.length - 1,
|
||||||
closest
|
file.wpt.filter((wpt, wptIndex) =>
|
||||||
.filter((c) =>
|
closest[wptIndex].some(
|
||||||
c.some(
|
([trackIndex, segmentIndex]) => segmentIndex === index
|
||||||
([trackIndex, segmentIndex]) =>
|
|
||||||
segmentIndex === index
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
.map((c, wptIndex) => file.wpt[wptIndex])
|
)
|
||||||
);
|
);
|
||||||
newFile._data.id = fileIds[index];
|
newFile._data.id = fileIds[index];
|
||||||
newFile.metadata.name = `${file.trk[0].name ?? file.metadata.name} (${index + 1})`;
|
newFile.metadata.name = `${file.trk[0].name ?? file.metadata.name} (${index + 1})`;
|
||||||
|
|||||||
@@ -62,15 +62,20 @@ export function getClosestTrackSegments(
|
|||||||
let segmentBounds = segmentStatistics.global.bounds;
|
let segmentBounds = segmentStatistics.global.bounds;
|
||||||
let northEast = segmentBounds.northEast;
|
let northEast = segmentBounds.northEast;
|
||||||
let southWest = segmentBounds.southWest;
|
let southWest = segmentBounds.southWest;
|
||||||
let northWest: Coordinates = { lat: northEast.lat, lon: southWest.lon };
|
let bounds = new mapboxgl.LngLatBounds(southWest, northEast);
|
||||||
let southEast: Coordinates = { lat: southWest.lat, lon: northEast.lon };
|
if (bounds.contains(point)) {
|
||||||
let distanceToSegment = Math.min(
|
segmentBoundsDistances.push([0, trackIndex, segmentIndex]);
|
||||||
crossarcDistance(northWest, northEast, point),
|
} else {
|
||||||
crossarcDistance(northEast, southEast, point),
|
let northWest: Coordinates = { lat: northEast.lat, lon: southWest.lon };
|
||||||
crossarcDistance(southEast, southWest, point),
|
let southEast: Coordinates = { lat: southWest.lat, lon: northEast.lon };
|
||||||
crossarcDistance(southWest, northWest, point)
|
let distanceToBounds = Math.min(
|
||||||
);
|
crossarcDistance(northWest, northEast, point),
|
||||||
segmentBoundsDistances.push([distanceToSegment, trackIndex, segmentIndex]);
|
crossarcDistance(northEast, southEast, point),
|
||||||
|
crossarcDistance(southEast, southWest, point),
|
||||||
|
crossarcDistance(southWest, northWest, point)
|
||||||
|
);
|
||||||
|
segmentBoundsDistances.push([distanceToBounds, trackIndex, segmentIndex]);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
segmentBoundsDistances.sort((a, b) => a[0] - b[0]);
|
segmentBoundsDistances.sort((a, b) => a[0] - b[0]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user