mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2025-09-02 16:52:31 +00:00
progress
This commit is contained in:
@@ -34,11 +34,9 @@
|
||||
<ElevationProfile />
|
||||
</div>
|
||||
</div>
|
||||
<div class="shrink-0">
|
||||
{#if $verticalFileView}
|
||||
<FileList orientation="vertical" recursive={true} class="w-60" />
|
||||
{/if}
|
||||
</div>
|
||||
{#if $verticalFileView}
|
||||
<FileList orientation="vertical" recursive={true} class="w-60" />
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style lang="postcss">
|
||||
|
@@ -14,7 +14,7 @@
|
||||
</script>
|
||||
|
||||
<ScrollArea
|
||||
class={orientation === 'vertical' ? 'p-1 pr-3' : 'h-10 px-1'}
|
||||
class="shrink-0 {orientation === 'vertical' ? 'p-1 pr-3' : 'h-10 px-1'}"
|
||||
{orientation}
|
||||
scrollbarXClasses={orientation === 'vertical' ? '' : 'mt-1 h-2'}
|
||||
scrollbarYClasses={orientation === 'vertical' ? '' : ''}
|
||||
|
@@ -58,7 +58,21 @@
|
||||
|
||||
if ($fileOrder.length !== $fileObservers.size) {
|
||||
// Files were added or removed
|
||||
fileOrder.set(sortable.toArray());
|
||||
fileOrder.update((order) => {
|
||||
for (let i = 0; i < order.length; ) {
|
||||
if (!$fileObservers.has(order[i])) {
|
||||
order.splice(i, 1);
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
for (let id of $fileObservers.keys()) {
|
||||
if (!order.includes(id)) {
|
||||
order.push(id);
|
||||
}
|
||||
}
|
||||
return order;
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,6 @@
|
||||
import { distance, type Coordinates, TrackPoint, TrackSegment } from "gpx";
|
||||
import { original } from "immer";
|
||||
import { get, type Readable } from "svelte/store";
|
||||
import { computeAnchorPoints } from "./Simplify";
|
||||
import mapboxgl from "mapbox-gl";
|
||||
import { route } from "./Routing";
|
||||
|
||||
@@ -66,22 +65,6 @@ export class RoutingControls {
|
||||
for (let segmentIndex = 0; segmentIndex < segments.length; segmentIndex++) {
|
||||
let segment = segments[segmentIndex];
|
||||
|
||||
if (!segment._data.anchors) { // New segment, compute anchor points for it
|
||||
computeAnchorPoints(segment);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
for (let point of segment.trkpt) { // Update the existing anchors (could be improved by matching the existing anchors with the new ones?)
|
||||
if (point._data.anchor) {
|
||||
if (anchorIndex < this.anchors.length) {
|
||||
@@ -433,17 +416,19 @@ export class RoutingControls {
|
||||
}
|
||||
|
||||
if (anchors[0].point._data.index === 0) { // First anchor is the first point of the segment
|
||||
anchors[0].point = response[0]; // Update the first anchor
|
||||
anchors[0].point = response[0]; // Replace the first anchor
|
||||
anchors[0].point._data.index = 0;
|
||||
} else {
|
||||
response.splice(0, 0, anchors[0].point); // Keep the original start point
|
||||
anchors[0].point = anchors[0].point.clone(); // Clone the anchor to assign new properties
|
||||
response.splice(0, 0, anchors[0].point); // Insert it in the response to keep it
|
||||
}
|
||||
|
||||
if (anchors[anchors.length - 1].point._data.index === segment.trkpt.length - 1) { // Last anchor is the last point of the segment
|
||||
anchors[anchors.length - 1].point = response[response.length - 1]; // Update the last anchor
|
||||
anchors[anchors.length - 1].point = response[response.length - 1]; // Replace the last anchor
|
||||
anchors[anchors.length - 1].point._data.index = segment.trkpt.length - 1;
|
||||
} else {
|
||||
response.push(anchors[anchors.length - 1].point); // Keep the original end point
|
||||
anchors[anchors.length - 1].point = anchors[anchors.length - 1].point.clone(); // Clone the anchor to assign new properties
|
||||
response.push(anchors[anchors.length - 1].point); // Insert it in the response to keep it
|
||||
}
|
||||
|
||||
for (let i = 1; i < anchors.length - 1; i++) {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import type { Coordinates, TrackPoint, TrackSegment } from "gpx";
|
||||
import type { Coordinates, GPXFile, TrackPoint, TrackSegment } from "gpx";
|
||||
|
||||
type SimplifiedTrackPoint = { point: TrackPoint, distance?: number };
|
||||
|
||||
@@ -15,7 +15,32 @@ export function getZoomLevelForDistance(latitude: number, distance?: number): nu
|
||||
return Math.min(20, Math.max(0, Math.floor(Math.log2((earthRadius * Math.cos(lat)) / distance))));
|
||||
}
|
||||
|
||||
export function computeAnchorPoints(segment: TrackSegment) {
|
||||
export function updateAnchorPoints(file: GPXFile) {
|
||||
let segments = file.getSegments();
|
||||
|
||||
for (let segmentIndex = 0; segmentIndex < segments.length; segmentIndex++) {
|
||||
let segment = segments[segmentIndex];
|
||||
|
||||
if (!segment._data.anchors) { // New segment, compute anchor points for it
|
||||
computeAnchorPoints(segment);
|
||||
continue;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function computeAnchorPoints(segment: TrackSegment) {
|
||||
let points = segment.trkpt;
|
||||
let anchors = ramerDouglasPeucker(points);
|
||||
anchors.forEach((anchor) => {
|
||||
|
Reference in New Issue
Block a user