fixes time and speed in route planning
This commit is contained in:
@@ -93,11 +93,29 @@ export async function editRoute(index: number, waypoints: Waypoint[]) {
|
||||
segment.trkpt = waypoints
|
||||
}
|
||||
route.features = route.getTotals();
|
||||
|
||||
}
|
||||
|
||||
export function deleteFromRoute(index: number) {
|
||||
route.trk?.at(0)?.trkseg?.splice(index, 1);
|
||||
route.features = route.getTotals();
|
||||
}
|
||||
|
||||
export function normalizeRouteTime() {
|
||||
let currentTime = new Date();
|
||||
|
||||
for (const seg of route.trk?.at(0)?.trkseg ?? []) {
|
||||
|
||||
if (!seg.trkpt?.length) {
|
||||
continue
|
||||
}
|
||||
const baseTime = seg.trkpt[0].time?.getTime() ?? 0;
|
||||
for (let i = 0; i < seg.trkpt.length; i++) {
|
||||
const wp = seg.trkpt![i];
|
||||
const offset = (wp.time?.getTime() ?? 0) - baseTime;
|
||||
const adjustedTime = new Date(currentTime.getTime() + offset);
|
||||
|
||||
wp.time = adjustedTime
|
||||
}
|
||||
currentTime = new Date(seg.trkpt[seg.trkpt.length - 1].time!.getTime());
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ export function bbox(
|
||||
result[3] = coord[1];
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -52,9 +52,9 @@ export function findStartAndEndPoints(geojson: GeoJsonObject): Position[] {
|
||||
|
||||
export function splitMultiLineStringToLineStrings(geojson: GeoJsonObject): FeatureCollection {
|
||||
const features: Feature[] = [];
|
||||
|
||||
(geojson as any).features.forEach((feature: any) => {
|
||||
if (feature.geometry.type === "MultiLineString") {
|
||||
|
||||
feature.geometry.coordinates.forEach((lineString: any, lineIndex: number) => {
|
||||
features.push({
|
||||
type: "Feature",
|
||||
@@ -64,6 +64,10 @@ export function splitMultiLineStringToLineStrings(geojson: GeoJsonObject): Featu
|
||||
},
|
||||
properties: {
|
||||
...feature.properties,
|
||||
coordinateProperties: {
|
||||
...feature.properties.coordinateProperties,
|
||||
times: feature.properties.coordinateProperties.times[lineIndex]
|
||||
},
|
||||
featureId: features.length,
|
||||
segmentId: lineIndex,
|
||||
},
|
||||
|
||||
@@ -648,7 +648,7 @@ export class ElevationProfile {
|
||||
if (this.settings.tooltipDisplaySpeed && this.speed.length) {
|
||||
tooltipInfo.push(`Speed: ${this.speed[
|
||||
tooltipItem.dataIndex
|
||||
].toFixed(2)} ${distanceUnit}/h`
|
||||
]?.toFixed(2)} ${distanceUnit}/h`
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user