mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2025-12-03 18:32:12 +00:00
progress
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import ToolbarItem from '$lib/components/toolbar/ToolbarItem.svelte';
|
||||
import ToolbarItemMenu from '$lib/components/toolbar/ToolbarItemMenu.svelte';
|
||||
import { Tool } from '$lib/components/toolbar/utils.svelte';
|
||||
import { Tool } from '$lib/components/toolbar/tools';
|
||||
import {
|
||||
Group,
|
||||
CalendarClock,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { Button } from '$lib/components/ui/button';
|
||||
import * as Tooltip from '$lib/components/ui/tooltip/index.js';
|
||||
import { tool, Tool } from '$lib/components/toolbar/utils.svelte';
|
||||
import { tool, Tool } from '$lib/components/toolbar/tools';
|
||||
import type { Snippet } from 'svelte';
|
||||
|
||||
let {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { Tool, tool } from '$lib/components/toolbar/utils.svelte';
|
||||
import { Tool, tool } from '$lib/components/toolbar/tools';
|
||||
import * as Card from '$lib/components/ui/card';
|
||||
import Routing from '$lib/components/toolbar/tools/routing/Routing.svelte';
|
||||
import Scissors from '$lib/components/toolbar/tools/scissors/Scissors.svelte';
|
||||
@@ -13,7 +13,7 @@
|
||||
import RoutingControlPopup from '$lib/components/toolbar/tools/routing/RoutingControlPopup.svelte';
|
||||
import { onMount } from 'svelte';
|
||||
import mapboxgl from 'mapbox-gl';
|
||||
import { settings } from '$lib/logic/settings.svelte';
|
||||
import { settings } from '$lib/logic/settings';
|
||||
|
||||
let {
|
||||
popupElement,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { writable, type Writable } from 'svelte/store';
|
||||
|
||||
export enum Tool {
|
||||
ROUTING,
|
||||
WAYPOINT,
|
||||
@@ -10,8 +12,4 @@ export enum Tool {
|
||||
CLEAN,
|
||||
}
|
||||
|
||||
export const tool: {
|
||||
current: Tool | null;
|
||||
} = $state({
|
||||
current: null,
|
||||
});
|
||||
export const currentTool: Writable<Tool | null> = writable(null);
|
||||
@@ -1,4 +1,4 @@
|
||||
<script lang="ts" context="module">
|
||||
<script lang="ts" module>
|
||||
enum CleanType {
|
||||
INSIDE = 'inside',
|
||||
OUTSIDE = 'outside',
|
||||
@@ -15,10 +15,10 @@
|
||||
import { onDestroy, onMount } from 'svelte';
|
||||
import { getURLForLanguage, resetCursor, setCrosshairCursor } from '$lib/utils';
|
||||
import { Trash2 } from '@lucide/svelte';
|
||||
import { map } from '$lib/components/map/utils.svelte';
|
||||
import { map } from '$lib/components/map/map';
|
||||
import type { GeoJSONSource } from 'mapbox-gl';
|
||||
import { selection } from '$lib/logic/selection.svelte';
|
||||
import { fileActions } from '$lib/logic/file-actions.svelte';
|
||||
import { selection } from '$lib/logic/selection';
|
||||
import { fileActions } from '$lib/logic/file-actions';
|
||||
|
||||
let props: {
|
||||
class?: string;
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
import { Button } from '$lib/components/ui/button';
|
||||
import Help from '$lib/components/Help.svelte';
|
||||
import { MountainSnow } from '@lucide/svelte';
|
||||
import { map } from '$lib/components/map/utils.svelte';
|
||||
import { map } from '$lib/components/map/map';
|
||||
import { i18n } from '$lib/i18n.svelte';
|
||||
import { getURLForLanguage } from '$lib/utils';
|
||||
import { selection } from '$lib/logic/selection.svelte';
|
||||
import { fileActions } from '$lib/logic/file-actions.svelte';
|
||||
import { selection } from '$lib/logic/selection';
|
||||
import { fileActions } from '$lib/logic/file-actions';
|
||||
|
||||
let props: {
|
||||
class?: string;
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
import Help from '$lib/components/Help.svelte';
|
||||
import { i18n } from '$lib/i18n.svelte';
|
||||
import { getURLForLanguage } from '$lib/utils';
|
||||
import { selection } from '$lib/logic/selection.svelte';
|
||||
import { fileStateCollection } from '$lib/logic/file-state.svelte';
|
||||
import { fileActions } from '$lib/logic/file-actions.svelte';
|
||||
import { selection } from '$lib/logic/selection';
|
||||
import { fileStateCollection } from '$lib/logic/file-state';
|
||||
import { fileActions } from '$lib/logic/file-actions';
|
||||
|
||||
let props: {
|
||||
class?: string;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<script lang="ts" context="module">
|
||||
<script lang="ts" module>
|
||||
enum MergeType {
|
||||
TRACES = 'traces',
|
||||
CONTENTS = 'contents',
|
||||
@@ -17,9 +17,9 @@
|
||||
import { getURLForLanguage } from '$lib/utils';
|
||||
import Shortcut from '$lib/components/Shortcut.svelte';
|
||||
import { gpxStatistics } from '$lib/stores';
|
||||
import { selection } from '$lib/logic/selection.svelte';
|
||||
import { fileStateCollection } from '$lib/logic/file-state.svelte';
|
||||
import { fileActions } from '$lib/logic/file-actions.svelte';
|
||||
import { selection } from '$lib/logic/selection';
|
||||
import { fileStateCollection } from '$lib/logic/file-state';
|
||||
import { fileActions } from '$lib/logic/file-actions';
|
||||
|
||||
let props: {
|
||||
class?: string;
|
||||
|
||||
@@ -11,13 +11,13 @@
|
||||
import { Funnel } from '@lucide/svelte';
|
||||
import { i18n } from '$lib/i18n.svelte';
|
||||
import WithUnits from '$lib/components/WithUnits.svelte';
|
||||
import { map } from '$lib/components/map/utils.svelte';
|
||||
import { map } from '$lib/components/map/map';
|
||||
import { onDestroy } from 'svelte';
|
||||
import { ramerDouglasPeucker, TrackPoint, type SimplifiedTrackPoint } from 'gpx';
|
||||
import { getURLForLanguage } from '$lib/utils';
|
||||
import type { GeoJSONSource } from 'mapbox-gl';
|
||||
import { selection } from '$lib/logic/selection.svelte';
|
||||
import { fileActions } from '$lib/logic/file-actions.svelte';
|
||||
import { selection } from '$lib/logic/selection';
|
||||
import { fileActions } from '$lib/logic/file-actions';
|
||||
|
||||
let props: { class?: string } = $props();
|
||||
|
||||
|
||||
@@ -24,10 +24,10 @@
|
||||
} from '$lib/components/file-list/file-list';
|
||||
import Help from '$lib/components/Help.svelte';
|
||||
import { getURLForLanguage } from '$lib/utils';
|
||||
import { selection } from '$lib/logic/selection.svelte';
|
||||
import { settings } from '$lib/logic/settings.svelte';
|
||||
import { fileActions } from '$lib/logic/file-actions.svelte';
|
||||
import { fileActionManager } from '$lib/logic/file-action-manager.svelte';
|
||||
import { selection } from '$lib/logic/selection';
|
||||
import { settings } from '$lib/logic/settings';
|
||||
import { fileActions } from '$lib/logic/file-actions';
|
||||
import { fileActionManager } from '$lib/logic/file-action-manager';
|
||||
|
||||
let props: {
|
||||
class?: string;
|
||||
|
||||
@@ -35,11 +35,11 @@
|
||||
import { getURLForLanguage, resetCursor, setCrosshairCursor } from '$lib/utils';
|
||||
import { onDestroy, onMount } from 'svelte';
|
||||
import { TrackPoint } from 'gpx';
|
||||
import { settings } from '$lib/logic/settings.svelte';
|
||||
import { map } from '$lib/components/map/utils.svelte';
|
||||
import { fileStateCollection } from '$lib/logic/file-state.svelte';
|
||||
import { selection } from '$lib/logic/selection.svelte';
|
||||
import { fileActions, getFileIds, newGPXFile } from '$lib/logic/file-actions.svelte';
|
||||
import { settings } from '$lib/logic/settings';
|
||||
import { map } from '$lib/components/map/map';
|
||||
import { fileStateCollection } from '$lib/logic/file-state';
|
||||
import { selection } from '$lib/logic/selection';
|
||||
import { fileActions, getFileIds, newGPXFile } from '$lib/logic/file-actions';
|
||||
|
||||
let {
|
||||
minimized = $bindable(false),
|
||||
@@ -85,11 +85,11 @@
|
||||
// }
|
||||
|
||||
let validSelection = $derived(
|
||||
selection.value.hasAnyChildren(new ListRootItem(), true, ['waypoints'])
|
||||
$selection.hasAnyChildren(new ListRootItem(), true, ['waypoints'])
|
||||
);
|
||||
|
||||
function createFileWithPoint(e: any) {
|
||||
if (selection.value.size === 0) {
|
||||
if ($selection.size === 0) {
|
||||
let file = newGPXFile();
|
||||
file.replaceTrackPoints(0, 0, 0, 0, [
|
||||
new TrackPoint({
|
||||
@@ -107,12 +107,12 @@
|
||||
|
||||
onMount(() => {
|
||||
// setCrosshairCursor();
|
||||
map.value?.on('click', createFileWithPoint);
|
||||
$map?.on('click', createFileWithPoint);
|
||||
});
|
||||
|
||||
onDestroy(() => {
|
||||
// resetCursor();
|
||||
map.value?.off('click', createFileWithPoint);
|
||||
$map?.off('click', createFileWithPoint);
|
||||
|
||||
// routingControls.forEach((controls) => controls.destroy());
|
||||
// routingControls.clear();
|
||||
@@ -233,7 +233,7 @@
|
||||
variant="outline"
|
||||
class="flex flex-row gap-1 text-xs px-2"
|
||||
disabled={!validSelection}
|
||||
onclick={dbUtils.createRoundTripForSelection}
|
||||
onclick={fileActions.createRoundTripForSelection}
|
||||
>
|
||||
<Repeat size="12" />{i18n._('toolbar.routing.round_trip.button')}
|
||||
</ButtonWithTooltip>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { Coordinates } from 'gpx';
|
||||
import { TrackPoint, distance } from 'gpx';
|
||||
import { settings } from '$lib/logic/settings.svelte';
|
||||
import { settings } from '$lib/logic/settings';
|
||||
import { getElevation } from '$lib/utils';
|
||||
|
||||
const { routing, routingProfile, privateRoads } = settings;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { splitAs, SplitType } from '$lib/components/toolbar/tools/scissors/utils.svelte';
|
||||
import { splitAs, SplitType } from '$lib/components/toolbar/tools/scissors/scissors';
|
||||
import Help from '$lib/components/Help.svelte';
|
||||
import { ListRootItem } from '$lib/components/file-list/file-list';
|
||||
import { Label } from '$lib/components/ui/label/index.js';
|
||||
@@ -8,7 +8,7 @@
|
||||
import * as Select from '$lib/components/ui/select';
|
||||
import { Separator } from '$lib/components/ui/separator';
|
||||
import { gpxStatistics, slicedGPXStatistics } from '$lib/stores';
|
||||
import { map } from '$lib/components/map/map.svelte';
|
||||
import { map } from '$lib/components/map/map';
|
||||
import { get } from 'svelte/store';
|
||||
import { i18n } from '$lib/i18n.svelte';
|
||||
import { onDestroy, tick } from 'svelte';
|
||||
@@ -16,7 +16,7 @@
|
||||
import { dbUtils } from '$lib/db';
|
||||
import { SplitControls } from './split-controls';
|
||||
import { getURLForLanguage } from '$lib/utils';
|
||||
import { selection } from '$lib/logic/selection.svelte';
|
||||
import { selection } from '$lib/logic/selection';
|
||||
|
||||
let props: {
|
||||
class?: string;
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import { writable, type Writable } from 'svelte/store';
|
||||
|
||||
export enum SplitType {
|
||||
FILES = 'files',
|
||||
TRACKS = 'tracks',
|
||||
SEGMENTS = 'segments',
|
||||
}
|
||||
|
||||
export let splitAs: Writable<SplitType> = writable(SplitType.FILES);
|
||||
@@ -3,10 +3,10 @@ import mapboxgl from 'mapbox-gl';
|
||||
import { dbUtils, getFile } from '$lib/db';
|
||||
import { ListTrackSegmentItem } from '$lib/components/file-list/file-list';
|
||||
import { gpxStatistics } from '$lib/stores';
|
||||
import { tool, Tool } from '$lib/components/toolbar/utils.svelte';
|
||||
import { splitAs } from '$lib/components/toolbar/tools/scissors/utils.svelte';
|
||||
import { tool, Tool } from '$lib/components/toolbar/tools';
|
||||
import { splitAs } from '$lib/components/toolbar/tools/scissors/scissors';
|
||||
import { Scissors } from 'lucide-static';
|
||||
import { applyToOrderedSelectedItemsFromFile, selection } from '$lib/logic/selection.svelte';
|
||||
import { selection } from '$lib/logic/selection';
|
||||
|
||||
export class SplitControls {
|
||||
active: boolean = false;
|
||||
@@ -53,7 +53,7 @@ export class SplitControls {
|
||||
updateControls() {
|
||||
// Update the markers when the files change
|
||||
let controlIndex = 0;
|
||||
applyToOrderedSelectedItemsFromFile((fileId, level, items) => {
|
||||
selection.applyToOrderedSelectedItemsFromFile((fileId, level, items) => {
|
||||
let file = getFile(fileId);
|
||||
|
||||
if (file) {
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
export enum SplitType {
|
||||
FILES = 'files',
|
||||
TRACKS = 'tracks',
|
||||
SEGMENTS = 'segments',
|
||||
}
|
||||
|
||||
export let splitAs = $state({
|
||||
current: SplitType.FILES,
|
||||
});
|
||||
@@ -14,8 +14,8 @@
|
||||
import { getURLForLanguage, resetCursor, setCrosshairCursor } from '$lib/utils';
|
||||
import { MapPin, CircleX, Save } from '@lucide/svelte';
|
||||
import { getSymbolKey, symbols } from '$lib/assets/symbols';
|
||||
import { selection } from '$lib/logic/selection.svelte';
|
||||
import { selectedWaypoint } from './utils.svelte';
|
||||
import { selection } from '$lib/logic/selection';
|
||||
import { selectedWaypoint } from './waypoint';
|
||||
|
||||
let props: {
|
||||
class?: string;
|
||||
|
||||
@@ -1,16 +1,27 @@
|
||||
import { ListWaypointItem } from '$lib/components/file-list/file-list';
|
||||
import { fileStateCollection } from '$lib/logic/file-state.svelte';
|
||||
import { selection } from '$lib/logic/selection.svelte';
|
||||
import { settings } from '$lib/logic/settings.svelte';
|
||||
import { fileStateCollection } from '$lib/logic/file-state';
|
||||
import { selection } from '$lib/logic/selection';
|
||||
import { settings } from '$lib/logic/settings';
|
||||
import type { Waypoint } from 'gpx';
|
||||
import { get, writable, type Writable } from 'svelte/store';
|
||||
|
||||
export class WaypointSelection {
|
||||
private _selection: [Waypoint, string] | undefined;
|
||||
private _selection: Writable<[Waypoint, string] | undefined>;
|
||||
|
||||
constructor() {
|
||||
this._selection = $derived.by(() => {
|
||||
if (settings.treeFileView.value && selection.value.size === 1) {
|
||||
let item = selection.value.getSelected()[0];
|
||||
this._selection = writable(undefined);
|
||||
settings.treeFileView.subscribe(() => {
|
||||
this.update();
|
||||
});
|
||||
selection.subscribe(() => {
|
||||
this.update();
|
||||
});
|
||||
}
|
||||
|
||||
update() {
|
||||
this._selection.update(() => {
|
||||
if (get(settings.treeFileView) && get(selection).size === 1) {
|
||||
let item = get(selection).getSelected()[0];
|
||||
if (item instanceof ListWaypointItem) {
|
||||
let file = fileStateCollection.getFile(item.getFileId());
|
||||
let waypoint = file?.wpt[item.getWaypointIndex()];
|
||||
@@ -24,15 +35,17 @@ export class WaypointSelection {
|
||||
}
|
||||
|
||||
reset() {
|
||||
this._selection = undefined;
|
||||
this._selection.set(undefined);
|
||||
}
|
||||
|
||||
get wpt(): Waypoint | undefined {
|
||||
return this._selection ? this._selection[0] : undefined;
|
||||
const selection = get(this._selection);
|
||||
return selection ? selection[0] : undefined;
|
||||
}
|
||||
|
||||
get fileId(): string | undefined {
|
||||
return this._selection ? this._selection[1] : undefined;
|
||||
const selection = get(this._selection);
|
||||
return selection ? selection[1] : undefined;
|
||||
}
|
||||
|
||||
// TODO update the waypoint data if the file changes
|
||||
Reference in New Issue
Block a user