mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2026-11-30 09:34:29 +00:00
Compare commits
16
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c0e6e3d2eb | ||
|
|
9bd38cd5f8 | ||
|
|
a163e1b897 | ||
|
|
33abec525a | ||
|
|
77c542d9aa | ||
|
|
17b5c1d567 | ||
|
|
2048076fe6 | ||
|
|
d7ff7d645b | ||
|
|
262b590bd4 | ||
|
|
14bf9cddd2 | ||
|
|
b9566160e5 | ||
|
|
0cc9d6f664 | ||
|
|
1942e0b9e1 | ||
|
|
70a24f53b3 | ||
|
|
001246a49e | ||
|
|
8fe7d8d64d |
No files matched your search
@@ -0,0 +1,67 @@
|
|||||||
|
name: Deploy to Cloudflare Pages
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: 'dev'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: cloudflare-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
deployments: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v5
|
||||||
|
|
||||||
|
- name: Install Node.js
|
||||||
|
uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version: 24
|
||||||
|
cache: npm
|
||||||
|
cache-dependency-path: website/package-lock.json
|
||||||
|
|
||||||
|
- name: Install Rust
|
||||||
|
uses: dtolnay/rust-toolchain@stable
|
||||||
|
with:
|
||||||
|
targets: wasm32-unknown-unknown
|
||||||
|
|
||||||
|
- name: Install wasm-pack
|
||||||
|
uses: taiki-e/install-action@v2
|
||||||
|
with:
|
||||||
|
tool: wasm-pack
|
||||||
|
|
||||||
|
- name: Test gpx-rs
|
||||||
|
run: cargo test
|
||||||
|
|
||||||
|
- name: Build wasm
|
||||||
|
run: wasm-pack build --target bundler
|
||||||
|
working-directory: wasm
|
||||||
|
|
||||||
|
- name: Install dependencies for website
|
||||||
|
run: npm install --prefix website
|
||||||
|
|
||||||
|
- name: Test website
|
||||||
|
run: npm test --prefix website
|
||||||
|
|
||||||
|
- name: Create env file
|
||||||
|
run: echo PUBLIC_MAPTILER_KEY=${{ secrets.PUBLIC_MAPTILER_KEY }} >> website/.env
|
||||||
|
|
||||||
|
- name: Build website
|
||||||
|
env:
|
||||||
|
BASE_PATH: ''
|
||||||
|
run: npm run build --prefix website
|
||||||
|
|
||||||
|
- name: Deploy to Cloudflare Pages
|
||||||
|
uses: cloudflare/wrangler-action@v3
|
||||||
|
with:
|
||||||
|
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||||
|
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||||
|
command: pages deploy website/build --project-name=${{ vars.CLOUDFLARE_PROJECT_NAME || 'gpxstudio' }} --branch=${{ github.ref_name }} --commit-dirty=true
|
||||||
|
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
|
||||||
@@ -0,0 +1,124 @@
|
|||||||
|
name: Desktop beta
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: 'dev'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: desktop-beta-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- platform: macos-latest
|
||||||
|
rust_targets: aarch64-apple-darwin,x86_64-apple-darwin,wasm32-unknown-unknown
|
||||||
|
args: --target universal-apple-darwin
|
||||||
|
bundles: target/universal-apple-darwin/release/bundle/dmg/*.dmg
|
||||||
|
# the oldest supported Ubuntu, so that the AppImage runs on older systems too
|
||||||
|
- platform: ubuntu-22.04
|
||||||
|
rust_targets: wasm32-unknown-unknown
|
||||||
|
args: ''
|
||||||
|
bundles: |
|
||||||
|
target/release/bundle/deb/*.deb
|
||||||
|
target/release/bundle/rpm/*.rpm
|
||||||
|
target/release/bundle/appimage/*.AppImage
|
||||||
|
- platform: windows-latest
|
||||||
|
rust_targets: wasm32-unknown-unknown
|
||||||
|
args: ''
|
||||||
|
bundles: |
|
||||||
|
target/release/bundle/msi/*.msi
|
||||||
|
target/release/bundle/nsis/*.exe
|
||||||
|
|
||||||
|
runs-on: ${{ matrix.platform }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v5
|
||||||
|
|
||||||
|
- name: Install Linux dependencies
|
||||||
|
if: runner.os == 'Linux'
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
|
||||||
|
|
||||||
|
- name: Install Node.js
|
||||||
|
uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version: 24
|
||||||
|
cache: npm
|
||||||
|
cache-dependency-path: website/package-lock.json
|
||||||
|
|
||||||
|
- name: Install Rust
|
||||||
|
uses: dtolnay/rust-toolchain@stable
|
||||||
|
with:
|
||||||
|
targets: ${{ matrix.rust_targets }}
|
||||||
|
|
||||||
|
- name: Cache Rust build
|
||||||
|
uses: Swatinem/rust-cache@v2
|
||||||
|
|
||||||
|
- name: Install wasm-pack
|
||||||
|
uses: taiki-e/install-action@v2
|
||||||
|
with:
|
||||||
|
tool: wasm-pack
|
||||||
|
|
||||||
|
# the desktop app does not use it, but the website depends on its package
|
||||||
|
- name: Build wasm
|
||||||
|
run: wasm-pack build --target bundler
|
||||||
|
working-directory: wasm
|
||||||
|
|
||||||
|
- name: Install dependencies for website
|
||||||
|
run: npm install --prefix website
|
||||||
|
|
||||||
|
# the key would be readable in the app: it is left empty, so only the MapTiler layer fails
|
||||||
|
- name: Create env file
|
||||||
|
run: echo "PUBLIC_MAPTILER_KEY=" >> website/.env
|
||||||
|
|
||||||
|
- name: Build app
|
||||||
|
run: npx --yes @tauri-apps/cli@2 build ${{ matrix.args }}
|
||||||
|
working-directory: tauri
|
||||||
|
|
||||||
|
# after the build, which gives the app the website it embeds
|
||||||
|
- name: Test engine and app
|
||||||
|
run: cargo test -p gpx-engine -p gpx-studio-desktop
|
||||||
|
|
||||||
|
- name: Upload bundles
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: bundles-${{ matrix.platform }}
|
||||||
|
path: ${{ matrix.bundles }}
|
||||||
|
if-no-files-found: error
|
||||||
|
|
||||||
|
# replaces the beta release only once every platform is built
|
||||||
|
release:
|
||||||
|
needs: build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
GH_REPO: ${{ github.repository }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Download bundles
|
||||||
|
uses: actions/download-artifact@v5
|
||||||
|
with:
|
||||||
|
pattern: bundles-*
|
||||||
|
path: bundles
|
||||||
|
merge-multiple: true
|
||||||
|
|
||||||
|
- name: Publish beta release
|
||||||
|
# the bundles of a platform are in a folder per format (deb, msi…)
|
||||||
|
run: |
|
||||||
|
mapfile -t files < <(find bundles -type f)
|
||||||
|
gh release delete desktop-beta --cleanup-tag --yes || true
|
||||||
|
gh release create desktop-beta "${files[@]}" \
|
||||||
|
--prerelease \
|
||||||
|
--target ${{ github.sha }} \
|
||||||
|
--title "Desktop beta" \
|
||||||
|
--notes "Beta of the desktop app, built from ${{ github.sha }} on the dev branch. The builds are not signed yet: macOS and Windows will warn before opening them."
|
||||||
@@ -0,0 +1,505 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<gpx xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns="http://www.topografix.com/GPX/1/1"
|
||||||
|
xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd
|
||||||
|
http://www.garmin.com/xmlschemas/GpxExtensions/v3 http://www.garmin.com/xmlschemas/GpxExtensionsv3.xsd
|
||||||
|
http://www.garmin.com/xmlschemas/TrackPointExtension/v1 http://www.garmin.com/xmlschemas/TrackPointExtensionv1.xsd
|
||||||
|
http://www.topografix.com/GPX/gpx_style/0/2 http://www.topografix.com/GPX/gpx_style/0/2/gpx_style.xsd"
|
||||||
|
xmlns:gpxtpx="http://www.garmin.com/xmlschemas/TrackPointExtension/v1"
|
||||||
|
xmlns:gpxpx="http://www.garmin.com/xmlschemas/PowerExtension/v1"
|
||||||
|
xmlns:gpx_style="http://www.topografix.com/GPX/gpx_style/0/2" version="1.1"
|
||||||
|
creator="https://gpx.studio">
|
||||||
|
<metadata>
|
||||||
|
<name>with_power</name>
|
||||||
|
<author>
|
||||||
|
<name>gpx.studio</name>
|
||||||
|
<link href="https://gpx.studio"></link>
|
||||||
|
</author>
|
||||||
|
</metadata>
|
||||||
|
<trk>
|
||||||
|
<name>with_power</name>
|
||||||
|
<type>Cycling</type>
|
||||||
|
<trkseg>
|
||||||
|
<trkpt lat="50.790867" lon="4.404968">
|
||||||
|
<ele>109.0</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.790714" lon="4.405036">
|
||||||
|
<ele>110.8</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.790336" lon="4.405259">
|
||||||
|
<ele>110.3</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.790165" lon="4.405331">
|
||||||
|
<ele>110.0</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.790008" lon="4.405359">
|
||||||
|
<ele>110.3</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.789818" lon="4.405359">
|
||||||
|
<ele>109.3</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.789409" lon="4.40534">
|
||||||
|
<ele>107.0</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.789105" lon="4.405411">
|
||||||
|
<ele>106.0</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.788799" lon="4.405527">
|
||||||
|
<ele>108.5</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.788645" lon="4.405606">
|
||||||
|
<ele>109.8</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.7885" lon="4.405711">
|
||||||
|
<ele>110.8</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.78822" lon="4.405959">
|
||||||
|
<ele>112.0</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.787956" lon="4.406092">
|
||||||
|
<ele>112.8</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.787814" lon="4.406143">
|
||||||
|
<ele>113.5</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.787674" lon="4.406177">
|
||||||
|
<ele>114.3</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.787451" lon="4.406199">
|
||||||
|
<ele>115.3</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.787297" lon="4.406177">
|
||||||
|
<ele>114.8</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.78716" lon="4.406098">
|
||||||
|
<ele>114.3</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.787045" lon="4.405984">
|
||||||
|
<ele>114.3</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.786683" lon="4.405653">
|
||||||
|
<ele>114.5</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.786538" lon="4.405543">
|
||||||
|
<ele>115.0</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.78635" lon="4.405441">
|
||||||
|
<ele>115.8</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.786275" lon="4.40542">
|
||||||
|
<ele>115.8</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.786182" lon="4.405435">
|
||||||
|
<ele>116.0</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.786121" lon="4.405475">
|
||||||
|
<ele>115.8</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.786042" lon="4.405558">
|
||||||
|
<ele>115.5</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.785821" lon="4.405925">
|
||||||
|
<ele>114.5</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.785672" lon="4.406119">
|
||||||
|
<ele>112.5</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.785516" lon="4.406256">
|
||||||
|
<ele>110.8</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.785384" lon="4.406364">
|
||||||
|
<ele>109.0</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.785126" lon="4.406475">
|
||||||
|
<ele>106.3</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.784697" lon="4.406537">
|
||||||
|
<ele>104.3</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.784591" lon="4.40657">
|
||||||
|
<ele>104.0</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.784507" lon="4.406612">
|
||||||
|
<ele>103.8</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.784435" lon="4.40669">
|
||||||
|
<ele>103.3</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.784209" lon="4.407148">
|
||||||
|
<ele>103.5</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.784162" lon="4.407257">
|
||||||
|
<ele>103.8</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.784077" lon="4.407372">
|
||||||
|
<ele>104.8</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.784006" lon="4.407435">
|
||||||
|
<ele>105.8</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.783924" lon="4.407471">
|
||||||
|
<ele>106.8</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.783837" lon="4.407486">
|
||||||
|
<ele>107.8</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.783771" lon="4.407472">
|
||||||
|
<ele>108.5</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.783697" lon="4.407428">
|
||||||
|
<ele>109.3</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.783626" lon="4.407363">
|
||||||
|
<ele>110.0</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.783548" lon="4.407274">
|
||||||
|
<ele>110.5</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.783458" lon="4.407134">
|
||||||
|
<ele>110.8</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.783123" lon="4.406435">
|
||||||
|
<ele>111.8</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.782982" lon="4.406168">
|
||||||
|
<ele>112.8</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.782871" lon="4.406044">
|
||||||
|
<ele>113.3</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.78279" lon="4.406021">
|
||||||
|
<ele>113.5</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.782714" lon="4.406018">
|
||||||
|
<ele>113.5</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.782607" lon="4.406047">
|
||||||
|
<ele>113.8</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.782405" lon="4.406194">
|
||||||
|
<ele>114.8</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.782175" lon="4.406413">
|
||||||
|
<ele>115.8</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.781749" lon="4.407018">
|
||||||
|
<ele>118.5</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.781654" lon="4.407316">
|
||||||
|
<ele>119.5</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.781563" lon="4.407764">
|
||||||
|
<ele>121.3</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.781487" lon="4.407984">
|
||||||
|
<ele>122.0</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.781422" lon="4.408216">
|
||||||
|
<ele>122.8</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.781395" lon="4.408508">
|
||||||
|
<ele>123.5</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.781399" lon="4.409114">
|
||||||
|
<ele>126.3</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.781367" lon="4.409428">
|
||||||
|
<ele>128.0</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.781286" lon="4.409607">
|
||||||
|
<ele>129.0</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.78116" lon="4.409789">
|
||||||
|
<ele>130.0</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.780804" lon="4.409993">
|
||||||
|
<ele>130.8</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.780389" lon="4.410334">
|
||||||
|
<ele>131.8</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.780232" lon="4.410563">
|
||||||
|
<ele>132.3</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.780094" lon="4.410827">
|
||||||
|
<ele>132.8</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.779723" lon="4.411582">
|
||||||
|
<ele>135.8</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.779591" lon="4.411791">
|
||||||
|
<ele>135.5</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.779125" lon="4.412435">
|
||||||
|
<ele>132.5</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.778676" lon="4.412979">
|
||||||
|
<ele>134.0</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.778194" lon="4.413466">
|
||||||
|
<ele>136.8</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.777427" lon="4.414302">
|
||||||
|
<ele>137.5</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.777165" lon="4.414736">
|
||||||
|
<ele>137.3</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.776927" lon="4.415201">
|
||||||
|
<ele>137.5</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.776778" lon="4.415613">
|
||||||
|
<ele>137.3</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.776553" lon="4.416425">
|
||||||
|
<ele>134.8</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.776326" lon="4.417304">
|
||||||
|
<ele>132.3</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
<trkpt lat="50.776129" lon="4.418383">
|
||||||
|
<ele>129.5</ele>
|
||||||
|
<extensions>
|
||||||
|
<gpxpx:PowerInWatts>210</gpxpx:PowerInWatts>
|
||||||
|
</extensions>
|
||||||
|
</trkpt>
|
||||||
|
</trkseg>
|
||||||
|
</trk>
|
||||||
|
</gpx>
|
||||||
@@ -1222,6 +1222,19 @@ mod tests {
|
|||||||
assert!(trkpt.power.is_some_and(|p| p == 200));
|
assert!(trkpt.power.is_some_and(|p| p == 200));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_parse_trackpoint_power_3() {
|
||||||
|
let gpx = parse_data("with_power_3");
|
||||||
|
|
||||||
|
assert_eq!(gpx.trk.len(), 1);
|
||||||
|
let trk = &gpx.trk[0];
|
||||||
|
assert_eq!(trk.trkseg.len(), 1);
|
||||||
|
let trkseg = &trk.trkseg[0];
|
||||||
|
assert!(!trkseg.is_empty());
|
||||||
|
let trkpt = &trkseg[0];
|
||||||
|
assert!(trkpt.power.is_some_and(|p| p == 200));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_trackpoint_atemp() {
|
fn test_parse_trackpoint_atemp() {
|
||||||
let gpx = parse_data("with_temp");
|
let gpx = parse_data("with_temp");
|
||||||
|
|||||||
@@ -402,9 +402,10 @@ fn write_point(
|
|||||||
Ok(())
|
Ok(())
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
|
// `PowerInWatts` is itself the root element of Garmin's power extension, without a
|
||||||
|
// wrapper
|
||||||
if let Some(power) = power {
|
if let Some(power) = power {
|
||||||
w.create_element("gpxpx:PowerExtension")
|
number(w, "gpxpx:PowerInWatts", power)?;
|
||||||
.write_inner_content(|w| number(w, "gpxpx:PowerInWatts", power))?;
|
|
||||||
}
|
}
|
||||||
if !path.is_empty() {
|
if !path.is_empty() {
|
||||||
w.create_element("gpxx:RoutePointExtension")
|
w.create_element("gpxx:RoutePointExtension")
|
||||||
@@ -511,6 +512,7 @@ mod tests {
|
|||||||
"with_temp",
|
"with_temp",
|
||||||
"with_power_1",
|
"with_power_1",
|
||||||
"with_power_2",
|
"with_power_2",
|
||||||
|
"with_power_3",
|
||||||
"with_surface",
|
"with_surface",
|
||||||
"with_highway",
|
"with_highway",
|
||||||
"with_style",
|
"with_style",
|
||||||
@@ -578,6 +580,16 @@ mod tests {
|
|||||||
assert_eq!(again.trk[0].info.name.as_deref(), Some("a <b> & c"));
|
assert_eq!(again.trk[0].info.name.as_deref(), Some("a <b> & c"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_power_is_written_without_a_wrapper() {
|
||||||
|
let (file, categories) = read("with_power_2");
|
||||||
|
let text: String = written_text(&file, &categories, ExportOptions::ALL)
|
||||||
|
.split_whitespace()
|
||||||
|
.collect();
|
||||||
|
assert!(text.contains("<extensions><gpxpx:PowerInWatts>200</gpxpx:PowerInWatts>"));
|
||||||
|
assert!(!text.contains("<gpxpx:PowerExtension>"));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_exportable_data() {
|
fn test_exportable_data() {
|
||||||
let (file, _) = read("with_time");
|
let (file, _) = read("with_time");
|
||||||
|
|||||||
@@ -107,9 +107,9 @@ impl Apply for Convert {
|
|||||||
Err(CommandError::NothingToDo)
|
Err(CommandError::NothingToDo)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
Selection::Empty
|
Selection::Empty | Selection::Waypoints { .. } | Selection::Waypoint { .. } => {
|
||||||
| Selection::Waypoints { .. }
|
return Err(CommandError::NothingToDo);
|
||||||
| Selection::Waypoint { .. } => return Err(CommandError::NothingToDo),
|
}
|
||||||
};
|
};
|
||||||
let empty = match &next {
|
let empty = match &next {
|
||||||
Selection::Route { rte_ids, .. } => rte_ids.is_empty(),
|
Selection::Route { rte_ids, .. } => rte_ids.is_empty(),
|
||||||
|
|||||||
@@ -7,6 +7,15 @@ edition = "2024"
|
|||||||
[lib]
|
[lib]
|
||||||
name = "gpx_studio_desktop_lib"
|
name = "gpx_studio_desktop_lib"
|
||||||
crate-type = ["staticlib", "cdylib", "rlib"]
|
crate-type = ["staticlib", "cdylib", "rlib"]
|
||||||
|
# the tests are in `tests/app`: on Windows, a test binary of the library or of the app could not
|
||||||
|
# start without the manifest, which `build.rs` only gives to the binaries of `tests`
|
||||||
|
test = false
|
||||||
|
doctest = false
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "gpx-studio-desktop"
|
||||||
|
path = "src/main.rs"
|
||||||
|
test = false
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tauri = { version = "2", features = ["test"] }
|
tauri = { version = "2", features = ["test"] }
|
||||||
|
|||||||
@@ -1,3 +1,20 @@
|
|||||||
fn main() {
|
fn main() {
|
||||||
|
// On Windows, the dialogs need Common Controls v6, which a binary only gets with a manifest that
|
||||||
|
// asks for it: tauri-build gives one to the app, but not to the test binaries, which would stop
|
||||||
|
// with STATUS_ENTRYPOINT_NOT_FOUND before running any test. This gives them the same manifest
|
||||||
|
// (`-tests` only reaches the binaries of `tests`, hence the tests are there).
|
||||||
|
if std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("windows")
|
||||||
|
&& std::env::var("CARGO_CFG_TARGET_ENV").as_deref() == Ok("msvc")
|
||||||
|
{
|
||||||
|
let manifest = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
|
||||||
|
.join("tests")
|
||||||
|
.join("windows-test.manifest");
|
||||||
|
println!("cargo:rerun-if-changed={}", manifest.display());
|
||||||
|
println!("cargo:rustc-link-arg-tests=/MANIFEST:EMBED");
|
||||||
|
println!(
|
||||||
|
"cargo:rustc-link-arg-tests=/MANIFESTINPUT:{}",
|
||||||
|
manifest.display()
|
||||||
|
);
|
||||||
|
}
|
||||||
tauri_build::build()
|
tauri_build::build()
|
||||||
}
|
}
|
||||||
+6
-9
@@ -3,20 +3,20 @@
|
|||||||
|
|
||||||
mod bytes;
|
mod bytes;
|
||||||
mod commands;
|
mod commands;
|
||||||
mod state;
|
pub mod state;
|
||||||
mod store;
|
pub mod store;
|
||||||
mod workspace;
|
pub mod workspace;
|
||||||
|
|
||||||
use commands::*;
|
use commands::*;
|
||||||
use tauri::{Emitter, Manager};
|
use tauri::{Emitter, Manager};
|
||||||
|
|
||||||
/// The engine of the app: each file has its own history, so that undoing only concerns the
|
/// The engine of the app: each file has its own history, so that undoing only concerns the
|
||||||
/// selected files, and opening or closing a file is not something to undo.
|
/// selected files, and opening or closing a file is not something to undo.
|
||||||
pub(crate) type Engine = gpx_engine::Engine<gpx_engine::PerFileHistory>;
|
pub type Engine = gpx_engine::Engine<gpx_engine::PerFileHistory>;
|
||||||
|
|
||||||
/// The GPX files among what the system gave to the app (the arguments of the command line, when a
|
/// The GPX files among what the system gave to the app (the arguments of the command line, when a
|
||||||
/// file is opened with it).
|
/// file is opened with it).
|
||||||
fn gpx_paths(arguments: impl IntoIterator<Item = String>) -> Vec<std::path::PathBuf> {
|
pub fn gpx_paths(arguments: impl IntoIterator<Item = String>) -> Vec<std::path::PathBuf> {
|
||||||
arguments
|
arguments
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(std::path::PathBuf::from)
|
.map(std::path::PathBuf::from)
|
||||||
@@ -108,7 +108,7 @@ fn menu<R: tauri::Runtime>(app: &tauri::AppHandle<R>) -> tauri::Result<tauri::me
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Gives the builder the commands that reach the engine (which it has to be given as `AppState`).
|
/// Gives the builder the commands that reach the engine (which it has to be given as `AppState`).
|
||||||
fn register_commands<R: tauri::Runtime>(builder: tauri::Builder<R>) -> tauri::Builder<R> {
|
pub fn register_commands<R: tauri::Runtime>(builder: tauri::Builder<R>) -> tauri::Builder<R> {
|
||||||
builder.invoke_handler(tauri::generate_handler![
|
builder.invoke_handler(tauri::generate_handler![
|
||||||
// selection
|
// selection
|
||||||
selection::select,
|
selection::select,
|
||||||
@@ -234,6 +234,3 @@ fn register_commands<R: tauri::Runtime>(builder: tauri::Builder<R>) -> tauri::Bu
|
|||||||
system::reveal_path,
|
system::reveal_path,
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests;
|
|
||||||
@@ -280,13 +280,6 @@ impl AppState {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An engine that keeps its data in a directory of its own, and has nobody to tell.
|
|
||||||
#[cfg(test)]
|
|
||||||
pub fn temporary() -> Self {
|
|
||||||
let directory = std::env::temp_dir().join(format!("gpx-studio-{}", uuid::Uuid::new_v4()));
|
|
||||||
Self::open(directory, Arc::new(|_, _| {})).expect("the storage can be opened")
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Opens files that the system gave to the app, see `Core::open_external`.
|
/// Opens files that the system gave to the app, see `Core::open_external`.
|
||||||
pub fn open_external(&self, paths: Vec<PathBuf>) {
|
pub fn open_external(&self, paths: Vec<PathBuf>) {
|
||||||
self.core(move |core| core.open_external(&paths));
|
self.core(move |core| core.open_external(&paths));
|
||||||
|
|||||||
@@ -217,69 +217,3 @@ impl Storage for FileStorage {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use crate::Engine;
|
|
||||||
use gpx_engine::{Action, Command, Load, LoadFiles, Persister};
|
|
||||||
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
fn directory() -> PathBuf {
|
|
||||||
std::env::temp_dir().join(format!("gpx-studio-store-{}", Uuid::new_v4()))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn engine_with_a_file() -> Engine {
|
|
||||||
let mut engine = Engine::default();
|
|
||||||
let data = std::fs::read("../gpx-rs/data/simple.gpx").unwrap();
|
|
||||||
engine
|
|
||||||
.execute(Action::Edit(Command::LoadFiles(LoadFiles {
|
|
||||||
files: vec![Load {
|
|
||||||
data: &data,
|
|
||||||
name: "simple",
|
|
||||||
}],
|
|
||||||
})))
|
|
||||||
.unwrap();
|
|
||||||
engine
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn keeps_the_files_and_the_settings_between_sessions() {
|
|
||||||
let root = directory();
|
|
||||||
let engine = engine_with_a_file();
|
|
||||||
let order = engine.order().to_vec();
|
|
||||||
|
|
||||||
let storage = FileStorage::open(&root).unwrap();
|
|
||||||
pollster::block_on(Persister::default().save(&storage, engine.snapshot())).unwrap();
|
|
||||||
pollster::block_on(storage.put_setting("units", "\"metric\"")).unwrap();
|
|
||||||
|
|
||||||
// another session
|
|
||||||
let storage = FileStorage::open(&root).unwrap();
|
|
||||||
let restored = pollster::block_on(Persister::default().restore(&storage)).unwrap();
|
|
||||||
let mut other = Engine::default();
|
|
||||||
other.restore(restored);
|
|
||||||
assert_eq!(other.order(), order);
|
|
||||||
assert_eq!(
|
|
||||||
other.file_statistics(&order[0]).unwrap().total_distance,
|
|
||||||
engine.file_statistics(&order[0]).unwrap().total_distance
|
|
||||||
);
|
|
||||||
assert_eq!(storage.settings()["units"], "\"metric\"");
|
|
||||||
fs::remove_dir_all(root).unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn refuses_a_commit_that_is_not_based_on_the_head() {
|
|
||||||
let root = directory();
|
|
||||||
let storage = FileStorage::open(&root).unwrap();
|
|
||||||
let batch = Batch {
|
|
||||||
order: Some(vec![]),
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
assert_eq!(pollster::block_on(storage.commit(&batch)), Ok(Revision(1)));
|
|
||||||
assert_eq!(
|
|
||||||
pollster::block_on(storage.commit(&batch)),
|
|
||||||
Err(CommitError::Stale { head: Revision(1) })
|
|
||||||
);
|
|
||||||
fs::remove_dir_all(root).unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+2
-812
@@ -148,7 +148,7 @@ pub struct Entry {
|
|||||||
pub is_dir: bool,
|
pub is_dir: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_gpx(path: &Path) -> bool {
|
pub fn is_gpx(path: &Path) -> bool {
|
||||||
path.extension()
|
path.extension()
|
||||||
.and_then(|extension| extension.to_str())
|
.and_then(|extension| extension.to_str())
|
||||||
.is_some_and(|extension| extension.eq_ignore_ascii_case("gpx"))
|
.is_some_and(|extension| extension.eq_ignore_ascii_case("gpx"))
|
||||||
@@ -156,7 +156,7 @@ fn is_gpx(path: &Path) -> bool {
|
|||||||
|
|
||||||
/// Compares names the way people read them: the numbers in them by their value ("track 2" before
|
/// Compares names the way people read them: the numbers in them by their value ("track 2" before
|
||||||
/// "track 10"), the rest regardless of case.
|
/// "track 10"), the rest regardless of case.
|
||||||
fn natural_cmp(a: &str, b: &str) -> Ordering {
|
pub fn natural_cmp(a: &str, b: &str) -> Ordering {
|
||||||
let (mut a, mut b) = (a.chars().peekable(), b.chars().peekable());
|
let (mut a, mut b) = (a.chars().peekable(), b.chars().peekable());
|
||||||
loop {
|
loop {
|
||||||
let order = match (a.peek().copied(), b.peek().copied()) {
|
let order = match (a.peek().copied(), b.peek().copied()) {
|
||||||
@@ -1040,813 +1040,3 @@ impl Workspace {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use gpx_engine::SelectMode;
|
|
||||||
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
fn gpx(name: &str) -> String {
|
|
||||||
format!(
|
|
||||||
r#"<?xml version="1.0"?><gpx version="1.1" creator="test" xmlns="http://www.topografix.com/GPX/1/1"><metadata><name>{name}</name></metadata><trk><name>{name}</name><trkseg><trkpt lat="50.0" lon="4.0"><ele>10</ele></trkpt><trkpt lat="50.1" lon="4.1"><ele>20</ele></trkpt></trkseg></trk></gpx>"#
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The GPX files of a folder and of the folders in it.
|
|
||||||
pub(super) fn gpx_files(folder: &Path) -> Vec<PathBuf> {
|
|
||||||
let mut found = vec![];
|
|
||||||
for entry in fs::read_dir(folder).unwrap().flatten() {
|
|
||||||
let path = entry.path();
|
|
||||||
if path.is_dir() {
|
|
||||||
found.extend(gpx_files(&path));
|
|
||||||
} else if is_gpx(&path) {
|
|
||||||
found.push(path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
found.sort();
|
|
||||||
found
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Fixture {
|
|
||||||
folder: PathBuf,
|
|
||||||
engine: Engine,
|
|
||||||
workspace: Workspace,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Fixture {
|
|
||||||
fn new() -> Self {
|
|
||||||
let folder =
|
|
||||||
canonical(&std::env::temp_dir()).join(format!("gpx-ws-{}", Uuid::new_v4()));
|
|
||||||
fs::create_dir_all(&folder).unwrap();
|
|
||||||
Self {
|
|
||||||
folder,
|
|
||||||
engine: Engine::default(),
|
|
||||||
workspace: Workspace::default(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn write(&self, name: &str, title: &str) -> PathBuf {
|
|
||||||
let path = self.folder.join(name);
|
|
||||||
fs::write(&path, gpx(title)).unwrap();
|
|
||||||
path
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Opens the folder, and all the files that are in it.
|
|
||||||
fn open_folder(&mut self) {
|
|
||||||
let folder = self.folder.clone();
|
|
||||||
self.workspace.open_folder(&mut self.engine, &folder, false);
|
|
||||||
let files = gpx_files(&folder);
|
|
||||||
self.workspace.open_files(&mut self.engine, &files, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn reconcile(&mut self, changed: Option<&[PathBuf]>) -> Option<api::Outcome> {
|
|
||||||
self.workspace.reconcile(&mut self.engine, changed)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn save(&mut self, ids: &[Uuid]) {
|
|
||||||
self.workspace
|
|
||||||
.save(&mut self.engine, ids, &BTreeMap::new(), None)
|
|
||||||
.unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn ids(&self) -> Vec<Uuid> {
|
|
||||||
self.engine.order().iter().map(|id| id.0).collect()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn id_named(&self, name: &str) -> Uuid {
|
|
||||||
self.ids()
|
|
||||||
.into_iter()
|
|
||||||
.find(|id| self.name(*id) == name)
|
|
||||||
.unwrap()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn name(&self, id: Uuid) -> String {
|
|
||||||
self.engine
|
|
||||||
.file_structure(&FileId(id))
|
|
||||||
.unwrap()
|
|
||||||
.name
|
|
||||||
.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// What the file holds: the name of its track (its own name is the one of the file).
|
|
||||||
fn content(&self, id: Uuid) -> String {
|
|
||||||
self.engine.file_structure(&FileId(id)).unwrap().tracks[0]
|
|
||||||
.info
|
|
||||||
.name
|
|
||||||
.clone()
|
|
||||||
.unwrap_or_default()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn rename(&mut self, id: Uuid, name: &str) {
|
|
||||||
api::select(&mut self.engine, &[id], SelectMode::Replace);
|
|
||||||
assert!(!api::metadata(&mut self.engine, name, "").has_error());
|
|
||||||
}
|
|
||||||
|
|
||||||
fn status(&self, id: Uuid) -> FileStatus {
|
|
||||||
self.workspace
|
|
||||||
.state(&self.engine)
|
|
||||||
.files
|
|
||||||
.remove(&id.to_string())
|
|
||||||
.unwrap()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Drop for Fixture {
|
|
||||||
fn drop(&mut self) {
|
|
||||||
let _ = fs::remove_dir_all(&self.folder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn an_opened_file_is_clean_until_it_is_edited_and_clean_again_once_saved() {
|
|
||||||
let mut fx = Fixture::new();
|
|
||||||
let path = fx.write("a.gpx", "a");
|
|
||||||
fx.workspace
|
|
||||||
.open_files(&mut fx.engine, std::slice::from_ref(&path), true);
|
|
||||||
let id = fx.ids()[0];
|
|
||||||
assert!(!fx.workspace.is_dirty(&fx.engine, id));
|
|
||||||
assert_eq!(fx.status(id).path.as_deref(), path.to_str());
|
|
||||||
|
|
||||||
fx.rename(id, "renamed");
|
|
||||||
assert!(fx.workspace.is_dirty(&fx.engine, id));
|
|
||||||
// nothing is written before it is saved
|
|
||||||
assert!(fs::read_to_string(&path).unwrap().contains(">a<"));
|
|
||||||
|
|
||||||
fx.save(&[id]);
|
|
||||||
assert!(!fx.workspace.is_dirty(&fx.engine, id));
|
|
||||||
assert!(fs::read_to_string(&path).unwrap().contains(">renamed<"));
|
|
||||||
|
|
||||||
// going back before the save is an edit again
|
|
||||||
api::select(&mut fx.engine, &[id], SelectMode::Replace);
|
|
||||||
api::undo(&mut fx.engine);
|
|
||||||
assert!(fx.workspace.is_dirty(&fx.engine, id));
|
|
||||||
api::redo(&mut fx.engine);
|
|
||||||
assert!(!fx.workspace.is_dirty(&fx.engine, id));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn a_file_that_is_not_on_the_disk_is_unsaved_until_it_is_given_a_place() {
|
|
||||||
let mut fx = Fixture::new();
|
|
||||||
api::new_file(&mut fx.engine, "fresh", None, None, None, false);
|
|
||||||
let id = fx.ids()[0];
|
|
||||||
assert!(fx.workspace.is_dirty(&fx.engine, id));
|
|
||||||
assert_eq!(
|
|
||||||
fx.workspace.unlinked(&fx.engine, &[id]),
|
|
||||||
[(id, "fresh".to_string())]
|
|
||||||
);
|
|
||||||
// nowhere to put it without being told
|
|
||||||
fx.save(&[id]);
|
|
||||||
assert!(fx.workspace.is_dirty(&fx.engine, id));
|
|
||||||
|
|
||||||
let path = fx.folder.join("fresh.gpx");
|
|
||||||
let paths = BTreeMap::from([(id, path.clone())]);
|
|
||||||
fx.workspace
|
|
||||||
.save(&mut fx.engine, &[id], &paths, None)
|
|
||||||
.unwrap();
|
|
||||||
assert!(path.exists());
|
|
||||||
assert!(!fx.workspace.is_dirty(&fx.engine, id));
|
|
||||||
assert!(fx.workspace.unlinked(&fx.engine, &[id]).is_empty());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn several_files_without_a_place_go_in_a_folder_with_names_that_are_free() {
|
|
||||||
let mut fx = Fixture::new();
|
|
||||||
fx.write("fresh.gpx", "already there");
|
|
||||||
api::new_file(&mut fx.engine, "fresh", None, None, None, false);
|
|
||||||
api::new_file(&mut fx.engine, "a/b: c", None, None, None, false);
|
|
||||||
api::new_file(&mut fx.engine, "fresh", None, None, None, false);
|
|
||||||
let ids = fx.ids();
|
|
||||||
let folder = fx.folder.clone();
|
|
||||||
fx.workspace
|
|
||||||
.save(&mut fx.engine, &ids, &BTreeMap::new(), Some(&folder))
|
|
||||||
.unwrap();
|
|
||||||
for name in ["fresh (2).gpx", "fresh (3).gpx", "a_b_ c.gpx"] {
|
|
||||||
assert!(fx.folder.join(name).exists(), "{name}");
|
|
||||||
}
|
|
||||||
assert!(ids.iter().all(|id| !fx.workspace.is_dirty(&fx.engine, *id)));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn what_this_app_writes_is_not_a_change_of_the_disk() {
|
|
||||||
let mut fx = Fixture::new();
|
|
||||||
let path = fx.write("a.gpx", "a");
|
|
||||||
fx.open_folder();
|
|
||||||
let id = fx.ids()[0];
|
|
||||||
api::select(&mut fx.engine, &[id], SelectMode::Replace);
|
|
||||||
assert!(!api::style(&mut fx.engine, Some("#ff0000"), None, None).has_error());
|
|
||||||
fx.save(&[id]);
|
|
||||||
assert!(fx.reconcile(Some(&[path])).is_none());
|
|
||||||
assert!(!fx.status(id).replaced && !fx.status(id).dirty);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn the_folders_of_the_files_outside_the_open_folder_are_watched_too() {
|
|
||||||
let mut fx = Fixture::new();
|
|
||||||
let inside = fx.write("in.gpx", "in");
|
|
||||||
let elsewhere = canonical(&std::env::temp_dir()).join(format!("gpx-ws-{}", Uuid::new_v4()));
|
|
||||||
fs::create_dir_all(&elsewhere).unwrap();
|
|
||||||
let (one, two) = (elsewhere.join("one.gpx"), elsewhere.join("two.gpx"));
|
|
||||||
fs::write(&one, gpx("one")).unwrap();
|
|
||||||
fs::write(&two, gpx("two")).unwrap();
|
|
||||||
let folder = fx.folder.clone();
|
|
||||||
|
|
||||||
// no folder: only the folder of the files
|
|
||||||
fx.workspace.open_files(&mut fx.engine, &[one, two], false);
|
|
||||||
assert_eq!(fx.workspace.watched(), [(elsewhere.clone(), false)]);
|
|
||||||
|
|
||||||
// the open folder as a whole, and the file in it needs nothing more
|
|
||||||
fx.workspace.open_folder(&mut fx.engine, &folder, false);
|
|
||||||
fx.workspace.open_files(&mut fx.engine, &[inside], false);
|
|
||||||
assert_eq!(
|
|
||||||
fx.workspace.watched(),
|
|
||||||
[(folder, true), (elsewhere.clone(), false)]
|
|
||||||
);
|
|
||||||
|
|
||||||
// closing the files stops it
|
|
||||||
let ids = fx.ids();
|
|
||||||
fx.workspace.close_files(&mut fx.engine, &ids, true);
|
|
||||||
assert_eq!(fx.workspace.watched(), [(fx.folder.clone(), true)]);
|
|
||||||
fs::remove_dir_all(elsewhere).unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn opening_a_folder_does_not_open_its_files() {
|
|
||||||
let mut fx = Fixture::new();
|
|
||||||
fx.write("a.gpx", "a");
|
|
||||||
let folder = fx.folder.clone();
|
|
||||||
let outcome = fx.workspace.open_folder(&mut fx.engine, &folder, false);
|
|
||||||
assert!(!outcome.changed);
|
|
||||||
assert!(fx.ids().is_empty());
|
|
||||||
assert_eq!(fx.workspace.folder.as_deref(), Some(folder.as_path()));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn folders_are_made_renamed_and_moved_and_the_open_files_follow() {
|
|
||||||
let mut fx = Fixture::new();
|
|
||||||
let a = fx.write("a.gpx", "a");
|
|
||||||
fx.open_folder();
|
|
||||||
let id = fx.ids()[0];
|
|
||||||
let root = fx.folder.clone();
|
|
||||||
let path_of = |fx: &Fixture| PathBuf::from(fx.status(id).path.unwrap());
|
|
||||||
|
|
||||||
let first = fx.workspace.create_folder(&root, "New folder").unwrap();
|
|
||||||
let second = fx.workspace.create_folder(&root, "New folder").unwrap();
|
|
||||||
assert_eq!(first, root.join("New folder"));
|
|
||||||
assert_eq!(second, root.join("New folder 2"));
|
|
||||||
|
|
||||||
fx.workspace.move_paths(&[a], &first).unwrap();
|
|
||||||
assert_eq!(path_of(&fx), first.join("a.gpx"));
|
|
||||||
assert!(first.join("a.gpx").exists() && !fx.status(id).dirty);
|
|
||||||
|
|
||||||
let trips = fx.workspace.rename_path(&first, "Trips").unwrap();
|
|
||||||
assert_eq!(path_of(&fx), root.join("Trips/a.gpx"));
|
|
||||||
// a folder does not go into itself, nor onto something else
|
|
||||||
assert!(
|
|
||||||
fx.workspace
|
|
||||||
.move_paths(std::slice::from_ref(&trips), &trips)
|
|
||||||
.is_err()
|
|
||||||
);
|
|
||||||
assert_eq!(
|
|
||||||
fx.workspace.rename_path(&trips, "New folder 2"),
|
|
||||||
Err(NAME_TAKEN.to_owned())
|
|
||||||
);
|
|
||||||
fx.workspace.move_paths(&[trips], &second).unwrap();
|
|
||||||
assert_eq!(path_of(&fx), second.join("Trips/a.gpx"));
|
|
||||||
|
|
||||||
// a file keeps its extension
|
|
||||||
let closed = fx.write("c.gpx", "c");
|
|
||||||
assert_eq!(
|
|
||||||
fx.workspace.rename_path(&closed, "d").unwrap(),
|
|
||||||
root.join("d.gpx")
|
|
||||||
);
|
|
||||||
// the open folder and what is not in it are left alone
|
|
||||||
assert!(fx.workspace.rename_path(&root, "x").is_err());
|
|
||||||
let elsewhere = canonical(&std::env::temp_dir());
|
|
||||||
assert!(fx.workspace.rename_path(&elsewhere, "x").is_err());
|
|
||||||
assert!(fx.workspace.create_folder(&elsewhere, "x").is_err());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn deleted_files_are_closed_unless_they_have_edits() {
|
|
||||||
let mut fx = Fixture::new();
|
|
||||||
let a = fx.write("a.gpx", "a");
|
|
||||||
let b = fx.write("b.gpx", "b");
|
|
||||||
fx.open_folder();
|
|
||||||
let (id_a, id_b) = (fx.id_named("a"), fx.id_named("b"));
|
|
||||||
api::select(&mut fx.engine, &[id_b], SelectMode::Replace);
|
|
||||||
assert!(!api::style(&mut fx.engine, Some("#ff0000"), None, None).has_error());
|
|
||||||
|
|
||||||
let outcome = fx
|
|
||||||
.workspace
|
|
||||||
.delete_paths(&mut fx.engine, &[a.clone(), b.clone()], |paths| {
|
|
||||||
paths.iter().for_each(|path| fs::remove_file(path).unwrap());
|
|
||||||
Ok(())
|
|
||||||
})
|
|
||||||
.unwrap();
|
|
||||||
assert!(outcome.changed);
|
|
||||||
assert_eq!(fx.ids(), [id_b]);
|
|
||||||
assert!(!fx.ids().contains(&id_a));
|
|
||||||
let status = fx.status(id_b);
|
|
||||||
assert!(status.dirty && status.missing);
|
|
||||||
assert!(!a.exists() && !b.exists());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn the_tree_of_the_folder_shows_folders_first_and_only_gpx_files() {
|
|
||||||
let mut fx = Fixture::new();
|
|
||||||
fx.write("b.gpx", "b");
|
|
||||||
fx.write("A.GPX", "a");
|
|
||||||
fx.write("b 10.gpx", "b 10");
|
|
||||||
fx.write("b 2.gpx", "b 2");
|
|
||||||
fx.write("notes.txt", "not a track");
|
|
||||||
fx.write(".hidden.gpx", "hidden");
|
|
||||||
fs::create_dir(fx.folder.join("zoo")).unwrap();
|
|
||||||
fs::create_dir(fx.folder.join("Alps")).unwrap();
|
|
||||||
fs::create_dir(fx.folder.join(".git")).unwrap();
|
|
||||||
fx.write("zoo/c.gpx", "c");
|
|
||||||
let folder = fx.folder.clone();
|
|
||||||
fx.workspace.open_folder(&mut fx.engine, &folder, false);
|
|
||||||
|
|
||||||
let names = |entries: Vec<Entry>| -> Vec<(String, bool)> {
|
|
||||||
entries.into_iter().map(|e| (e.name, e.is_dir)).collect()
|
|
||||||
};
|
|
||||||
assert_eq!(
|
|
||||||
names(fx.workspace.list_folder(&folder).unwrap()),
|
|
||||||
[
|
|
||||||
("Alps".to_string(), true),
|
|
||||||
("zoo".to_string(), true),
|
|
||||||
("A.GPX".to_string(), false),
|
|
||||||
("b.gpx".to_string(), false),
|
|
||||||
("b 2.gpx".to_string(), false),
|
|
||||||
("b 10.gpx".to_string(), false),
|
|
||||||
]
|
|
||||||
);
|
|
||||||
assert_eq!(
|
|
||||||
names(fx.workspace.list_folder(&folder.join("zoo")).unwrap()),
|
|
||||||
[("c.gpx".to_string(), false)]
|
|
||||||
);
|
|
||||||
// only what is in the open folder can be listed
|
|
||||||
let elsewhere = canonical(&std::env::temp_dir());
|
|
||||||
assert!(fx.workspace.list_folder(&elsewhere).is_err());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn names_are_sorted_by_the_numbers_they_hold() {
|
|
||||||
let mut names = vec![
|
|
||||||
"track 10",
|
|
||||||
"track 2",
|
|
||||||
"Track 1",
|
|
||||||
"track",
|
|
||||||
"track 02b",
|
|
||||||
"track 2a",
|
|
||||||
"b",
|
|
||||||
"A",
|
|
||||||
];
|
|
||||||
names.sort_by(|a, b| natural_cmp(a, b).then_with(|| a.cmp(b)));
|
|
||||||
assert_eq!(
|
|
||||||
names,
|
|
||||||
[
|
|
||||||
"A",
|
|
||||||
"b",
|
|
||||||
"track",
|
|
||||||
"Track 1",
|
|
||||||
"track 2",
|
|
||||||
"track 2a",
|
|
||||||
"track 02b",
|
|
||||||
"track 10",
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn a_file_without_edits_is_read_again_when_the_disk_changes() {
|
|
||||||
let mut fx = Fixture::new();
|
|
||||||
let a = fx.write("a.gpx", "a");
|
|
||||||
fx.open_folder();
|
|
||||||
let id = fx.ids()[0];
|
|
||||||
|
|
||||||
fx.write("a.gpx", "theirs");
|
|
||||||
let outcome = fx.reconcile(Some(std::slice::from_ref(&a))).unwrap();
|
|
||||||
assert!(outcome.changed);
|
|
||||||
// the same file, now the one on the disk
|
|
||||||
assert_eq!(fx.ids(), [id]);
|
|
||||||
assert_eq!(fx.content(id), "theirs");
|
|
||||||
let status = fx.status(id);
|
|
||||||
assert!(!status.dirty && !status.replaced);
|
|
||||||
// looking again changes nothing
|
|
||||||
assert!(fx.reconcile(Some(std::slice::from_ref(&a))).is_none());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn a_file_with_edits_is_flagged_when_the_disk_changes_and_not_read_again() {
|
|
||||||
let mut fx = Fixture::new();
|
|
||||||
let a = fx.write("a.gpx", "a");
|
|
||||||
fx.open_folder();
|
|
||||||
let id = fx.ids()[0];
|
|
||||||
fx.rename(id, "mine");
|
|
||||||
|
|
||||||
fx.write("a.gpx", "theirs");
|
|
||||||
let outcome = fx.reconcile(Some(std::slice::from_ref(&a))).unwrap();
|
|
||||||
assert!(!outcome.changed);
|
|
||||||
assert_eq!(fx.name(id), "mine");
|
|
||||||
let status = fx.status(id);
|
|
||||||
assert!(status.dirty && status.replaced && !status.missing);
|
|
||||||
// looking again changes nothing
|
|
||||||
assert!(fx.reconcile(Some(std::slice::from_ref(&a))).is_none());
|
|
||||||
|
|
||||||
// the disk goes back to what was read: only the edits are left
|
|
||||||
fx.write("a.gpx", "a");
|
|
||||||
assert!(fx.reconcile(Some(std::slice::from_ref(&a))).is_some());
|
|
||||||
let status = fx.status(id);
|
|
||||||
assert!(status.dirty && !status.replaced);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn the_user_can_take_the_disk_instead_of_the_edits() {
|
|
||||||
let mut fx = Fixture::new();
|
|
||||||
fx.write("a.gpx", "a");
|
|
||||||
fx.open_folder();
|
|
||||||
let id = fx.ids()[0];
|
|
||||||
fx.rename(id, "mine");
|
|
||||||
fx.write("a.gpx", "theirs");
|
|
||||||
fx.reconcile(None);
|
|
||||||
assert!(fx.status(id).replaced);
|
|
||||||
|
|
||||||
fx.workspace.reload(&mut fx.engine, &[id]).unwrap();
|
|
||||||
assert_eq!(fx.content(id), "theirs");
|
|
||||||
let status = fx.status(id);
|
|
||||||
assert!(!status.dirty && !status.replaced);
|
|
||||||
// and it is one undo step
|
|
||||||
api::select(&mut fx.engine, &[id], SelectMode::Replace);
|
|
||||||
api::undo(&mut fx.engine);
|
|
||||||
assert_eq!(fx.content(id), "mine");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn saving_overwrites_what_replaced_the_file() {
|
|
||||||
let mut fx = Fixture::new();
|
|
||||||
let a = fx.write("a.gpx", "a");
|
|
||||||
fx.open_folder();
|
|
||||||
let id = fx.ids()[0];
|
|
||||||
fx.rename(id, "mine");
|
|
||||||
fx.write("a.gpx", "theirs");
|
|
||||||
fx.reconcile(None);
|
|
||||||
assert!(fx.status(id).replaced);
|
|
||||||
|
|
||||||
fx.save(&[id]);
|
|
||||||
assert!(fs::read_to_string(a).unwrap().contains(">mine<"));
|
|
||||||
assert!(!fx.status(id).replaced && !fx.status(id).dirty);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn a_file_that_is_gone_from_the_disk_stays_open_and_dirty_until_it_is_saved_again() {
|
|
||||||
let mut fx = Fixture::new();
|
|
||||||
let a = fx.write("a.gpx", "a");
|
|
||||||
fx.open_folder();
|
|
||||||
let id = fx.ids()[0];
|
|
||||||
|
|
||||||
fs::remove_file(&a).unwrap();
|
|
||||||
assert!(fx.reconcile(Some(std::slice::from_ref(&a))).is_some());
|
|
||||||
assert_eq!(fx.ids(), [id]);
|
|
||||||
let status = fx.status(id);
|
|
||||||
assert!(status.dirty && status.missing && status.path.is_some());
|
|
||||||
|
|
||||||
// saving puts it back
|
|
||||||
fx.save(&[id]);
|
|
||||||
assert!(a.exists());
|
|
||||||
let status = fx.status(id);
|
|
||||||
assert!(!status.dirty && !status.missing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn a_file_that_comes_back_different_is_read_again() {
|
|
||||||
let mut fx = Fixture::new();
|
|
||||||
let a = fx.write("a.gpx", "a");
|
|
||||||
fx.open_folder();
|
|
||||||
let id = fx.ids()[0];
|
|
||||||
fs::remove_file(&a).unwrap();
|
|
||||||
fx.reconcile(None);
|
|
||||||
assert!(fx.status(id).missing);
|
|
||||||
|
|
||||||
fx.write("a.gpx", "back");
|
|
||||||
fx.reconcile(None);
|
|
||||||
assert_eq!(fx.content(id), "back");
|
|
||||||
let status = fx.status(id);
|
|
||||||
assert!(!status.dirty && !status.missing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn what_changed_while_the_app_was_closed_is_found_when_it_starts() {
|
|
||||||
let mut fx = Fixture::new();
|
|
||||||
let a = fx.write("a.gpx", "a");
|
|
||||||
fx.open_folder();
|
|
||||||
let id = fx.ids()[0];
|
|
||||||
fx.write("a.gpx", "changed");
|
|
||||||
assert!(fx.reconcile(None).is_some());
|
|
||||||
assert_eq!(fx.content(id), "changed");
|
|
||||||
fs::remove_file(a).unwrap();
|
|
||||||
assert!(fx.reconcile(None).is_some());
|
|
||||||
assert!(fx.status(id).missing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn new_files_made_from_a_file_of_the_folder_are_saved_next_to_it() {
|
|
||||||
let mut fx = Fixture::new();
|
|
||||||
fs::create_dir(fx.folder.join("sub")).unwrap();
|
|
||||||
fx.write("sub/b.gpx", "b");
|
|
||||||
fx.write("a.gpx", "a");
|
|
||||||
fx.open_folder();
|
|
||||||
let b = fx.id_named("b");
|
|
||||||
let sub = fx.folder.join("sub");
|
|
||||||
assert_eq!(fx.workspace.source_dir(&[b]), Some(canonical(&sub)));
|
|
||||||
|
|
||||||
let before = fx.ids();
|
|
||||||
api::select(&mut fx.engine, &[b], SelectMode::Replace);
|
|
||||||
let outcome = api::duplicate(&mut fx.engine);
|
|
||||||
let copy = fx
|
|
||||||
.ids()
|
|
||||||
.into_iter()
|
|
||||||
.find(|id| !before.contains(id))
|
|
||||||
.unwrap();
|
|
||||||
fx.workspace.inherit(outcome.added(), &canonical(&sub));
|
|
||||||
assert_eq!(fx.status(copy).folder.as_deref(), canonical(&sub).to_str());
|
|
||||||
assert!(fx.status(copy).path.is_none() && fx.status(copy).dirty);
|
|
||||||
// nobody needs to be asked where it goes
|
|
||||||
assert!(fx.workspace.unlinked(&fx.engine, &[copy]).is_empty());
|
|
||||||
|
|
||||||
fx.save(&[copy]);
|
|
||||||
assert!(sub.join("b (2).gpx").exists());
|
|
||||||
let status = fx.status(copy);
|
|
||||||
assert!(!status.dirty && status.folder.is_none());
|
|
||||||
assert_eq!(
|
|
||||||
status.path.as_deref(),
|
|
||||||
canonical(&sub.join("b (2).gpx")).to_str()
|
|
||||||
);
|
|
||||||
// the copy of the copy is next to it as well
|
|
||||||
assert_eq!(fx.workspace.source_dir(&[copy]), Some(canonical(&sub)));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn a_file_outside_the_open_folder_hands_nothing_down() {
|
|
||||||
let mut fx = Fixture::new();
|
|
||||||
let elsewhere = canonical(&std::env::temp_dir()).join(format!("gpx-ws-{}", Uuid::new_v4()));
|
|
||||||
fs::create_dir_all(&elsewhere).unwrap();
|
|
||||||
let outside = elsewhere.join("o.gpx");
|
|
||||||
fs::write(&outside, gpx("o")).unwrap();
|
|
||||||
let folder = fx.folder.clone();
|
|
||||||
fx.workspace.open_folder(&mut fx.engine, &folder, false);
|
|
||||||
fx.workspace
|
|
||||||
.open_files(&mut fx.engine, std::slice::from_ref(&outside), true);
|
|
||||||
let id = fx.ids()[0];
|
|
||||||
assert_eq!(fx.workspace.source_dir(&[id]), None);
|
|
||||||
// a new file with no source is not linked to a folder by `source_dir`: the caller falls back
|
|
||||||
fs::remove_dir_all(elsewhere).unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn closing_files_asks_what_to_do_with_the_unsaved_ones() {
|
|
||||||
let mut fx = Fixture::new();
|
|
||||||
fx.write("a.gpx", "a");
|
|
||||||
fx.write("b.gpx", "b");
|
|
||||||
fx.open_folder();
|
|
||||||
let (a, b) = (fx.id_named("a"), fx.id_named("b"));
|
|
||||||
fx.rename(a, "edited");
|
|
||||||
assert_eq!(fx.workspace.unsaved(&fx.engine, &[a, b]), [a]);
|
|
||||||
|
|
||||||
// without a choice what has edits stays
|
|
||||||
let outcome = fx.workspace.close_files(&mut fx.engine, &[a, b], false);
|
|
||||||
assert!(outcome.changed);
|
|
||||||
assert_eq!(fx.ids(), [a]);
|
|
||||||
|
|
||||||
// saved first
|
|
||||||
fx.save(&[a]);
|
|
||||||
fx.workspace.close_files(&mut fx.engine, &[a], false);
|
|
||||||
assert!(fx.ids().is_empty());
|
|
||||||
assert!(
|
|
||||||
fs::read_to_string(fx.folder.join("a.gpx"))
|
|
||||||
.unwrap()
|
|
||||||
.contains("edited")
|
|
||||||
);
|
|
||||||
assert!(fx.workspace.links.is_empty());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn closing_files_can_discard_their_edits() {
|
|
||||||
let mut fx = Fixture::new();
|
|
||||||
fx.write("a.gpx", "a");
|
|
||||||
fx.open_folder();
|
|
||||||
let a = fx.ids()[0];
|
|
||||||
fx.rename(a, "edited");
|
|
||||||
api::new_file(&mut fx.engine, "fresh", None, None, None, false);
|
|
||||||
let fresh = fx.id_named("fresh");
|
|
||||||
fx.workspace.close_files(&mut fx.engine, &[a, fresh], true);
|
|
||||||
assert!(fx.ids().is_empty());
|
|
||||||
assert!(
|
|
||||||
fs::read_to_string(fx.folder.join("a.gpx"))
|
|
||||||
.unwrap()
|
|
||||||
.contains(">a<")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn closing_the_folder_closes_every_file() {
|
|
||||||
let mut fx = Fixture::new();
|
|
||||||
fx.write("a.gpx", "a");
|
|
||||||
fx.open_folder();
|
|
||||||
api::new_file(&mut fx.engine, "fresh", None, None, None, false);
|
|
||||||
assert_eq!(fx.ids().len(), 2);
|
|
||||||
|
|
||||||
// the new file has nowhere to go: it has to be discarded
|
|
||||||
let outcome = fx.workspace.close_folder(&mut fx.engine, false);
|
|
||||||
assert!(outcome.changed);
|
|
||||||
assert_eq!(fx.ids().len(), 1);
|
|
||||||
assert!(fx.workspace.folder.is_none());
|
|
||||||
|
|
||||||
let outcome = fx.workspace.close_folder(&mut fx.engine, true);
|
|
||||||
assert!(outcome.changed);
|
|
||||||
assert!(fx.ids().is_empty());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn opening_another_folder_closes_the_first_with_all_its_files() {
|
|
||||||
let mut fx = Fixture::new();
|
|
||||||
fx.write("a.gpx", "a");
|
|
||||||
fx.open_folder();
|
|
||||||
let a = fx.ids()[0];
|
|
||||||
fx.rename(a, "edited");
|
|
||||||
let other = canonical(&std::env::temp_dir()).join(format!("gpx-ws-{}", Uuid::new_v4()));
|
|
||||||
fs::create_dir_all(&other).unwrap();
|
|
||||||
|
|
||||||
// the edits stay, nothing is lost without a choice
|
|
||||||
fx.workspace.open_folder(&mut fx.engine, &other, false);
|
|
||||||
assert_eq!(fx.ids(), [a]);
|
|
||||||
assert_eq!(fx.workspace.folder.as_deref(), Some(other.as_path()));
|
|
||||||
|
|
||||||
let first = fx.folder.clone();
|
|
||||||
fx.workspace.open_folder(&mut fx.engine, &first, true);
|
|
||||||
assert!(fx.ids().is_empty());
|
|
||||||
assert!(
|
|
||||||
fs::read_to_string(fx.folder.join("a.gpx"))
|
|
||||||
.unwrap()
|
|
||||||
.contains(">a<")
|
|
||||||
);
|
|
||||||
fs::remove_dir_all(other).unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn opening_the_same_folder_again_changes_nothing() {
|
|
||||||
let mut fx = Fixture::new();
|
|
||||||
fx.write("a.gpx", "a");
|
|
||||||
fx.open_folder();
|
|
||||||
let folder = fx.folder.clone();
|
|
||||||
let outcome = fx.workspace.open_folder(&mut fx.engine, &folder, true);
|
|
||||||
assert!(!outcome.changed);
|
|
||||||
assert_eq!(fx.ids().len(), 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn a_failed_save_stops_at_the_file_and_leaves_it_dirty() {
|
|
||||||
let mut fx = Fixture::new();
|
|
||||||
fx.write("a.gpx", "a");
|
|
||||||
fx.open_folder();
|
|
||||||
let id = fx.ids()[0];
|
|
||||||
fx.rename(id, "edited");
|
|
||||||
// the place of the file is taken by a folder
|
|
||||||
fs::remove_file(fx.folder.join("a.gpx")).unwrap();
|
|
||||||
fs::create_dir(fx.folder.join("a.gpx")).unwrap();
|
|
||||||
let result = fx
|
|
||||||
.workspace
|
|
||||||
.save(&mut fx.engine, &[id], &BTreeMap::new(), None);
|
|
||||||
assert!(result.is_err());
|
|
||||||
assert!(fx.workspace.is_dirty(&fx.engine, id));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn saving_as_gives_the_file_another_place() {
|
|
||||||
let mut fx = Fixture::new();
|
|
||||||
let a = fx.write("a.gpx", "a");
|
|
||||||
fx.write("b.gpx", "b");
|
|
||||||
fx.open_folder();
|
|
||||||
let id = fx.id_named("a");
|
|
||||||
let other = fx.id_named("b");
|
|
||||||
fx.rename(id, "edited");
|
|
||||||
|
|
||||||
let target = fx.folder.join("copy.gpx");
|
|
||||||
fx.workspace.save_as(&mut fx.engine, id, &target).unwrap();
|
|
||||||
assert!(fs::read_to_string(&target).unwrap().contains("edited"));
|
|
||||||
assert!(fs::read_to_string(a).unwrap().contains(">a<"));
|
|
||||||
let status = fx.status(id);
|
|
||||||
assert!(!status.dirty);
|
|
||||||
assert_eq!(status.path.as_deref(), canonical(&target).to_str());
|
|
||||||
|
|
||||||
// the place of another open file is not available
|
|
||||||
let taken = fx.folder.join("b.gpx");
|
|
||||||
assert!(fx.workspace.save_as(&mut fx.engine, id, &taken).is_err());
|
|
||||||
assert!(!fx.workspace.is_dirty(&fx.engine, other));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod restart_tests {
|
|
||||||
use gpx_engine::Persister;
|
|
||||||
|
|
||||||
use super::*;
|
|
||||||
use crate::store::FileStorage;
|
|
||||||
|
|
||||||
/// What the app does when it starts again: the engine and the links are read from what was
|
|
||||||
/// kept.
|
|
||||||
fn restart(engine: &Engine, workspace: &Workspace, root: &Path) -> (Engine, Workspace) {
|
|
||||||
let storage = FileStorage::open(root).unwrap();
|
|
||||||
pollster::block_on(Persister::default().save(&storage, engine.snapshot())).unwrap();
|
|
||||||
let mut restarted = Engine::default();
|
|
||||||
let restored = pollster::block_on(Persister::default().restore(&storage)).unwrap();
|
|
||||||
restarted.restore(restored);
|
|
||||||
let links = serde_json::to_string(workspace).unwrap();
|
|
||||||
(restarted, serde_json::from_str(&links).unwrap())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn setup() -> (PathBuf, Engine, Workspace, Vec<Uuid>) {
|
|
||||||
let root = std::env::temp_dir().join(format!("gpx-restart-{}", Uuid::new_v4()));
|
|
||||||
let folder = root.join("tracks");
|
|
||||||
fs::create_dir_all(&folder).unwrap();
|
|
||||||
for name in ["with_tracks", "with_time", "with_waypoint"] {
|
|
||||||
let _ = fs::copy(
|
|
||||||
format!("../gpx-rs/data/{name}.gpx"),
|
|
||||||
folder.join(format!("{name}.gpx")),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
let mut engine = Engine::default();
|
|
||||||
let mut workspace = Workspace::default();
|
|
||||||
workspace.open_folder(&mut engine, &folder, false);
|
|
||||||
workspace.open_files(&mut engine, &tests::gpx_files(&folder), false);
|
|
||||||
let ids = engine.order().iter().map(|id| id.0).collect();
|
|
||||||
(root, engine, workspace, ids)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn files_that_were_not_edited_are_not_unsaved_after_a_restart() {
|
|
||||||
let (root, engine, workspace, ids) = setup();
|
|
||||||
assert!(ids.len() >= 2);
|
|
||||||
let (restarted, mut workspace) = restart(&engine, &workspace, &root.join("store"));
|
|
||||||
// the files are the same, but the engine knows their contents by new identities
|
|
||||||
assert!(ids.iter().any(|id| workspace.is_dirty(&restarted, *id)));
|
|
||||||
workspace.verify(&restarted);
|
|
||||||
assert!(ids.iter().all(|id| !workspace.is_dirty(&restarted, *id)));
|
|
||||||
fs::remove_dir_all(root).unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn files_that_were_edited_are_still_unsaved_after_a_restart() {
|
|
||||||
let (root, mut engine, workspace, ids) = setup();
|
|
||||||
api::select(&mut engine, &[ids[0]], gpx_engine::SelectMode::Replace);
|
|
||||||
api::metadata(&mut engine, "edited", "");
|
|
||||||
assert!(workspace.is_dirty(&engine, ids[0]));
|
|
||||||
let (restarted, mut workspace) = restart(&engine, &workspace, &root.join("store"));
|
|
||||||
workspace.verify(&restarted);
|
|
||||||
assert!(workspace.is_dirty(&restarted, ids[0]));
|
|
||||||
assert!(
|
|
||||||
ids[1..]
|
|
||||||
.iter()
|
|
||||||
.all(|id| !workspace.is_dirty(&restarted, *id))
|
|
||||||
);
|
|
||||||
fs::remove_dir_all(root).unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn links_made_before_the_content_was_kept_are_checked_against_the_disk() {
|
|
||||||
let (root, mut engine, mut workspace, ids) = setup();
|
|
||||||
api::select(&mut engine, &[ids[0]], gpx_engine::SelectMode::Replace);
|
|
||||||
api::metadata(&mut engine, "edited", "");
|
|
||||||
for link in workspace.links.values_mut() {
|
|
||||||
link.export_hash = 0;
|
|
||||||
}
|
|
||||||
let (restarted, mut workspace) = restart(&engine, &workspace, &root.join("store"));
|
|
||||||
workspace.verify(&restarted);
|
|
||||||
assert!(workspace.is_dirty(&restarted, ids[0]));
|
|
||||||
assert!(
|
|
||||||
ids[1..]
|
|
||||||
.iter()
|
|
||||||
.all(|id| !workspace.is_dirty(&restarted, *id))
|
|
||||||
);
|
|
||||||
fs::remove_dir_all(root).unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn the_folders_of_new_files_and_the_old_flag_name_survive_a_restart() {
|
|
||||||
let (root, engine, mut workspace, ids) = setup();
|
|
||||||
let folder = workspace.folder.clone().unwrap();
|
|
||||||
let fresh = Uuid::new_v4();
|
|
||||||
workspace.inherit(&[fresh.to_string()], &folder);
|
|
||||||
workspace.links.get_mut(&ids[0]).unwrap().replaced = true;
|
|
||||||
let json = serde_json::to_string(&workspace).unwrap();
|
|
||||||
// links written by the previous version had `conflict`, which is the same thing
|
|
||||||
let json = json.replace("\"replaced\"", "\"conflict\"");
|
|
||||||
assert!(json.contains("\"conflict\":true"));
|
|
||||||
let read: Workspace = serde_json::from_str(&json).unwrap();
|
|
||||||
assert!(read.links[&ids[0]].replaced);
|
|
||||||
assert_eq!(read.dirs.get(&fresh), Some(&folder));
|
|
||||||
let _ = engine;
|
|
||||||
fs::remove_dir_all(root).unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,12 +6,21 @@ use tauri::test::{INVOKE_KEY, get_ipc_response, mock_builder, mock_context, noop
|
|||||||
use tauri::webview::InvokeRequest;
|
use tauri::webview::InvokeRequest;
|
||||||
use tauri::{WebviewWindow, ipc::CallbackFn, ipc::InvokeBody, ipc::InvokeResponseBody};
|
use tauri::{WebviewWindow, ipc::CallbackFn, ipc::InvokeBody, ipc::InvokeResponseBody};
|
||||||
|
|
||||||
|
/// The origin of the pages of the app, the one Tauri allows the commands from: Windows has no
|
||||||
|
/// custom protocols, the pages come from `http://tauri.localhost` there.
|
||||||
|
const ORIGIN: &str = if cfg!(windows) {
|
||||||
|
"http://tauri.localhost"
|
||||||
|
} else {
|
||||||
|
"tauri://localhost"
|
||||||
|
};
|
||||||
|
|
||||||
struct App(WebviewWindow<tauri::test::MockRuntime>);
|
struct App(WebviewWindow<tauri::test::MockRuntime>);
|
||||||
|
|
||||||
impl App {
|
impl App {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
let app =
|
let app = gpx_studio_desktop_lib::register_commands(
|
||||||
crate::register_commands(mock_builder().manage(crate::state::AppState::temporary()))
|
mock_builder().manage(crate::temporary_state()),
|
||||||
|
)
|
||||||
.build(mock_context(noop_assets()))
|
.build(mock_context(noop_assets()))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let window = tauri::WebviewWindowBuilder::new(&app, "main", Default::default())
|
let window = tauri::WebviewWindowBuilder::new(&app, "main", Default::default())
|
||||||
@@ -34,7 +43,7 @@ impl App {
|
|||||||
cmd: cmd.into(),
|
cmd: cmd.into(),
|
||||||
callback: CallbackFn(0),
|
callback: CallbackFn(0),
|
||||||
error: CallbackFn(1),
|
error: CallbackFn(1),
|
||||||
url: "tauri://localhost".parse().unwrap(),
|
url: ORIGIN.parse().unwrap(),
|
||||||
body,
|
body,
|
||||||
headers,
|
headers,
|
||||||
invoke_key: INVOKE_KEY.to_string(),
|
invoke_key: INVOKE_KEY.to_string(),
|
||||||
@@ -56,7 +65,7 @@ impl App {
|
|||||||
cmd: cmd.into(),
|
cmd: cmd.into(),
|
||||||
callback: CallbackFn(0),
|
callback: CallbackFn(0),
|
||||||
error: CallbackFn(1),
|
error: CallbackFn(1),
|
||||||
url: "tauri://localhost".parse().unwrap(),
|
url: ORIGIN.parse().unwrap(),
|
||||||
body: InvokeBody::Json(args),
|
body: InvokeBody::Json(args),
|
||||||
headers: Default::default(),
|
headers: Default::default(),
|
||||||
invoke_key: INVOKE_KEY.to_string(),
|
invoke_key: INVOKE_KEY.to_string(),
|
||||||
@@ -311,8 +320,8 @@ fn keeps_settings_for_the_session() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn the_files_are_still_there_in_the_next_session() {
|
fn the_files_are_still_there_in_the_next_session() {
|
||||||
use crate::state::AppState;
|
|
||||||
use gpx_engine::api;
|
use gpx_engine::api;
|
||||||
|
use gpx_studio_desktop_lib::state::AppState;
|
||||||
|
|
||||||
let directory =
|
let directory =
|
||||||
std::env::temp_dir().join(format!("gpx-studio-session-{}", uuid::Uuid::new_v4()));
|
std::env::temp_dir().join(format!("gpx-studio-session-{}", uuid::Uuid::new_v4()));
|
||||||
@@ -347,14 +356,14 @@ fn only_gpx_files_that_exist_are_taken_from_what_the_system_gives() {
|
|||||||
text.to_string_lossy().into_owned(),
|
text.to_string_lossy().into_owned(),
|
||||||
directory.join("missing.gpx").to_string_lossy().into_owned(),
|
directory.join("missing.gpx").to_string_lossy().into_owned(),
|
||||||
];
|
];
|
||||||
assert_eq!(crate::gpx_paths(arguments), [track]);
|
assert_eq!(gpx_studio_desktop_lib::gpx_paths(arguments), [track]);
|
||||||
std::fs::remove_dir_all(directory).unwrap();
|
std::fs::remove_dir_all(directory).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn a_file_opened_with_the_app_is_opened_selected_and_announced() {
|
fn a_file_opened_with_the_app_is_opened_selected_and_announced() {
|
||||||
use crate::state::AppState;
|
|
||||||
use gpx_engine::api;
|
use gpx_engine::api;
|
||||||
|
use gpx_studio_desktop_lib::state::AppState;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
let directory = std::env::temp_dir().join(format!("gpx-studio-open-{}", uuid::Uuid::new_v4()));
|
let directory = std::env::temp_dir().join(format!("gpx-studio-open-{}", uuid::Uuid::new_v4()));
|
||||||
@@ -441,7 +450,7 @@ fn a_file_outside_the_open_folder_is_read_again_when_the_disk_changes() {
|
|||||||
|
|
||||||
let (events, received) = mpsc::channel();
|
let (events, received) = mpsc::channel();
|
||||||
let directory = std::env::temp_dir().join(format!("gpx-store-{}", uuid::Uuid::new_v4()));
|
let directory = std::env::temp_dir().join(format!("gpx-store-{}", uuid::Uuid::new_v4()));
|
||||||
let state = crate::state::AppState::open(
|
let state = gpx_studio_desktop_lib::state::AppState::open(
|
||||||
directory.clone(),
|
directory.clone(),
|
||||||
std::sync::Arc::new(move |name, _| {
|
std::sync::Arc::new(move |name, _| {
|
||||||
let _ = events.send(name.to_string());
|
let _ = events.send(name.to_string());
|
||||||
@@ -461,8 +470,8 @@ fn a_file_outside_the_open_folder_is_read_again_when_the_disk_changes() {
|
|||||||
});
|
});
|
||||||
let id = uuid::Uuid::parse_str(&id).unwrap();
|
let id = uuid::Uuid::parse_str(&id).unwrap();
|
||||||
// the name comes from the path, which does not change: the content does
|
// the name comes from the path, which does not change: the content does
|
||||||
let signature = |state: &crate::state::AppState| {
|
let signature = |state: &gpx_studio_desktop_lib::state::AppState| {
|
||||||
state.core(move |core| crate::workspace::signature(&core.engine, id))
|
state.core(move |core| gpx_studio_desktop_lib::workspace::signature(&core.engine, id))
|
||||||
};
|
};
|
||||||
let before = signature(&state);
|
let before = signature(&state);
|
||||||
|
|
||||||
@@ -483,7 +492,7 @@ fn a_file_outside_the_open_folder_is_read_again_when_the_disk_changes() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn files_made_from_a_file_of_the_open_folder_are_written_next_to_it_at_once() {
|
fn files_made_from_a_file_of_the_open_folder_are_written_next_to_it_at_once() {
|
||||||
let state = crate::state::AppState::temporary();
|
let state = crate::temporary_state();
|
||||||
let folder = std::env::temp_dir().join(format!("gpx-tests-{}", uuid::Uuid::new_v4()));
|
let folder = std::env::temp_dir().join(format!("gpx-tests-{}", uuid::Uuid::new_v4()));
|
||||||
std::fs::create_dir_all(folder.join("sub")).unwrap();
|
std::fs::create_dir_all(folder.join("sub")).unwrap();
|
||||||
std::fs::copy("../gpx-rs/data/simple.gpx", folder.join("sub/track.gpx")).unwrap();
|
std::fs::copy("../gpx-rs/data/simple.gpx", folder.join("sub/track.gpx")).unwrap();
|
||||||
@@ -516,19 +525,23 @@ fn files_made_from_a_file_of_the_open_folder_are_written_next_to_it_at_once() {
|
|||||||
.collect();
|
.collect();
|
||||||
// the copy is in the subfolder, named after its name (the one in the file, not of the file)
|
// the copy is in the subfolder, named after its name (the one in the file, not of the file)
|
||||||
assert!(
|
assert!(
|
||||||
paths.iter().any(|path| path.ends_with("sub/simple.gpx")),
|
paths
|
||||||
|
.iter()
|
||||||
|
.any(|path| std::path::Path::new(path).ends_with("sub/simple.gpx")),
|
||||||
"{paths:?}"
|
"{paths:?}"
|
||||||
);
|
);
|
||||||
// the new file went where the selected file is
|
// the new file went where the selected file is
|
||||||
assert!(
|
assert!(
|
||||||
paths.iter().any(|path| path.ends_with("sub/fresh.gpx")),
|
paths
|
||||||
|
.iter()
|
||||||
|
.any(|path| std::path::Path::new(path).ends_with("sub/fresh.gpx")),
|
||||||
"{paths:?}"
|
"{paths:?}"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn the_parts_of_a_split_are_numbered_from_one() {
|
fn the_parts_of_a_split_are_numbered_from_one() {
|
||||||
let state = crate::state::AppState::temporary();
|
let state = crate::temporary_state();
|
||||||
let folder = std::env::temp_dir().join(format!("gpx-tests-{}", uuid::Uuid::new_v4()));
|
let folder = std::env::temp_dir().join(format!("gpx-tests-{}", uuid::Uuid::new_v4()));
|
||||||
std::fs::create_dir_all(&folder).unwrap();
|
std::fs::create_dir_all(&folder).unwrap();
|
||||||
std::fs::copy("../gpx-rs/data/simple.gpx", folder.join("track.gpx")).unwrap();
|
std::fs::copy("../gpx-rs/data/simple.gpx", folder.join("track.gpx")).unwrap();
|
||||||
@@ -649,7 +662,7 @@ fn a_file_keeps_its_name_and_its_file_is_renamed_apart() {
|
|||||||
|
|
||||||
// the name of another file is not taken
|
// the name of another file is not taken
|
||||||
let error = app.error("rename_file", json!({ "fileId": id, "name": "taken" }));
|
let error = app.error("rename_file", json!({ "fileId": id, "name": "taken" }));
|
||||||
assert_eq!(error, crate::workspace::NAME_TAKEN);
|
assert_eq!(error, gpx_studio_desktop_lib::workspace::NAME_TAKEN);
|
||||||
assert!(folder.join("moved.gpx").exists());
|
assert!(folder.join("moved.gpx").exists());
|
||||||
|
|
||||||
// a name is one that a file can have
|
// a name is one that a file can have
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
//! The tests of the desktop app. They are integration tests, in a single binary, rather than unit
|
||||||
|
//! tests: on Windows, only test binaries can be given the manifest that the app needs to start
|
||||||
|
//! (see `build.rs`).
|
||||||
|
|
||||||
|
mod commands;
|
||||||
|
mod store;
|
||||||
|
mod workspace;
|
||||||
|
|
||||||
|
use gpx_studio_desktop_lib::state::AppState;
|
||||||
|
|
||||||
|
/// An engine that keeps its data in a directory of its own, and has nobody to tell.
|
||||||
|
fn temporary_state() -> AppState {
|
||||||
|
let directory = std::env::temp_dir().join(format!("gpx-studio-{}", uuid::Uuid::new_v4()));
|
||||||
|
AppState::open(directory, std::sync::Arc::new(|_, _| {})).expect("the storage can be opened")
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
//! The storage of the engine on the file system (`store`).
|
||||||
|
|
||||||
|
use std::fs;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
use gpx_engine::{
|
||||||
|
Action, Batch, Command, CommitError, Load, LoadFiles, Persister, Revision, Storage,
|
||||||
|
};
|
||||||
|
use gpx_studio_desktop_lib::Engine;
|
||||||
|
use gpx_studio_desktop_lib::store::FileStorage;
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
fn directory() -> PathBuf {
|
||||||
|
std::env::temp_dir().join(format!("gpx-studio-store-{}", Uuid::new_v4()))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn engine_with_a_file() -> Engine {
|
||||||
|
let mut engine = Engine::default();
|
||||||
|
let data = std::fs::read("../gpx-rs/data/simple.gpx").unwrap();
|
||||||
|
engine
|
||||||
|
.execute(Action::Edit(Command::LoadFiles(LoadFiles {
|
||||||
|
files: vec![Load {
|
||||||
|
data: &data,
|
||||||
|
name: "simple",
|
||||||
|
}],
|
||||||
|
})))
|
||||||
|
.unwrap();
|
||||||
|
engine
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn keeps_the_files_and_the_settings_between_sessions() {
|
||||||
|
let root = directory();
|
||||||
|
let engine = engine_with_a_file();
|
||||||
|
let order = engine.order().to_vec();
|
||||||
|
|
||||||
|
let storage = FileStorage::open(&root).unwrap();
|
||||||
|
pollster::block_on(Persister::default().save(&storage, engine.snapshot())).unwrap();
|
||||||
|
pollster::block_on(storage.put_setting("units", "\"metric\"")).unwrap();
|
||||||
|
|
||||||
|
// another session
|
||||||
|
let storage = FileStorage::open(&root).unwrap();
|
||||||
|
let restored = pollster::block_on(Persister::default().restore(&storage)).unwrap();
|
||||||
|
let mut other = Engine::default();
|
||||||
|
other.restore(restored);
|
||||||
|
assert_eq!(other.order(), order);
|
||||||
|
assert_eq!(
|
||||||
|
other.file_statistics(&order[0]).unwrap().total_distance,
|
||||||
|
engine.file_statistics(&order[0]).unwrap().total_distance
|
||||||
|
);
|
||||||
|
assert_eq!(storage.settings()["units"], "\"metric\"");
|
||||||
|
fs::remove_dir_all(root).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn refuses_a_commit_that_is_not_based_on_the_head() {
|
||||||
|
let root = directory();
|
||||||
|
let storage = FileStorage::open(&root).unwrap();
|
||||||
|
let batch = Batch {
|
||||||
|
order: Some(vec![]),
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
assert_eq!(pollster::block_on(storage.commit(&batch)), Ok(Revision(1)));
|
||||||
|
assert_eq!(
|
||||||
|
pollster::block_on(storage.commit(&batch)),
|
||||||
|
Err(CommitError::Stale { head: Revision(1) })
|
||||||
|
);
|
||||||
|
fs::remove_dir_all(root).unwrap();
|
||||||
|
}
|
||||||
@@ -0,0 +1,811 @@
|
|||||||
|
//! The places of the files of the engine on the disk (`workspace`).
|
||||||
|
|
||||||
|
use std::collections::BTreeMap;
|
||||||
|
use std::fs;
|
||||||
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
|
use gpx_engine::{FileId, SelectMode, api};
|
||||||
|
use gpx_studio_desktop_lib::Engine;
|
||||||
|
use gpx_studio_desktop_lib::workspace::*;
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
fn gpx(name: &str) -> String {
|
||||||
|
format!(
|
||||||
|
r#"<?xml version="1.0"?><gpx version="1.1" creator="test" xmlns="http://www.topografix.com/GPX/1/1"><metadata><name>{name}</name></metadata><trk><name>{name}</name><trkseg><trkpt lat="50.0" lon="4.0"><ele>10</ele></trkpt><trkpt lat="50.1" lon="4.1"><ele>20</ele></trkpt></trkseg></trk></gpx>"#
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The GPX files of a folder and of the folders in it.
|
||||||
|
pub fn gpx_files(folder: &Path) -> Vec<PathBuf> {
|
||||||
|
let mut found = vec![];
|
||||||
|
for entry in fs::read_dir(folder).unwrap().flatten() {
|
||||||
|
let path = entry.path();
|
||||||
|
if path.is_dir() {
|
||||||
|
found.extend(gpx_files(&path));
|
||||||
|
} else if is_gpx(&path) {
|
||||||
|
found.push(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
found.sort();
|
||||||
|
found
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Fixture {
|
||||||
|
folder: PathBuf,
|
||||||
|
engine: Engine,
|
||||||
|
workspace: Workspace,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Fixture {
|
||||||
|
fn new() -> Self {
|
||||||
|
let folder = canonical(&std::env::temp_dir()).join(format!("gpx-ws-{}", Uuid::new_v4()));
|
||||||
|
fs::create_dir_all(&folder).unwrap();
|
||||||
|
Self {
|
||||||
|
folder,
|
||||||
|
engine: Engine::default(),
|
||||||
|
workspace: Workspace::default(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn write(&self, name: &str, title: &str) -> PathBuf {
|
||||||
|
let path = self.folder.join(name);
|
||||||
|
fs::write(&path, gpx(title)).unwrap();
|
||||||
|
path
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Opens the folder, and all the files that are in it.
|
||||||
|
fn open_folder(&mut self) {
|
||||||
|
let folder = self.folder.clone();
|
||||||
|
self.workspace.open_folder(&mut self.engine, &folder, false);
|
||||||
|
let files = gpx_files(&folder);
|
||||||
|
self.workspace.open_files(&mut self.engine, &files, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn reconcile(&mut self, changed: Option<&[PathBuf]>) -> Option<api::Outcome> {
|
||||||
|
self.workspace.reconcile(&mut self.engine, changed)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn save(&mut self, ids: &[Uuid]) {
|
||||||
|
self.workspace
|
||||||
|
.save(&mut self.engine, ids, &BTreeMap::new(), None)
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn ids(&self) -> Vec<Uuid> {
|
||||||
|
self.engine.order().iter().map(|id| id.0).collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn id_named(&self, name: &str) -> Uuid {
|
||||||
|
self.ids()
|
||||||
|
.into_iter()
|
||||||
|
.find(|id| self.name(*id) == name)
|
||||||
|
.unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn name(&self, id: Uuid) -> String {
|
||||||
|
self.engine
|
||||||
|
.file_structure(&FileId(id))
|
||||||
|
.unwrap()
|
||||||
|
.name
|
||||||
|
.clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// What the file holds: the name of its track (its own name is the one of the file).
|
||||||
|
fn content(&self, id: Uuid) -> String {
|
||||||
|
self.engine.file_structure(&FileId(id)).unwrap().tracks[0]
|
||||||
|
.info
|
||||||
|
.name
|
||||||
|
.clone()
|
||||||
|
.unwrap_or_default()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn rename(&mut self, id: Uuid, name: &str) {
|
||||||
|
api::select(&mut self.engine, &[id], SelectMode::Replace);
|
||||||
|
assert!(!api::metadata(&mut self.engine, name, "").has_error());
|
||||||
|
}
|
||||||
|
|
||||||
|
fn status(&self, id: Uuid) -> FileStatus {
|
||||||
|
self.workspace
|
||||||
|
.state(&self.engine)
|
||||||
|
.files
|
||||||
|
.remove(&id.to_string())
|
||||||
|
.unwrap()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Drop for Fixture {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
let _ = fs::remove_dir_all(&self.folder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn an_opened_file_is_clean_until_it_is_edited_and_clean_again_once_saved() {
|
||||||
|
let mut fx = Fixture::new();
|
||||||
|
let path = fx.write("a.gpx", "a");
|
||||||
|
fx.workspace
|
||||||
|
.open_files(&mut fx.engine, std::slice::from_ref(&path), true);
|
||||||
|
let id = fx.ids()[0];
|
||||||
|
assert!(!fx.workspace.is_dirty(&fx.engine, id));
|
||||||
|
assert_eq!(fx.status(id).path.as_deref(), path.to_str());
|
||||||
|
|
||||||
|
fx.rename(id, "renamed");
|
||||||
|
assert!(fx.workspace.is_dirty(&fx.engine, id));
|
||||||
|
// nothing is written before it is saved
|
||||||
|
assert!(fs::read_to_string(&path).unwrap().contains(">a<"));
|
||||||
|
|
||||||
|
fx.save(&[id]);
|
||||||
|
assert!(!fx.workspace.is_dirty(&fx.engine, id));
|
||||||
|
assert!(fs::read_to_string(&path).unwrap().contains(">renamed<"));
|
||||||
|
|
||||||
|
// going back before the save is an edit again
|
||||||
|
api::select(&mut fx.engine, &[id], SelectMode::Replace);
|
||||||
|
api::undo(&mut fx.engine);
|
||||||
|
assert!(fx.workspace.is_dirty(&fx.engine, id));
|
||||||
|
api::redo(&mut fx.engine);
|
||||||
|
assert!(!fx.workspace.is_dirty(&fx.engine, id));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_file_that_is_not_on_the_disk_is_unsaved_until_it_is_given_a_place() {
|
||||||
|
let mut fx = Fixture::new();
|
||||||
|
api::new_file(&mut fx.engine, "fresh", None, None, None, false);
|
||||||
|
let id = fx.ids()[0];
|
||||||
|
assert!(fx.workspace.is_dirty(&fx.engine, id));
|
||||||
|
assert_eq!(
|
||||||
|
fx.workspace.unlinked(&fx.engine, &[id]),
|
||||||
|
[(id, "fresh".to_string())]
|
||||||
|
);
|
||||||
|
// nowhere to put it without being told
|
||||||
|
fx.save(&[id]);
|
||||||
|
assert!(fx.workspace.is_dirty(&fx.engine, id));
|
||||||
|
|
||||||
|
let path = fx.folder.join("fresh.gpx");
|
||||||
|
let paths = BTreeMap::from([(id, path.clone())]);
|
||||||
|
fx.workspace
|
||||||
|
.save(&mut fx.engine, &[id], &paths, None)
|
||||||
|
.unwrap();
|
||||||
|
assert!(path.exists());
|
||||||
|
assert!(!fx.workspace.is_dirty(&fx.engine, id));
|
||||||
|
assert!(fx.workspace.unlinked(&fx.engine, &[id]).is_empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn several_files_without_a_place_go_in_a_folder_with_names_that_are_free() {
|
||||||
|
let mut fx = Fixture::new();
|
||||||
|
fx.write("fresh.gpx", "already there");
|
||||||
|
api::new_file(&mut fx.engine, "fresh", None, None, None, false);
|
||||||
|
api::new_file(&mut fx.engine, "a/b: c", None, None, None, false);
|
||||||
|
api::new_file(&mut fx.engine, "fresh", None, None, None, false);
|
||||||
|
let ids = fx.ids();
|
||||||
|
let folder = fx.folder.clone();
|
||||||
|
fx.workspace
|
||||||
|
.save(&mut fx.engine, &ids, &BTreeMap::new(), Some(&folder))
|
||||||
|
.unwrap();
|
||||||
|
for name in ["fresh (2).gpx", "fresh (3).gpx", "a_b_ c.gpx"] {
|
||||||
|
assert!(fx.folder.join(name).exists(), "{name}");
|
||||||
|
}
|
||||||
|
assert!(ids.iter().all(|id| !fx.workspace.is_dirty(&fx.engine, *id)));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn what_this_app_writes_is_not_a_change_of_the_disk() {
|
||||||
|
let mut fx = Fixture::new();
|
||||||
|
let path = fx.write("a.gpx", "a");
|
||||||
|
fx.open_folder();
|
||||||
|
let id = fx.ids()[0];
|
||||||
|
api::select(&mut fx.engine, &[id], SelectMode::Replace);
|
||||||
|
assert!(!api::style(&mut fx.engine, Some("#ff0000"), None, None).has_error());
|
||||||
|
fx.save(&[id]);
|
||||||
|
assert!(fx.reconcile(Some(&[path])).is_none());
|
||||||
|
assert!(!fx.status(id).replaced && !fx.status(id).dirty);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn the_folders_of_the_files_outside_the_open_folder_are_watched_too() {
|
||||||
|
let mut fx = Fixture::new();
|
||||||
|
let inside = fx.write("in.gpx", "in");
|
||||||
|
let elsewhere = canonical(&std::env::temp_dir()).join(format!("gpx-ws-{}", Uuid::new_v4()));
|
||||||
|
fs::create_dir_all(&elsewhere).unwrap();
|
||||||
|
let (one, two) = (elsewhere.join("one.gpx"), elsewhere.join("two.gpx"));
|
||||||
|
fs::write(&one, gpx("one")).unwrap();
|
||||||
|
fs::write(&two, gpx("two")).unwrap();
|
||||||
|
let folder = fx.folder.clone();
|
||||||
|
|
||||||
|
// no folder: only the folder of the files
|
||||||
|
fx.workspace.open_files(&mut fx.engine, &[one, two], false);
|
||||||
|
assert_eq!(fx.workspace.watched(), [(elsewhere.clone(), false)]);
|
||||||
|
|
||||||
|
// the open folder as a whole, and the file in it needs nothing more
|
||||||
|
fx.workspace.open_folder(&mut fx.engine, &folder, false);
|
||||||
|
fx.workspace.open_files(&mut fx.engine, &[inside], false);
|
||||||
|
assert_eq!(
|
||||||
|
fx.workspace.watched(),
|
||||||
|
[(folder, true), (elsewhere.clone(), false)]
|
||||||
|
);
|
||||||
|
|
||||||
|
// closing the files stops it
|
||||||
|
let ids = fx.ids();
|
||||||
|
fx.workspace.close_files(&mut fx.engine, &ids, true);
|
||||||
|
assert_eq!(fx.workspace.watched(), [(fx.folder.clone(), true)]);
|
||||||
|
fs::remove_dir_all(elsewhere).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn opening_a_folder_does_not_open_its_files() {
|
||||||
|
let mut fx = Fixture::new();
|
||||||
|
fx.write("a.gpx", "a");
|
||||||
|
let folder = fx.folder.clone();
|
||||||
|
let outcome = fx.workspace.open_folder(&mut fx.engine, &folder, false);
|
||||||
|
assert!(!outcome.changed);
|
||||||
|
assert!(fx.ids().is_empty());
|
||||||
|
assert_eq!(fx.workspace.folder.as_deref(), Some(folder.as_path()));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn folders_are_made_renamed_and_moved_and_the_open_files_follow() {
|
||||||
|
let mut fx = Fixture::new();
|
||||||
|
let a = fx.write("a.gpx", "a");
|
||||||
|
fx.open_folder();
|
||||||
|
let id = fx.ids()[0];
|
||||||
|
let root = fx.folder.clone();
|
||||||
|
let path_of = |fx: &Fixture| PathBuf::from(fx.status(id).path.unwrap());
|
||||||
|
|
||||||
|
let first = fx.workspace.create_folder(&root, "New folder").unwrap();
|
||||||
|
let second = fx.workspace.create_folder(&root, "New folder").unwrap();
|
||||||
|
assert_eq!(first, root.join("New folder"));
|
||||||
|
assert_eq!(second, root.join("New folder 2"));
|
||||||
|
|
||||||
|
fx.workspace.move_paths(&[a], &first).unwrap();
|
||||||
|
assert_eq!(path_of(&fx), first.join("a.gpx"));
|
||||||
|
assert!(first.join("a.gpx").exists() && !fx.status(id).dirty);
|
||||||
|
|
||||||
|
let trips = fx.workspace.rename_path(&first, "Trips").unwrap();
|
||||||
|
assert_eq!(path_of(&fx), root.join("Trips/a.gpx"));
|
||||||
|
// a folder does not go into itself, nor onto something else
|
||||||
|
assert!(
|
||||||
|
fx.workspace
|
||||||
|
.move_paths(std::slice::from_ref(&trips), &trips)
|
||||||
|
.is_err()
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
fx.workspace.rename_path(&trips, "New folder 2"),
|
||||||
|
Err(NAME_TAKEN.to_owned())
|
||||||
|
);
|
||||||
|
fx.workspace.move_paths(&[trips], &second).unwrap();
|
||||||
|
assert_eq!(path_of(&fx), second.join("Trips/a.gpx"));
|
||||||
|
|
||||||
|
// a file keeps its extension
|
||||||
|
let closed = fx.write("c.gpx", "c");
|
||||||
|
assert_eq!(
|
||||||
|
fx.workspace.rename_path(&closed, "d").unwrap(),
|
||||||
|
root.join("d.gpx")
|
||||||
|
);
|
||||||
|
// the open folder and what is not in it are left alone
|
||||||
|
assert!(fx.workspace.rename_path(&root, "x").is_err());
|
||||||
|
let elsewhere = canonical(&std::env::temp_dir());
|
||||||
|
assert!(fx.workspace.rename_path(&elsewhere, "x").is_err());
|
||||||
|
assert!(fx.workspace.create_folder(&elsewhere, "x").is_err());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn deleted_files_are_closed_unless_they_have_edits() {
|
||||||
|
let mut fx = Fixture::new();
|
||||||
|
let a = fx.write("a.gpx", "a");
|
||||||
|
let b = fx.write("b.gpx", "b");
|
||||||
|
fx.open_folder();
|
||||||
|
let (id_a, id_b) = (fx.id_named("a"), fx.id_named("b"));
|
||||||
|
api::select(&mut fx.engine, &[id_b], SelectMode::Replace);
|
||||||
|
assert!(!api::style(&mut fx.engine, Some("#ff0000"), None, None).has_error());
|
||||||
|
|
||||||
|
let outcome = fx
|
||||||
|
.workspace
|
||||||
|
.delete_paths(&mut fx.engine, &[a.clone(), b.clone()], |paths| {
|
||||||
|
paths.iter().for_each(|path| fs::remove_file(path).unwrap());
|
||||||
|
Ok(())
|
||||||
|
})
|
||||||
|
.unwrap();
|
||||||
|
assert!(outcome.changed);
|
||||||
|
assert_eq!(fx.ids(), [id_b]);
|
||||||
|
assert!(!fx.ids().contains(&id_a));
|
||||||
|
let status = fx.status(id_b);
|
||||||
|
assert!(status.dirty && status.missing);
|
||||||
|
assert!(!a.exists() && !b.exists());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn the_tree_of_the_folder_shows_folders_first_and_only_gpx_files() {
|
||||||
|
let mut fx = Fixture::new();
|
||||||
|
fx.write("b.gpx", "b");
|
||||||
|
fx.write("A.GPX", "a");
|
||||||
|
fx.write("b 10.gpx", "b 10");
|
||||||
|
fx.write("b 2.gpx", "b 2");
|
||||||
|
fx.write("notes.txt", "not a track");
|
||||||
|
fx.write(".hidden.gpx", "hidden");
|
||||||
|
fs::create_dir(fx.folder.join("zoo")).unwrap();
|
||||||
|
fs::create_dir(fx.folder.join("Alps")).unwrap();
|
||||||
|
fs::create_dir(fx.folder.join(".git")).unwrap();
|
||||||
|
fx.write("zoo/c.gpx", "c");
|
||||||
|
let folder = fx.folder.clone();
|
||||||
|
fx.workspace.open_folder(&mut fx.engine, &folder, false);
|
||||||
|
|
||||||
|
let names = |entries: Vec<Entry>| -> Vec<(String, bool)> {
|
||||||
|
entries.into_iter().map(|e| (e.name, e.is_dir)).collect()
|
||||||
|
};
|
||||||
|
assert_eq!(
|
||||||
|
names(fx.workspace.list_folder(&folder).unwrap()),
|
||||||
|
[
|
||||||
|
("Alps".to_string(), true),
|
||||||
|
("zoo".to_string(), true),
|
||||||
|
("A.GPX".to_string(), false),
|
||||||
|
("b.gpx".to_string(), false),
|
||||||
|
("b 2.gpx".to_string(), false),
|
||||||
|
("b 10.gpx".to_string(), false),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
names(fx.workspace.list_folder(&folder.join("zoo")).unwrap()),
|
||||||
|
[("c.gpx".to_string(), false)]
|
||||||
|
);
|
||||||
|
// only what is in the open folder can be listed
|
||||||
|
let elsewhere = canonical(&std::env::temp_dir());
|
||||||
|
assert!(fx.workspace.list_folder(&elsewhere).is_err());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn names_are_sorted_by_the_numbers_they_hold() {
|
||||||
|
let mut names = vec![
|
||||||
|
"track 10",
|
||||||
|
"track 2",
|
||||||
|
"Track 1",
|
||||||
|
"track",
|
||||||
|
"track 02b",
|
||||||
|
"track 2a",
|
||||||
|
"b",
|
||||||
|
"A",
|
||||||
|
];
|
||||||
|
names.sort_by(|a, b| natural_cmp(a, b).then_with(|| a.cmp(b)));
|
||||||
|
assert_eq!(
|
||||||
|
names,
|
||||||
|
[
|
||||||
|
"A",
|
||||||
|
"b",
|
||||||
|
"track",
|
||||||
|
"Track 1",
|
||||||
|
"track 2",
|
||||||
|
"track 2a",
|
||||||
|
"track 02b",
|
||||||
|
"track 10",
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_file_without_edits_is_read_again_when_the_disk_changes() {
|
||||||
|
let mut fx = Fixture::new();
|
||||||
|
let a = fx.write("a.gpx", "a");
|
||||||
|
fx.open_folder();
|
||||||
|
let id = fx.ids()[0];
|
||||||
|
|
||||||
|
fx.write("a.gpx", "theirs");
|
||||||
|
let outcome = fx.reconcile(Some(std::slice::from_ref(&a))).unwrap();
|
||||||
|
assert!(outcome.changed);
|
||||||
|
// the same file, now the one on the disk
|
||||||
|
assert_eq!(fx.ids(), [id]);
|
||||||
|
assert_eq!(fx.content(id), "theirs");
|
||||||
|
let status = fx.status(id);
|
||||||
|
assert!(!status.dirty && !status.replaced);
|
||||||
|
// looking again changes nothing
|
||||||
|
assert!(fx.reconcile(Some(std::slice::from_ref(&a))).is_none());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_file_with_edits_is_flagged_when_the_disk_changes_and_not_read_again() {
|
||||||
|
let mut fx = Fixture::new();
|
||||||
|
let a = fx.write("a.gpx", "a");
|
||||||
|
fx.open_folder();
|
||||||
|
let id = fx.ids()[0];
|
||||||
|
fx.rename(id, "mine");
|
||||||
|
|
||||||
|
fx.write("a.gpx", "theirs");
|
||||||
|
let outcome = fx.reconcile(Some(std::slice::from_ref(&a))).unwrap();
|
||||||
|
assert!(!outcome.changed);
|
||||||
|
assert_eq!(fx.name(id), "mine");
|
||||||
|
let status = fx.status(id);
|
||||||
|
assert!(status.dirty && status.replaced && !status.missing);
|
||||||
|
// looking again changes nothing
|
||||||
|
assert!(fx.reconcile(Some(std::slice::from_ref(&a))).is_none());
|
||||||
|
|
||||||
|
// the disk goes back to what was read: only the edits are left
|
||||||
|
fx.write("a.gpx", "a");
|
||||||
|
assert!(fx.reconcile(Some(std::slice::from_ref(&a))).is_some());
|
||||||
|
let status = fx.status(id);
|
||||||
|
assert!(status.dirty && !status.replaced);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn the_user_can_take_the_disk_instead_of_the_edits() {
|
||||||
|
let mut fx = Fixture::new();
|
||||||
|
fx.write("a.gpx", "a");
|
||||||
|
fx.open_folder();
|
||||||
|
let id = fx.ids()[0];
|
||||||
|
fx.rename(id, "mine");
|
||||||
|
fx.write("a.gpx", "theirs");
|
||||||
|
fx.reconcile(None);
|
||||||
|
assert!(fx.status(id).replaced);
|
||||||
|
|
||||||
|
fx.workspace.reload(&mut fx.engine, &[id]).unwrap();
|
||||||
|
assert_eq!(fx.content(id), "theirs");
|
||||||
|
let status = fx.status(id);
|
||||||
|
assert!(!status.dirty && !status.replaced);
|
||||||
|
// and it is one undo step
|
||||||
|
api::select(&mut fx.engine, &[id], SelectMode::Replace);
|
||||||
|
api::undo(&mut fx.engine);
|
||||||
|
assert_eq!(fx.content(id), "mine");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn saving_overwrites_what_replaced_the_file() {
|
||||||
|
let mut fx = Fixture::new();
|
||||||
|
let a = fx.write("a.gpx", "a");
|
||||||
|
fx.open_folder();
|
||||||
|
let id = fx.ids()[0];
|
||||||
|
fx.rename(id, "mine");
|
||||||
|
fx.write("a.gpx", "theirs");
|
||||||
|
fx.reconcile(None);
|
||||||
|
assert!(fx.status(id).replaced);
|
||||||
|
|
||||||
|
fx.save(&[id]);
|
||||||
|
assert!(fs::read_to_string(a).unwrap().contains(">mine<"));
|
||||||
|
assert!(!fx.status(id).replaced && !fx.status(id).dirty);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_file_that_is_gone_from_the_disk_stays_open_and_dirty_until_it_is_saved_again() {
|
||||||
|
let mut fx = Fixture::new();
|
||||||
|
let a = fx.write("a.gpx", "a");
|
||||||
|
fx.open_folder();
|
||||||
|
let id = fx.ids()[0];
|
||||||
|
|
||||||
|
fs::remove_file(&a).unwrap();
|
||||||
|
assert!(fx.reconcile(Some(std::slice::from_ref(&a))).is_some());
|
||||||
|
assert_eq!(fx.ids(), [id]);
|
||||||
|
let status = fx.status(id);
|
||||||
|
assert!(status.dirty && status.missing && status.path.is_some());
|
||||||
|
|
||||||
|
// saving puts it back
|
||||||
|
fx.save(&[id]);
|
||||||
|
assert!(a.exists());
|
||||||
|
let status = fx.status(id);
|
||||||
|
assert!(!status.dirty && !status.missing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_file_that_comes_back_different_is_read_again() {
|
||||||
|
let mut fx = Fixture::new();
|
||||||
|
let a = fx.write("a.gpx", "a");
|
||||||
|
fx.open_folder();
|
||||||
|
let id = fx.ids()[0];
|
||||||
|
fs::remove_file(&a).unwrap();
|
||||||
|
fx.reconcile(None);
|
||||||
|
assert!(fx.status(id).missing);
|
||||||
|
|
||||||
|
fx.write("a.gpx", "back");
|
||||||
|
fx.reconcile(None);
|
||||||
|
assert_eq!(fx.content(id), "back");
|
||||||
|
let status = fx.status(id);
|
||||||
|
assert!(!status.dirty && !status.missing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn what_changed_while_the_app_was_closed_is_found_when_it_starts() {
|
||||||
|
let mut fx = Fixture::new();
|
||||||
|
let a = fx.write("a.gpx", "a");
|
||||||
|
fx.open_folder();
|
||||||
|
let id = fx.ids()[0];
|
||||||
|
fx.write("a.gpx", "changed");
|
||||||
|
assert!(fx.reconcile(None).is_some());
|
||||||
|
assert_eq!(fx.content(id), "changed");
|
||||||
|
fs::remove_file(a).unwrap();
|
||||||
|
assert!(fx.reconcile(None).is_some());
|
||||||
|
assert!(fx.status(id).missing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn new_files_made_from_a_file_of_the_folder_are_saved_next_to_it() {
|
||||||
|
let mut fx = Fixture::new();
|
||||||
|
fs::create_dir(fx.folder.join("sub")).unwrap();
|
||||||
|
fx.write("sub/b.gpx", "b");
|
||||||
|
fx.write("a.gpx", "a");
|
||||||
|
fx.open_folder();
|
||||||
|
let b = fx.id_named("b");
|
||||||
|
let sub = fx.folder.join("sub");
|
||||||
|
assert_eq!(fx.workspace.source_dir(&[b]), Some(canonical(&sub)));
|
||||||
|
|
||||||
|
let before = fx.ids();
|
||||||
|
api::select(&mut fx.engine, &[b], SelectMode::Replace);
|
||||||
|
let outcome = api::duplicate(&mut fx.engine);
|
||||||
|
let copy = fx
|
||||||
|
.ids()
|
||||||
|
.into_iter()
|
||||||
|
.find(|id| !before.contains(id))
|
||||||
|
.unwrap();
|
||||||
|
fx.workspace.inherit(outcome.added(), &canonical(&sub));
|
||||||
|
assert_eq!(fx.status(copy).folder.as_deref(), canonical(&sub).to_str());
|
||||||
|
assert!(fx.status(copy).path.is_none() && fx.status(copy).dirty);
|
||||||
|
// nobody needs to be asked where it goes
|
||||||
|
assert!(fx.workspace.unlinked(&fx.engine, &[copy]).is_empty());
|
||||||
|
|
||||||
|
fx.save(&[copy]);
|
||||||
|
assert!(sub.join("b (2).gpx").exists());
|
||||||
|
let status = fx.status(copy);
|
||||||
|
assert!(!status.dirty && status.folder.is_none());
|
||||||
|
assert_eq!(
|
||||||
|
status.path.as_deref(),
|
||||||
|
canonical(&sub.join("b (2).gpx")).to_str()
|
||||||
|
);
|
||||||
|
// the copy of the copy is next to it as well
|
||||||
|
assert_eq!(fx.workspace.source_dir(&[copy]), Some(canonical(&sub)));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_file_outside_the_open_folder_hands_nothing_down() {
|
||||||
|
let mut fx = Fixture::new();
|
||||||
|
let elsewhere = canonical(&std::env::temp_dir()).join(format!("gpx-ws-{}", Uuid::new_v4()));
|
||||||
|
fs::create_dir_all(&elsewhere).unwrap();
|
||||||
|
let outside = elsewhere.join("o.gpx");
|
||||||
|
fs::write(&outside, gpx("o")).unwrap();
|
||||||
|
let folder = fx.folder.clone();
|
||||||
|
fx.workspace.open_folder(&mut fx.engine, &folder, false);
|
||||||
|
fx.workspace
|
||||||
|
.open_files(&mut fx.engine, std::slice::from_ref(&outside), true);
|
||||||
|
let id = fx.ids()[0];
|
||||||
|
assert_eq!(fx.workspace.source_dir(&[id]), None);
|
||||||
|
// a new file with no source is not linked to a folder by `source_dir`: the caller falls back
|
||||||
|
fs::remove_dir_all(elsewhere).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn closing_files_asks_what_to_do_with_the_unsaved_ones() {
|
||||||
|
let mut fx = Fixture::new();
|
||||||
|
fx.write("a.gpx", "a");
|
||||||
|
fx.write("b.gpx", "b");
|
||||||
|
fx.open_folder();
|
||||||
|
let (a, b) = (fx.id_named("a"), fx.id_named("b"));
|
||||||
|
fx.rename(a, "edited");
|
||||||
|
assert_eq!(fx.workspace.unsaved(&fx.engine, &[a, b]), [a]);
|
||||||
|
|
||||||
|
// without a choice what has edits stays
|
||||||
|
let outcome = fx.workspace.close_files(&mut fx.engine, &[a, b], false);
|
||||||
|
assert!(outcome.changed);
|
||||||
|
assert_eq!(fx.ids(), [a]);
|
||||||
|
|
||||||
|
// saved first
|
||||||
|
fx.save(&[a]);
|
||||||
|
fx.workspace.close_files(&mut fx.engine, &[a], false);
|
||||||
|
assert!(fx.ids().is_empty());
|
||||||
|
assert!(
|
||||||
|
fs::read_to_string(fx.folder.join("a.gpx"))
|
||||||
|
.unwrap()
|
||||||
|
.contains("edited")
|
||||||
|
);
|
||||||
|
assert!(fx.workspace.links.is_empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn closing_files_can_discard_their_edits() {
|
||||||
|
let mut fx = Fixture::new();
|
||||||
|
fx.write("a.gpx", "a");
|
||||||
|
fx.open_folder();
|
||||||
|
let a = fx.ids()[0];
|
||||||
|
fx.rename(a, "edited");
|
||||||
|
api::new_file(&mut fx.engine, "fresh", None, None, None, false);
|
||||||
|
let fresh = fx.id_named("fresh");
|
||||||
|
fx.workspace.close_files(&mut fx.engine, &[a, fresh], true);
|
||||||
|
assert!(fx.ids().is_empty());
|
||||||
|
assert!(
|
||||||
|
fs::read_to_string(fx.folder.join("a.gpx"))
|
||||||
|
.unwrap()
|
||||||
|
.contains(">a<")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn closing_the_folder_closes_every_file() {
|
||||||
|
let mut fx = Fixture::new();
|
||||||
|
fx.write("a.gpx", "a");
|
||||||
|
fx.open_folder();
|
||||||
|
api::new_file(&mut fx.engine, "fresh", None, None, None, false);
|
||||||
|
assert_eq!(fx.ids().len(), 2);
|
||||||
|
|
||||||
|
// the new file has nowhere to go: it has to be discarded
|
||||||
|
let outcome = fx.workspace.close_folder(&mut fx.engine, false);
|
||||||
|
assert!(outcome.changed);
|
||||||
|
assert_eq!(fx.ids().len(), 1);
|
||||||
|
assert!(fx.workspace.folder.is_none());
|
||||||
|
|
||||||
|
let outcome = fx.workspace.close_folder(&mut fx.engine, true);
|
||||||
|
assert!(outcome.changed);
|
||||||
|
assert!(fx.ids().is_empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn opening_another_folder_closes_the_first_with_all_its_files() {
|
||||||
|
let mut fx = Fixture::new();
|
||||||
|
fx.write("a.gpx", "a");
|
||||||
|
fx.open_folder();
|
||||||
|
let a = fx.ids()[0];
|
||||||
|
fx.rename(a, "edited");
|
||||||
|
let other = canonical(&std::env::temp_dir()).join(format!("gpx-ws-{}", Uuid::new_v4()));
|
||||||
|
fs::create_dir_all(&other).unwrap();
|
||||||
|
|
||||||
|
// the edits stay, nothing is lost without a choice
|
||||||
|
fx.workspace.open_folder(&mut fx.engine, &other, false);
|
||||||
|
assert_eq!(fx.ids(), [a]);
|
||||||
|
assert_eq!(fx.workspace.folder.as_deref(), Some(other.as_path()));
|
||||||
|
|
||||||
|
let first = fx.folder.clone();
|
||||||
|
fx.workspace.open_folder(&mut fx.engine, &first, true);
|
||||||
|
assert!(fx.ids().is_empty());
|
||||||
|
assert!(
|
||||||
|
fs::read_to_string(fx.folder.join("a.gpx"))
|
||||||
|
.unwrap()
|
||||||
|
.contains(">a<")
|
||||||
|
);
|
||||||
|
fs::remove_dir_all(other).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn opening_the_same_folder_again_changes_nothing() {
|
||||||
|
let mut fx = Fixture::new();
|
||||||
|
fx.write("a.gpx", "a");
|
||||||
|
fx.open_folder();
|
||||||
|
let folder = fx.folder.clone();
|
||||||
|
let outcome = fx.workspace.open_folder(&mut fx.engine, &folder, true);
|
||||||
|
assert!(!outcome.changed);
|
||||||
|
assert_eq!(fx.ids().len(), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_failed_save_stops_at_the_file_and_leaves_it_dirty() {
|
||||||
|
let mut fx = Fixture::new();
|
||||||
|
fx.write("a.gpx", "a");
|
||||||
|
fx.open_folder();
|
||||||
|
let id = fx.ids()[0];
|
||||||
|
fx.rename(id, "edited");
|
||||||
|
// the place of the file is taken by a folder
|
||||||
|
fs::remove_file(fx.folder.join("a.gpx")).unwrap();
|
||||||
|
fs::create_dir(fx.folder.join("a.gpx")).unwrap();
|
||||||
|
let result = fx
|
||||||
|
.workspace
|
||||||
|
.save(&mut fx.engine, &[id], &BTreeMap::new(), None);
|
||||||
|
assert!(result.is_err());
|
||||||
|
assert!(fx.workspace.is_dirty(&fx.engine, id));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn saving_as_gives_the_file_another_place() {
|
||||||
|
let mut fx = Fixture::new();
|
||||||
|
let a = fx.write("a.gpx", "a");
|
||||||
|
fx.write("b.gpx", "b");
|
||||||
|
fx.open_folder();
|
||||||
|
let id = fx.id_named("a");
|
||||||
|
let other = fx.id_named("b");
|
||||||
|
fx.rename(id, "edited");
|
||||||
|
|
||||||
|
let target = fx.folder.join("copy.gpx");
|
||||||
|
fx.workspace.save_as(&mut fx.engine, id, &target).unwrap();
|
||||||
|
assert!(fs::read_to_string(&target).unwrap().contains("edited"));
|
||||||
|
assert!(fs::read_to_string(a).unwrap().contains(">a<"));
|
||||||
|
let status = fx.status(id);
|
||||||
|
assert!(!status.dirty);
|
||||||
|
assert_eq!(status.path.as_deref(), canonical(&target).to_str());
|
||||||
|
|
||||||
|
// the place of another open file is not available
|
||||||
|
let taken = fx.folder.join("b.gpx");
|
||||||
|
assert!(fx.workspace.save_as(&mut fx.engine, id, &taken).is_err());
|
||||||
|
assert!(!fx.workspace.is_dirty(&fx.engine, other));
|
||||||
|
}
|
||||||
|
|
||||||
|
mod restart {
|
||||||
|
use gpx_engine::Persister;
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
use gpx_studio_desktop_lib::store::FileStorage;
|
||||||
|
|
||||||
|
/// What the app does when it starts again: the engine and the links are read from what was
|
||||||
|
/// kept.
|
||||||
|
fn restart(engine: &Engine, workspace: &Workspace, root: &Path) -> (Engine, Workspace) {
|
||||||
|
let storage = FileStorage::open(root).unwrap();
|
||||||
|
pollster::block_on(Persister::default().save(&storage, engine.snapshot())).unwrap();
|
||||||
|
let mut restarted = Engine::default();
|
||||||
|
let restored = pollster::block_on(Persister::default().restore(&storage)).unwrap();
|
||||||
|
restarted.restore(restored);
|
||||||
|
let links = serde_json::to_string(workspace).unwrap();
|
||||||
|
(restarted, serde_json::from_str(&links).unwrap())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn setup() -> (PathBuf, Engine, Workspace, Vec<Uuid>) {
|
||||||
|
let root = std::env::temp_dir().join(format!("gpx-restart-{}", Uuid::new_v4()));
|
||||||
|
let folder = root.join("tracks");
|
||||||
|
fs::create_dir_all(&folder).unwrap();
|
||||||
|
for name in ["with_tracks", "with_time", "with_waypoint"] {
|
||||||
|
let _ = fs::copy(
|
||||||
|
format!("../gpx-rs/data/{name}.gpx"),
|
||||||
|
folder.join(format!("{name}.gpx")),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
let mut engine = Engine::default();
|
||||||
|
let mut workspace = Workspace::default();
|
||||||
|
workspace.open_folder(&mut engine, &folder, false);
|
||||||
|
workspace.open_files(&mut engine, &gpx_files(&folder), false);
|
||||||
|
let ids = engine.order().iter().map(|id| id.0).collect();
|
||||||
|
(root, engine, workspace, ids)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn files_that_were_not_edited_are_not_unsaved_after_a_restart() {
|
||||||
|
let (root, engine, workspace, ids) = setup();
|
||||||
|
assert!(ids.len() >= 2);
|
||||||
|
let (restarted, mut workspace) = restart(&engine, &workspace, &root.join("store"));
|
||||||
|
// the files are the same, but the engine knows their contents by new identities
|
||||||
|
assert!(ids.iter().any(|id| workspace.is_dirty(&restarted, *id)));
|
||||||
|
workspace.verify(&restarted);
|
||||||
|
assert!(ids.iter().all(|id| !workspace.is_dirty(&restarted, *id)));
|
||||||
|
fs::remove_dir_all(root).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn files_that_were_edited_are_still_unsaved_after_a_restart() {
|
||||||
|
let (root, mut engine, workspace, ids) = setup();
|
||||||
|
api::select(&mut engine, &[ids[0]], gpx_engine::SelectMode::Replace);
|
||||||
|
api::metadata(&mut engine, "edited", "");
|
||||||
|
assert!(workspace.is_dirty(&engine, ids[0]));
|
||||||
|
let (restarted, mut workspace) = restart(&engine, &workspace, &root.join("store"));
|
||||||
|
workspace.verify(&restarted);
|
||||||
|
assert!(workspace.is_dirty(&restarted, ids[0]));
|
||||||
|
assert!(
|
||||||
|
ids[1..]
|
||||||
|
.iter()
|
||||||
|
.all(|id| !workspace.is_dirty(&restarted, *id))
|
||||||
|
);
|
||||||
|
fs::remove_dir_all(root).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn links_made_before_the_content_was_kept_are_checked_against_the_disk() {
|
||||||
|
let (root, mut engine, mut workspace, ids) = setup();
|
||||||
|
api::select(&mut engine, &[ids[0]], gpx_engine::SelectMode::Replace);
|
||||||
|
api::metadata(&mut engine, "edited", "");
|
||||||
|
for link in workspace.links.values_mut() {
|
||||||
|
link.export_hash = 0;
|
||||||
|
}
|
||||||
|
let (restarted, mut workspace) = restart(&engine, &workspace, &root.join("store"));
|
||||||
|
workspace.verify(&restarted);
|
||||||
|
assert!(workspace.is_dirty(&restarted, ids[0]));
|
||||||
|
assert!(
|
||||||
|
ids[1..]
|
||||||
|
.iter()
|
||||||
|
.all(|id| !workspace.is_dirty(&restarted, *id))
|
||||||
|
);
|
||||||
|
fs::remove_dir_all(root).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn the_folders_of_new_files_and_the_old_flag_name_survive_a_restart() {
|
||||||
|
let (root, engine, mut workspace, ids) = setup();
|
||||||
|
let folder = workspace.folder.clone().unwrap();
|
||||||
|
let fresh = Uuid::new_v4();
|
||||||
|
workspace.inherit(&[fresh.to_string()], &folder);
|
||||||
|
workspace.links.get_mut(&ids[0]).unwrap().replaced = true;
|
||||||
|
let json = serde_json::to_string(&workspace).unwrap();
|
||||||
|
// links written by the previous version had `conflict`, which is the same thing
|
||||||
|
let json = json.replace("\"replaced\"", "\"conflict\"");
|
||||||
|
assert!(json.contains("\"conflict\":true"));
|
||||||
|
let read: Workspace = serde_json::from_str(&json).unwrap();
|
||||||
|
assert!(read.links[&ids[0]].replaced);
|
||||||
|
assert_eq!(read.dirs.get(&fresh), Some(&folder));
|
||||||
|
let _ = engine;
|
||||||
|
fs::remove_dir_all(root).unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||||
|
<dependency>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity
|
||||||
|
type="win32"
|
||||||
|
name="Microsoft.Windows.Common-Controls"
|
||||||
|
version="6.0.0.0"
|
||||||
|
processorArchitecture="*"
|
||||||
|
publicKeyToken="6595b64144ccf1df"
|
||||||
|
language="*"
|
||||||
|
/>
|
||||||
|
</dependentAssembly>
|
||||||
|
</dependency>
|
||||||
|
</assembly>
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
.DS_Store
|
|
||||||
node_modules
|
|
||||||
/build
|
|
||||||
/.svelte-kit
|
|
||||||
/package
|
|
||||||
.env
|
|
||||||
.env.*
|
|
||||||
!.env.example
|
|
||||||
|
|
||||||
# Ignore files for PNPM, NPM and YARN
|
|
||||||
pnpm-lock.yaml
|
|
||||||
package-lock.json
|
|
||||||
yarn.lock
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
/** @type { import("eslint").Linter.Config } */
|
|
||||||
module.exports = {
|
|
||||||
root: true,
|
|
||||||
extends: [
|
|
||||||
'eslint:recommended',
|
|
||||||
'plugin:@typescript-eslint/recommended',
|
|
||||||
'plugin:svelte/recommended',
|
|
||||||
'prettier',
|
|
||||||
],
|
|
||||||
parser: '@typescript-eslint/parser',
|
|
||||||
plugins: ['@typescript-eslint'],
|
|
||||||
parserOptions: {
|
|
||||||
sourceType: 'module',
|
|
||||||
ecmaVersion: 2020,
|
|
||||||
extraFileExtensions: ['.svelte'],
|
|
||||||
},
|
|
||||||
env: {
|
|
||||||
browser: true,
|
|
||||||
es2017: true,
|
|
||||||
node: true,
|
|
||||||
},
|
|
||||||
overrides: [
|
|
||||||
{
|
|
||||||
files: ['*.svelte'],
|
|
||||||
parser: 'svelte-eslint-parser',
|
|
||||||
parserOptions: {
|
|
||||||
parser: '@typescript-eslint/parser',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
import js from '@eslint/js';
|
||||||
|
import ts from '@typescript-eslint/eslint-plugin';
|
||||||
|
import tsParser from '@typescript-eslint/parser';
|
||||||
|
import svelte from 'eslint-plugin-svelte';
|
||||||
|
import prettier from 'eslint-config-prettier';
|
||||||
|
import globals from 'globals';
|
||||||
|
|
||||||
|
/** @type {import('eslint').Linter.Config[]} */
|
||||||
|
export default [
|
||||||
|
{
|
||||||
|
ignores: ['build/', '.svelte-kit/', 'package/'],
|
||||||
|
},
|
||||||
|
js.configs.recommended,
|
||||||
|
...ts.configs['flat/recommended'],
|
||||||
|
...svelte.configs['flat/recommended'],
|
||||||
|
prettier,
|
||||||
|
...svelte.configs['flat/prettier'],
|
||||||
|
{
|
||||||
|
languageOptions: {
|
||||||
|
globals: { ...globals.browser, ...globals.node },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
rules: {
|
||||||
|
// TypeScript already reports undefined names
|
||||||
|
'no-undef': 'off',
|
||||||
|
'no-empty': ['error', { allowEmptyCatch: true }],
|
||||||
|
'@typescript-eslint/no-unused-vars': [
|
||||||
|
'error',
|
||||||
|
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ['**/*.svelte', '**/*.svelte.ts', '**/*.svelte.js'],
|
||||||
|
languageOptions: {
|
||||||
|
parserOptions: {
|
||||||
|
parser: tsParser,
|
||||||
|
extraFileExtensions: ['.svelte'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
// $effect dependencies are tracked by reading them
|
||||||
|
'@typescript-eslint/no-unused-expressions': 'off',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
Generated
+32
-2
@@ -20,7 +20,7 @@
|
|||||||
"mapillary-js": "^4.1.2",
|
"mapillary-js": "^4.1.2",
|
||||||
"maplibre-gl": "^6.15.0",
|
"maplibre-gl": "^6.15.0",
|
||||||
"sanitize-html": "^2.17.0",
|
"sanitize-html": "^2.17.0",
|
||||||
"sortablejs": "^1.15.6"
|
"sortablejs": "^1.15.7"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@fontsource-variable/inter": "^5.2.8",
|
"@fontsource-variable/inter": "^5.2.8",
|
||||||
@@ -39,11 +39,12 @@
|
|||||||
"@types/mapbox__tilebelt": "^1.0.4",
|
"@types/mapbox__tilebelt": "^1.0.4",
|
||||||
"@types/node": "^22.15.30",
|
"@types/node": "^22.15.30",
|
||||||
"@types/sanitize-html": "^2.16.0",
|
"@types/sanitize-html": "^2.16.0",
|
||||||
"@types/sortablejs": "^1.15.8",
|
"@types/sortablejs": "^1.15.9",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.33.1",
|
"@typescript-eslint/eslint-plugin": "^8.33.1",
|
||||||
"@typescript-eslint/parser": "^8.33.1",
|
"@typescript-eslint/parser": "^8.33.1",
|
||||||
"bits-ui": "^2.17.2",
|
"bits-ui": "^2.17.2",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
|
"cross-env": "^10.1.0",
|
||||||
"eslint": "^9.28.0",
|
"eslint": "^9.28.0",
|
||||||
"eslint-config-prettier": "^10.1.5",
|
"eslint-config-prettier": "^10.1.5",
|
||||||
"eslint-plugin-svelte": "^3.9.1",
|
"eslint-plugin-svelte": "^3.9.1",
|
||||||
@@ -354,6 +355,13 @@
|
|||||||
"tslib": "^2.4.0"
|
"tslib": "^2.4.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@epic-web/invariant": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@epic-web/invariant/-/invariant-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-lrTPqgvfFQtR/eY/qkIzp98OGdNJu0m5ji3q/nJI8v3SXkRKEnWiOxMmbvcSoAIzv/cGiuvRy57k4suKQSAdwA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/@esbuild/aix-ppc64": {
|
"node_modules/@esbuild/aix-ppc64": {
|
||||||
"version": "0.27.7",
|
"version": "0.27.7",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.7.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.7.tgz",
|
||||||
@@ -2762,6 +2770,8 @@
|
|||||||
},
|
},
|
||||||
"node_modules/@types/sortablejs": {
|
"node_modules/@types/sortablejs": {
|
||||||
"version": "1.15.9",
|
"version": "1.15.9",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/sortablejs/-/sortablejs-1.15.9.tgz",
|
||||||
|
"integrity": "sha512-7HP+rZGE2p886PKV9c9OJzLBI6BBJu1O7lJGYnPyG3fS4/duUCcngkNCjsLwIMV+WMqANe3tt4irrXHSIe68OQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
@@ -3273,6 +3283,24 @@
|
|||||||
"version": "1.0.3",
|
"version": "1.0.3",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/cross-env": {
|
||||||
|
"version": "10.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/cross-env/-/cross-env-10.1.0.tgz",
|
||||||
|
"integrity": "sha512-GsYosgnACZTADcmEyJctkJIoqAhHjttw7RsFrVoJNXbsWWqaq6Ym+7kZjq6mS45O0jij6vtiReppKQEtqWy6Dw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@epic-web/invariant": "^1.0.0",
|
||||||
|
"cross-spawn": "^7.0.6"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"cross-env": "dist/bin/cross-env.js",
|
||||||
|
"cross-env-shell": "dist/bin/cross-env-shell.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/cross-spawn": {
|
"node_modules/cross-spawn": {
|
||||||
"version": "7.0.6",
|
"version": "7.0.6",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
@@ -5599,6 +5627,8 @@
|
|||||||
},
|
},
|
||||||
"node_modules/sortablejs": {
|
"node_modules/sortablejs": {
|
||||||
"version": "1.15.7",
|
"version": "1.15.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/sortablejs/-/sortablejs-1.15.7.tgz",
|
||||||
|
"integrity": "sha512-Kk8wLQPlS+yi1ZEf48a4+fzHa4yxjC30M/Sr2AnQu+f/MPwvvX9XjZ6OWejiz8crBsLwSq8GHqaxaET7u6ux0A==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/source-map-js": {
|
"node_modules/source-map-js": {
|
||||||
|
|||||||
@@ -5,11 +5,12 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite dev",
|
"dev": "vite dev",
|
||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"build:desktop": "BUILD_TARGET=desktop BASE_PATH='' vite build",
|
"build:desktop": "cross-env BUILD_TARGET=desktop BASE_PATH= vite build",
|
||||||
"prebuild": "npx tsx src/lib/scripts/pwa-manifest.ts",
|
"prebuild": "npx tsx src/lib/scripts/pwa-manifest.ts",
|
||||||
"postbuild": "npx tsx src/lib/scripts/sitemap.ts",
|
"postbuild": "npx tsx src/lib/scripts/sitemap.ts",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
||||||
|
"pretest": "svelte-kit sync",
|
||||||
"test": "node --import tsx --import ./src/test/register.mjs --experimental-wasm-modules --disable-warning=ExperimentalWarning --test \"src/**/*.test.ts\"",
|
"test": "node --import tsx --import ./src/test/register.mjs --experimental-wasm-modules --disable-warning=ExperimentalWarning --test \"src/**/*.test.ts\"",
|
||||||
"generate:example": "node --import tsx src/lib/scripts/example-statistics.ts",
|
"generate:example": "node --import tsx src/lib/scripts/example-statistics.ts",
|
||||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
||||||
@@ -33,11 +34,12 @@
|
|||||||
"@types/mapbox__tilebelt": "^1.0.4",
|
"@types/mapbox__tilebelt": "^1.0.4",
|
||||||
"@types/node": "^22.15.30",
|
"@types/node": "^22.15.30",
|
||||||
"@types/sanitize-html": "^2.16.0",
|
"@types/sanitize-html": "^2.16.0",
|
||||||
"@types/sortablejs": "^1.15.8",
|
"@types/sortablejs": "^1.15.9",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.33.1",
|
"@typescript-eslint/eslint-plugin": "^8.33.1",
|
||||||
"@typescript-eslint/parser": "^8.33.1",
|
"@typescript-eslint/parser": "^8.33.1",
|
||||||
"bits-ui": "^2.17.2",
|
"bits-ui": "^2.17.2",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
|
"cross-env": "^10.1.0",
|
||||||
"eslint": "^9.28.0",
|
"eslint": "^9.28.0",
|
||||||
"eslint-config-prettier": "^10.1.5",
|
"eslint-config-prettier": "^10.1.5",
|
||||||
"eslint-plugin-svelte": "^3.9.1",
|
"eslint-plugin-svelte": "^3.9.1",
|
||||||
@@ -80,6 +82,6 @@
|
|||||||
"mapillary-js": "^4.1.2",
|
"mapillary-js": "^4.1.2",
|
||||||
"maplibre-gl": "^6.15.0",
|
"maplibre-gl": "^6.15.0",
|
||||||
"sanitize-html": "^2.17.0",
|
"sanitize-html": "^2.17.0",
|
||||||
"sortablejs": "^1.15.6"
|
"sortablejs": "^1.15.7"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
@import 'tailwindcss';
|
@import 'tailwindcss';
|
||||||
@import 'tw-animate-css';
|
@import 'tw-animate-css';
|
||||||
@import "shadcn-svelte/tailwind.css";
|
@import 'shadcn-svelte/tailwind.css';
|
||||||
@import "@fontsource-variable/inter";
|
@import '@fontsource-variable/inter';
|
||||||
|
|
||||||
@custom-variant dark (&:is(.dark *));
|
@custom-variant dark (&:is(.dark *));
|
||||||
|
|
||||||
|
|||||||
Vendored
+5
@@ -8,6 +8,11 @@ declare global {
|
|||||||
// interface PageState {}
|
// interface PageState {}
|
||||||
// interface Platform {}
|
// interface Platform {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface Window {
|
||||||
|
/** The map, for extensions (set once it has loaded). */
|
||||||
|
_map?: import('maplibre-gl').Map;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export {};
|
export {};
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { base } from '$app/paths';
|
import { asset, resolve as resolvePath } from '$app/paths';
|
||||||
import { languages } from '$lib/i18n/languages';
|
import { languages } from '$lib/i18n/languages';
|
||||||
import { getURLForLanguage } from '$lib/utils';
|
import { getURLForLanguage } from '$lib/utils';
|
||||||
|
|
||||||
@@ -37,16 +37,16 @@ export async function handle({ event, resolve }) {
|
|||||||
<meta property="og:description" content="${description}" />
|
<meta property="og:description" content="${description}" />
|
||||||
<meta name="twitter:title" content="gpx.studio — ${title}" />
|
<meta name="twitter:title" content="gpx.studio — ${title}" />
|
||||||
<meta name="twitter:description" content="${description}" />
|
<meta name="twitter:description" content="${description}" />
|
||||||
<meta property="og:image" content="https://gpx.studio${base}/og_logo.png" />
|
<meta property="og:image" content="https://gpx.studio${asset('/og_logo.png')}" />
|
||||||
<meta property="og:url" content="https://gpx.studio/" />
|
<meta property="og:url" content="https://gpx.studio/" />
|
||||||
<meta property="og:type" content="website" />
|
<meta property="og:type" content="website" />
|
||||||
<meta property="og:site_name" content="gpx.studio" />
|
<meta property="og:site_name" content="gpx.studio" />
|
||||||
<meta name="twitter:card" content="summary_large_image" />
|
<meta name="twitter:card" content="summary_large_image" />
|
||||||
<meta name="twitter:image" content="https://gpx.studio${base}/og_logo.png" />
|
<meta name="twitter:image" content="https://gpx.studio${asset('/og_logo.png')}" />
|
||||||
<meta name="twitter:url" content="https://gpx.studio/" />
|
<meta name="twitter:url" content="https://gpx.studio/" />
|
||||||
<meta name="twitter:site" content="@gpxstudio" />
|
<meta name="twitter:site" content="@gpxstudio" />
|
||||||
<meta name="twitter:creator" content="@gpxstudio" />
|
<meta name="twitter:creator" content="@gpxstudio" />
|
||||||
<link rel="alternate" hreflang="x-default" href="https://gpx.studio${getURLForLanguage('en', path)}" />`;
|
<link rel="alternate" hreflang="x-default" href="https://gpx.studio${resolvePath(getURLForLanguage('en', path))}" />`;
|
||||||
|
|
||||||
// the manifests are made for the website, not for the desktop app (`npm run build:desktop`)
|
// the manifests are made for the website, not for the desktop app (`npm run build:desktop`)
|
||||||
if (process.env.BUILD_TARGET !== 'desktop') {
|
if (process.env.BUILD_TARGET !== 'desktop') {
|
||||||
@@ -56,7 +56,7 @@ export async function handle({ event, resolve }) {
|
|||||||
|
|
||||||
if (page !== '404') {
|
if (page !== '404') {
|
||||||
for (let lang of Object.keys(languages)) {
|
for (let lang of Object.keys(languages)) {
|
||||||
headTag += ` <link rel="alternate" hreflang="${lang}" href="https://gpx.studio${getURLForLanguage(lang, path)}" />
|
headTag += ` <link rel="alternate" hreflang="${lang}" href="https://gpx.studio${resolvePath(getURLForLanguage(lang, path))}" />
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
<link rel="preconnect" href="https://21XLD94PE3-dsn.algolia.net" crossorigin />
|
<link rel="preconnect" href="https://21XLD94PE3-dsn.algolia.net" crossorigin="anonymous" />
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
<div id="docsearch" class={props.class ?? ''}></div>
|
<div id="docsearch" class={props.class ?? ''}></div>
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
<Tooltip.Root>
|
<Tooltip.Root>
|
||||||
<Tooltip.Trigger>
|
<Tooltip.Trigger>
|
||||||
{#snippet child({ props })}
|
{#snippet child({ props })}
|
||||||
<Button {...props} {variant} class="bg-inherit {className}" {onclick}>
|
<Button {...props} {variant} {disabled} class="bg-inherit {className}" {onclick}>
|
||||||
{@render children()}
|
{@render children()}
|
||||||
</Button>
|
</Button>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { resolve } from '$app/paths';
|
||||||
import { Button } from '$lib/components/ui/button';
|
import { Button } from '$lib/components/ui/button';
|
||||||
import LanguageSelect from '$lib/components/LanguageSelect.svelte';
|
import LanguageSelect from '$lib/components/LanguageSelect.svelte';
|
||||||
import ModeSwitch from '$lib/components/ModeSwitch.svelte';
|
import ModeSwitch from '$lib/components/ModeSwitch.svelte';
|
||||||
@@ -31,7 +32,7 @@
|
|||||||
<Button
|
<Button
|
||||||
variant="link"
|
variant="link"
|
||||||
class="h-6 px-0 has-[>svg]:px-0 text-muted-foreground"
|
class="h-6 px-0 has-[>svg]:px-0 text-muted-foreground"
|
||||||
href={getURLForLanguage(i18n.lang, '/')}
|
href={resolve(getURLForLanguage(i18n.lang, '/'))}
|
||||||
>
|
>
|
||||||
<House size="16" />
|
<House size="16" />
|
||||||
{i18n._('homepage.home')}
|
{i18n._('homepage.home')}
|
||||||
@@ -40,7 +41,7 @@
|
|||||||
data-sveltekit-reload
|
data-sveltekit-reload
|
||||||
variant="link"
|
variant="link"
|
||||||
class="h-6 px-0 has-[>svg]:px-0 text-muted-foreground"
|
class="h-6 px-0 has-[>svg]:px-0 text-muted-foreground"
|
||||||
href={getURLForLanguage(i18n.lang, '/app')}
|
href={resolve(getURLForLanguage(i18n.lang, '/app'))}
|
||||||
>
|
>
|
||||||
<Map size="16" />
|
<Map size="16" />
|
||||||
{i18n._('homepage.app')}
|
{i18n._('homepage.app')}
|
||||||
@@ -48,7 +49,7 @@
|
|||||||
<Button
|
<Button
|
||||||
variant="link"
|
variant="link"
|
||||||
class="h-6 px-0 has-[>svg]:px-0 text-muted-foreground"
|
class="h-6 px-0 has-[>svg]:px-0 text-muted-foreground"
|
||||||
href={getURLForLanguage(i18n.lang, '/help')}
|
href={resolve(getURLForLanguage(i18n.lang, '/help'))}
|
||||||
>
|
>
|
||||||
<BookOpenText size="16" />
|
<BookOpenText size="16" />
|
||||||
{i18n._('menu.help')}
|
{i18n._('menu.help')}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
import { CircleQuestionMark } from '@lucide/svelte';
|
import { CircleQuestionMark } from '@lucide/svelte';
|
||||||
import { i18n } from '$lib/i18n/i18n.svelte';
|
import { i18n } from '$lib/i18n/i18n.svelte';
|
||||||
import type { Snippet } from 'svelte';
|
import type { Snippet } from 'svelte';
|
||||||
|
import { resolve } from '$app/paths';
|
||||||
|
|
||||||
let {
|
let {
|
||||||
link,
|
link,
|
||||||
@@ -19,7 +20,7 @@
|
|||||||
<div>
|
<div>
|
||||||
{@render children()}
|
{@render children()}
|
||||||
{#if link}
|
{#if link}
|
||||||
<a href={link} target="_blank" class="text-[13px] text-link hover:underline">
|
<a href={resolve(link)} target="_blank" class="text-[13px] text-link hover:underline">
|
||||||
{i18n._('menu.more')}
|
{i18n._('menu.more')}
|
||||||
</a>
|
</a>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { resolve } from '$app/paths';
|
||||||
import { page } from '$app/state';
|
import { page } from '$app/state';
|
||||||
import * as Select from '$lib/components/ui/select';
|
import * as Select from '$lib/components/ui/select';
|
||||||
import { languages } from '$lib/i18n/languages';
|
import { languages } from '$lib/i18n/languages';
|
||||||
@@ -15,13 +16,13 @@
|
|||||||
</span>
|
</span>
|
||||||
</Select.Trigger>
|
</Select.Trigger>
|
||||||
<Select.Content>
|
<Select.Content>
|
||||||
{#each Object.entries(languages) as [lang, label]}
|
{#each Object.entries(languages) as [lang, label] (lang)}
|
||||||
{#if page.url.pathname.includes('404')}
|
{#if page.url.pathname.includes('404')}
|
||||||
<a href={getURLForLanguage(lang, '/')}>
|
<a href={resolve(getURLForLanguage(lang, '/'))}>
|
||||||
<Select.Item value={lang}>{label}</Select.Item>
|
<Select.Item value={lang}>{label}</Select.Item>
|
||||||
</a>
|
</a>
|
||||||
{:else}
|
{:else}
|
||||||
<a href={getURLForLanguage(lang, page.url.pathname)}>
|
<a href={resolve(getURLForLanguage(lang, page.url.pathname))}>
|
||||||
<Select.Item value={lang}>{label}</Select.Item>
|
<Select.Item value={lang}>{label}</Select.Item>
|
||||||
</a>
|
</a>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { mode } from 'mode-watcher';
|
import { mode } from 'mode-watcher';
|
||||||
import { base } from '$app/paths';
|
import { asset } from '$app/paths';
|
||||||
|
|
||||||
let {
|
let {
|
||||||
iconOnly = false,
|
iconOnly = false,
|
||||||
@@ -9,13 +9,13 @@
|
|||||||
}: {
|
}: {
|
||||||
iconOnly?: boolean;
|
iconOnly?: boolean;
|
||||||
company?: 'gpx.studio' | 'github' | 'crowdin' | 'facebook' | 'reddit';
|
company?: 'gpx.studio' | 'github' | 'crowdin' | 'facebook' | 'reddit';
|
||||||
[key: string]: any;
|
[key: string]: unknown;
|
||||||
} = $props();
|
} = $props();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if company === 'gpx.studio'}
|
{#if company === 'gpx.studio'}
|
||||||
<img
|
<img
|
||||||
src="{base}/{iconOnly ? 'icon' : 'logo'}{mode.current === 'dark' ? '-dark' : ''}.svg"
|
src={asset(`/${iconOnly ? 'icon' : 'logo'}${mode.current === 'dark' ? '-dark' : ''}.svg`)}
|
||||||
alt="Logo of gpx.studio."
|
alt="Logo of gpx.studio."
|
||||||
{...others}
|
{...others}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { resolve } from '$app/paths';
|
||||||
import * as Menubar from '$lib/components/ui/menubar/index.js';
|
import * as Menubar from '$lib/components/ui/menubar/index.js';
|
||||||
import { Button } from '$lib/components/ui/button';
|
import { Button } from '$lib/components/ui/button';
|
||||||
import Logo from '$lib/components/Logo.svelte';
|
import Logo from '$lib/components/Logo.svelte';
|
||||||
@@ -148,7 +149,7 @@
|
|||||||
<div
|
<div
|
||||||
class="w-fit flex flex-row items-center justify-center p-1 bg-background rounded-b-md md:rounded-md pointer-events-auto shadow-md"
|
class="w-fit flex flex-row items-center justify-center p-1 bg-background rounded-b-md md:rounded-md pointer-events-auto shadow-md"
|
||||||
>
|
>
|
||||||
<a href={getURLForLanguage(i18n.lang, '/')} target="_blank" class="shrink-0">
|
<a href={resolve(getURLForLanguage(i18n.lang, '/'))} target="_blank" class="shrink-0">
|
||||||
<Logo class="h-5 mt-0.5 mx-2 md:hidden" iconOnly={true} width="16" />
|
<Logo class="h-5 mt-0.5 mx-2 md:hidden" iconOnly={true} width="16" />
|
||||||
<Logo class="h-5 mt-0.5 mx-2 hidden md:block" width="96" />
|
<Logo class="h-5 mt-0.5 mx-2 hidden md:block" width="96" />
|
||||||
</a>
|
</a>
|
||||||
@@ -526,8 +527,8 @@
|
|||||||
</Menubar.SubTrigger>
|
</Menubar.SubTrigger>
|
||||||
<Menubar.SubContent>
|
<Menubar.SubContent>
|
||||||
<Menubar.RadioGroup value={i18n.lang}>
|
<Menubar.RadioGroup value={i18n.lang}>
|
||||||
{#each Object.entries(languages) as [lang, label]}
|
{#each Object.entries(languages) as [lang, label] (lang)}
|
||||||
<a href={getURLForLanguage(lang, '/app')}>
|
<a href={resolve(getURLForLanguage(lang, '/app'))}>
|
||||||
<Menubar.RadioItem value={lang}>{label}</Menubar.RadioItem>
|
<Menubar.RadioItem value={lang}>{label}</Menubar.RadioItem>
|
||||||
</a>
|
</a>
|
||||||
{/each}
|
{/each}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { resolve } from '$app/paths';
|
||||||
import Logo from '$lib/components/Logo.svelte';
|
import Logo from '$lib/components/Logo.svelte';
|
||||||
import { Button } from '$lib/components/ui/button';
|
import { Button } from '$lib/components/ui/button';
|
||||||
import { BookOpenText, House, Map } from '@lucide/svelte';
|
import { BookOpenText, House, Map } from '@lucide/svelte';
|
||||||
@@ -9,7 +10,7 @@
|
|||||||
<nav class="sticky top-0 w-full px-12 py-2 bg-background z-50 flex flex-col items-center border-b">
|
<nav class="sticky top-0 w-full px-12 py-2 bg-background z-50 flex flex-col items-center border-b">
|
||||||
<div class="w-full max-w-5xl flex flex-row items-center gap-4 sm:gap-8">
|
<div class="w-full max-w-5xl flex flex-row items-center gap-4 sm:gap-8">
|
||||||
<a
|
<a
|
||||||
href={getURLForLanguage(i18n.lang, '/')}
|
href={resolve(getURLForLanguage(i18n.lang, '/'))}
|
||||||
class="shrink-0 translate-y-0.25 justify-self-start"
|
class="shrink-0 translate-y-0.25 justify-self-start"
|
||||||
>
|
>
|
||||||
<Logo class="h-8 xs:hidden" iconOnly={true} width="26" />
|
<Logo class="h-8 xs:hidden" iconOnly={true} width="26" />
|
||||||
@@ -18,7 +19,7 @@
|
|||||||
<Button
|
<Button
|
||||||
variant="link"
|
variant="link"
|
||||||
class="text-base px-0 has-[>svg]:px-0 ml-auto"
|
class="text-base px-0 has-[>svg]:px-0 ml-auto"
|
||||||
href={getURLForLanguage(i18n.lang, '/')}
|
href={resolve(getURLForLanguage(i18n.lang, '/'))}
|
||||||
>
|
>
|
||||||
<House size="18" />
|
<House size="18" />
|
||||||
{i18n._('homepage.home')}
|
{i18n._('homepage.home')}
|
||||||
@@ -27,7 +28,7 @@
|
|||||||
data-sveltekit-reload
|
data-sveltekit-reload
|
||||||
variant="link"
|
variant="link"
|
||||||
class="text-base px-0 has-[>svg]:px-0"
|
class="text-base px-0 has-[>svg]:px-0"
|
||||||
href={getURLForLanguage(i18n.lang, '/app')}
|
href={resolve(getURLForLanguage(i18n.lang, '/app'))}
|
||||||
>
|
>
|
||||||
<Map size="18" />
|
<Map size="18" />
|
||||||
{i18n._('homepage.app')}
|
{i18n._('homepage.app')}
|
||||||
@@ -35,7 +36,7 @@
|
|||||||
<Button
|
<Button
|
||||||
variant="link"
|
variant="link"
|
||||||
class="text-base px-0 has-[>svg]:px-0"
|
class="text-base px-0 has-[>svg]:px-0"
|
||||||
href={getURLForLanguage(i18n.lang, '/help')}
|
href={resolve(getURLForLanguage(i18n.lang, '/help'))}
|
||||||
>
|
>
|
||||||
<BookOpenText size="18" />
|
<BookOpenText size="18" />
|
||||||
{i18n._('menu.help')}
|
{i18n._('menu.help')}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export function getPreviousGuide(currentGuide: string): string | undefined {
|
|||||||
return `${previousGuide}/${guides[previousGuide][guides[previousGuide].length - 1]}`;
|
return `${previousGuide}/${guides[previousGuide][guides[previousGuide].length - 1]}`;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (guides.hasOwnProperty(subguides[0])) {
|
if (Object.hasOwn(guides, subguides[0])) {
|
||||||
const subguideIndex = guides[subguides[0]].indexOf(subguides[1]);
|
const subguideIndex = guides[subguides[0]].indexOf(subguides[1]);
|
||||||
if (subguideIndex > 0) {
|
if (subguideIndex > 0) {
|
||||||
return `${subguides[0]}/${guides[subguides[0]][subguideIndex - 1]}`;
|
return `${subguides[0]}/${guides[subguides[0]][subguideIndex - 1]}`;
|
||||||
@@ -56,7 +56,7 @@ export function getNextGuide(currentGuide: string): string | undefined {
|
|||||||
const subguides = currentGuide.split('/');
|
const subguides = currentGuide.split('/');
|
||||||
|
|
||||||
if (subguides.length === 1) {
|
if (subguides.length === 1) {
|
||||||
if (guides.hasOwnProperty(currentGuide)) {
|
if (Object.hasOwn(guides, currentGuide)) {
|
||||||
if (guides[currentGuide].length === 0) {
|
if (guides[currentGuide].length === 0) {
|
||||||
const keys = Object.keys(guides);
|
const keys = Object.keys(guides);
|
||||||
const index = keys.indexOf(currentGuide);
|
const index = keys.indexOf(currentGuide);
|
||||||
@@ -68,7 +68,7 @@ export function getNextGuide(currentGuide: string): string | undefined {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (guides.hasOwnProperty(subguides[0])) {
|
if (Object.hasOwn(guides, subguides[0])) {
|
||||||
const subguideIndex = guides[subguides[0]].indexOf(subguides[1]);
|
const subguideIndex = guides[subguides[0]].indexOf(subguides[1]);
|
||||||
if (subguideIndex < guides[subguides[0]].length - 1) {
|
if (subguideIndex < guides[subguides[0]].length - 1) {
|
||||||
return `${subguides[0]}/${guides[subguides[0]][subguideIndex + 1]}`;
|
return `${subguides[0]}/${guides[subguides[0]][subguideIndex + 1]}`;
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ export class ElevationProfile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
initialize() {
|
initialize() {
|
||||||
let options: ChartOptions<'line'> = {
|
const options: ChartOptions<'line'> = {
|
||||||
animation: false,
|
animation: false,
|
||||||
parsing: false,
|
parsing: false,
|
||||||
maintainAspectRatio: false,
|
maintainAspectRatio: false,
|
||||||
@@ -178,6 +178,7 @@ export class ElevationProfile {
|
|||||||
tension: 0.4,
|
tension: 0.4,
|
||||||
borderWidth: 2,
|
borderWidth: 2,
|
||||||
cubicInterpolationMode: 'monotone',
|
cubicInterpolationMode: 'monotone',
|
||||||
|
spanGaps: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
interaction: {
|
interaction: {
|
||||||
@@ -199,7 +200,7 @@ export class ElevationProfile {
|
|||||||
return '';
|
return '';
|
||||||
},
|
},
|
||||||
label: (context: TooltipItem<'line'>) => {
|
label: (context: TooltipItem<'line'>) => {
|
||||||
let point = context.raw as ElevationProfilePoint;
|
const point = context.raw as ElevationProfilePoint;
|
||||||
if (context.datasetIndex === 0) {
|
if (context.datasetIndex === 0) {
|
||||||
this._hoveredPoint.set(
|
this._hoveredPoint.set(
|
||||||
this._dragging
|
this._dragging
|
||||||
@@ -223,16 +224,18 @@ export class ElevationProfile {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
afterBody: (contexts: TooltipItem<'line'>[]) => {
|
afterBody: (contexts: TooltipItem<'line'>[]) => {
|
||||||
let context = contexts.filter((context) => context.datasetIndex === 0);
|
const context = contexts.filter(
|
||||||
|
(context) => context.datasetIndex === 0
|
||||||
|
);
|
||||||
if (context.length === 0) return;
|
if (context.length === 0) return;
|
||||||
let point = context[0].raw as ElevationProfilePoint;
|
const point = context[0].raw as ElevationProfilePoint;
|
||||||
// the rest of the data is there once it is read (see `hover`)
|
// the rest of the data is there once it is read (see `hover`)
|
||||||
const hovered = this._hovered;
|
const hovered = this._hovered;
|
||||||
const details =
|
const details =
|
||||||
hovered?.index === point.index ? hovered.point : undefined;
|
hovered?.index === point.index ? hovered.point : undefined;
|
||||||
const elevationFill = get(this._elevationFill);
|
const elevationFill = get(this._elevationFill);
|
||||||
|
|
||||||
let labels = [
|
const labels = [
|
||||||
` ${i18n._('quantities.distance')}: ${getDistanceWithUnits(point.x, false)}`,
|
` ${i18n._('quantities.distance')}: ${getDistanceWithUnits(point.x, false)}`,
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -250,10 +253,10 @@ export class ElevationProfile {
|
|||||||
}
|
}
|
||||||
labels.push(` ${i18n._('quantities.slope')}: ${slope}`);
|
labels.push(` ${i18n._('quantities.slope')}: ${slope}`);
|
||||||
}
|
}
|
||||||
let surface = details.surface ?? 'unknown';
|
const surface = details.surface ?? 'unknown';
|
||||||
let highway = details.highway ?? 'unknown';
|
const highway = details.highway ?? 'unknown';
|
||||||
let sacScale = details.sacScale;
|
const sacScale = details.sacScale;
|
||||||
let mtbScale = details.mtbScale;
|
const mtbScale = details.mtbScale;
|
||||||
|
|
||||||
if (elevationFill === 'surface') {
|
if (elevationFill === 'surface') {
|
||||||
labels.push(
|
labels.push(
|
||||||
@@ -305,7 +308,7 @@ export class ElevationProfile {
|
|||||||
enabled: true,
|
enabled: true,
|
||||||
},
|
},
|
||||||
mode: 'x',
|
mode: 'x',
|
||||||
onZoomStart: ({ chart, event }: { chart: Chart; event: any }) => {
|
onZoomStart: ({ event }: { event: any }) => {
|
||||||
if (!this._chart) {
|
if (!this._chart) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -335,7 +338,7 @@ export class ElevationProfile {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let datasets: string[] = ['speed', 'hr', 'cad', 'atemp', 'power'];
|
const datasets: string[] = ['speed', 'hr', 'cad', 'atemp', 'power'];
|
||||||
datasets.forEach((id) => {
|
datasets.forEach((id) => {
|
||||||
options.scales![`y${id}`] = {
|
options.scales![`y${id}`] = {
|
||||||
type: 'linear',
|
type: 'linear',
|
||||||
@@ -343,7 +346,8 @@ export class ElevationProfile {
|
|||||||
grid: {
|
grid: {
|
||||||
display: false,
|
display: false,
|
||||||
},
|
},
|
||||||
reverse: () => id === 'speed' && get(velocityUnits) === 'pace',
|
// the pace axis is reversed: set with the data, which the units change
|
||||||
|
reverse: false,
|
||||||
display: false,
|
display: false,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@@ -559,6 +563,8 @@ export class ElevationProfile {
|
|||||||
global.totalDistance,
|
global.totalDistance,
|
||||||
units.distance
|
units.distance
|
||||||
);
|
);
|
||||||
|
// a faster pace is a lower value, it goes up like a higher speed
|
||||||
|
this._chart.options.scales!.yspeed!.reverse = units.velocity === 'pace';
|
||||||
|
|
||||||
this.setVisibility();
|
this.setVisibility();
|
||||||
this.setFill();
|
this.setFill();
|
||||||
@@ -580,11 +586,11 @@ export class ElevationProfile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const additionalDatasets = get(this._additionalDatasets);
|
const additionalDatasets = get(this._additionalDatasets);
|
||||||
let includeSpeed = additionalDatasets.includes('speed');
|
const includeSpeed = additionalDatasets.includes('speed');
|
||||||
let includeHeartRate = additionalDatasets.includes('hr');
|
const includeHeartRate = additionalDatasets.includes('hr');
|
||||||
let includeCadence = additionalDatasets.includes('cad');
|
const includeCadence = additionalDatasets.includes('cad');
|
||||||
let includeTemperature = additionalDatasets.includes('atemp');
|
const includeTemperature = additionalDatasets.includes('atemp');
|
||||||
let includePower = additionalDatasets.includes('power');
|
const includePower = additionalDatasets.includes('power');
|
||||||
if (this._chart.data.datasets.length == 6) {
|
if (this._chart.data.datasets.length == 6) {
|
||||||
this._chart.data.datasets[1].hidden = !includeSpeed;
|
this._chart.data.datasets[1].hidden = !includeSpeed;
|
||||||
this._chart.data.datasets[2].hidden = !includeHeartRate;
|
this._chart.data.datasets[2].hidden = !includeHeartRate;
|
||||||
@@ -639,21 +645,21 @@ export class ElevationProfile {
|
|||||||
|
|
||||||
const slicedStatistics = get(this._slicedStatistics);
|
const slicedStatistics = get(this._slicedStatistics);
|
||||||
if (slicedStatistics) {
|
if (slicedStatistics) {
|
||||||
let startIndex = slicedStatistics.start;
|
const startIndex = slicedStatistics.start;
|
||||||
let endIndex = slicedStatistics.end;
|
const endIndex = slicedStatistics.end;
|
||||||
|
|
||||||
// Draw selection rectangle
|
// Draw selection rectangle
|
||||||
let selectionContext = this._overlay.getContext('2d');
|
const selectionContext = this._overlay.getContext('2d');
|
||||||
if (selectionContext) {
|
if (selectionContext) {
|
||||||
selectionContext.fillStyle = mode.current === 'dark' ? 'white' : 'black';
|
selectionContext.fillStyle = mode.current === 'dark' ? 'white' : 'black';
|
||||||
selectionContext.globalAlpha = mode.current === 'dark' ? 0.2 : 0.1;
|
selectionContext.globalAlpha = mode.current === 'dark' ? 0.2 : 0.1;
|
||||||
selectionContext.clearRect(0, 0, this._overlay.width, this._overlay.height);
|
selectionContext.clearRect(0, 0, this._overlay.width, this._overlay.height);
|
||||||
|
|
||||||
const statistics = get(this._statistics);
|
const statistics = get(this._statistics);
|
||||||
let startPixel = this._chart.scales.x.getPixelForValue(
|
const startPixel = this._chart.scales.x.getPixelForValue(
|
||||||
getConvertedDistance(statistics.totalDistance[startIndex] ?? 0)
|
getConvertedDistance(statistics.totalDistance[startIndex] ?? 0)
|
||||||
);
|
);
|
||||||
let endPixel = this._chart.scales.x.getPixelForValue(
|
const endPixel = this._chart.scales.x.getPixelForValue(
|
||||||
getConvertedDistance(statistics.totalDistance[endIndex] ?? 0)
|
getConvertedDistance(statistics.totalDistance[endIndex] ?? 0)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -665,7 +671,7 @@ export class ElevationProfile {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else if (this._overlay) {
|
} else if (this._overlay) {
|
||||||
let selectionContext = this._overlay.getContext('2d');
|
const selectionContext = this._overlay.getContext('2d');
|
||||||
if (selectionContext) {
|
if (selectionContext) {
|
||||||
selectionContext.clearRect(0, 0, this._overlay.width, this._overlay.height);
|
selectionContext.clearRect(0, 0, this._overlay.width, this._overlay.height);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,9 +25,10 @@
|
|||||||
import { PUBLIC_MAPTILER_KEY } from '$env/static/public';
|
import { PUBLIC_MAPTILER_KEY } from '$env/static/public';
|
||||||
import Embedding from './Embedding.svelte';
|
import Embedding from './Embedding.svelte';
|
||||||
import { onDestroy } from 'svelte';
|
import { onDestroy } from 'svelte';
|
||||||
import { base } from '$app/paths';
|
import { resolve } from '$app/paths';
|
||||||
import { map } from '$lib/components/map/map';
|
import { map } from '$lib/components/map/map';
|
||||||
import { mode } from 'mode-watcher';
|
import { mode } from 'mode-watcher';
|
||||||
|
import { getURLForLanguage } from '$lib/utils';
|
||||||
|
|
||||||
let options = $state(
|
let options = $state(
|
||||||
getMergedEmbeddingOptions(
|
getMergedEmbeddingOptions(
|
||||||
@@ -114,7 +115,7 @@
|
|||||||
{i18n._(`layers.label.${options.basemap}`)}
|
{i18n._(`layers.label.${options.basemap}`)}
|
||||||
</Select.Trigger>
|
</Select.Trigger>
|
||||||
<Select.Content class="max-h-60 overflow-y-scroll">
|
<Select.Content class="max-h-60 overflow-y-scroll">
|
||||||
{#each allowedEmbeddingBasemaps as basemap}
|
{#each allowedEmbeddingBasemaps as basemap (basemap)}
|
||||||
<Select.Item value={basemap}
|
<Select.Item value={basemap}
|
||||||
>{i18n._(`layers.label.${basemap}`)}</Select.Item
|
>{i18n._(`layers.label.${basemap}`)}</Select.Item
|
||||||
>
|
>
|
||||||
@@ -321,7 +322,7 @@
|
|||||||
<pre
|
<pre
|
||||||
class="bg-primary text-primary-foreground p-3 rounded-md whitespace-normal break-all">
|
class="bg-primary text-primary-foreground p-3 rounded-md whitespace-normal break-all">
|
||||||
<code class="language-html">
|
<code class="language-html">
|
||||||
{`<iframe src="https://gpx.studio${base}/embed?options=${encodeURIComponent(JSON.stringify(getCleanedEmbeddingOptions(iframeOptions)))}${hash}" width="100%" height="600px" frameborder="0" style="outline: none;"/>`}
|
{`<iframe src="https://gpx.studio${resolve(getURLForLanguage(i18n.lang, '/embed'))}?options=${encodeURIComponent(JSON.stringify(getCleanedEmbeddingOptions(iframeOptions)))}${hash}" width="100%" height="600px" frameborder="0" style="outline: none;"/>`}
|
||||||
</code>
|
</code>
|
||||||
</pre>
|
</pre>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { resolve } from '$app/paths';
|
||||||
import { Button } from '$lib/components/ui/button';
|
import { Button } from '$lib/components/ui/button';
|
||||||
import Logo from '$lib/components/Logo.svelte';
|
import Logo from '$lib/components/Logo.svelte';
|
||||||
import { getURLForLanguage } from '$lib/utils';
|
import { getURLForLanguage } from '$lib/utils';
|
||||||
@@ -16,7 +17,7 @@
|
|||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
class="absolute top-0 flex-wrap h-fit bg-background font-semibold rounded-md py-1 px-2 gap-1.5 xs:text-base mt-2.5 ml-2.5 mr-12"
|
class="absolute top-0 flex-wrap h-fit bg-background font-semibold rounded-md py-1 px-2 gap-1.5 xs:text-base mt-2.5 ml-2.5 mr-12"
|
||||||
href="{getURLForLanguage(i18n.lang, '/app')}?{files.length > 0
|
href="{resolve(getURLForLanguage(i18n.lang, '/app'))}?{files.length > 0
|
||||||
? `files=${encodeURIComponent(JSON.stringify(files))}`
|
? `files=${encodeURIComponent(JSON.stringify(files))}`
|
||||||
: ''}{files.length > 0 && ids.length > 0 ? '&' : ''}{ids.length > 0
|
: ''}{files.length > 0 && ids.length > 0 ? '&' : ''}{ids.length > 0
|
||||||
? `ids=${encodeURIComponent(JSON.stringify(ids))}`
|
? `ids=${encodeURIComponent(JSON.stringify(ids))}`
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ export function getURLForGoogleDriveFile(fileId: string): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function convertOldEmbeddingOptions(options: URLSearchParams): any {
|
export function convertOldEmbeddingOptions(options: URLSearchParams): any {
|
||||||
let newOptions: any = {
|
const newOptions: any = {
|
||||||
key: PUBLIC_MAPTILER_KEY,
|
key: PUBLIC_MAPTILER_KEY,
|
||||||
files: [],
|
files: [],
|
||||||
ids: [],
|
ids: [],
|
||||||
@@ -128,7 +128,7 @@ export function convertOldEmbeddingOptions(options: URLSearchParams): any {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (options.has('source')) {
|
if (options.has('source')) {
|
||||||
let basemap = options.get('source')!;
|
const basemap = options.get('source')!;
|
||||||
if (basemap === 'satellite') {
|
if (basemap === 'satellite') {
|
||||||
newOptions.basemap = 'libertySatellite';
|
newOptions.basemap = 'libertySatellite';
|
||||||
} else if (basemap === 'otm') {
|
} else if (basemap === 'otm') {
|
||||||
|
|||||||
@@ -132,7 +132,6 @@
|
|||||||
<div class="flex flex-col h-full">
|
<div class="flex flex-col h-full">
|
||||||
<div class="px-2 py-1 text-sm font-semibold shrink-0">{i18n._('menu.explorer')}</div>
|
<div class="px-2 py-1 text-sm font-semibold shrink-0">{i18n._('menu.explorer')}</div>
|
||||||
<ScrollArea class="grow min-h-0">
|
<ScrollArea class="grow min-h-0">
|
||||||
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
|
|
||||||
<div
|
<div
|
||||||
bind:this={container}
|
bind:this={container}
|
||||||
data-explorer
|
data-explorer
|
||||||
|
|||||||
@@ -121,7 +121,6 @@
|
|||||||
let isCut = $derived($clipboard?.cut === true && isInClipboard($clipboard, node));
|
let isCut = $derived($clipboard?.cut === true && isInClipboard($clipboard, node));
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
||||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||||
<ContextMenu.Root
|
<ContextMenu.Root
|
||||||
onOpenChange={(open) => {
|
onOpenChange={(open) => {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
</AlertDialog.Description>
|
</AlertDialog.Description>
|
||||||
</AlertDialog.Header>
|
</AlertDialog.Header>
|
||||||
<ul class="list-disc pl-6 text-sm max-h-40 overflow-y-auto">
|
<ul class="list-disc pl-6 text-sm max-h-40 overflow-y-auto">
|
||||||
{#each prompt.names as name}
|
{#each prompt.names as name, i (i)}
|
||||||
<li>{name}</li>
|
<li>{name}</li>
|
||||||
{/each}
|
{/each}
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { isMac } from '$lib/utils';
|
import { isMac } from '$lib/utils';
|
||||||
import Sortable, { type Direction } from 'sortablejs/Sortable';
|
import Sortable from './sortable';
|
||||||
|
import type { Direction } from 'sortablejs';
|
||||||
import { get, writable } from 'svelte/store';
|
import { get, writable } from 'svelte/store';
|
||||||
import { tick } from 'svelte';
|
import { tick } from 'svelte';
|
||||||
import { engine, type MoveTarget, type Selection } from '$lib/engine';
|
import { engine, type MoveTarget, type Selection } from '$lib/engine';
|
||||||
@@ -78,9 +79,13 @@ export class SortableFileList {
|
|||||||
setTimeout(() => this.updateToSelection(e), 50),
|
setTimeout(() => this.updateToSelection(e), 50),
|
||||||
onDeselect: (e: Sortable.SortableEvent) =>
|
onDeselect: (e: Sortable.SortableEvent) =>
|
||||||
setTimeout(() => this.updateToSelection(e), 50),
|
setTimeout(() => this.updateToSelection(e), 50),
|
||||||
onStart: (e: Sortable.SortableEvent) => {
|
onChoose: () => {
|
||||||
// all the nodes, not only the elements: the comments are the anchors of the Svelte blocks
|
// all the nodes, not only the elements: the comments are the anchors of the Svelte
|
||||||
|
// blocks. Taken before the drag starts, when MultiDrag removes the other selected
|
||||||
|
// elements from the list.
|
||||||
this._snapshot = Array.from(container.childNodes);
|
this._snapshot = Array.from(container.childNodes);
|
||||||
|
},
|
||||||
|
onStart: (e: Sortable.SortableEvent) => {
|
||||||
dragging.set(sortableLevel);
|
dragging.set(sortableLevel);
|
||||||
// the files that are dragged (or whose elements are) are open for good
|
// the files that are dragged (or whose elements are) are open for good
|
||||||
engine.keepPreview(this.draggedFiles(e));
|
engine.keepPreview(this.draggedFiles(e));
|
||||||
@@ -241,9 +246,9 @@ export class SortableFileList {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const selection_ = get(engine.selection);
|
const selection_ = get(engine.selection);
|
||||||
for (let id of changed) {
|
for (const id of changed) {
|
||||||
let element = this._elements[id];
|
const element = this._elements[id];
|
||||||
let node = this.childNode(id);
|
const node = this.childNode(id);
|
||||||
if (element && node) {
|
if (element && node) {
|
||||||
if (isSelected(selection_, node)) {
|
if (isSelected(selection_, node)) {
|
||||||
Sortable.utils.select(element);
|
Sortable.utils.select(element);
|
||||||
@@ -258,7 +263,7 @@ export class SortableFileList {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateToSelection(e: Sortable.SortableEvent) {
|
updateToSelection(e: Sortable.SortableEvent & { originalEvent?: MouseEvent }) {
|
||||||
if (!this._sortable) return;
|
if (!this._sortable) return;
|
||||||
if (this._updatingSelection || this._applying) return;
|
if (this._updatingSelection || this._applying) return;
|
||||||
this._updatingSelection = true;
|
this._updatingSelection = true;
|
||||||
@@ -344,7 +349,7 @@ export class SortableFileList {
|
|||||||
const files = get(engine.files);
|
const files = get(engine.files);
|
||||||
this._container.childNodes.forEach((element) => {
|
this._container.childNodes.forEach((element) => {
|
||||||
if (element instanceof HTMLElement) {
|
if (element instanceof HTMLElement) {
|
||||||
let attr = element.getAttribute('data-id');
|
const attr = element.getAttribute('data-id');
|
||||||
if (attr) {
|
if (attr) {
|
||||||
if (this._sortableLevel === 'file' && !files.has(attr)) {
|
if (this._sortableLevel === 'file' && !files.has(attr)) {
|
||||||
this.forget(element);
|
this.forget(element);
|
||||||
@@ -392,12 +397,12 @@ export class SortableFileList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getChangedIds() {
|
getChangedIds() {
|
||||||
let changed: string[] = [];
|
const changed: string[] = [];
|
||||||
const selection_ = get(engine.selection);
|
const selection_ = get(engine.selection);
|
||||||
Object.entries(this._elements).forEach(([id, element]) => {
|
Object.entries(this._elements).forEach(([id, element]) => {
|
||||||
const node = this.childNode(id);
|
const node = this.childNode(id);
|
||||||
let inSelection = node !== undefined && isSelected(selection_, node);
|
const inSelection = node !== undefined && isSelected(selection_, node);
|
||||||
let isSelectedInList = element.classList.contains('sortable-selected');
|
const isSelectedInList = element.classList.contains('sortable-selected');
|
||||||
if (inSelection !== isSelectedInList) {
|
if (inSelection !== isSelectedInList) {
|
||||||
changed.push(id);
|
changed.push(id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import Sortable, { MultiDrag } from 'sortablejs';
|
||||||
|
|
||||||
|
// The ESM build leaves out the MultiDrag plugin. Mounting it twice throws, so it is done here
|
||||||
|
// rather than in a module that hot reloading runs again.
|
||||||
|
Sortable.mount(new MultiDrag());
|
||||||
|
|
||||||
|
export default Sortable;
|
||||||
@@ -48,7 +48,7 @@
|
|||||||
<Card.Title class="text-md">
|
<Card.Title class="text-md">
|
||||||
{@const link = waypoint.item.links?.[0]}
|
{@const link = waypoint.item.links?.[0]}
|
||||||
{#if link?.href}
|
{#if link?.href}
|
||||||
<a href={link.href} target="_blank">
|
<a href={link.href} target="_blank" rel="external">
|
||||||
{waypoint.item.name ?? link.href}
|
{waypoint.item.name ?? link.href}
|
||||||
<ExternalLink size="12" class="inline-block mb-1.5" />
|
<ExternalLink size="12" class="inline-block mb-1.5" />
|
||||||
</a>
|
</a>
|
||||||
@@ -77,9 +77,11 @@
|
|||||||
</div>
|
</div>
|
||||||
<ScrollArea class="flex flex-col max-h-[30dvh]">
|
<ScrollArea class="flex flex-col max-h-[30dvh]">
|
||||||
{#if waypoint.item.desc}
|
{#if waypoint.item.desc}
|
||||||
|
<!-- eslint-disable-next-line svelte/no-at-html-tags -- sanitized -->
|
||||||
<span class="whitespace-pre-wrap">{@html sanitize(waypoint.item.desc)}</span>
|
<span class="whitespace-pre-wrap">{@html sanitize(waypoint.item.desc)}</span>
|
||||||
{/if}
|
{/if}
|
||||||
{#if waypoint.item.cmt && waypoint.item.cmt !== waypoint.item.desc}
|
{#if waypoint.item.cmt && waypoint.item.cmt !== waypoint.item.desc}
|
||||||
|
<!-- eslint-disable-next-line svelte/no-at-html-tags -- sanitized -->
|
||||||
<span class="whitespace-pre-wrap">{@html sanitize(waypoint.item.cmt)}</span>
|
<span class="whitespace-pre-wrap">{@html sanitize(waypoint.item.cmt)}</span>
|
||||||
{/if}
|
{/if}
|
||||||
</ScrollArea>
|
</ScrollArea>
|
||||||
|
|||||||
@@ -35,7 +35,8 @@ export class DistanceMarkers {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (get(distanceMarkers) && !get(allHidden)) {
|
if (get(distanceMarkers) && !get(allHidden)) {
|
||||||
let distanceSource: GeoJSONSource | undefined = map_.getSource('distance-markers');
|
const distanceSource: GeoJSONSource | undefined =
|
||||||
|
map_.getSource('distance-markers');
|
||||||
if (distanceSource) {
|
if (distanceSource) {
|
||||||
distanceSource.setData(this.getDistanceMarkersGeoJSON());
|
distanceSource.setData(this.getDistanceMarkersGeoJSON());
|
||||||
} else {
|
} else {
|
||||||
@@ -90,7 +91,7 @@ export class DistanceMarkers {
|
|||||||
map_.removeLayer('distance-markers');
|
map_.removeLayer('distance-markers');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch {
|
||||||
// No reliable way to check if the map is ready to add sources and layers
|
// No reliable way to check if the map is ready to add sources and layers
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -104,12 +105,12 @@ export class DistanceMarkers {
|
|||||||
// the distance from the start of the selection, and the position, of each trackpoint
|
// the distance from the start of the selection, and the position, of each trackpoint
|
||||||
const { length, totalDistance, lng, lat } = get(engine.statistics);
|
const { length, totalDistance, lng, lat } = get(engine.statistics);
|
||||||
|
|
||||||
let features: GeoJSON.Feature[] = [];
|
const features: GeoJSON.Feature[] = [];
|
||||||
let currentTargetDistance = 1;
|
let currentTargetDistance = 1;
|
||||||
for (let i = 0; i < length; i++) {
|
for (let i = 0; i < length; i++) {
|
||||||
if (totalDistance[i] >= getConvertedDistanceToKilometers(currentTargetDistance)) {
|
if (totalDistance[i] >= getConvertedDistanceToKilometers(currentTargetDistance)) {
|
||||||
let distance = currentTargetDistance.toFixed(0);
|
const distance = currentTargetDistance.toFixed(0);
|
||||||
let level = levels.find((level) => currentTargetDistance % level === 0) || 1;
|
const level = levels.find((level) => currentTargetDistance % level === 0) || 1;
|
||||||
features.push({
|
features.push({
|
||||||
type: 'Feature',
|
type: 'Feature',
|
||||||
geometry: {
|
geometry: {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import { mapCursor, MapCursorState } from '$lib/state/map-cursor';
|
|||||||
import { ANCHOR_LAYER_KEY } from '$lib/components/map/style';
|
import { ANCHOR_LAYER_KEY } from '$lib/components/map/style';
|
||||||
|
|
||||||
export function getSvgForSymbol(symbol?: string | undefined, layerColor?: string | undefined) {
|
export function getSvgForSymbol(symbol?: string | undefined, layerColor?: string | undefined) {
|
||||||
let symbolSvg = symbol ? symbols[symbol]?.iconSvg : undefined;
|
const symbolSvg = symbol ? symbols[symbol]?.iconSvg : undefined;
|
||||||
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
||||||
${
|
${
|
||||||
layerColor
|
layerColor
|
||||||
@@ -63,12 +63,12 @@ export class GPXLayer {
|
|||||||
currentWaypointData: GeoJSON.FeatureCollection | null = null;
|
currentWaypointData: GeoJSON.FeatureCollection | null = null;
|
||||||
draggedWaypointIndex: number | null = null;
|
draggedWaypointIndex: number | null = null;
|
||||||
draggingStartingPosition: Point = new Point(0, 0);
|
draggingStartingPosition: Point = new Point(0, 0);
|
||||||
unsubscribe: Function[] = [];
|
unsubscribe: (() => void)[] = [];
|
||||||
|
|
||||||
updateBinded: () => void = this.update.bind(this);
|
updateBinded: () => void = this.update.bind(this);
|
||||||
layerOnMouseEnterBinded: (e: any) => void = this.layerOnMouseEnter.bind(this);
|
layerOnMouseEnterBinded: (e: MapLayerMouseEvent) => void = this.layerOnMouseEnter.bind(this);
|
||||||
layerOnMouseLeaveBinded: () => void = this.layerOnMouseLeave.bind(this);
|
layerOnMouseLeaveBinded: () => void = this.layerOnMouseLeave.bind(this);
|
||||||
layerOnMouseMoveBinded: (e: any) => void = this.layerOnMouseMove.bind(this);
|
layerOnMouseMoveBinded: (e: MapLayerMouseEvent) => void = this.layerOnMouseMove.bind(this);
|
||||||
layerOnClickBinded: (e: MapLayerMouseEvent) => void = this.layerOnClick.bind(this);
|
layerOnClickBinded: (e: MapLayerMouseEvent) => void = this.layerOnClick.bind(this);
|
||||||
layerOnContextMenuBinded: (e: MapLayerMouseEvent) => void = this.layerOnContextMenu.bind(this);
|
layerOnContextMenuBinded: (e: MapLayerMouseEvent) => void = this.layerOnContextMenu.bind(this);
|
||||||
waypointLayerOnMouseEnterBinded: (e: MapLayerMouseEvent) => void =
|
waypointLayerOnMouseEnterBinded: (e: MapLayerMouseEvent) => void =
|
||||||
@@ -101,7 +101,7 @@ export class GPXLayer {
|
|||||||
this.unsubscribe.push(
|
this.unsubscribe.push(
|
||||||
engine.selection.subscribe(($selection) => {
|
engine.selection.subscribe(($selection) => {
|
||||||
this.selectionState = $selection;
|
this.selectionState = $selection;
|
||||||
let newSelected = hasSelectionWithin($selection, this.fileNode());
|
const newSelected = hasSelectionWithin($selection, this.fileNode());
|
||||||
if (this.selected || newSelected) {
|
if (this.selected || newSelected) {
|
||||||
this.selected = newSelected;
|
this.selected = newSelected;
|
||||||
this.update();
|
this.update();
|
||||||
@@ -146,7 +146,7 @@ export class GPXLayer {
|
|||||||
this.loadIcons();
|
this.loadIcons();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let source = _map.getSource(this.fileId) as GeoJSONSource | undefined;
|
const source = _map.getSource(this.fileId) as GeoJSONSource | undefined;
|
||||||
if (source) {
|
if (source) {
|
||||||
source.setData(this.getGeoJSON());
|
source.setData(this.getGeoJSON());
|
||||||
} else {
|
} else {
|
||||||
@@ -234,7 +234,7 @@ export class GPXLayer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let waypointSource = _map.getSource(this.fileId + '-waypoints') as
|
const waypointSource = _map.getSource(this.fileId + '-waypoints') as
|
||||||
| GeoJSONSource
|
| GeoJSONSource
|
||||||
| undefined;
|
| undefined;
|
||||||
this.currentWaypointData = this.getWaypointsGeoJSON();
|
this.currentWaypointData = this.getWaypointsGeoJSON();
|
||||||
@@ -301,7 +301,7 @@ export class GPXLayer {
|
|||||||
['in', ['get', 'waypointIndex'], ['literal', visibleWaypoints]],
|
['in', ['get', 'waypointIndex'], ['literal', visibleWaypoints]],
|
||||||
{ validate: false }
|
{ validate: false }
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch {
|
||||||
// No reliable way to check if the map is ready to add sources and layers
|
// No reliable way to check if the map is ready to add sources and layers
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -386,10 +386,10 @@ export class GPXLayer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
layerOnMouseEnter(e: any) {
|
layerOnMouseEnter(e: MapLayerMouseEvent) {
|
||||||
if (
|
if (
|
||||||
get(currentTool) === Tool.SCISSORS &&
|
get(currentTool) === Tool.SCISSORS &&
|
||||||
isCovered(this.selectionState, this.segmentNode(e.features[0].properties))
|
isCovered(this.selectionState, this.segmentNode(e.features![0].properties))
|
||||||
) {
|
) {
|
||||||
mapCursor.notify(MapCursorState.SCISSORS, true);
|
mapCursor.notify(MapCursorState.SCISSORS, true);
|
||||||
} else {
|
} else {
|
||||||
@@ -402,9 +402,9 @@ export class GPXLayer {
|
|||||||
mapCursor.notify(MapCursorState.LAYER_HOVER, false);
|
mapCursor.notify(MapCursorState.LAYER_HOVER, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
async layerOnMouseMove(e: any) {
|
async layerOnMouseMove(e: MapLayerMouseEvent) {
|
||||||
if (e.originalEvent.shiftKey) {
|
if (e.originalEvent.shiftKey) {
|
||||||
const { segmentId } = e.features[0].properties;
|
const { segmentId } = e.features![0].properties;
|
||||||
const lngLat = { lng: e.lngLat.lng, lat: e.lngLat.lat };
|
const lngLat = { lng: e.lngLat.lng, lat: e.lngLat.lat };
|
||||||
const index = closestPointIndex(await engine.segmentCoordinates(segmentId), lngLat);
|
const index = closestPointIndex(await engine.segmentCoordinates(segmentId), lngLat);
|
||||||
const trackpoint =
|
const trackpoint =
|
||||||
@@ -469,7 +469,7 @@ export class GPXLayer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
layerOnContextMenu(e: any) {
|
layerOnContextMenu(e: MapLayerMouseEvent) {
|
||||||
if (e.originalEvent.ctrlKey) {
|
if (e.originalEvent.ctrlKey) {
|
||||||
this.layerOnClick(e);
|
this.layerOnClick(e);
|
||||||
}
|
}
|
||||||
@@ -584,7 +584,7 @@ export class GPXLayer {
|
|||||||
this.currentWaypointData!.features[this.draggedWaypointIndex].geometry as GeoJSON.Point
|
this.currentWaypointData!.features[this.draggedWaypointIndex].geometry as GeoJSON.Point
|
||||||
).coordinates = [e.lngLat.lng, e.lngLat.lat];
|
).coordinates = [e.lngLat.lng, e.lngLat.lat];
|
||||||
|
|
||||||
let waypointSource = get(map)?.getSource(this.fileId + '-waypoints') as
|
const waypointSource = get(map)?.getSource(this.fileId + '-waypoints') as
|
||||||
| GeoJSONSource
|
| GeoJSONSource
|
||||||
| undefined;
|
| undefined;
|
||||||
if (waypointSource) {
|
if (waypointSource) {
|
||||||
@@ -698,7 +698,7 @@ export class GPXLayer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let symbols = new Set<string | undefined>();
|
const symbols = new Set<string | undefined>();
|
||||||
get(this.file).waypoints.features.forEach((feature) => {
|
get(this.file).waypoints.features.forEach((feature) => {
|
||||||
symbols.add(getSymbolKey(feature.properties.sym));
|
symbols.add(getSymbolKey(feature.properties.sym));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ export class StartEndMarkers {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let source = map_.getSource('start-end-markers') as GeoJSONSource | undefined;
|
const source = map_.getSource('start-end-markers') as GeoJSONSource | undefined;
|
||||||
if (source) {
|
if (source) {
|
||||||
source.setData(data);
|
source.setData(data);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
Layers2,
|
Layers2,
|
||||||
} from '@lucide/svelte';
|
} from '@lucide/svelte';
|
||||||
import { i18n } from '$lib/i18n/i18n.svelte';
|
import { i18n } from '$lib/i18n/i18n.svelte';
|
||||||
import { defaultBasemap, type CustomLayer } from '$lib/data/layers';
|
import { defaultBasemap, layerGroup, type CustomLayer } from '$lib/data/layers';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import { remove } from './utils';
|
import { remove } from './utils';
|
||||||
import { settings } from '$lib/state/settings';
|
import { settings } from '$lib/state/settings';
|
||||||
@@ -128,15 +128,16 @@
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
addLayer(layerId);
|
|
||||||
$customLayers[layerId] = layer;
|
$customLayers[layerId] = layer;
|
||||||
|
addLayer(layerId);
|
||||||
selectedLayerId = undefined;
|
selectedLayerId = undefined;
|
||||||
setDataFromSelectedLayer();
|
setDataFromSelectedLayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLayerId() {
|
function getLayerId() {
|
||||||
for (let id = 0; ; id++) {
|
for (let id = 0; ; id++) {
|
||||||
if (!$customLayers.hasOwnProperty(`custom-${id}`)) {
|
if (!Object.hasOwn($customLayers, `custom-${id}`)) {
|
||||||
return `custom-${id}`;
|
return `custom-${id}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -145,7 +146,7 @@
|
|||||||
function addLayer(layerId: string) {
|
function addLayer(layerId: string) {
|
||||||
if (layerType === 'basemap') {
|
if (layerType === 'basemap') {
|
||||||
selectedBasemapTree.update(($tree) => {
|
selectedBasemapTree.update(($tree) => {
|
||||||
if (!$tree.basemaps.hasOwnProperty('custom')) {
|
if (!Object.hasOwn($tree.basemaps, 'custom')) {
|
||||||
$tree.basemaps['custom'] = {};
|
$tree.basemaps['custom'] = {};
|
||||||
}
|
}
|
||||||
$tree.basemaps['custom'][layerId] = true;
|
$tree.basemaps['custom'][layerId] = true;
|
||||||
@@ -161,7 +162,7 @@
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
selectedOverlayTree.update(($tree) => {
|
selectedOverlayTree.update(($tree) => {
|
||||||
if (!$tree.overlays.hasOwnProperty('custom')) {
|
if (!Object.hasOwn($tree.overlays, 'custom')) {
|
||||||
$tree.overlays['custom'] = {};
|
$tree.overlays['custom'] = {};
|
||||||
}
|
}
|
||||||
$tree.overlays['custom'][layerId] = true;
|
$tree.overlays['custom'][layerId] = true;
|
||||||
@@ -169,7 +170,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
currentOverlays.update(($overlays) => {
|
currentOverlays.update(($overlays) => {
|
||||||
if (!$overlays.overlays.hasOwnProperty('custom')) {
|
if (!Object.hasOwn($overlays.overlays, 'custom')) {
|
||||||
$overlays.overlays['custom'] = {};
|
$overlays.overlays['custom'] = {};
|
||||||
}
|
}
|
||||||
$overlays.overlays['custom'][layerId] = true;
|
$overlays.overlays['custom'][layerId] = true;
|
||||||
@@ -182,8 +183,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function tryDeleteLayer(node: any, id: string): any {
|
function tryDeleteLayer<T>(node: Record<string, T>, id: string): Record<string, T> {
|
||||||
if (node.hasOwnProperty(id)) {
|
if (Object.hasOwn(node, id)) {
|
||||||
delete node[id];
|
delete node[id];
|
||||||
}
|
}
|
||||||
return node;
|
return node;
|
||||||
@@ -255,13 +256,12 @@
|
|||||||
onfinalize={(e) => {
|
onfinalize={(e) => {
|
||||||
customBasemapItems = e.detail.items;
|
customBasemapItems = e.detail.items;
|
||||||
$customBasemapOrder = customBasemapItems.map((item) => item.id);
|
$customBasemapOrder = customBasemapItems.map((item) => item.id);
|
||||||
$selectedBasemapTree.basemaps['custom'] = customBasemapItems.reduce(
|
selectedBasemapTree.update(($tree) => {
|
||||||
(acc, item) => {
|
layerGroup($tree.basemaps)['custom'] = Object.fromEntries(
|
||||||
acc[item.id] = true;
|
customBasemapItems.map((item) => [item.id, true])
|
||||||
return acc;
|
|
||||||
},
|
|
||||||
{}
|
|
||||||
);
|
);
|
||||||
|
return $tree;
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{#each customBasemapItems as item (item.id)}
|
{#each customBasemapItems as item (item.id)}
|
||||||
@@ -315,13 +315,12 @@
|
|||||||
onfinalize={(e) => {
|
onfinalize={(e) => {
|
||||||
customOverlayItems = e.detail.items;
|
customOverlayItems = e.detail.items;
|
||||||
$customOverlayOrder = customOverlayItems.map((item) => item.id);
|
$customOverlayOrder = customOverlayItems.map((item) => item.id);
|
||||||
$selectedOverlayTree.overlays['custom'] = customOverlayItems.reduce(
|
selectedOverlayTree.update(($tree) => {
|
||||||
(acc, item) => {
|
layerGroup($tree.overlays)['custom'] = Object.fromEntries(
|
||||||
acc[item.id] = true;
|
customOverlayItems.map((item) => [item.id, true])
|
||||||
return acc;
|
|
||||||
},
|
|
||||||
{}
|
|
||||||
);
|
);
|
||||||
|
return $tree;
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{#each customOverlayItems as item (item.id)}
|
{#each customOverlayItems as item (item.id)}
|
||||||
@@ -365,7 +364,7 @@
|
|||||||
<Label for="name">{i18n._('menu.metadata.name')}</Label>
|
<Label for="name">{i18n._('menu.metadata.name')}</Label>
|
||||||
<Input bind:value={name} id="name" class="h-8" />
|
<Input bind:value={name} id="name" class="h-8" />
|
||||||
<Label for="url">{i18n._('layers.custom_layers.urls')}</Label>
|
<Label for="url">{i18n._('layers.custom_layers.urls')}</Label>
|
||||||
{#each tileUrls as url, i}
|
{#each tileUrls as _, i (i)}
|
||||||
<div class="flex flex-row gap-2">
|
<div class="flex flex-row gap-2">
|
||||||
<Input
|
<Input
|
||||||
bind:value={tileUrls[i]}
|
bind:value={tileUrls[i]}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
|
|
||||||
function setOpacityFromSelection() {
|
function setOpacityFromSelection() {
|
||||||
if (selectedOverlay) {
|
if (selectedOverlay) {
|
||||||
if ($opacities.hasOwnProperty(selectedOverlay)) {
|
if (Object.hasOwn($opacities, selectedOverlay)) {
|
||||||
overlayOpacity = $opacities[selectedOverlay];
|
overlayOpacity = $opacities[selectedOverlay];
|
||||||
} else {
|
} else {
|
||||||
overlayOpacity = 1;
|
overlayOpacity = 1;
|
||||||
@@ -169,7 +169,7 @@
|
|||||||
{#if isSelected($selectedOverlayTree, selectedOverlay)}
|
{#if isSelected($selectedOverlayTree, selectedOverlay)}
|
||||||
{#if $isLayerFromExtension(selectedOverlay)}
|
{#if $isLayerFromExtension(selectedOverlay)}
|
||||||
{$getLayerName(selectedOverlay)}
|
{$getLayerName(selectedOverlay)}
|
||||||
{:else if $customLayers.hasOwnProperty(selectedOverlay)}
|
{:else if Object.hasOwn($customLayers, selectedOverlay)}
|
||||||
{$customLayers[selectedOverlay].name}
|
{$customLayers[selectedOverlay].name}
|
||||||
{:else}
|
{:else}
|
||||||
{i18n._(`layers.label.${selectedOverlay}`)}
|
{i18n._(`layers.label.${selectedOverlay}`)}
|
||||||
@@ -178,7 +178,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</Select.Trigger>
|
</Select.Trigger>
|
||||||
<Select.Content class="h-fit max-h-[40dvh] overflow-y-auto">
|
<Select.Content class="h-fit max-h-[40dvh] overflow-y-auto">
|
||||||
{#each Object.keys(overlays) as id}
|
{#each Object.keys(overlays) as id (id)}
|
||||||
{#if isSelected($selectedOverlayTree, id)}
|
{#if isSelected($selectedOverlayTree, id)}
|
||||||
<Select.Item value={id}>
|
<Select.Item value={id}>
|
||||||
{#if $isLayerFromExtension(id)}
|
{#if $isLayerFromExtension(id)}
|
||||||
@@ -189,7 +189,7 @@
|
|||||||
</Select.Item>
|
</Select.Item>
|
||||||
{/if}
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
{#each Object.entries($customLayers) as [id, layer]}
|
{#each Object.entries($customLayers) as [id, layer] (id)}
|
||||||
{#if layer.layerType === 'overlay'}
|
{#if layer.layerType === 'overlay'}
|
||||||
<Select.Item value={id}>{layer.name}</Select.Item>
|
<Select.Item value={id}>{layer.name}</Select.Item>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -218,7 +218,7 @@
|
|||||||
if ($map.getLayer(selectedOverlay)) {
|
if ($map.getLayer(selectedOverlay)) {
|
||||||
$map.removeLayer(selectedOverlay);
|
$map.removeLayer(selectedOverlay);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch {
|
||||||
// No reliable way to check if the map is ready to remove sources and layers
|
// No reliable way to check if the map is ready to remove sources and layers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -247,7 +247,7 @@
|
|||||||
{i18n._(`layers.label.${$terrainSource}`)}
|
{i18n._(`layers.label.${$terrainSource}`)}
|
||||||
</Select.Trigger>
|
</Select.Trigger>
|
||||||
<Select.Content class="h-fit max-h-[40dvh] overflow-y-auto">
|
<Select.Content class="h-fit max-h-[40dvh] overflow-y-auto">
|
||||||
{#each Object.keys(terrainSources) as id}
|
{#each Object.keys(terrainSources) as id (id)}
|
||||||
<Select.Item value={id}>
|
<Select.Item value={id}>
|
||||||
{i18n._(`layers.label.${id}`)}
|
{i18n._(`layers.label.${id}`)}
|
||||||
</Select.Item>
|
</Select.Item>
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
selected?: string;
|
selected?: string;
|
||||||
onselect?: (value: string) => void;
|
onselect?: (value: string) => void;
|
||||||
multiple: boolean;
|
multiple: boolean;
|
||||||
checked: LayerTreeType;
|
checked?: LayerTreeType;
|
||||||
} = $props();
|
} = $props();
|
||||||
|
|
||||||
const { customLayers } = settings;
|
const { customLayers } = settings;
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
$effect.pre(() => {
|
$effect.pre(() => {
|
||||||
if (checked !== undefined) {
|
if (checked !== undefined) {
|
||||||
Object.keys(node).forEach((id) => {
|
Object.keys(node).forEach((id) => {
|
||||||
if (!checked.hasOwnProperty(id)) {
|
if (!Object.hasOwn(checked, id)) {
|
||||||
if (typeof node[id] == 'boolean') {
|
if (typeof node[id] == 'boolean') {
|
||||||
checked[id] = false;
|
checked[id] = false;
|
||||||
} else {
|
} else {
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex flex-col gap-[3px]">
|
<div class="flex flex-col gap-[3px]">
|
||||||
{#each Object.keys(node) as id}
|
{#each Object.keys(node) as id (id)}
|
||||||
{#if typeof node[id] == 'boolean'}
|
{#if typeof node[id] == 'boolean'}
|
||||||
{#if node[id]}
|
{#if node[id]}
|
||||||
<div class="flex flex-row items-center gap-2 first:mt-0.5 h-4">
|
<div class="flex flex-row items-center gap-2 first:mt-0.5 h-4">
|
||||||
@@ -53,7 +53,9 @@
|
|||||||
id="{name}-{id}"
|
id="{name}-{id}"
|
||||||
{name}
|
{name}
|
||||||
value={id}
|
value={id}
|
||||||
bind:checked={checked[id]}
|
bind:checked={
|
||||||
|
() => checked[id] === true, (value) => (checked[id] = value)
|
||||||
|
}
|
||||||
class="scale-90"
|
class="scale-90"
|
||||||
aria-label={i18n._(`layers.label.${id}`)}
|
aria-label={i18n._(`layers.label.${id}`)}
|
||||||
/>
|
/>
|
||||||
@@ -72,7 +74,7 @@
|
|||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
<Label for="{name}-{id}" class="flex flex-row items-center gap-1">
|
<Label for="{name}-{id}" class="flex flex-row items-center gap-1">
|
||||||
{#if $customLayers.hasOwnProperty(id)}
|
{#if Object.hasOwn($customLayers, id)}
|
||||||
{$customLayers[id].name}
|
{$customLayers[id].name}
|
||||||
{:else if $isLayerFromExtension(id)}
|
{:else if $isLayerFromExtension(id)}
|
||||||
{$getLayerName(id)}
|
{$getLayerName(id)}
|
||||||
@@ -90,12 +92,18 @@
|
|||||||
{#snippet content()}
|
{#snippet content()}
|
||||||
<div class="ml-2">
|
<div class="ml-2">
|
||||||
<Self
|
<Self
|
||||||
node={node[id]}
|
node={node[id] as LayerTreeType}
|
||||||
{name}
|
{name}
|
||||||
{selected}
|
{selected}
|
||||||
{onselect}
|
{onselect}
|
||||||
{multiple}
|
{multiple}
|
||||||
bind:checked={checked[id]}
|
bind:checked={
|
||||||
|
() => {
|
||||||
|
const group = checked[id];
|
||||||
|
return typeof group === 'object' ? group : undefined;
|
||||||
|
},
|
||||||
|
(value) => (checked[id] = value ?? {})
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
|
|||||||
@@ -79,11 +79,16 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<div class="grid grid-cols-[auto_auto] gap-x-3">
|
<div class="grid grid-cols-[auto_auto] gap-x-3">
|
||||||
{#each Object.entries(tags) as [key, value]}
|
{#each Object.entries(tags) as [key, value] (key)}
|
||||||
{#if key !== 'name' && !key.includes('image')}
|
{#if key !== 'name' && !key.includes('image')}
|
||||||
<span class="font-mono">{key}</span>
|
<span class="font-mono">{key}</span>
|
||||||
{#if key === 'website' || key.startsWith('website:') || key.endsWith(':website') || key === 'contact:facebook' || key === 'contact:instagram' || key === 'contact:twitter'}
|
{#if key === 'website' || key.startsWith('website:') || key.endsWith(':website') || key === 'contact:facebook' || key === 'contact:instagram' || key === 'contact:twitter'}
|
||||||
<a href={value} target="_blank" class="text-link underline">{value}</a>
|
<a
|
||||||
|
href={value}
|
||||||
|
target="_blank"
|
||||||
|
rel="external"
|
||||||
|
class="text-link underline">{value}</a
|
||||||
|
>
|
||||||
{:else if key === 'wikipedia' || key.startsWith('wikipedia:') || key.endsWith(':wikipedia')}
|
{:else if key === 'wikipedia' || key.startsWith('wikipedia:') || key.endsWith(':wikipedia')}
|
||||||
<a
|
<a
|
||||||
href="https://wikipedia.org/wiki/{value}"
|
href="https://wikipedia.org/wiki/{value}"
|
||||||
|
|||||||
@@ -9,6 +9,15 @@ import { ExtensionAPI, type CustomOverlay } from './extension-api';
|
|||||||
import { isSelected } from './utils';
|
import { isSelected } from './utils';
|
||||||
|
|
||||||
const original = { set: engine.setSetting, delete: engine.deleteSetting };
|
const original = { set: engine.setSetting, delete: engine.deleteSetting };
|
||||||
|
|
||||||
|
/** The raster source that an overlay added by an extension uses. */
|
||||||
|
function rasterSource(id: string) {
|
||||||
|
const style = overlays[id];
|
||||||
|
assert.ok(typeof style === 'object');
|
||||||
|
const source = style.sources[id];
|
||||||
|
assert.ok(source?.type === 'raster');
|
||||||
|
return source;
|
||||||
|
}
|
||||||
const overlayTreeBefore = JSON.stringify(overlayTree);
|
const overlayTreeBefore = JSON.stringify(overlayTree);
|
||||||
const overlayIdsBefore = Object.keys(overlays).sort();
|
const overlayIdsBefore = Object.keys(overlays).sort();
|
||||||
|
|
||||||
@@ -45,10 +54,7 @@ describe('ExtensionAPI', () => {
|
|||||||
it('adds an overlay as a layer, in the tree of its extension', () => {
|
it('adds an overlay as a layer, in the tree of its extension', () => {
|
||||||
api.addOrUpdateOverlay(overlay('one'));
|
api.addOrUpdateOverlay(overlay('one'));
|
||||||
|
|
||||||
const layer = overlays['extension-one'];
|
const source = rasterSource('extension-one');
|
||||||
assert.ok(layer && typeof layer === 'object');
|
|
||||||
const source = (layer as any).sources['extension-one'];
|
|
||||||
assert.equal(source.type, 'raster');
|
|
||||||
assert.deepEqual(source.tiles, ['https://tiles.example.com/one/{z}/{x}/{y}.png']);
|
assert.deepEqual(source.tiles, ['https://tiles.example.com/one/{z}/{x}/{y}.png']);
|
||||||
assert.equal(source.tileSize, 256);
|
assert.equal(source.tileSize, 256);
|
||||||
assert.equal(source.maxzoom, 22);
|
assert.equal(source.maxzoom, 22);
|
||||||
@@ -69,7 +75,7 @@ describe('ExtensionAPI', () => {
|
|||||||
tileUrls: ['https://tiles.example.com/512/{z}/{x}/{y}.png'],
|
tileUrls: ['https://tiles.example.com/512/{z}/{x}/{y}.png'],
|
||||||
maxZoom: 15,
|
maxZoom: 15,
|
||||||
});
|
});
|
||||||
const source = (overlays['extension-big'] as any).sources['extension-big'];
|
const source = rasterSource('extension-big');
|
||||||
assert.equal(source.tileSize, 512);
|
assert.equal(source.tileSize, 512);
|
||||||
assert.equal(source.maxzoom, 15);
|
assert.equal(source.maxzoom, 15);
|
||||||
});
|
});
|
||||||
@@ -100,9 +106,7 @@ describe('ExtensionAPI', () => {
|
|||||||
tileUrls: ['https://other/{z}'],
|
tileUrls: ['https://other/{z}'],
|
||||||
});
|
});
|
||||||
assert.equal(get(api.getLayerName)('extension-one'), 'Renamed');
|
assert.equal(get(api.getLayerName)('extension-one'), 'Renamed');
|
||||||
assert.deepEqual((overlays['extension-one'] as any).sources['extension-one'].tiles, [
|
assert.deepEqual(rasterSource('extension-one').tiles, ['https://other/{z}']);
|
||||||
'https://other/{z}',
|
|
||||||
]);
|
|
||||||
assert.equal(isSelected(get(settings.currentOverlays)!, 'extension-one'), true);
|
assert.equal(isSelected(get(settings.currentOverlays)!, 'extension-one'), true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { settings } from '$lib/state/settings';
|
import { settings } from '$lib/state/settings';
|
||||||
import { derived, get, writable, type Writable } from 'svelte/store';
|
import { derived, get, writable, type Writable } from 'svelte/store';
|
||||||
import { isSelected, remove, removeAll } from './utils';
|
import { isSelected, remove, removeAll } from './utils';
|
||||||
import { overlays, overlayTree } from '$lib/data/layers';
|
import { layerGroup, overlays, overlayTree, type LayerTreeType } from '$lib/data/layers';
|
||||||
import { browser } from '$app/environment';
|
import { browser } from '$app/environment';
|
||||||
import { map } from '$lib/components/map/map';
|
import { map } from '$lib/components/map/map';
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ export class ExtensionAPI {
|
|||||||
private _overlays: Writable<Map<string, CustomOverlay>> = writable(new Map());
|
private _overlays: Writable<Map<string, CustomOverlay>> = writable(new Map());
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
if (browser && !window.hasOwnProperty('gpxstudio')) {
|
if (browser && !Object.hasOwn(window, 'gpxstudio')) {
|
||||||
Object.defineProperty(window, 'gpxstudio', {
|
Object.defineProperty(window, 'gpxstudio', {
|
||||||
value: this,
|
value: this,
|
||||||
});
|
});
|
||||||
@@ -84,14 +84,15 @@ export class ExtensionAPI {
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!overlayTree.overlays.hasOwnProperty(overlay.extensionName)) {
|
const extensions = layerGroup(overlayTree.overlays);
|
||||||
overlayTree.overlays[overlay.extensionName] = {};
|
if (!Object.hasOwn(extensions, overlay.extensionName)) {
|
||||||
|
extensions[overlay.extensionName] = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
overlayTree.overlays[overlay.extensionName][overlay.id] = true;
|
layerGroup(extensions[overlay.extensionName])[overlay.id] = true;
|
||||||
|
|
||||||
selectedOverlayTree.update((selected) => {
|
selectedOverlayTree.update((selected) => {
|
||||||
if (!selected.overlays.hasOwnProperty(overlay.extensionName)) {
|
if (!Object.hasOwn(selected.overlays, overlay.extensionName)) {
|
||||||
selected.overlays[overlay.extensionName] = {};
|
selected.overlays[overlay.extensionName] = {};
|
||||||
}
|
}
|
||||||
selected.overlays[overlay.extensionName][overlay.id] = true;
|
selected.overlays[overlay.extensionName][overlay.id] = true;
|
||||||
@@ -104,13 +105,13 @@ export class ExtensionAPI {
|
|||||||
show = true;
|
show = true;
|
||||||
try {
|
try {
|
||||||
get(map)?.removeLayer(overlay.id);
|
get(map)?.removeLayer(overlay.id);
|
||||||
} catch (e) {
|
} catch {
|
||||||
// No reliable way to check if the map is ready to remove sources and layers
|
// No reliable way to check if the map is ready to remove sources and layers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
currentOverlays.update((current) => {
|
currentOverlays.update((current) => {
|
||||||
if (!current.overlays.hasOwnProperty(overlay.extensionName)) {
|
if (!Object.hasOwn(current.overlays, overlay.extensionName)) {
|
||||||
current.overlays[overlay.extensionName] = {};
|
current.overlays[overlay.extensionName] = {};
|
||||||
}
|
}
|
||||||
current.overlays[overlay.extensionName][overlay.id] = show;
|
current.overlays[overlay.extensionName][overlay.id] = show;
|
||||||
@@ -155,13 +156,13 @@ export class ExtensionAPI {
|
|||||||
updateOverlaysOrder(ids: string[]) {
|
updateOverlaysOrder(ids: string[]) {
|
||||||
ids = ids.map((id) => this.getOverlayId(id));
|
ids = ids.map((id) => this.getOverlayId(id));
|
||||||
selectedOverlayTree.update((selected) => {
|
selectedOverlayTree.update((selected) => {
|
||||||
let isSelected: Record<string, boolean> = {};
|
const isSelected: Record<string, boolean> = {};
|
||||||
ids.forEach((id) => {
|
ids.forEach((id) => {
|
||||||
const overlay = get(this._overlays).get(id);
|
const overlay = get(this._overlays).get(id);
|
||||||
if (
|
if (
|
||||||
overlay &&
|
overlay &&
|
||||||
selected.overlays.hasOwnProperty(overlay.extensionName) &&
|
Object.hasOwn(selected.overlays, overlay.extensionName) &&
|
||||||
selected.overlays[overlay.extensionName].hasOwnProperty(id)
|
Object.hasOwn(selected.overlays[overlay.extensionName] as LayerTreeType, id)
|
||||||
) {
|
) {
|
||||||
isSelected[id] = selected.overlays[overlay.extensionName][id];
|
isSelected[id] = selected.overlays[overlay.extensionName][id];
|
||||||
delete selected.overlays[overlay.extensionName][id];
|
delete selected.overlays[overlay.extensionName][id];
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { get, writable } from 'svelte/store';
|
|||||||
import { overpassQueryData } from '$lib/data/layers';
|
import { overpassQueryData } from '$lib/data/layers';
|
||||||
import { MapPopup } from '$lib/components/map/map-popup';
|
import { MapPopup } from '$lib/components/map/map-popup';
|
||||||
import { settings } from '$lib/state/settings';
|
import { settings } from '$lib/state/settings';
|
||||||
import type { GeoJSONSource, Map as MapLibreMap } from 'maplibre-gl';
|
import type { GeoJSONSource, MapLayerMouseEvent, Map as MapLibreMap } from 'maplibre-gl';
|
||||||
import { ANCHOR_LAYER_KEY } from '$lib/components/map/style';
|
import { ANCHOR_LAYER_KEY } from '$lib/components/map/style';
|
||||||
import type { MapLayerEventManager } from '$lib/components/map/map-layer-event-manager';
|
import type { MapLayerEventManager } from '$lib/components/map/map-layer-event-manager';
|
||||||
import { loadSVGIcon } from '$lib/utils';
|
import { loadSVGIcon } from '$lib/utils';
|
||||||
@@ -86,7 +86,7 @@ export class OverpassLayer {
|
|||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let source = this.map.getSource('overpass') as GeoJSONSource | undefined;
|
const source = this.map.getSource('overpass') as GeoJSONSource | undefined;
|
||||||
if (source) {
|
if (source) {
|
||||||
source.setData(d);
|
source.setData(d);
|
||||||
} else {
|
} else {
|
||||||
@@ -115,7 +115,7 @@ export class OverpassLayer {
|
|||||||
this.layerEventManager.on('mouseenter', 'overpass', this.onHoverBinded);
|
this.layerEventManager.on('mouseenter', 'overpass', this.onHoverBinded);
|
||||||
this.layerEventManager.on('click', 'overpass', this.onHoverBinded);
|
this.layerEventManager.on('click', 'overpass', this.onHoverBinded);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch {
|
||||||
// No reliable way to check if the map is ready to add sources and layers
|
// No reliable way to check if the map is ready to add sources and layers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -135,28 +135,28 @@ export class OverpassLayer {
|
|||||||
if (this.map.getSource('overpass')) {
|
if (this.map.getSource('overpass')) {
|
||||||
this.map.removeSource('overpass');
|
this.map.removeSource('overpass');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch {
|
||||||
// No reliable way to check if the map is ready to remove sources and layers
|
// No reliable way to check if the map is ready to remove sources and layers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onHover(e: any) {
|
onHover(e: MapLayerMouseEvent) {
|
||||||
this.popup.setItem({
|
this.popup.setItem({
|
||||||
kind: 'overpass',
|
kind: 'overpass',
|
||||||
item: {
|
item: {
|
||||||
...e.features[0].properties,
|
...e.features![0].properties,
|
||||||
sym: overpassQueryData[e.features[0].properties.query].symbol ?? '',
|
sym: overpassQueryData[e.features![0].properties.query].symbol ?? '',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
query(bbox: [number, number, number, number]) {
|
query(bbox: [number, number, number, number]) {
|
||||||
let queries = getCurrentQueries();
|
const queries = getCurrentQueries();
|
||||||
if (queries.length === 0) {
|
if (queries.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let tileLimits = mercator.xyz(bbox, this.queryZoom);
|
const tileLimits = mercator.xyz(bbox, this.queryZoom);
|
||||||
|
|
||||||
for (let x = tileLimits.minX; x <= tileLimits.maxX; x++) {
|
for (let x = tileLimits.minX; x <= tileLimits.maxX; x++) {
|
||||||
for (let y = tileLimits.minY; y <= tileLimits.maxY; y++) {
|
for (let y = tileLimits.minY; y <= tileLimits.maxY; y++) {
|
||||||
@@ -189,8 +189,8 @@ export class OverpassLayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.data.update((updatedData) => {
|
this.data.update((updatedData) => {
|
||||||
for (let element of data.elements) {
|
for (const element of data.elements) {
|
||||||
for (let query of queries) {
|
for (const query of queries) {
|
||||||
if (belongsToQuery(element, query)) {
|
if (belongsToQuery(element, query)) {
|
||||||
updatedData.features.push({
|
updatedData.features.push({
|
||||||
type: 'Feature',
|
type: 'Feature',
|
||||||
@@ -224,7 +224,7 @@ export class OverpassLayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
loadIcons() {
|
loadIcons() {
|
||||||
let currentQueries = getCurrentQueries();
|
const currentQueries = getCurrentQueries();
|
||||||
currentQueries.forEach((query) => {
|
currentQueries.forEach((query) => {
|
||||||
loadSVGIcon(
|
loadSVGIcon(
|
||||||
this.map,
|
this.map,
|
||||||
@@ -257,7 +257,7 @@ function getQuery(query: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getQueryItem(tags: Record<string, string | string[]>) {
|
function getQueryItem(tags: Record<string, string | string[]>) {
|
||||||
let arrayEntry = Object.entries(tags).find((entry): entry is [string, string[]] =>
|
const arrayEntry = Object.entries(tags).find((entry): entry is [string, string[]] =>
|
||||||
Array.isArray(entry[1])
|
Array.isArray(entry[1])
|
||||||
);
|
);
|
||||||
if (arrayEntry !== undefined) {
|
if (arrayEntry !== undefined) {
|
||||||
@@ -291,12 +291,12 @@ function belongsToQueryItem(element: any, tags: Record<string, string | string[]
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getCurrentQueries() {
|
function getCurrentQueries() {
|
||||||
let currentQueries = get(currentOverpassQueries);
|
const currentQueries = get(currentOverpassQueries);
|
||||||
if (currentQueries === undefined) {
|
if (currentQueries === undefined) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return Object.entries(getLayers(currentQueries))
|
return Object.entries(getLayers(currentQueries))
|
||||||
.filter(([_, selected]) => selected)
|
.filter(([, selected]) => selected)
|
||||||
.map(([query, _]) => query);
|
.map(([query]) => query);
|
||||||
}
|
}
|
||||||
@@ -235,7 +235,7 @@ export class MapLayerEventManager {
|
|||||||
|
|
||||||
private _filterLayersIntersectingBounds(layerIds: string[], bounds: LngLatBounds): string[] {
|
private _filterLayersIntersectingBounds(layerIds: string[], bounds: LngLatBounds): string[] {
|
||||||
const files = get(engine.files);
|
const files = get(engine.files);
|
||||||
let result = layerIds.filter((layerId) => {
|
const result = layerIds.filter((layerId) => {
|
||||||
if (!this._map.getLayer(layerId)) return false;
|
if (!this._map.getLayer(layerId)) return false;
|
||||||
const fileId = layerId.replace('-waypoints', '');
|
const fileId = layerId.replace('-waypoints', '');
|
||||||
if (fileId === layerId) {
|
if (fileId === layerId) {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import { MapLayerEventManager } from '$lib/components/map/map-layer-event-manage
|
|||||||
|
|
||||||
const { treeFileView, elevationProfile, bottomPanelSize, rightPanelSize, distanceUnits } = settings;
|
const { treeFileView, elevationProfile, bottomPanelSize, rightPanelSize, distanceUnits } = settings;
|
||||||
|
|
||||||
let fitBoundsOptions: maplibregl.MapOptions['fitBoundsOptions'] = {
|
const fitBoundsOptions: maplibregl.MapOptions['fitBoundsOptions'] = {
|
||||||
maxZoom: 15,
|
maxZoom: 15,
|
||||||
linear: true,
|
linear: true,
|
||||||
easing: () => 1,
|
easing: () => 1,
|
||||||
@@ -75,7 +75,7 @@ export class MapLibreGLMap {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
if (geocoder) {
|
if (geocoder) {
|
||||||
let geocoder = new MaplibreGeocoder(
|
const geocoder = new MaplibreGeocoder(
|
||||||
{
|
{
|
||||||
forwardGeocode: async (config) => {
|
forwardGeocode: async (config) => {
|
||||||
const results: MaplibreGeocoderFeatureResults = {
|
const results: MaplibreGeocoderFeatureResults = {
|
||||||
@@ -85,18 +85,26 @@ export class MapLibreGLMap {
|
|||||||
try {
|
try {
|
||||||
const request = `https://nominatim.openstreetmap.org/search?format=json&q=${config.query}&limit=5&accept-language=${language}`;
|
const request = `https://nominatim.openstreetmap.org/search?format=json&q=${config.query}&limit=5&accept-language=${language}`;
|
||||||
const response = await fetch(request);
|
const response = await fetch(request);
|
||||||
const geojson = await response.json();
|
const places: {
|
||||||
results.features = geojson.map((result: any) => {
|
lat: string;
|
||||||
|
lon: string;
|
||||||
|
type: string;
|
||||||
|
display_name: string;
|
||||||
|
}[] = await response.json();
|
||||||
|
results.features = places.map((result) => {
|
||||||
return {
|
return {
|
||||||
type: 'Feature',
|
type: 'Feature',
|
||||||
geometry: {
|
geometry: {
|
||||||
type: 'Point',
|
type: 'Point',
|
||||||
coordinates: [result.lon, result.lat],
|
coordinates: [Number(result.lon), Number(result.lat)],
|
||||||
},
|
},
|
||||||
|
properties: {},
|
||||||
|
text: result.display_name,
|
||||||
place_name: result.display_name,
|
place_name: result.display_name,
|
||||||
|
place_type: [result.type],
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
} catch (e) {}
|
} catch {}
|
||||||
return results;
|
return results;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import {
|
|||||||
type MapLayerMouseEvent,
|
type MapLayerMouseEvent,
|
||||||
type VectorSourceSpecification,
|
type VectorSourceSpecification,
|
||||||
} from 'maplibre-gl';
|
} from 'maplibre-gl';
|
||||||
import { Viewer, type ViewerBearingEvent } from 'mapillary-js/dist/mapillary.module';
|
import { Viewer, type ViewerBearingEvent } from 'mapillary-js';
|
||||||
import 'mapillary-js/dist/mapillary.css';
|
import 'mapillary-js/dist/mapillary.css';
|
||||||
import { mapCursor, MapCursorState } from '$lib/state/map-cursor';
|
import { mapCursor, MapCursorState } from '$lib/state/map-cursor';
|
||||||
import { ANCHOR_LAYER_KEY } from '$lib/components/map/style';
|
import { ANCHOR_LAYER_KEY } from '$lib/components/map/style';
|
||||||
@@ -89,7 +89,7 @@ export class MapillaryLayer {
|
|||||||
this.viewer.on('position', async () => {
|
this.viewer.on('position', async () => {
|
||||||
if (this.active) {
|
if (this.active) {
|
||||||
popupOpen.value = true;
|
popupOpen.value = true;
|
||||||
let latLng = await this.viewer.getPosition();
|
const latLng = await this.viewer.getPosition();
|
||||||
this.marker.setLngLat(latLng).addTo(this.map);
|
this.marker.setLngLat(latLng).addTo(this.map);
|
||||||
if (!this.map.getBounds()?.contains(latLng)) {
|
if (!this.map.getBounds()?.contains(latLng)) {
|
||||||
this.map.panTo(latLng);
|
this.map.panTo(latLng);
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ export class StyleManager {
|
|||||||
updateBasemap() {
|
updateBasemap() {
|
||||||
const map_ = get(this._map);
|
const map_ = get(this._map);
|
||||||
if (!map_) return;
|
if (!map_) return;
|
||||||
let basemap = get(currentBasemap);
|
const basemap = get(currentBasemap);
|
||||||
this.buildStyle(basemap).then((style) => {
|
this.buildStyle(basemap).then((style) => {
|
||||||
if (get(currentBasemap) === basemap) map_.setStyle(style);
|
if (get(currentBasemap) === basemap) map_.setStyle(style);
|
||||||
});
|
});
|
||||||
@@ -125,7 +125,7 @@ export class StyleManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e.message);
|
console.error(e instanceof Error ? e.message : e);
|
||||||
}
|
}
|
||||||
this.merge(style, basemapStyle);
|
this.merge(style, basemapStyle);
|
||||||
style.sky ??= sky;
|
style.sky ??= sky;
|
||||||
@@ -148,18 +148,18 @@ export class StyleManager {
|
|||||||
const overlayOpacities = get(opacities);
|
const overlayOpacities = get(opacities);
|
||||||
try {
|
try {
|
||||||
const layers = getLayers(get(currentOverlays) ?? {});
|
const layers = getLayers(get(currentOverlays) ?? {});
|
||||||
for (let overlay in layers) {
|
for (const overlay in layers) {
|
||||||
if (!layers[overlay]) {
|
if (!layers[overlay]) {
|
||||||
if (this._pastOverlays.has(overlay)) {
|
if (this._pastOverlays.has(overlay)) {
|
||||||
const overlayInfo = custom[overlay]?.value ?? overlays[overlay];
|
const overlayInfo = custom[overlay]?.value ?? overlays[overlay];
|
||||||
try {
|
try {
|
||||||
const overlayStyle = await this.get(overlayInfo);
|
const overlayStyle = await this.get(overlayInfo);
|
||||||
for (let layer of overlayStyle.layers ?? []) {
|
for (const layer of overlayStyle.layers ?? []) {
|
||||||
if (map_.getLayer(layer.id)) {
|
if (map_.getLayer(layer.id)) {
|
||||||
map_.removeLayer(layer.id);
|
map_.removeLayer(layer.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch {
|
||||||
// Should not happen
|
// Should not happen
|
||||||
}
|
}
|
||||||
this._pastOverlays.delete(overlay);
|
this._pastOverlays.delete(overlay);
|
||||||
@@ -170,13 +170,13 @@ export class StyleManager {
|
|||||||
const overlayStyle = await this.get(overlayInfo);
|
const overlayStyle = await this.get(overlayInfo);
|
||||||
const opacity = overlayOpacities[overlay];
|
const opacity = overlayOpacities[overlay];
|
||||||
|
|
||||||
for (let sourceId in overlayStyle.sources) {
|
for (const sourceId in overlayStyle.sources) {
|
||||||
if (!map_.getSource(sourceId)) {
|
if (!map_.getSource(sourceId)) {
|
||||||
map_.addSource(sourceId, overlayStyle.sources[sourceId]);
|
map_.addSource(sourceId, overlayStyle.sources[sourceId]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let layer of overlayStyle.layers ?? []) {
|
for (const layer of overlayStyle.layers ?? []) {
|
||||||
if (!map_.getLayer(layer.id)) {
|
if (!map_.getLayer(layer.id)) {
|
||||||
if (opacity !== undefined) {
|
if (opacity !== undefined) {
|
||||||
if (layer.type === 'raster') {
|
if (layer.type === 'raster') {
|
||||||
@@ -196,11 +196,11 @@ export class StyleManager {
|
|||||||
}
|
}
|
||||||
this._pastOverlays.add(overlay);
|
this._pastOverlays.add(overlay);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e.message);
|
console.error(e instanceof Error ? e.message : e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTerrain() {
|
updateTerrain() {
|
||||||
@@ -223,7 +223,7 @@ export class StyleManager {
|
|||||||
|
|
||||||
async get(styleInfo: StyleSpecification | string): Promise<StyleSpecification> {
|
async get(styleInfo: StyleSpecification | string): Promise<StyleSpecification> {
|
||||||
if (typeof styleInfo === 'string') {
|
if (typeof styleInfo === 'string') {
|
||||||
let styleUrl = styleInfo as string;
|
const styleUrl = styleInfo as string;
|
||||||
const response = await fetch(styleUrl, { cache: 'force-cache' });
|
const response = await fetch(styleUrl, { cache: 'force-cache' });
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(`HTTP error fetching style "${styleInfo}": ${response.status}`);
|
throw new Error(`HTTP error fetching style "${styleInfo}": ${response.status}`);
|
||||||
@@ -238,7 +238,7 @@ export class StyleManager {
|
|||||||
merge(style: StyleSpecification, other: StyleSpecification) {
|
merge(style: StyleSpecification, other: StyleSpecification) {
|
||||||
style.sources = { ...style.sources, ...other.sources };
|
style.sources = { ...style.sources, ...other.sources };
|
||||||
const units = get(distanceUnits);
|
const units = get(distanceUnits);
|
||||||
for (let layer of other.layers ?? []) {
|
for (const layer of other.layers ?? []) {
|
||||||
if ('source' in layer) {
|
if ('source' in layer) {
|
||||||
if (layer.source == 'contours_m' && units === 'imperial') continue;
|
if (layer.source == 'contours_m' && units === 'imperial') continue;
|
||||||
if (layer.source == 'contours_ft' && units !== 'imperial') continue;
|
if (layer.source == 'contours_ft' && units !== 'imperial') continue;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
import { getURLForLanguage } from '$lib/utils';
|
import { getURLForLanguage } from '$lib/utils';
|
||||||
import { Trash2 } from '@lucide/svelte';
|
import { Trash2 } from '@lucide/svelte';
|
||||||
import { map } from '$lib/components/map/map';
|
import { map } from '$lib/components/map/map';
|
||||||
import type { GeoJSONSource, LngLat } from 'maplibre-gl';
|
import type { GeoJSONSource, LngLat, MapMouseEvent, MapTouchEvent } from 'maplibre-gl';
|
||||||
import { engine } from '$lib/engine';
|
import { engine } from '$lib/engine';
|
||||||
import { mapCursor, MapCursorState } from '$lib/state/map-cursor';
|
import { mapCursor, MapCursorState } from '$lib/state/map-cursor';
|
||||||
import { ANCHOR_LAYER_KEY } from '$lib/components/map/style';
|
import { ANCHOR_LAYER_KEY } from '$lib/components/map/style';
|
||||||
@@ -81,18 +81,18 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
let mousedown = false;
|
let mousedown = false;
|
||||||
function onMouseDown(e: any) {
|
function onMouseDown(e: MapMouseEvent | MapTouchEvent) {
|
||||||
mousedown = true;
|
mousedown = true;
|
||||||
rectangleCoordinates = [e.lngLat, e.lngLat];
|
rectangleCoordinates = [e.lngLat, e.lngLat];
|
||||||
}
|
}
|
||||||
|
|
||||||
function onMouseMove(e: any) {
|
function onMouseMove(e: MapMouseEvent | MapTouchEvent) {
|
||||||
if (mousedown) {
|
if (mousedown) {
|
||||||
rectangleCoordinates[1] = e.lngLat;
|
rectangleCoordinates[1] = e.lngLat;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onMouseUp(e: any) {
|
function onMouseUp() {
|
||||||
mousedown = false;
|
mousedown = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { Popup } from 'maplibre-gl';
|
import type { MapMouseEvent, Popup } from 'maplibre-gl';
|
||||||
import * as Select from '$lib/components/ui/select';
|
import * as Select from '$lib/components/ui/select';
|
||||||
import { Switch } from '$lib/components/ui/switch';
|
import { Switch } from '$lib/components/ui/switch';
|
||||||
import { Label } from '$lib/components/ui/label/index.js';
|
import { Label } from '$lib/components/ui/label/index.js';
|
||||||
@@ -58,7 +58,7 @@
|
|||||||
// the tool works on files, routes, tracks and segments, not on waypoints
|
// the tool works on files, routes, tracks and segments, not on waypoints
|
||||||
let validSelection = $derived(coversSegments($selection));
|
let validSelection = $derived(coversSegments($selection));
|
||||||
|
|
||||||
function createFileWithPoint(e: any) {
|
function createFileWithPoint(e: MapMouseEvent) {
|
||||||
if ($selection.type === 'empty') {
|
if ($selection.type === 'empty') {
|
||||||
// the engine selects the new file, which starts with the trackpoint: one undo step
|
// the engine selects the new file, which starts with the trackpoint: one undo step
|
||||||
engine.newFile(newFileName(), { lng: e.lngLat.lng, lat: e.lngLat.lat });
|
engine.newFile(newFileName(), { lng: e.lngLat.lng, lat: e.lngLat.lat });
|
||||||
@@ -130,7 +130,7 @@
|
|||||||
{i18n._(`toolbar.routing.activities.${$routingProfile}`)}
|
{i18n._(`toolbar.routing.activities.${$routingProfile}`)}
|
||||||
</Select.Trigger>
|
</Select.Trigger>
|
||||||
<Select.Content>
|
<Select.Content>
|
||||||
{#each Object.keys(routingProfiles) as profile}
|
{#each Object.keys(routingProfiles) as profile (profile)}
|
||||||
<Select.Item value={profile}
|
<Select.Item value={profile}
|
||||||
>{i18n._(
|
>{i18n._(
|
||||||
`toolbar.routing.activities.${profile}`
|
`toolbar.routing.activities.${profile}`
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ export class RoutingControls {
|
|||||||
listenedFileIds: string[] = [];
|
listenedFileIds: string[] = [];
|
||||||
popup: Popup;
|
popup: Popup;
|
||||||
popupElement: HTMLElement;
|
popupElement: HTMLElement;
|
||||||
unsubscribes: Function[] = [];
|
unsubscribes: (() => void)[] = [];
|
||||||
|
|
||||||
updateBinded: () => void = this.update.bind(this);
|
updateBinded: () => void = this.update.bind(this);
|
||||||
appendAnchorBinded: (e: MapMouseEvent) => void = this.appendAnchor.bind(this);
|
appendAnchorBinded: (e: MapMouseEvent) => void = this.appendAnchor.bind(this);
|
||||||
@@ -270,7 +270,7 @@ export class RoutingControls {
|
|||||||
layerEventManager.on('mousedown', LAYER_ID, this.onMouseDownBinded);
|
layerEventManager.on('mousedown', LAYER_ID, this.onMouseDownBinded);
|
||||||
layerEventManager.on('touchstart', LAYER_ID, this.onTouchStartBinded);
|
layerEventManager.on('touchstart', LAYER_ID, this.onTouchStartBinded);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch {
|
||||||
// No reliable way to check if the map is ready to add sources and layers
|
// No reliable way to check if the map is ready to add sources and layers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -303,7 +303,7 @@ export class RoutingControls {
|
|||||||
if (map_?.getSource(LAYER_ID)) {
|
if (map_?.getSource(LAYER_ID)) {
|
||||||
map_?.removeSource(LAYER_ID);
|
map_?.removeSource(LAYER_ID);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch {
|
||||||
// No reliable way to check if the map is ready to remove sources and layers
|
// No reliable way to check if the map is ready to remove sources and layers
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -556,8 +556,9 @@ export class RoutingControls {
|
|||||||
let response;
|
let response;
|
||||||
try {
|
try {
|
||||||
response = await route(targets);
|
response = await route(targets);
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
toast.error(i18n._(e.message, e.message));
|
const message = e instanceof Error ? e.message : String(e);
|
||||||
|
toast.error(i18n._(message, message));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -802,7 +803,7 @@ export class RoutingControls {
|
|||||||
this.moveAnchorFeature(this.anchorWithId(this.anchors.length)!, position);
|
this.moveAnchorFeature(this.anchorWithId(this.anchors.length)!, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
temporaryAnchorCloseToOtherAnchor(e: any) {
|
temporaryAnchorCloseToOtherAnchor(e: MapMouseEvent) {
|
||||||
const map_ = get(map);
|
const map_ = get(map);
|
||||||
if (!map_) {
|
if (!map_) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ async function getGraphHopperRoute(
|
|||||||
graphHopperProfile: string,
|
graphHopperProfile: string,
|
||||||
privateRoads: boolean
|
privateRoads: boolean
|
||||||
): Promise<RoutedPoints> {
|
): Promise<RoutedPoints> {
|
||||||
let response = await fetch('https://graphhopper.gpx.studio/route', {
|
const response = await fetch('https://graphhopper.gpx.studio/route', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@@ -222,9 +222,9 @@ async function getBRouterRoute(
|
|||||||
points: Coordinates[],
|
points: Coordinates[],
|
||||||
brouterProfile: string
|
brouterProfile: string
|
||||||
): Promise<RoutedPoints> {
|
): Promise<RoutedPoints> {
|
||||||
let url = `https://brouter.de/brouter?lonlats=${points.map((point) => `${point.lng.toFixed(8)},${point.lat.toFixed(8)}`).join('|')}&profile=${brouterProfile}&format=geojson&alternativeidx=0`;
|
const url = `https://brouter.de/brouter?lonlats=${points.map((point) => `${point.lng.toFixed(8)},${point.lat.toFixed(8)}`).join('|')}&profile=${brouterProfile}&format=geojson&alternativeidx=0`;
|
||||||
|
|
||||||
let response = await fetch(url);
|
const response = await fetch(url);
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw brouterError(await response.text());
|
throw brouterError(await response.text());
|
||||||
@@ -289,11 +289,10 @@ export function parseBRouterRoute(geojson: any): RoutedPoints {
|
|||||||
/** The tags of a way, `key=value` separated by spaces, with the `:` of the keys as `_`. */
|
/** The tags of a way, `key=value` separated by spaces, with the `:` of the keys as `_`. */
|
||||||
export function getTags(message: string): { [key: string]: string } {
|
export function getTags(message: string): { [key: string]: string } {
|
||||||
const fields = message.split(' ');
|
const fields = message.split(' ');
|
||||||
let tags: { [key: string]: string } = {};
|
const tags: { [key: string]: string } = {};
|
||||||
for (let i = 0; i < fields.length; i++) {
|
for (let i = 0; i < fields.length; i++) {
|
||||||
let [key, value] = fields[i].split('=');
|
const [key, value] = fields[i].split('=');
|
||||||
key = key.replace(/:/g, '_');
|
tags[key.replace(/:/g, '_')] = value;
|
||||||
tags[key] = value;
|
|
||||||
}
|
}
|
||||||
return tags;
|
return tags;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,7 +131,7 @@
|
|||||||
{i18n._('gpx.' + $splitAs)}
|
{i18n._('gpx.' + $splitAs)}
|
||||||
</Select.Trigger>
|
</Select.Trigger>
|
||||||
<Select.Content>
|
<Select.Content>
|
||||||
{#each splitTypes as splitType}
|
{#each splitTypes as splitType (splitType)}
|
||||||
<Select.Item value={splitType}>{i18n._('gpx.' + splitType)}</Select.Item>
|
<Select.Item value={splitType}>{i18n._('gpx.' + splitType)}</Select.Item>
|
||||||
{/each}
|
{/each}
|
||||||
</Select.Content>
|
</Select.Content>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export const SplitType = {
|
|||||||
} as const satisfies Record<string, EngineSplitType>;
|
} as const satisfies Record<string, EngineSplitType>;
|
||||||
export type SplitType = (typeof SplitType)[keyof typeof SplitType];
|
export type SplitType = (typeof SplitType)[keyof typeof SplitType];
|
||||||
|
|
||||||
export let splitAs: Writable<SplitType> = writable(SplitType.FILES);
|
export const splitAs: Writable<SplitType> = writable(SplitType.FILES);
|
||||||
|
|
||||||
/** The ids of the segments of the routes of the files of the selection. */
|
/** The ids of the segments of the routes of the files of the selection. */
|
||||||
export function routeSegmentIds(selection: Selection): Set<string> {
|
export function routeSegmentIds(selection: Selection): Set<string> {
|
||||||
|
|||||||
@@ -23,15 +23,15 @@ import {
|
|||||||
export class SplitControls {
|
export class SplitControls {
|
||||||
map: Map;
|
map: Map;
|
||||||
layerEventManager: MapLayerEventManager;
|
layerEventManager: MapLayerEventManager;
|
||||||
unsubscribes: Function[] = [];
|
unsubscribes: (() => void)[] = [];
|
||||||
/** What the tool needs from the engine, while it shows the anchors. */
|
/** What the tool needs from the engine, while it shows the anchors. */
|
||||||
request: StatisticsRequest = engine.requestStatistics();
|
request: StatisticsRequest = engine.requestStatistics();
|
||||||
selection: Selection = { type: 'empty' };
|
selection: Selection = { type: 'empty' };
|
||||||
statistics: SelectionStatistics | undefined = undefined;
|
statistics: SelectionStatistics | undefined = undefined;
|
||||||
|
|
||||||
layerOnMouseEnterBinded: (e: any) => void = this.layerOnMouseEnter.bind(this);
|
layerOnMouseEnterBinded: () => void = this.layerOnMouseEnter.bind(this);
|
||||||
layerOnMouseLeaveBinded: () => void = this.layerOnMouseLeave.bind(this);
|
layerOnMouseLeaveBinded: () => void = this.layerOnMouseLeave.bind(this);
|
||||||
layerOnClickBinded: (e: any) => void = this.layerOnClick.bind(this);
|
layerOnClickBinded: (e: MapLayerMouseEvent) => void = this.layerOnClick.bind(this);
|
||||||
|
|
||||||
constructor(map: Map, layerEventManager: MapLayerEventManager) {
|
constructor(map: Map, layerEventManager: MapLayerEventManager) {
|
||||||
this.map = map;
|
this.map = map;
|
||||||
@@ -116,7 +116,7 @@ export class SplitControls {
|
|||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let source = this.map.getSource('split-controls') as GeoJSONSource | undefined;
|
const source = this.map.getSource('split-controls') as GeoJSONSource | undefined;
|
||||||
if (source) {
|
if (source) {
|
||||||
source.setData(data);
|
source.setData(data);
|
||||||
} else {
|
} else {
|
||||||
@@ -154,7 +154,7 @@ export class SplitControls {
|
|||||||
);
|
);
|
||||||
this.layerEventManager.on('click', 'split-controls', this.layerOnClickBinded);
|
this.layerEventManager.on('click', 'split-controls', this.layerOnClickBinded);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch {
|
||||||
// No reliable way to check if the map is ready to add sources and layers
|
// No reliable way to check if the map is ready to add sources and layers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -172,12 +172,12 @@ export class SplitControls {
|
|||||||
if (this.map.getSource('split-controls')) {
|
if (this.map.getSource('split-controls')) {
|
||||||
this.map.removeSource('split-controls');
|
this.map.removeSource('split-controls');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch {
|
||||||
// No reliable way to check if the map is ready to remove sources and layers
|
// No reliable way to check if the map is ready to remove sources and layers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
layerOnMouseEnter(e: any) {
|
layerOnMouseEnter() {
|
||||||
mapCursor.notify(MapCursorState.SPLIT_CONTROL, true);
|
mapCursor.notify(MapCursorState.SPLIT_CONTROL, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
import { selectedWaypoint } from './waypoint';
|
import { selectedWaypoint } from './waypoint';
|
||||||
import { map } from '$lib/components/map/map';
|
import { map } from '$lib/components/map/map';
|
||||||
import { mapCursor, MapCursorState } from '$lib/state/map-cursor';
|
import { mapCursor, MapCursorState } from '$lib/state/map-cursor';
|
||||||
import { Marker } from 'maplibre-gl';
|
import { Marker, type MapMouseEvent } from 'maplibre-gl';
|
||||||
import { getSvgForSymbol } from '$lib/components/map/gpx-layer/gpx-layer';
|
import { getSvgForSymbol } from '$lib/components/map/gpx-layer/gpx-layer';
|
||||||
|
|
||||||
let props: {
|
let props: {
|
||||||
@@ -108,7 +108,7 @@
|
|||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
function setCoordinates(e: any) {
|
function setCoordinates(e: MapMouseEvent) {
|
||||||
if (
|
if (
|
||||||
$map?.queryRenderedFeatures(e.point, {
|
$map?.queryRenderedFeatures(e.point, {
|
||||||
layers: $map.getLayersOrder().filter((layerId) => layerId.endsWith('-waypoints')),
|
layers: $map.getLayersOrder().filter((layerId) => layerId.endsWith('-waypoints')),
|
||||||
@@ -117,8 +117,8 @@
|
|||||||
// Clicked on a waypoint, ignoring
|
// Clicked on a waypoint, ignoring
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
latitude = e.lngLat.lat.toFixed(6);
|
latitude = parseFloat(e.lngLat.lat.toFixed(6));
|
||||||
longitude = e.lngLat.lng.toFixed(6);
|
longitude = parseFloat(e.lngLat.lng.toFixed(6));
|
||||||
}
|
}
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
@@ -212,7 +212,7 @@
|
|||||||
</span>
|
</span>
|
||||||
</Select.Trigger>
|
</Select.Trigger>
|
||||||
<Select.Content class="max-h-60">
|
<Select.Content class="max-h-60">
|
||||||
{#each sortedSymbols as [key, symbol]}
|
{#each sortedSymbols as [key, symbol] (key)}
|
||||||
<Select.Item value={symbol.value}>
|
<Select.Item value={symbol.value}>
|
||||||
<span>
|
<span>
|
||||||
{#if symbol.icon}
|
{#if symbol.icon}
|
||||||
|
|||||||
@@ -56,6 +56,8 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if href}
|
{#if href}
|
||||||
|
<!-- the href comes resolved (or external) from the users of the button -->
|
||||||
|
<!-- eslint-disable svelte/no-navigation-without-resolve -->
|
||||||
<a
|
<a
|
||||||
bind:this={ref}
|
bind:this={ref}
|
||||||
data-slot="button"
|
data-slot="button"
|
||||||
@@ -68,6 +70,7 @@
|
|||||||
>
|
>
|
||||||
{@render children?.()}
|
{@render children?.()}
|
||||||
</a>
|
</a>
|
||||||
|
<!-- eslint-enable svelte/no-navigation-without-resolve -->
|
||||||
{:else}
|
{:else}
|
||||||
<button
|
<button
|
||||||
bind:this={ref}
|
bind:this={ref}
|
||||||
|
|||||||
@@ -101,10 +101,7 @@
|
|||||||
if (typeof hours === 'string') {
|
if (typeof hours === 'string') {
|
||||||
hours = parseInt(hours);
|
hours = parseInt(hours);
|
||||||
}
|
}
|
||||||
if (hours >= 0) {
|
if (hours < 0) {
|
||||||
} else if (hours < 0) {
|
|
||||||
hours = 0;
|
|
||||||
} else {
|
|
||||||
hours = 0;
|
hours = 0;
|
||||||
}
|
}
|
||||||
onChange();
|
onChange();
|
||||||
@@ -124,12 +121,9 @@
|
|||||||
if (typeof minutes === 'string') {
|
if (typeof minutes === 'string') {
|
||||||
minutes = parseInt(minutes);
|
minutes = parseInt(minutes);
|
||||||
}
|
}
|
||||||
if (minutes >= 0 && (minutes <= 59 || !showHours)) {
|
if (showHours && minutes > 59) {
|
||||||
} else if (minutes < 0) {
|
|
||||||
minutes = 0;
|
|
||||||
} else if (showHours && minutes > 59) {
|
|
||||||
minutes = 59;
|
minutes = 59;
|
||||||
} else {
|
} else if (minutes < 0) {
|
||||||
minutes = 0;
|
minutes = 0;
|
||||||
}
|
}
|
||||||
minutes = minutes.toString().padStart(showHours ? 2 : 1, '0');
|
minutes = minutes.toString().padStart(showHours ? 2 : 1, '0');
|
||||||
@@ -149,12 +143,9 @@
|
|||||||
if (typeof seconds === 'string') {
|
if (typeof seconds === 'string') {
|
||||||
seconds = parseInt(seconds);
|
seconds = parseInt(seconds);
|
||||||
}
|
}
|
||||||
if (seconds >= 0 && seconds <= 59) {
|
if (seconds > 59) {
|
||||||
} else if (seconds < 0) {
|
|
||||||
seconds = 0;
|
|
||||||
} else if (seconds > 59) {
|
|
||||||
seconds = 59;
|
seconds = 59;
|
||||||
} else {
|
} else if (seconds < 0) {
|
||||||
seconds = 0;
|
seconds = 0;
|
||||||
}
|
}
|
||||||
seconds = seconds.toString().padStart(2, '0');
|
seconds = seconds.toString().padStart(2, '0');
|
||||||
|
|||||||
@@ -96,10 +96,10 @@ function createPattern(
|
|||||||
size: number = 16,
|
size: number = 16,
|
||||||
lineWidth: number = 4
|
lineWidth: number = 4
|
||||||
) {
|
) {
|
||||||
let canvas = document.createElement('canvas');
|
const canvas = document.createElement('canvas');
|
||||||
canvas.width = size;
|
canvas.width = size;
|
||||||
canvas.height = size;
|
canvas.height = size;
|
||||||
let ctx = canvas.getContext('2d');
|
const ctx = canvas.getContext('2d');
|
||||||
if (ctx) {
|
if (ctx) {
|
||||||
ctx.fillStyle = backgroundColor;
|
ctx.fillStyle = backgroundColor;
|
||||||
ctx.fillRect(0, 0, size, size);
|
ctx.fillRect(0, 0, size, size);
|
||||||
@@ -139,11 +139,11 @@ export function getHighwayColor(
|
|||||||
sacScale: string | undefined,
|
sacScale: string | undefined,
|
||||||
mtbScale: string | undefined
|
mtbScale: string | undefined
|
||||||
) {
|
) {
|
||||||
let backgroundColor = highwayColors[highway] ? highwayColors[highway] : highwayColors.missing;
|
const backgroundColor = highwayColors[highway] ? highwayColors[highway] : highwayColors.missing;
|
||||||
let sacScaleColor = sacScale ? sacScaleColors[sacScale] : undefined;
|
const sacScaleColor = sacScale ? sacScaleColors[sacScale] : undefined;
|
||||||
let mtbScaleColor = mtbScale ? mtbScaleColors[mtbScale] : undefined;
|
const mtbScaleColor = mtbScale ? mtbScaleColors[mtbScale] : undefined;
|
||||||
if (sacScale || mtbScale) {
|
if (sacScale || mtbScale) {
|
||||||
let patternId = `${backgroundColor}-${[sacScale, mtbScale].filter((x) => x).join('-')}`;
|
const patternId = `${backgroundColor}-${[sacScale, mtbScale].filter((x) => x).join('-')}`;
|
||||||
if (!patterns[patternId]) {
|
if (!patterns[patternId]) {
|
||||||
patterns[patternId] = createPattern(backgroundColor, sacScaleColor, mtbScaleColor);
|
patterns[patternId] = createPattern(backgroundColor, sacScaleColor, mtbScaleColor);
|
||||||
}
|
}
|
||||||
@@ -164,8 +164,8 @@ export function getSlopeColor(slope: number): string {
|
|||||||
v = 1 / (1 + Math.exp(-6 * v));
|
v = 1 / (1 + Math.exp(-6 * v));
|
||||||
v = v - 0.5;
|
v = v - 0.5;
|
||||||
|
|
||||||
let hue = ((0.5 - v) * 120).toString(10);
|
const hue = ((0.5 - v) * 120).toString(10);
|
||||||
let lightness = 90 - Math.abs(v) * 70;
|
const lightness = 90 - Math.abs(v) * 70;
|
||||||
|
|
||||||
return `hsl(${hue},70%,${lightness}%)`;
|
return `hsl(${hue},70%,${lightness}%)`;
|
||||||
}
|
}
|
||||||
@@ -794,6 +794,14 @@ export const defaultOpacities: { [key: string]: number } = {
|
|||||||
|
|
||||||
export type LayerTreeType = { [key: string]: LayerTreeType | boolean };
|
export type LayerTreeType = { [key: string]: LayerTreeType | boolean };
|
||||||
|
|
||||||
|
/** A node of a layer tree that is a group of layers, not a layer (which is selected or not). */
|
||||||
|
export function layerGroup(node: LayerTreeType | boolean | undefined): LayerTreeType {
|
||||||
|
if (typeof node !== 'object') {
|
||||||
|
throw new Error('Not a group of layers');
|
||||||
|
}
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
// Hierarchy containing all basemaps
|
// Hierarchy containing all basemaps
|
||||||
export const basemapTree: LayerTreeType = {
|
export const basemapTree: LayerTreeType = {
|
||||||
basemaps: {
|
basemaps: {
|
||||||
@@ -1170,6 +1178,25 @@ export type CustomLayer = {
|
|||||||
value: string | StyleSpecification;
|
value: string | StyleSpecification;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Whether a saved value is a custom layer, with all that the layers have had from the start. */
|
||||||
|
export function isCustomLayer(value: unknown): value is CustomLayer {
|
||||||
|
if (typeof value !== 'object' || value === null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const layer: Partial<Record<keyof CustomLayer, unknown>> = value;
|
||||||
|
return (
|
||||||
|
typeof layer.id === 'string' &&
|
||||||
|
typeof layer.name === 'string' &&
|
||||||
|
Array.isArray(layer.tileUrls) &&
|
||||||
|
layer.tileUrls.every((url) => typeof url === 'string') &&
|
||||||
|
typeof layer.maxZoom === 'number' &&
|
||||||
|
(layer.layerType === 'basemap' || layer.layerType === 'overlay') &&
|
||||||
|
(layer.resourceType === 'raster' || layer.resourceType === 'vector') &&
|
||||||
|
(typeof layer.value === 'string' ||
|
||||||
|
(typeof layer.value === 'object' && layer.value !== null))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
type OverpassQueryData = {
|
type OverpassQueryData = {
|
||||||
icon: {
|
icon: {
|
||||||
svg: string;
|
svg: string;
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ By right-clicking on a file tab, you can access the same actions as in the [edit
|
|||||||
|
|
||||||
As mentioned in the [view options section](./menu/view), you can switch to a tree layout for the files list.
|
As mentioned in the [view options section](./menu/view), you can switch to a tree layout for the files list.
|
||||||
This layout is ideal for managing a large number of open files, as it organizes them into a vertical list on the right side of the map.
|
This layout is ideal for managing a large number of open files, as it organizes them into a vertical list on the right side of the map.
|
||||||
In addition, the file tree view enables you to inspect the [tracks, segments, and points of interest](./gpx) contained inside the files through collapsible sections.
|
In addition, the file tree view enables you to inspect the [tracks, segments, routes, and points of interest](./gpx) contained inside the files through collapsible sections.
|
||||||
|
|
||||||
You can also apply [edit actions](./menu/edit) and [tools](./toolbar) to internal file items.
|
You can also apply [edit actions](./menu/edit) and [tools](./toolbar) to internal file items.
|
||||||
Furthermore, you can drag and drop the inner items to reorder them, or move them in the hierarchy or even to another file.
|
Furthermore, you can drag and drop the inner items to reorder them, or move them in the hierarchy or even to another file.
|
||||||
|
|||||||
@@ -3,13 +3,15 @@ title: Фармат файла GPX
|
|||||||
---
|
---
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { Waypoints, MapPin } from '@lucide/svelte';
|
import DocsNote from '$lib/components/docs/DocsNote.svelte';
|
||||||
|
import { Waypoints, Route, MapPin } from '@lucide/svelte';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
# { title }
|
# { title }
|
||||||
|
|
||||||
<a href="https://www.topografix.com/gpx.asp" target="_blank">Фармат файла GPX</a> - гэта адкрыты стандарт для абмену дадзенымі GPS паміж праграмамі і прыладамі GPS.
|
<a href="https://www.topografix.com/gpx.asp" target="_blank">Фармат файла GPX</a> - гэта адкрыты стандарт для абмену дадзенымі GPS паміж праграмамі і прыладамі GPS.
|
||||||
Па сутнасці, ён складаецца з серыі кропак GPS, якія кадзіруюць адну або некалькі слядоў GPS, і, па жаданні, некаторыя кропкі цікавасці.
|
Па сутнасці, ён складаецца з серыі кропак GPS, якія кадзіруюць адну або некалькі слядоў GPS, і, па жаданні, некаторыя кропкі цікавасці.
|
||||||
|
These traces can be stored either as tracks or as routes.
|
||||||
|
|
||||||
Файлы GPX могуць таксама ўтрымліваць метададзеныя, з якіх палі **імя** і **апісанне** найбольш карысныя для карыстальнікаў.
|
Файлы GPX могуць таксама ўтрымліваць метададзеныя, з якіх палі **імя** і **апісанне** найбольш карысныя для карыстальнікаў.
|
||||||
|
|
||||||
@@ -27,6 +29,20 @@ title: Фармат файла GPX
|
|||||||
У большасці выпадкаў файлы GPX утрымліваюць адзін трэк з адным сегментам.
|
У большасці выпадкаў файлы GPX утрымліваюць адзін трэк з адным сегментам.
|
||||||
Аднак іерархія, апісаная вышэй, дазваляе выкарыстоўваць больш складаныя выпадкі, напрыклад, планаваць шматдзённыя паездкі з некалькімі варыянтамі на кожны дзень.
|
Аднак іерархія, апісаная вышэй, дазваляе выкарыстоўваць больш складаныя выпадкі, напрыклад, планаваць шматдзённыя паездкі з некалькімі варыянтамі на кожны дзень.
|
||||||
|
|
||||||
|
### <Route size="16" class="inline-block" style="margin-bottom: 2px" /> Routes
|
||||||
|
|
||||||
|
A **route** is a single continuous path made of a sequence of **route points**.
|
||||||
|
These are mandatory checkpoints, which correspond to the anchor points of the [routing tool](./toolbar/routing).
|
||||||
|
The points in between are only a suggested path connecting the route points.
|
||||||
|
Like a track, a route can have a **name**, a **description**, and **appearance properties**.
|
||||||
|
|
||||||
|
<DocsNote>
|
||||||
|
|
||||||
|
Nowadays, most apps and GPS devices work perfectly well with tracks, even for navigation.
|
||||||
|
However, some of them only work with routes: in that case, you can [convert](./menu/edit) your tracks to routes, or [create](./menu/file) a route file from the start.
|
||||||
|
|
||||||
|
</DocsNote>
|
||||||
|
|
||||||
### <MapPin size="16" class="inline-block" style="margin-bottom: 2px" /> Кропкі цікавасці
|
### <MapPin size="16" class="inline-block" style="margin-bottom: 2px" /> Кропкі цікавасці
|
||||||
|
|
||||||
**Кропкі цікавасці** (тэхнічна званыя _маршрутнымі кропкамі_) уяўляюць цікавыя месцы, якія можна паказаць альбо на прыладзе GPS, альбо на лічбавай карце.
|
**Кропкі цікавасці** (тэхнічна званыя _маршрутнымі кропкамі_) уяўляюць цікавыя месцы, якія можна паказаць альбо на прыладзе GPS, альбо на лічбавай карце.
|
||||||
|
|||||||
@@ -3,14 +3,14 @@ title: Edit actions
|
|||||||
---
|
---
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Undo2, Redo2, Info, PaintBucket, EyeOff, FileStack, ClipboardCopy, Scissors, ClipboardPaste, Trash2, Maximize, Plus } from '@lucide/svelte';
|
import { Undo2, Redo2, Info, PaintBucket, ArrowRightLeft, FileStack, ClipboardCopy, Scissors, ClipboardPaste, Trash2, Plus } from '@lucide/svelte';
|
||||||
import DocsNote from '$lib/components/docs/DocsNote.svelte';
|
import DocsNote from '$lib/components/docs/DocsNote.svelte';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
# { title }
|
# { title }
|
||||||
|
|
||||||
Unlike the file actions, the edit actions can potentially modify the content of the currently selected files.
|
Unlike the file actions, the edit actions can potentially modify the content of the currently selected files.
|
||||||
Moreover, when the tree layout of the files list is enabled (see [Files and statistics](../files-and-stats)), they can also be applied to [tracks, segments, and points of interest](../gpx).
|
Moreover, when the tree layout of the files list is enabled (see [Files and statistics](../files-and-stats)), they can also be applied to [tracks, segments, routes, and points of interest](../gpx).
|
||||||
Therefore, we will refer to the elements that can be modified by these actions as _file items_.
|
Therefore, we will refer to the elements that can be modified by these actions as _file items_.
|
||||||
Note that except for the undo and redo actions, the edit actions are also accessible through the context menu (right-click) of the file items.
|
Note that except for the undo and redo actions, the edit actions are also accessible through the context menu (right-click) of the file items.
|
||||||
|
|
||||||
@@ -27,10 +27,6 @@ Open the information dialog of the currently selected file item, where you can s
|
|||||||
|
|
||||||
Open the appearance dialog, where you can change the color, opacity, and width of the selected file items on the map.
|
Open the appearance dialog, where you can change the color, opacity, and width of the selected file items on the map.
|
||||||
|
|
||||||
### <EyeOff size="16" class="inline-block" style="margin-bottom: 2px" /> Hide/unhide
|
|
||||||
|
|
||||||
Toggle the visibility of the selected file items on the map.
|
|
||||||
|
|
||||||
### <Plus size="16" class="inline-block" style="margin-bottom: 2px" /> New track
|
### <Plus size="16" class="inline-block" style="margin-bottom: 2px" /> New track
|
||||||
|
|
||||||
Create a new track in the selected file.
|
Create a new track in the selected file.
|
||||||
@@ -42,6 +38,17 @@ Additionally, the selection must be a single file.
|
|||||||
|
|
||||||
</DocsNote>
|
</DocsNote>
|
||||||
|
|
||||||
|
### <Plus size="16" class="inline-block" style="margin-bottom: 2px" /> New route
|
||||||
|
|
||||||
|
Create a new route in the selected file.
|
||||||
|
|
||||||
|
<DocsNote>
|
||||||
|
|
||||||
|
This action is only available when the tree layout of the files list is enabled.
|
||||||
|
Additionally, the selection must be a single file.
|
||||||
|
|
||||||
|
</DocsNote>
|
||||||
|
|
||||||
### <Plus size="16" class="inline-block" style="margin-bottom: 2px" /> New segment
|
### <Plus size="16" class="inline-block" style="margin-bottom: 2px" /> New segment
|
||||||
|
|
||||||
Create a new segment in the selected track.
|
Create a new segment in the selected track.
|
||||||
@@ -53,14 +60,17 @@ Additionally, the selection must be a single track.
|
|||||||
|
|
||||||
</DocsNote>
|
</DocsNote>
|
||||||
|
|
||||||
|
### <ArrowRightLeft size="16" class="inline-block" style="margin-bottom: 2px" /> Convert to route/track
|
||||||
|
|
||||||
|
Convert the selected routes to tracks, or the selected tracks or segments to routes.
|
||||||
|
Since a route has a single segment, a track with multiple segments is converted into one route per segment.
|
||||||
|
|
||||||
|
When the selected files contain only routes, or only tracks, you can also convert all of them at once.
|
||||||
|
|
||||||
### <FileStack size="16" class="inline-block" style="margin-bottom: 2px" /> Select all
|
### <FileStack size="16" class="inline-block" style="margin-bottom: 2px" /> Select all
|
||||||
|
|
||||||
Add all file items in the current hierarchy level to the selection.
|
Add all file items in the current hierarchy level to the selection.
|
||||||
|
|
||||||
### <Maximize size="16" class="inline-block" style="margin-bottom: 2px" /> Center
|
|
||||||
|
|
||||||
Center the map on the selected file items.
|
|
||||||
|
|
||||||
### <ClipboardCopy size="16" class="inline-block" style="margin-bottom: 2px" /> Copy
|
### <ClipboardCopy size="16" class="inline-block" style="margin-bottom: 2px" /> Copy
|
||||||
|
|
||||||
Copy the selected file items to the clipboard.
|
Copy the selected file items to the clipboard.
|
||||||
|
|||||||
@@ -15,6 +15,10 @@ The file actions menu contains a set of pretty self-explanatory file operations.
|
|||||||
|
|
||||||
Create a new empty file.
|
Create a new empty file.
|
||||||
|
|
||||||
|
### <Plus size="16" class="inline-block" style="margin-bottom: 2px" /> New route file
|
||||||
|
|
||||||
|
Create a new file containing an empty [route](../gpx).
|
||||||
|
|
||||||
### <FolderOpen size="16" class="inline-block" style="margin-bottom: 2px" /> Open...
|
### <FolderOpen size="16" class="inline-block" style="margin-bottom: 2px" /> Open...
|
||||||
|
|
||||||
Open files from your computer.
|
Open files from your computer.
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ title: View options
|
|||||||
---
|
---
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { ChartArea, ListTree, Map, Layers2, Coins, Milestone, Box, Maximize2 } from '@lucide/svelte';
|
import { ChartArea, ListTree, Map, Layers2, Coins, Milestone, EyeOff, Maximize, Box, Maximize2 } from '@lucide/svelte';
|
||||||
import DocsNote from '$lib/components/docs/DocsNote.svelte';
|
import DocsNote from '$lib/components/docs/DocsNote.svelte';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ Hide the elevation profile to make room for the map, or show it to inspect the c
|
|||||||
|
|
||||||
Toggle the tree layout for the [file list](../files-and-stats).
|
Toggle the tree layout for the [file list](../files-and-stats).
|
||||||
This layout is ideal for managing a large number of open files, as it organizes them into a vertical list on the right side of the map.
|
This layout is ideal for managing a large number of open files, as it organizes them into a vertical list on the right side of the map.
|
||||||
In addition, the file tree view enables you to inspect the [tracks, segments, and points of interest](../gpx) contained inside the files through collapsible sections.
|
In addition, the file tree view enables you to inspect the [tracks, segments, routes, and points of interest](../gpx) contained inside the files through collapsible sections.
|
||||||
|
|
||||||
### <Map size="16" class="inline-block" style="margin-bottom: 2px" /> Switch to previous basemap
|
### <Map size="16" class="inline-block" style="margin-bottom: 2px" /> Switch to previous basemap
|
||||||
|
|
||||||
@@ -38,6 +38,14 @@ They are displayed for the current selection, like the [elevation profile](../fi
|
|||||||
|
|
||||||
Toggle the visibility of direction arrows on the map.
|
Toggle the visibility of direction arrows on the map.
|
||||||
|
|
||||||
|
### <EyeOff size="16" class="inline-block" style="margin-bottom: 2px" /> Hide/unhide
|
||||||
|
|
||||||
|
Toggle the visibility of the selected file items on the map.
|
||||||
|
|
||||||
|
### <Maximize size="16" class="inline-block" style="margin-bottom: 2px" /> Center
|
||||||
|
|
||||||
|
Center the map on the selected file items.
|
||||||
|
|
||||||
### <Box size="16" class="inline-block" style="margin-bottom: 2px" /> Toggle 3D
|
### <Box size="16" class="inline-block" style="margin-bottom: 2px" /> Toggle 3D
|
||||||
|
|
||||||
Enter or exit the 3D map view.
|
Enter or exit the 3D map view.
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ This tool allows you to extract [tracks (or segments)](../gpx) from files (or tr
|
|||||||
<Extract class="text-foreground p-3 border rounded-md shadow-lg" />
|
<Extract class="text-foreground p-3 border rounded-md shadow-lg" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
Applying the tool to a file containing multiple tracks will create a new file for each of the tracks it contains.
|
Applying the tool to a file containing multiple [tracks or routes](../gpx) will create a new file for each of the tracks and routes it contains.
|
||||||
Similarly, applying the tool to a track containing multiple segments will create (in the same file) a new track for each of the segments it contains.
|
Similarly, applying the tool to a track containing multiple segments will create (in the same file) a new track for each of the segments it contains.
|
||||||
|
|
||||||
<DocsNote>
|
<DocsNote>
|
||||||
|
|||||||
@@ -10,11 +10,11 @@ title: Merge
|
|||||||
|
|
||||||
# <Group size="24" class="inline-block" style="margin-bottom: 5px" /> { title }
|
# <Group size="24" class="inline-block" style="margin-bottom: 5px" /> { title }
|
||||||
|
|
||||||
To use this tool, you need to [select](../files-and-stats) multiple files, [tracks, or segments](../gpx).
|
To use this tool, you need to [select](../files-and-stats) multiple files, [tracks, segments or routes](../gpx).
|
||||||
|
|
||||||
- If your goal is to create a single continuous trace from your selection, use the **Connect the traces** option and validate.
|
- If your goal is to create a single continuous trace from your selection, use the **Connect the traces** option and validate.
|
||||||
- The second option can be used to create or manage files with multiple [tracks or segments](../gpx).
|
- The second option can be used to create or manage files with multiple [tracks, segments or routes](../gpx).
|
||||||
Merging files (or tracks) will result in a single file (or track) containing all tracks (or segments) from the selection.
|
Merging files (or tracks) will result in a single file (or track) containing all tracks and routes (or segments) from the selection.
|
||||||
|
|
||||||
<DocsNote>
|
<DocsNote>
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,6 @@ To split the selected trace into two parts, click on one of the split markers di
|
|||||||
To split at a specific point of your choice, hover over the trace on the map.
|
To split at a specific point of your choice, hover over the trace on the map.
|
||||||
Scissors will appear at the cursor position, showing that you can split the trace at that point.
|
Scissors will appear at the cursor position, showing that you can split the trace at that point.
|
||||||
|
|
||||||
You can choose to split the trace into two GPX files, or to keep the split parts in the same file as [tracks or segments](../gpx).
|
You can choose to split the trace into two GPX files, or to keep the split parts in the same file as [tracks, segments or routes](../gpx).
|
||||||
|
|
||||||
<DocsImage src="tools/split" alt="Hovering over the selected trace turns your cursor into scissors." />
|
<DocsImage src="tools/split" alt="Hovering over the selected trace turns your cursor into scissors." />
|
||||||
@@ -51,7 +51,7 @@ Clicant el botó dret en la pestanya d'un arxiu, pots accedir a les mateixes acc
|
|||||||
|
|
||||||
Tal i com es menciona en la [secció d'opcions de vista](./menu/view), pots canviar a un esquema d'arbre per a la llista d'arxius.
|
Tal i com es menciona en la [secció d'opcions de vista](./menu/view), pots canviar a un esquema d'arbre per a la llista d'arxius.
|
||||||
Aquesta disposició és ideal per tal d'administrar un gran nombre d'arxius oberts, ja que els organitza en una llista vertical en la part dreta del mapa.
|
Aquesta disposició és ideal per tal d'administrar un gran nombre d'arxius oberts, ja que els organitza en una llista vertical en la part dreta del mapa.
|
||||||
A més, la vista d'arbre d'arxius permet inspeccionar [tracs, segments i punts d'interès](./gpx) continguts dins dels arxius a través de seccions plegables.
|
In addition, the file tree view enables you to inspect the [tracks, segments, routes, and points of interest](./gpx) contained inside the files through collapsible sections.
|
||||||
|
|
||||||
També pots aplicar [accions d'edició](./menu/edit) i [eines](./toolbar) a elements interns de l'arxiu.
|
També pots aplicar [accions d'edició](./menu/edit) i [eines](./toolbar) a elements interns de l'arxiu.
|
||||||
A més, pots arrossegar i deixar anar els elements interns per reordenar-los, o moure'ls en la jerarquia o fins i tot a un altre arxiu.
|
A més, pots arrossegar i deixar anar els elements interns per reordenar-los, o moure'ls en la jerarquia o fins i tot a un altre arxiu.
|
||||||
|
|||||||
@@ -3,13 +3,15 @@ title: Format d'arxiu GPX
|
|||||||
---
|
---
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { Waypoints, MapPin } from '@lucide/svelte';
|
import DocsNote from '$lib/components/docs/DocsNote.svelte';
|
||||||
|
import { Waypoints, Route, MapPin } from '@lucide/svelte';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
# { title }
|
# { title }
|
||||||
|
|
||||||
El <a href="https://www.topografix.com/gpx.asp" target="_blank">format d'arxiu GPX</a> és un estàndard obert per intercanviar dades GPS entre aplicacions i aparells GPS.
|
El <a href="https://www.topografix.com/gpx.asp" target="_blank">format d'arxiu GPX</a> és un estàndard obert per intercanviar dades GPS entre aplicacions i aparells GPS.
|
||||||
Bàsicament consisteix en una sèrie de punts GPS que codifiquen una o diverses traces GPS i, opcionalment, alguns punts d'interès.
|
Bàsicament consisteix en una sèrie de punts GPS que codifiquen una o diverses traces GPS i, opcionalment, alguns punts d'interès.
|
||||||
|
These traces can be stored either as tracks or as routes.
|
||||||
|
|
||||||
Els arxius GPX poden contenir també metadades, de les quals els camps **nom** i **descripció** són els més útils pels usuaris.
|
Els arxius GPX poden contenir també metadades, de les quals els camps **nom** i **descripció** són els més útils pels usuaris.
|
||||||
|
|
||||||
@@ -27,6 +29,20 @@ Aquests estan organitzats en una estructura jeràrquica, amb els tracs en el niv
|
|||||||
En la majoria dels casos, els arxius GPX contenen un sol trac amb un sol segment.
|
En la majoria dels casos, els arxius GPX contenen un sol trac amb un sol segment.
|
||||||
Tanmateix, la jerarquia descrita a dalt permet casos d'ús més avançat, com la planificació de viatges de diversos dies amb variants per cada dia.
|
Tanmateix, la jerarquia descrita a dalt permet casos d'ús més avançat, com la planificació de viatges de diversos dies amb variants per cada dia.
|
||||||
|
|
||||||
|
### <Route size="16" class="inline-block" style="margin-bottom: 2px" /> Routes
|
||||||
|
|
||||||
|
A **route** is a single continuous path made of a sequence of **route points**.
|
||||||
|
These are mandatory checkpoints, which correspond to the anchor points of the [routing tool](./toolbar/routing).
|
||||||
|
The points in between are only a suggested path connecting the route points.
|
||||||
|
Like a track, a route can have a **name**, a **description**, and **appearance properties**.
|
||||||
|
|
||||||
|
<DocsNote>
|
||||||
|
|
||||||
|
Nowadays, most apps and GPS devices work perfectly well with tracks, even for navigation.
|
||||||
|
However, some of them only work with routes: in that case, you can [convert](./menu/edit) your tracks to routes, or [create](./menu/file) a route file from the start.
|
||||||
|
|
||||||
|
</DocsNote>
|
||||||
|
|
||||||
### <MapPin size="16" class="inline-block" style="margin-bottom: 2px" /> Punts d'interès
|
### <MapPin size="16" class="inline-block" style="margin-bottom: 2px" /> Punts d'interès
|
||||||
|
|
||||||
**Punts d'interès** (tècnicament anomenats _waypoints_) representen ubicacions d'interès per mostrar en un dispositiu GPS o en mapa digital.
|
**Punts d'interès** (tècnicament anomenats _waypoints_) representen ubicacions d'interès per mostrar en un dispositiu GPS o en mapa digital.
|
||||||
|
|||||||
@@ -3,14 +3,14 @@ title: Accions d'edició
|
|||||||
---
|
---
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Undo2, Redo2, Info, PaintBucket, EyeOff, FileStack, ClipboardCopy, Scissors, ClipboardPaste, Trash2, Maximize, Plus } from '@lucide/svelte';
|
import { Undo2, Redo2, Info, PaintBucket, ArrowRightLeft, FileStack, ClipboardCopy, Scissors, ClipboardPaste, Trash2, Plus } from '@lucide/svelte';
|
||||||
import DocsNote from '$lib/components/docs/DocsNote.svelte';
|
import DocsNote from '$lib/components/docs/DocsNote.svelte';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
# { title }
|
# { title }
|
||||||
|
|
||||||
A diferència de les accions de l'arxiu, les accions d'edició poden potencialment modificar el contingut dels arxius seleccionats actualment.
|
A diferència de les accions de l'arxiu, les accions d'edició poden potencialment modificar el contingut dels arxius seleccionats actualment.
|
||||||
A més a més, quan està habilitada la disposició de l'arbre de la llista d'arxius (veure [Arxius i estadístiques](../files-and-stats)), també es poden aplicar a [tracs, segments i punts d'interès](../gpx).
|
Moreover, when the tree layout of the files list is enabled (see [Files and statistics](../files-and-stats)), they can also be applied to [tracks, segments, routes, and points of interest](../gpx).
|
||||||
Per tant, ens referirem als elements que poden ser modificats per aquestes accions com a _elements d'arxiu_.
|
Per tant, ens referirem als elements que poden ser modificats per aquestes accions com a _elements d'arxiu_.
|
||||||
Tingui en compte que excepte per a les accions de desfer i refer, les accions d'edició també són accessibles a través del menú contextual (clic dret) dels elements de l'arxiu.
|
Tingui en compte que excepte per a les accions de desfer i refer, les accions d'edició també són accessibles a través del menú contextual (clic dret) dels elements de l'arxiu.
|
||||||
|
|
||||||
@@ -27,10 +27,6 @@ Obre el quadre de diàleg d'informació de l'element de l'arxiu seleccionat, on
|
|||||||
|
|
||||||
Obre el diàleg d'aparença, on pots canviar el color, l'opacitat i l'amplada del mapa dels elements de l'arxiu seleccionat.
|
Obre el diàleg d'aparença, on pots canviar el color, l'opacitat i l'amplada del mapa dels elements de l'arxiu seleccionat.
|
||||||
|
|
||||||
### <EyeOff size="16" class="inline-block" style="margin-bottom: 2px" /> Amaga/mostra
|
|
||||||
|
|
||||||
Alterna la visibilitat dels elements de l'arxiu seleccionat en el mapa.
|
|
||||||
|
|
||||||
### <Plus size="16" class="inline-block" style="margin-bottom: 2px" /> Nou trac
|
### <Plus size="16" class="inline-block" style="margin-bottom: 2px" /> Nou trac
|
||||||
|
|
||||||
Crear nova ruta en l'arxiu seleccionat.
|
Crear nova ruta en l'arxiu seleccionat.
|
||||||
@@ -42,6 +38,17 @@ A més, la selecció ha de ser un únic arxiu.
|
|||||||
|
|
||||||
</DocsNote>
|
</DocsNote>
|
||||||
|
|
||||||
|
### <Plus size="16" class="inline-block" style="margin-bottom: 2px" /> New route
|
||||||
|
|
||||||
|
Create a new route in the selected file.
|
||||||
|
|
||||||
|
<DocsNote>
|
||||||
|
|
||||||
|
Aquesta acció només està disponible quan està habilitada la disposició de l'arbre de la llista d'arxius.
|
||||||
|
A més, la selecció ha de ser un únic arxiu.
|
||||||
|
|
||||||
|
</DocsNote>
|
||||||
|
|
||||||
### <Plus size="16" class="inline-block" style="margin-bottom: 2px" /> Nou segment
|
### <Plus size="16" class="inline-block" style="margin-bottom: 2px" /> Nou segment
|
||||||
|
|
||||||
Crear un nou segment en el trac seleccionat.
|
Crear un nou segment en el trac seleccionat.
|
||||||
@@ -53,14 +60,17 @@ A més, la selecció ha de ser un trac únic.
|
|||||||
|
|
||||||
</DocsNote>
|
</DocsNote>
|
||||||
|
|
||||||
|
### <ArrowRightLeft size="16" class="inline-block" style="margin-bottom: 2px" /> Convert to route/track
|
||||||
|
|
||||||
|
Convert the selected routes to tracks, or the selected tracks or segments to routes.
|
||||||
|
Since a route has a single segment, a track with multiple segments is converted into one route per segment.
|
||||||
|
|
||||||
|
When the selected files contain only routes, or only tracks, you can also convert all of them at once.
|
||||||
|
|
||||||
### <FileStack size="16" class="inline-block" style="margin-bottom: 2px" /> Selecciona tot
|
### <FileStack size="16" class="inline-block" style="margin-bottom: 2px" /> Selecciona tot
|
||||||
|
|
||||||
Afegeix a la selecció tots els elements de l'arxiu en el nivell de jerarquia actual.
|
Afegeix a la selecció tots els elements de l'arxiu en el nivell de jerarquia actual.
|
||||||
|
|
||||||
### <Maximize size="16" class="inline-block" style="margin-bottom: 2px" /> Centrar
|
|
||||||
|
|
||||||
Centrar el mapa en els elements de l'arxiu seleccionat.
|
|
||||||
|
|
||||||
### <ClipboardCopy size="16" class="inline-block" style="margin-bottom: 2px" /> Copia
|
### <ClipboardCopy size="16" class="inline-block" style="margin-bottom: 2px" /> Copia
|
||||||
|
|
||||||
Copia els elements de l'arxiu seleccionat en el porta-retalls.
|
Copia els elements de l'arxiu seleccionat en el porta-retalls.
|
||||||
|
|||||||
@@ -15,6 +15,10 @@ El menú d'accions d'arxiu conté un conjunt d'operacions força autoexplicative
|
|||||||
|
|
||||||
Crea un arxiu nou buit.
|
Crea un arxiu nou buit.
|
||||||
|
|
||||||
|
### <Plus size="16" class="inline-block" style="margin-bottom: 2px" /> New route file
|
||||||
|
|
||||||
|
Create a new file containing an empty [route](../gpx).
|
||||||
|
|
||||||
### <FolderOpen size="16" class="inline-block" style="margin-bottom: 2px" /> Obrir...
|
### <FolderOpen size="16" class="inline-block" style="margin-bottom: 2px" /> Obrir...
|
||||||
|
|
||||||
Obrir arxius del teu equip.
|
Obrir arxius del teu equip.
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ title: Opcions de vista
|
|||||||
---
|
---
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { ChartArea, ListTree, Map, Layers2, Coins, Milestone, Box, Maximize2 } from '@lucide/svelte';
|
import { ChartArea, ListTree, Map, Layers2, Coins, Milestone, EyeOff, Maximize, Box, Maximize2 } from '@lucide/svelte';
|
||||||
import DocsNote from '$lib/components/docs/DocsNote.svelte';
|
import DocsNote from '$lib/components/docs/DocsNote.svelte';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ Amagar el perfil d'elevació per fer espai al mapa o mostra-lo per inspeccionar
|
|||||||
|
|
||||||
Alterna el disseny de l'arbre per la [llista d'arxius](../files-and-stats).
|
Alterna el disseny de l'arbre per la [llista d'arxius](../files-and-stats).
|
||||||
Aquesta disposició és ideal per tal d'administrar un gran nombre d'arxius oberts, ja que els organitza en una llista vertical en la part dreta del mapa.
|
Aquesta disposició és ideal per tal d'administrar un gran nombre d'arxius oberts, ja que els organitza en una llista vertical en la part dreta del mapa.
|
||||||
A més, la vista de l'arbre d'arxius permet inspeccionar [tracs, segments i punts d'interès](../gpx) continguts en els arxius a través de les seccions plegables.
|
In addition, the file tree view enables you to inspect the [tracks, segments, routes, and points of interest](../gpx) contained inside the files through collapsible sections.
|
||||||
|
|
||||||
### <Map size="16" class="inline-block" style="margin-bottom: 2px" /> Canvia la mapa base anterior
|
### <Map size="16" class="inline-block" style="margin-bottom: 2px" /> Canvia la mapa base anterior
|
||||||
|
|
||||||
@@ -38,6 +38,14 @@ Es mostren per a la selecció actual, com el [perfil d'elevació](../files-and-s
|
|||||||
|
|
||||||
Alterna la visibilitat de les fletxes de direcció en el mapa.
|
Alterna la visibilitat de les fletxes de direcció en el mapa.
|
||||||
|
|
||||||
|
### <EyeOff size="16" class="inline-block" style="margin-bottom: 2px" /> Hide/unhide
|
||||||
|
|
||||||
|
Toggle the visibility of the selected file items on the map.
|
||||||
|
|
||||||
|
### <Maximize size="16" class="inline-block" style="margin-bottom: 2px" /> Center
|
||||||
|
|
||||||
|
Center the map on the selected file items.
|
||||||
|
|
||||||
### <Box size="16" class="inline-block" style="margin-bottom: 2px" /> Alternar 3D
|
### <Box size="16" class="inline-block" style="margin-bottom: 2px" /> Alternar 3D
|
||||||
|
|
||||||
Entra o surt de la vista de mapa en 3D.
|
Entra o surt de la vista de mapa en 3D.
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ Aquesta eina permet extreure [tracs (o segments)](../gpx) des d'arxius (o tracs)
|
|||||||
<Extract class="text-foreground p-3 border rounded-md shadow-lg" />
|
<Extract class="text-foreground p-3 border rounded-md shadow-lg" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
Aplicant l'eina a un arxiu que contingui múltiples tracs, crearà un arxiu nou per cada trac que contingui.
|
Applying the tool to a file containing multiple [tracks or routes](../gpx) will create a new file for each of the tracks and routes it contains.
|
||||||
Igualment, aplicant l'eina a un trac que contingui múltiples segments, crearà (en el mateix arxiu) un nou trac per cada un dels segments que contingui.
|
Igualment, aplicant l'eina a un trac que contingui múltiples segments, crearà (en el mateix arxiu) un nou trac per cada un dels segments que contingui.
|
||||||
|
|
||||||
<DocsNote>
|
<DocsNote>
|
||||||
|
|||||||
@@ -10,11 +10,11 @@ title: Fusionar
|
|||||||
|
|
||||||
# <Group size="24" class="inline-block" style="margin-bottom: 5px" /> { title }
|
# <Group size="24" class="inline-block" style="margin-bottom: 5px" /> { title }
|
||||||
|
|
||||||
Per utilitzar aquesta eina, s'ha de [seleccionar](../files-and-stats) múltiples arxius, [tracs o segments](../gpx).
|
To use this tool, you need to [select](../files-and-stats) multiple files, [tracks, segments or routes](../gpx).
|
||||||
|
|
||||||
- Si el teu objectiu és crear una traça contínua a partir de la selecció, utilitza l'opció **Connectar les traces** i valida-ho.
|
- Si el teu objectiu és crear una traça contínua a partir de la selecció, utilitza l'opció **Connectar les traces** i valida-ho.
|
||||||
- La segona opció es pot utilitzar per a crear o gestionar arxius amb múltiples [tracs o segments](../gpx).
|
- The second option can be used to create or manage files with multiple [tracks, segments or routes](../gpx).
|
||||||
Fusionar arxius (o tracs) crearà un sol arxiu (o trac) que contindrà tots els tracs (o segments) seleccionats.
|
Merging files (or tracks) will result in a single file (or track) containing all tracks and routes (or segments) from the selection.
|
||||||
|
|
||||||
<DocsNote>
|
<DocsNote>
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,6 @@ Per dividir la traça seleccionada en dues parts, clica sobre un dels marcadors
|
|||||||
Per dividir en un punt triat específicament, situat sobre la traça del mapa.
|
Per dividir en un punt triat específicament, situat sobre la traça del mapa.
|
||||||
Les tisores apareixeran en la posició del cursor, mostrant que pots dividir el traçat en aquest punt.
|
Les tisores apareixeran en la posició del cursor, mostrant que pots dividir el traçat en aquest punt.
|
||||||
|
|
||||||
Pots triar dividir el traçat en dos arxius GPX o mantenir les parts dividides en el mateix arxiu com a [tracs o segments](../gpx).
|
You can choose to split the trace into two GPX files, or to keep the split parts in the same file as [tracks, segments or routes](../gpx).
|
||||||
|
|
||||||
<DocsImage src="tools/split" alt="Situar el cursor sobre el traçat seleccionat el converteix en tisores." />
|
<DocsImage src="tools/split" alt="Situar el cursor sobre el traçat seleccionat el converteix en tisores." />
|
||||||
@@ -51,7 +51,7 @@ Kliknutím pravým tlačítkem myši na kartu souboru můžete provést stejné
|
|||||||
|
|
||||||
Jak je uvedeno v části [možnosti zobrazení](./menu/view), můžete přepnout na stromové rozvržení seznamu souborů.
|
Jak je uvedeno v části [možnosti zobrazení](./menu/view), můžete přepnout na stromové rozvržení seznamu souborů.
|
||||||
Toto zobrazení je ideální pro správu velkého počtu otevřených souborů, protože je uspořádá do svislého seznamu na pravé straně mapy.
|
Toto zobrazení je ideální pro správu velkého počtu otevřených souborů, protože je uspořádá do svislého seznamu na pravé straně mapy.
|
||||||
Stromové rozvržení souborů navíc umožňuje zkontrolovat [trasy, úseky a body zájmu](./gpx) obsažené v souborech prostřednictvím sbalitelných sekcí.
|
In addition, the file tree view enables you to inspect the [tracks, segments, routes, and points of interest](./gpx) contained inside the files through collapsible sections.
|
||||||
|
|
||||||
Rovněž můžete využít [akce úprav](./menu/edit) a [nástroje](./toolbar) na prvky uvnitř souborů.
|
Rovněž můžete využít [akce úprav](./menu/edit) a [nástroje](./toolbar) na prvky uvnitř souborů.
|
||||||
Navíc přetažením prvků uvnitř souborů můžete změnit jejich pořadí nebo je přesunout v hierarchii či dokonce do jiného souboru.
|
Navíc přetažením prvků uvnitř souborů můžete změnit jejich pořadí nebo je přesunout v hierarchii či dokonce do jiného souboru.
|
||||||
|
|||||||
@@ -3,13 +3,15 @@ title: Formát souboru GPX
|
|||||||
---
|
---
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { Waypoints, MapPin } from '@lucide/svelte';
|
import DocsNote from '$lib/components/docs/DocsNote.svelte';
|
||||||
|
import { Waypoints, Route, MapPin } from '@lucide/svelte';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
# { title }
|
# { title }
|
||||||
|
|
||||||
<a href="https://www.topografix.com/gpx.asp" target="_blank">GPX formát</a> je otevřeným standardem pro výměnu GPS dat mezi aplikacemi a GPS zařízeními.
|
<a href="https://www.topografix.com/gpx.asp" target="_blank">GPX formát</a> je otevřeným standardem pro výměnu GPS dat mezi aplikacemi a GPS zařízeními.
|
||||||
V podstatě se skládá z řady GPS bodů kódujících jednu nebo více GPS stop a volitelně i nějaké body zájmu.
|
V podstatě se skládá z řady GPS bodů kódujících jednu nebo více GPS stop a volitelně i nějaké body zájmu.
|
||||||
|
These traces can be stored either as tracks or as routes.
|
||||||
|
|
||||||
GPX soubory mohou obsahovat také metadata, z nichž pole **název** a **popis** jsou pro uživatele nejužitečnější.
|
GPX soubory mohou obsahovat také metadata, z nichž pole **název** a **popis** jsou pro uživatele nejužitečnější.
|
||||||
|
|
||||||
@@ -27,6 +29,20 @@ Ty jsou uspořádány v hierarchické struktuře, přičemž trasy jsou na nejvy
|
|||||||
Ve většině případů obsahují GPX soubory pouze jednu trasu s jedním úsekem.
|
Ve většině případů obsahují GPX soubory pouze jednu trasu s jedním úsekem.
|
||||||
Nicméně výše popsaná hierarchie umožňuje pokročilejší případy použití, například plánování vícedenních výletů s několika variantami pro každý den.
|
Nicméně výše popsaná hierarchie umožňuje pokročilejší případy použití, například plánování vícedenních výletů s několika variantami pro každý den.
|
||||||
|
|
||||||
|
### <Route size="16" class="inline-block" style="margin-bottom: 2px" /> Routes
|
||||||
|
|
||||||
|
A **route** is a single continuous path made of a sequence of **route points**.
|
||||||
|
These are mandatory checkpoints, which correspond to the anchor points of the [routing tool](./toolbar/routing).
|
||||||
|
The points in between are only a suggested path connecting the route points.
|
||||||
|
Like a track, a route can have a **name**, a **description**, and **appearance properties**.
|
||||||
|
|
||||||
|
<DocsNote>
|
||||||
|
|
||||||
|
Nowadays, most apps and GPS devices work perfectly well with tracks, even for navigation.
|
||||||
|
However, some of them only work with routes: in that case, you can [convert](./menu/edit) your tracks to routes, or [create](./menu/file) a route file from the start.
|
||||||
|
|
||||||
|
</DocsNote>
|
||||||
|
|
||||||
### <MapPin size="16" class="inline-block" style="margin-bottom: 2px" /> Body zájmu
|
### <MapPin size="16" class="inline-block" style="margin-bottom: 2px" /> Body zájmu
|
||||||
|
|
||||||
**Body zájmu** (odborně nazývané _waypoints_) představují zajímavá místa, která se zobrazí buď na zařízení GPS, nebo na digitální mapě.
|
**Body zájmu** (odborně nazývané _waypoints_) představují zajímavá místa, která se zobrazí buď na zařízení GPS, nebo na digitální mapě.
|
||||||
|
|||||||
@@ -3,14 +3,14 @@ title: Akce úprav
|
|||||||
---
|
---
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Undo2, Redo2, Info, PaintBucket, EyeOff, FileStack, ClipboardCopy, Scissors, ClipboardPaste, Trash2, Maximize, Plus } from '@lucide/svelte';
|
import { Undo2, Redo2, Info, PaintBucket, ArrowRightLeft, FileStack, ClipboardCopy, Scissors, ClipboardPaste, Trash2, Plus } from '@lucide/svelte';
|
||||||
import DocsNote from '$lib/components/docs/DocsNote.svelte';
|
import DocsNote from '$lib/components/docs/DocsNote.svelte';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
# { title }
|
# { title }
|
||||||
|
|
||||||
Na rozdíl od akcí v menu Soubor, mohou akce úprav potenciálně změnit obsah aktuálně vybraných souborů.
|
Na rozdíl od akcí v menu Soubor, mohou akce úprav potenciálně změnit obsah aktuálně vybraných souborů.
|
||||||
Navíc pokud je povoleno rozvržení stromu seznamu souborů (viz [Soubory a statistiky](../files-and-stats)), mohou být také použity na [trasy, segmenty a body zájmu](../gpx).
|
Moreover, when the tree layout of the files list is enabled (see [Files and statistics](../files-and-stats)), they can also be applied to [tracks, segments, routes, and points of interest](../gpx).
|
||||||
Proto budeme všechny prvky, které mohou být těmito akcemi upraveny, označovat jako _prvky souborů_.
|
Proto budeme všechny prvky, které mohou být těmito akcemi upraveny, označovat jako _prvky souborů_.
|
||||||
Všechny akce kromě zpět a opakovat jsou také dostupné z kontextového menu (klik pravým tlačítkem) prvků souborů.
|
Všechny akce kromě zpět a opakovat jsou také dostupné z kontextového menu (klik pravým tlačítkem) prvků souborů.
|
||||||
|
|
||||||
@@ -27,10 +27,6 @@ Otevře informační dialog zvoleného prvku souborů, kde lze zobrazit a změni
|
|||||||
|
|
||||||
Otevře dialog vzhledu, kde můžete změnit barvu, neprůhlednost a tloušťku zvolených prvků souborů v mapě.
|
Otevře dialog vzhledu, kde můžete změnit barvu, neprůhlednost a tloušťku zvolených prvků souborů v mapě.
|
||||||
|
|
||||||
### <EyeOff size="16" class="inline-block" style="margin-bottom: 2px" /> Skrýt/zobrazit
|
|
||||||
|
|
||||||
Přepnout viditelnost zvolených prvků souborů v mapě.
|
|
||||||
|
|
||||||
### <Plus size="16" class="inline-block" style="margin-bottom: 2px" /> Nová trasa
|
### <Plus size="16" class="inline-block" style="margin-bottom: 2px" /> Nová trasa
|
||||||
|
|
||||||
Vytvořit novou trasu ve zvoleném souboru.
|
Vytvořit novou trasu ve zvoleném souboru.
|
||||||
@@ -42,6 +38,17 @@ Kromě toho musí být vybrán právě jeden soubor.
|
|||||||
|
|
||||||
</DocsNote>
|
</DocsNote>
|
||||||
|
|
||||||
|
### <Plus size="16" class="inline-block" style="margin-bottom: 2px" /> New route
|
||||||
|
|
||||||
|
Create a new route in the selected file.
|
||||||
|
|
||||||
|
<DocsNote>
|
||||||
|
|
||||||
|
Tato akce je dostupná pouze v případě, že je povoleno rozvržení stromu seznamu souborů.
|
||||||
|
Kromě toho musí být vybrán právě jeden soubor.
|
||||||
|
|
||||||
|
</DocsNote>
|
||||||
|
|
||||||
### <Plus size="16" class="inline-block" style="margin-bottom: 2px" /> Nový úsek
|
### <Plus size="16" class="inline-block" style="margin-bottom: 2px" /> Nový úsek
|
||||||
|
|
||||||
Vytvořit nový úsek na zvolené trase.
|
Vytvořit nový úsek na zvolené trase.
|
||||||
@@ -53,14 +60,17 @@ Kromě toho musí být zvolena právě jedna trasa.
|
|||||||
|
|
||||||
</DocsNote>
|
</DocsNote>
|
||||||
|
|
||||||
|
### <ArrowRightLeft size="16" class="inline-block" style="margin-bottom: 2px" /> Convert to route/track
|
||||||
|
|
||||||
|
Convert the selected routes to tracks, or the selected tracks or segments to routes.
|
||||||
|
Since a route has a single segment, a track with multiple segments is converted into one route per segment.
|
||||||
|
|
||||||
|
When the selected files contain only routes, or only tracks, you can also convert all of them at once.
|
||||||
|
|
||||||
### <FileStack size="16" class="inline-block" style="margin-bottom: 2px" /> Vybrat vše
|
### <FileStack size="16" class="inline-block" style="margin-bottom: 2px" /> Vybrat vše
|
||||||
|
|
||||||
Přidejte k výběru všechny prvky souborů v dané úrovni hierarchie.
|
Přidejte k výběru všechny prvky souborů v dané úrovni hierarchie.
|
||||||
|
|
||||||
### <Maximize size="16" class="inline-block" style="margin-bottom: 2px" /> Vycentrovat
|
|
||||||
|
|
||||||
Vystředí mapu na označené prvky souborů.
|
|
||||||
|
|
||||||
### <ClipboardCopy size="16" class="inline-block" style="margin-bottom: 2px" /> Kopírovat
|
### <ClipboardCopy size="16" class="inline-block" style="margin-bottom: 2px" /> Kopírovat
|
||||||
|
|
||||||
Zkopíruje zvolené prvky souborů do schránky.
|
Zkopíruje zvolené prvky souborů do schránky.
|
||||||
|
|||||||
@@ -15,6 +15,10 @@ Menu akce souboru obsahuje sadu poměrně samovysvětlujících operací.
|
|||||||
|
|
||||||
Vytvořit nový prázdný soubor.
|
Vytvořit nový prázdný soubor.
|
||||||
|
|
||||||
|
### <Plus size="16" class="inline-block" style="margin-bottom: 2px" /> New route file
|
||||||
|
|
||||||
|
Create a new file containing an empty [route](../gpx).
|
||||||
|
|
||||||
### <FolderOpen size="16" class="inline-block" style="margin-bottom: 2px" /> Otevřít...
|
### <FolderOpen size="16" class="inline-block" style="margin-bottom: 2px" /> Otevřít...
|
||||||
|
|
||||||
Otevřít soubor z vašeho počítače.
|
Otevřít soubor z vašeho počítače.
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ title: Možnosti zobrazení
|
|||||||
---
|
---
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { ChartArea, ListTree, Map, Layers2, Coins, Milestone, Box, Maximize2 } from '@lucide/svelte';
|
import { ChartArea, ListTree, Map, Layers2, Coins, Milestone, EyeOff, Maximize, Box, Maximize2 } from '@lucide/svelte';
|
||||||
import DocsNote from '$lib/components/docs/DocsNote.svelte';
|
import DocsNote from '$lib/components/docs/DocsNote.svelte';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ Skrýt výškový profil, aby se vytvořilo místo pro mapu, nebo ho zobrazit a
|
|||||||
|
|
||||||
Přepnout rozvržení stromu pro [seznam souborů](../files-and-stats).
|
Přepnout rozvržení stromu pro [seznam souborů](../files-and-stats).
|
||||||
Toto zobrazení je ideální pro správu velkého počtu otevřených souborů, protože je uspořádá do svislého seznamu na pravé straně mapy.
|
Toto zobrazení je ideální pro správu velkého počtu otevřených souborů, protože je uspořádá do svislého seznamu na pravé straně mapy.
|
||||||
Kromě jiného umožňuje zobrazení stromu souborů zkontrolovat [trasy, segmenty, a body zájmu](../gpx) obsažené uvnitř souborů skrze sbalitelné sekce.
|
In addition, the file tree view enables you to inspect the [tracks, segments, routes, and points of interest](../gpx) contained inside the files through collapsible sections.
|
||||||
|
|
||||||
### <Map size="16" class="inline-block" style="margin-bottom: 2px" /> Přepnout na předchozí základní mapu
|
### <Map size="16" class="inline-block" style="margin-bottom: 2px" /> Přepnout na předchozí základní mapu
|
||||||
|
|
||||||
@@ -38,6 +38,14 @@ Zobrazují se pro aktuální výběr, jako je [výškový profil](../files-and-s
|
|||||||
|
|
||||||
Přepnout viditelnost směrových šipek na mapě.
|
Přepnout viditelnost směrových šipek na mapě.
|
||||||
|
|
||||||
|
### <EyeOff size="16" class="inline-block" style="margin-bottom: 2px" /> Hide/unhide
|
||||||
|
|
||||||
|
Toggle the visibility of the selected file items on the map.
|
||||||
|
|
||||||
|
### <Maximize size="16" class="inline-block" style="margin-bottom: 2px" /> Center
|
||||||
|
|
||||||
|
Center the map on the selected file items.
|
||||||
|
|
||||||
### <Box size="16" class="inline-block" style="margin-bottom: 2px" /> Přepnout 3D
|
### <Box size="16" class="inline-block" style="margin-bottom: 2px" /> Přepnout 3D
|
||||||
|
|
||||||
Zapnout nebo vypnout 3D zobrazení mapy.
|
Zapnout nebo vypnout 3D zobrazení mapy.
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ Tento nástroj umožňuje extrahovat [trasy (nebo úseky)](../gpx) ze souborů (
|
|||||||
<Extract class="text-foreground p-3 border rounded-md shadow-lg" />
|
<Extract class="text-foreground p-3 border rounded-md shadow-lg" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
Použití nástroje na soubor obsahující více tras vytvoří nový soubor pro každou z tras, kterou obsahuje.
|
Applying the tool to a file containing multiple [tracks or routes](../gpx) will create a new file for each of the tracks and routes it contains.
|
||||||
Obdobně použití nástroje na trasu obsahující více úseků vytvoří (ve stejném souboru) novou trasu pro každý úsek, který obsahuje.
|
Obdobně použití nástroje na trasu obsahující více úseků vytvoří (ve stejném souboru) novou trasu pro každý úsek, který obsahuje.
|
||||||
|
|
||||||
<DocsNote>
|
<DocsNote>
|
||||||
|
|||||||
@@ -10,11 +10,11 @@ title: Sloučit
|
|||||||
|
|
||||||
# <Group size="24" class="inline-block" style="margin-bottom: 5px" /> { title }
|
# <Group size="24" class="inline-block" style="margin-bottom: 5px" /> { title }
|
||||||
|
|
||||||
Chcete-li použít tento nástroj, musíte [vybrat](../files-and-stats) více souborů, [tras nebo segmentů](../gpx).
|
To use this tool, you need to [select](../files-and-stats) multiple files, [tracks, segments or routes](../gpx).
|
||||||
|
|
||||||
- Pokud je vaším cílem vytvořit z vašeho výběru jednu spojitou stopu, použijte možnost **Připojit stopy** a potvrďte.
|
- Pokud je vaším cílem vytvořit z vašeho výběru jednu spojitou stopu, použijte možnost **Připojit stopy** a potvrďte.
|
||||||
- Druhá možnost může být použita k vytvoření nebo správě souborů s více [trasami nebo segmenty](../gpx).
|
- The second option can be used to create or manage files with multiple [tracks, segments or routes](../gpx).
|
||||||
Sloučením souborů (nebo tras) vznikne jeden soubor (nebo trasa) obsahující všechny trasy (nebo úseky) z výběru.
|
Merging files (or tracks) will result in a single file (or track) containing all tracks and routes (or segments) from the selection.
|
||||||
|
|
||||||
<DocsNote>
|
<DocsNote>
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,6 @@ Chcete-li rozdělit vybranou stopu na dvě části, klikněte na jednu z rozděl
|
|||||||
Chcete-li rozdělit stopu v určitém bodě dle vašeho výběru, najeďte nad stopu na mapě.
|
Chcete-li rozdělit stopu v určitém bodě dle vašeho výběru, najeďte nad stopu na mapě.
|
||||||
Na pozici kurzoru se objeví nůžky, což znázorňuje, že v tomto bodě můžete stopu rozdělit.
|
Na pozici kurzoru se objeví nůžky, což znázorňuje, že v tomto bodě můžete stopu rozdělit.
|
||||||
|
|
||||||
Můžete zvolit rozdělení stopy na dva GPX soubory, nebo uchovat rozdělené části ve stejném souboru jako [trasy nebo segmenty](../gpx).
|
You can choose to split the trace into two GPX files, or to keep the split parts in the same file as [tracks, segments or routes](../gpx).
|
||||||
|
|
||||||
<DocsImage src="tools/split" alt="Najetí kurzorem nad vybranou stopu změní kurzor v nůžky." />
|
<DocsImage src="tools/split" alt="Najetí kurzorem nad vybranou stopu změní kurzor v nůžky." />
|
||||||
@@ -51,7 +51,7 @@ By right-clicking on a file tab, you can access the same actions as in the [edit
|
|||||||
|
|
||||||
As mentioned in the [view options section](./menu/view), you can switch to a tree layout for the files list.
|
As mentioned in the [view options section](./menu/view), you can switch to a tree layout for the files list.
|
||||||
This layout is ideal for managing a large number of open files, as it organizes them into a vertical list on the right side of the map.
|
This layout is ideal for managing a large number of open files, as it organizes them into a vertical list on the right side of the map.
|
||||||
In addition, the file tree view enables you to inspect the [tracks, segments, and points of interest](./gpx) contained inside the files through collapsible sections.
|
In addition, the file tree view enables you to inspect the [tracks, segments, routes, and points of interest](./gpx) contained inside the files through collapsible sections.
|
||||||
|
|
||||||
You can also apply [edit actions](./menu/edit) and [tools](./toolbar) to internal file items.
|
You can also apply [edit actions](./menu/edit) and [tools](./toolbar) to internal file items.
|
||||||
Furthermore, you can drag and drop the inner items to reorder them, or move them in the hierarchy or even to another file.
|
Furthermore, you can drag and drop the inner items to reorder them, or move them in the hierarchy or even to another file.
|
||||||
|
|||||||
@@ -3,13 +3,15 @@ title: GPX file format
|
|||||||
---
|
---
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { Waypoints, MapPin } from '@lucide/svelte';
|
import DocsNote from '$lib/components/docs/DocsNote.svelte';
|
||||||
|
import { Waypoints, Route, MapPin } from '@lucide/svelte';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
# { title }
|
# { title }
|
||||||
|
|
||||||
The <a href="https://www.topografix.com/gpx.asp" target="_blank">GPX file format</a> is an open standard for exchanging GPS data between applications and GPS devices.
|
The <a href="https://www.topografix.com/gpx.asp" target="_blank">GPX file format</a> is an open standard for exchanging GPS data between applications and GPS devices.
|
||||||
It essentially consists of a series of GPS points encoding one or multiple GPS traces, and, optionally, some points of interest.
|
It essentially consists of a series of GPS points encoding one or multiple GPS traces, and, optionally, some points of interest.
|
||||||
|
These traces can be stored either as tracks or as routes.
|
||||||
|
|
||||||
GPX files may also contain metadata, of which the **name** and **description** fields are the most useful for users.
|
GPX files may also contain metadata, of which the **name** and **description** fields are the most useful for users.
|
||||||
|
|
||||||
@@ -27,6 +29,20 @@ These are organized in a hierarchical structure, with tracks at the top level.
|
|||||||
In most cases, GPX files contain a single track with a single segment.
|
In most cases, GPX files contain a single track with a single segment.
|
||||||
However, the hierarchy described above allows for more advanced use cases, such as planning multi-day trips with several variants for each day.
|
However, the hierarchy described above allows for more advanced use cases, such as planning multi-day trips with several variants for each day.
|
||||||
|
|
||||||
|
### <Route size="16" class="inline-block" style="margin-bottom: 2px" /> Routes
|
||||||
|
|
||||||
|
A **route** is a single continuous path made of a sequence of **route points**.
|
||||||
|
These are mandatory checkpoints, which correspond to the anchor points of the [routing tool](./toolbar/routing).
|
||||||
|
The points in between are only a suggested path connecting the route points.
|
||||||
|
Like a track, a route can have a **name**, a **description**, and **appearance properties**.
|
||||||
|
|
||||||
|
<DocsNote>
|
||||||
|
|
||||||
|
Nowadays, most apps and GPS devices work perfectly well with tracks, even for navigation.
|
||||||
|
However, some of them only work with routes: in that case, you can [convert](./menu/edit) your tracks to routes, or [create](./menu/file) a route file from the start.
|
||||||
|
|
||||||
|
</DocsNote>
|
||||||
|
|
||||||
### <MapPin size="16" class="inline-block" style="margin-bottom: 2px" /> Points of interest
|
### <MapPin size="16" class="inline-block" style="margin-bottom: 2px" /> Points of interest
|
||||||
|
|
||||||
**Points of interest** (technically called _waypoints_) represent locations of interest to show either on a GPS device or on a digital map.
|
**Points of interest** (technically called _waypoints_) represent locations of interest to show either on a GPS device or on a digital map.
|
||||||
|
|||||||
@@ -3,14 +3,14 @@ title: Edit actions
|
|||||||
---
|
---
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Undo2, Redo2, Info, PaintBucket, EyeOff, FileStack, ClipboardCopy, Scissors, ClipboardPaste, Trash2, Maximize, Plus } from '@lucide/svelte';
|
import { Undo2, Redo2, Info, PaintBucket, ArrowRightLeft, FileStack, ClipboardCopy, Scissors, ClipboardPaste, Trash2, Plus } from '@lucide/svelte';
|
||||||
import DocsNote from '$lib/components/docs/DocsNote.svelte';
|
import DocsNote from '$lib/components/docs/DocsNote.svelte';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
# { title }
|
# { title }
|
||||||
|
|
||||||
Unlike the file actions, the edit actions can potentially modify the content of the currently selected files.
|
Unlike the file actions, the edit actions can potentially modify the content of the currently selected files.
|
||||||
Moreover, when the tree layout of the files list is enabled (see [Files and statistics](../files-and-stats)), they can also be applied to [tracks, segments, and points of interest](../gpx).
|
Moreover, when the tree layout of the files list is enabled (see [Files and statistics](../files-and-stats)), they can also be applied to [tracks, segments, routes, and points of interest](../gpx).
|
||||||
Therefore, we will refer to the elements that can be modified by these actions as _file items_.
|
Therefore, we will refer to the elements that can be modified by these actions as _file items_.
|
||||||
Note that except for the undo and redo actions, the edit actions are also accessible through the context menu (right-click) of the file items.
|
Note that except for the undo and redo actions, the edit actions are also accessible through the context menu (right-click) of the file items.
|
||||||
|
|
||||||
@@ -27,10 +27,6 @@ Open the information dialog of the currently selected file item, where you can s
|
|||||||
|
|
||||||
Open the appearance dialog, where you can change the color, opacity, and width of the selected file items on the map.
|
Open the appearance dialog, where you can change the color, opacity, and width of the selected file items on the map.
|
||||||
|
|
||||||
### <EyeOff size="16" class="inline-block" style="margin-bottom: 2px" /> Hide/unhide
|
|
||||||
|
|
||||||
Toggle the visibility of the selected file items on the map.
|
|
||||||
|
|
||||||
### <Plus size="16" class="inline-block" style="margin-bottom: 2px" /> New track
|
### <Plus size="16" class="inline-block" style="margin-bottom: 2px" /> New track
|
||||||
|
|
||||||
Create a new track in the selected file.
|
Create a new track in the selected file.
|
||||||
@@ -42,6 +38,17 @@ Additionally, the selection must be a single file.
|
|||||||
|
|
||||||
</DocsNote>
|
</DocsNote>
|
||||||
|
|
||||||
|
### <Plus size="16" class="inline-block" style="margin-bottom: 2px" /> New route
|
||||||
|
|
||||||
|
Create a new route in the selected file.
|
||||||
|
|
||||||
|
<DocsNote>
|
||||||
|
|
||||||
|
This action is only available when the tree layout of the files list is enabled.
|
||||||
|
Additionally, the selection must be a single file.
|
||||||
|
|
||||||
|
</DocsNote>
|
||||||
|
|
||||||
### <Plus size="16" class="inline-block" style="margin-bottom: 2px" /> New segment
|
### <Plus size="16" class="inline-block" style="margin-bottom: 2px" /> New segment
|
||||||
|
|
||||||
Create a new segment in the selected track.
|
Create a new segment in the selected track.
|
||||||
@@ -53,14 +60,17 @@ Additionally, the selection must be a single track.
|
|||||||
|
|
||||||
</DocsNote>
|
</DocsNote>
|
||||||
|
|
||||||
|
### <ArrowRightLeft size="16" class="inline-block" style="margin-bottom: 2px" /> Convert to route/track
|
||||||
|
|
||||||
|
Convert the selected routes to tracks, or the selected tracks or segments to routes.
|
||||||
|
Since a route has a single segment, a track with multiple segments is converted into one route per segment.
|
||||||
|
|
||||||
|
When the selected files contain only routes, or only tracks, you can also convert all of them at once.
|
||||||
|
|
||||||
### <FileStack size="16" class="inline-block" style="margin-bottom: 2px" /> Select all
|
### <FileStack size="16" class="inline-block" style="margin-bottom: 2px" /> Select all
|
||||||
|
|
||||||
Add all file items in the current hierarchy level to the selection.
|
Add all file items in the current hierarchy level to the selection.
|
||||||
|
|
||||||
### <Maximize size="16" class="inline-block" style="margin-bottom: 2px" /> Center
|
|
||||||
|
|
||||||
Center the map on the selected file items.
|
|
||||||
|
|
||||||
### <ClipboardCopy size="16" class="inline-block" style="margin-bottom: 2px" /> Kopier
|
### <ClipboardCopy size="16" class="inline-block" style="margin-bottom: 2px" /> Kopier
|
||||||
|
|
||||||
Copy the selected file items to the clipboard.
|
Copy the selected file items to the clipboard.
|
||||||
|
|||||||
@@ -15,6 +15,10 @@ The file actions menu contains a set of pretty self-explanatory file operations.
|
|||||||
|
|
||||||
Create a new empty file.
|
Create a new empty file.
|
||||||
|
|
||||||
|
### <Plus size="16" class="inline-block" style="margin-bottom: 2px" /> New route file
|
||||||
|
|
||||||
|
Create a new file containing an empty [route](../gpx).
|
||||||
|
|
||||||
### <FolderOpen size="16" class="inline-block" style="margin-bottom: 2px" /> Open...
|
### <FolderOpen size="16" class="inline-block" style="margin-bottom: 2px" /> Open...
|
||||||
|
|
||||||
Open files from your computer.
|
Open files from your computer.
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ title: View options
|
|||||||
---
|
---
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { ChartArea, ListTree, Map, Layers2, Coins, Milestone, Box, Maximize2 } from '@lucide/svelte';
|
import { ChartArea, ListTree, Map, Layers2, Coins, Milestone, EyeOff, Maximize, Box, Maximize2 } from '@lucide/svelte';
|
||||||
import DocsNote from '$lib/components/docs/DocsNote.svelte';
|
import DocsNote from '$lib/components/docs/DocsNote.svelte';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ Hide the elevation profile to make room for the map, or show it to inspect the c
|
|||||||
|
|
||||||
Toggle the tree layout for the [file list](../files-and-stats).
|
Toggle the tree layout for the [file list](../files-and-stats).
|
||||||
This layout is ideal for managing a large number of open files, as it organizes them into a vertical list on the right side of the map.
|
This layout is ideal for managing a large number of open files, as it organizes them into a vertical list on the right side of the map.
|
||||||
In addition, the file tree view enables you to inspect the [tracks, segments, and points of interest](../gpx) contained inside the files through collapsible sections.
|
In addition, the file tree view enables you to inspect the [tracks, segments, routes, and points of interest](../gpx) contained inside the files through collapsible sections.
|
||||||
|
|
||||||
### <Map size="16" class="inline-block" style="margin-bottom: 2px" /> Switch to previous basemap
|
### <Map size="16" class="inline-block" style="margin-bottom: 2px" /> Switch to previous basemap
|
||||||
|
|
||||||
@@ -38,6 +38,14 @@ They are displayed for the current selection, like the [elevation profile](../fi
|
|||||||
|
|
||||||
Toggle the visibility of direction arrows on the map.
|
Toggle the visibility of direction arrows on the map.
|
||||||
|
|
||||||
|
### <EyeOff size="16" class="inline-block" style="margin-bottom: 2px" /> Hide/unhide
|
||||||
|
|
||||||
|
Toggle the visibility of the selected file items on the map.
|
||||||
|
|
||||||
|
### <Maximize size="16" class="inline-block" style="margin-bottom: 2px" /> Center
|
||||||
|
|
||||||
|
Center the map on the selected file items.
|
||||||
|
|
||||||
### <Box size="16" class="inline-block" style="margin-bottom: 2px" /> Toggle 3D
|
### <Box size="16" class="inline-block" style="margin-bottom: 2px" /> Toggle 3D
|
||||||
|
|
||||||
Enter or exit the 3D map view.
|
Enter or exit the 3D map view.
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ This tool allows you to extract [tracks (or segments)](../gpx) from files (or tr
|
|||||||
<Extract class="text-foreground p-3 border rounded-md shadow-lg" />
|
<Extract class="text-foreground p-3 border rounded-md shadow-lg" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
Applying the tool to a file containing multiple tracks will create a new file for each of the tracks it contains.
|
Applying the tool to a file containing multiple [tracks or routes](../gpx) will create a new file for each of the tracks and routes it contains.
|
||||||
Similarly, applying the tool to a track containing multiple segments will create (in the same file) a new track for each of the segments it contains.
|
Similarly, applying the tool to a track containing multiple segments will create (in the same file) a new track for each of the segments it contains.
|
||||||
|
|
||||||
<DocsNote>
|
<DocsNote>
|
||||||
|
|||||||
Loaded 100 of 421 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user