Merge branch 'dev'

This commit is contained in:
vcoppe committed 2026-11-15 13:15:08 +01:00
commit 2e0edc716b
11 files changed
+148 -73

No files matched your search

+13
View File
@@ -52,6 +52,18 @@ npm install
npm run dev npm run dev
``` ```
### Testing
Each part has its own tests:
```bash
cargo test # the engine (gpx-rs), from the root of the repository
(cd wasm && wasm-pack test --node) # the WebAssembly bindings
npm test --prefix website # the website, once the WebAssembly engine is built
```
See [`tauri`](tauri/README.md) for the tests of the desktop app.
## Credits ## Credits
This project has been made possible thanks to the following open source projects: This project has been made possible thanks to the following open source projects:
@@ -59,6 +71,7 @@ This project has been made possible thanks to the following open source projects
- Development: - Development:
- [Svelte](https://github.com/sveltejs/svelte) and [SvelteKit](https://github.com/sveltejs/kit) — seamless development experience - [Svelte](https://github.com/sveltejs/svelte) and [SvelteKit](https://github.com/sveltejs/kit) — seamless development experience
- [MDsveX](https://github.com/pngwn/MDsveX) — allowing a Markdown-based documentation - [MDsveX](https://github.com/pngwn/MDsveX) — allowing a Markdown-based documentation
- [Tauri](https://github.com/tauri-apps/tauri) – making a desktop app possible
- Design: - Design:
- [shadcn-svelte](https://github.com/huntabyte/shadcn-svelte) — beautiful components - [shadcn-svelte](https://github.com/huntabyte/shadcn-svelte) — beautiful components
- [@lucide/svelte](https://github.com/lucide-icons/lucide/tree/main/packages/svelte) — beautiful icons - [@lucide/svelte](https://github.com/lucide-icons/lucide/tree/main/packages/svelte) — beautiful icons
+31 -4
View File
@@ -3,11 +3,11 @@ use crate::{
TrackpointCategories, TrackpointChunk, Waypoint, WaypointChunk, distance, TrackpointCategories, TrackpointChunk, Waypoint, WaypointChunk, distance,
}; };
use chrono::DateTime; use chrono::DateTime;
use quick_xml::{Error, XmlVersion};
use quick_xml::escape::resolve_predefined_entity; use quick_xml::escape::resolve_predefined_entity;
use quick_xml::events::Event; use quick_xml::events::Event;
use quick_xml::events::attributes::{Attribute, Attributes}; use quick_xml::events::attributes::{Attribute, Attributes};
use quick_xml::reader::Reader; use quick_xml::reader::Reader;
use quick_xml::{Error, XmlVersion};
enum GPXElement { enum GPXElement {
Metadata, Metadata,
@@ -213,16 +213,21 @@ fn apply_text(
} }
Some(GPXElement::Time) => { Some(GPXElement::Time) => {
stack.pop(); stack.pop();
if let Some(GPXElement::Trackpoint(trkpt)) = stack.last_mut() { let time = DateTime::parse_from_rfc3339(e)
trkpt.time = DateTime::parse_from_rfc3339(e)
.ok() .ok()
.map(|time| time.timestamp_millis()); .map(|time| time.timestamp_millis());
match stack.last_mut() {
Some(GPXElement::Trackpoint(trkpt)) => trkpt.time = time,
Some(GPXElement::Waypoint(wpt)) => wpt.time = time,
Some(GPXElement::Metadata) => gpx.info.time = time,
_ => (),
} }
} }
Some(GPXElement::Temperature) => { Some(GPXElement::Temperature) => {
stack.pop(); stack.pop();
if let Some(GPXElement::Trackpoint(trkpt)) = stack.last_mut() { if let Some(GPXElement::Trackpoint(trkpt)) = stack.last_mut() {
trkpt.atemp = e.parse().ok(); // Garmin Connect writes whole degrees as "21.0"
trkpt.atemp = e.parse::<f64>().ok().map(|t| t.round() as i16);
} }
} }
Some(GPXElement::Heartrate) => { Some(GPXElement::Heartrate) => {
@@ -1142,6 +1147,20 @@ mod tests {
assert!(wpt.type_.as_ref().is_some_and(|t| t == "Bike Trail")); assert!(wpt.type_.as_ref().is_some_and(|t| t == "Bike Trail"));
} }
#[test]
fn test_parse_waypoint_time() {
let data = r#"<gpx><wpt lat="1" lon="2"><time>2024-05-01T06:10:00Z</time></wpt></gpx>"#;
let gpx = parse(data.as_bytes(), &mut Default::default()).unwrap();
assert_eq!(gpx.wpt[0].time, Some(1714543800000));
}
#[test]
fn test_parse_metadata_time() {
let data = r#"<gpx><metadata><time>2024-05-01T06:10:00Z</time></metadata></gpx>"#;
let gpx = parse(data.as_bytes(), &mut Default::default()).unwrap();
assert_eq!(gpx.info.time, Some(1714543800000));
}
#[test] #[test]
fn test_parse_trackpoint_time() { fn test_parse_trackpoint_time() {
let gpx = parse_data("with_time"); let gpx = parse_data("with_time");
@@ -1325,6 +1344,14 @@ mod tests {
assert!(trkpt.atemp.is_some_and(|t| t == 21)); assert!(trkpt.atemp.is_some_and(|t| t == 21));
} }
#[test]
fn test_parse_trackpoint_decimal_atemp() {
let data = r#"<gpx><trk><trkseg><trkpt lat="1" lon="2"><extensions><gpxtpx:TrackPointExtension>
<gpxtpx:atemp>21.0</gpxtpx:atemp></gpxtpx:TrackPointExtension></extensions></trkpt></trkseg></trk></gpx>"#;
let gpx = parse(data.as_bytes(), &mut Default::default()).unwrap();
assert_eq!(gpx.trk[0].trkseg[0][0].atemp, Some(21));
}
#[test] #[test]
fn test_parse_track_style() { fn test_parse_track_style() {
let gpx = parse_data("with_style"); let gpx = parse_data("with_style");
+38
View File
@@ -0,0 +1,38 @@
# tauri
The desktop app of gpx.studio, built with [Tauri 2](https://v2.tauri.app/).
Its UI is the website ([`../website`](../website)), and it runs the engine of [`../gpx-rs`](../gpx-rs) natively instead of in WebAssembly.
## Development
You will need the same tools as for the website: [Node.js](https://nodejs.org/), [Rust](https://rustup.rs/) and [wasm-pack](https://rustwasm.github.io/wasm-pack/).
To run the app in development mode, you will also need to install the [system dependencies of Tauri](https://v2.tauri.app/start/prerequisites/) for your platform and the Tauri CLI:
```bash
cargo install tauri-cli --version "^2"
```
### Setting up the frontend
The desktop app does not use the WebAssembly engine, but the website depends on its package.
From the root of the repository, build it once and install the website’s dependencies:
```bash
cd wasm && wasm-pack build --target bundler && cd ..
npm install --prefix website
```
For the MapTiler layers, add your key to `website/.env`, as explained in the [main README](../README.md#running-the-website).
### Running the app
```bash
cd tauri
cargo tauri dev
```
### Testing
```bash
cargo test -p gpx-studio-desktop
```
+13 -13
View File
@@ -18,7 +18,7 @@
"gpx-wasm": "file:../wasm/pkg", "gpx-wasm": "file:../wasm/pkg",
"jszip": "^3.10.1", "jszip": "^3.10.1",
"mapillary-js": "^4.1.2", "mapillary-js": "^4.1.2",
"maplibre-gl": "^6.15.0", "maplibre-gl": "^6.18.0",
"sanitize-html": "^2.17.0", "sanitize-html": "^2.17.0",
"sortablejs": "^1.15.7" "sortablejs": "^1.15.7"
}, },
@@ -1788,9 +1788,9 @@
} }
}, },
"node_modules/@maplibre/maplibre-gl-style-spec": { "node_modules/@maplibre/maplibre-gl-style-spec": {
"version": "26.4.4", "version": "26.7.0",
"resolved": "https://registry.npmjs.org/@maplibre/maplibre-gl-style-spec/-/maplibre-gl-style-spec-26.4.4.tgz", "resolved": "https://registry.npmjs.org/@maplibre/maplibre-gl-style-spec/-/maplibre-gl-style-spec-26.7.0.tgz",
"integrity": "sha512-hG4RZR4PBd/+6A3ODdZ3AnQRF106ZQk1y3bhwDg8bH/A4Oz2tnRUJVVWs9BZa6gXZ1d3UKe89C+Mm+olGBELvA==", "integrity": "sha512-9d7hK1zk1WRx/AFvq7NtmlTlaOGPXS2r+FZXsrMv8453Xy14bnXBpVCPJDBupCfQs/p8FL0/kb0ygbEWTufN0g==",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@mapbox/jsonlint-lines-primitives": "^2.0.3", "@mapbox/jsonlint-lines-primitives": "^2.0.3",
@@ -1816,14 +1816,14 @@
} }
}, },
"node_modules/@maplibre/vt-pbf": { "node_modules/@maplibre/vt-pbf": {
"version": "4.3.2", "version": "4.3.3",
"resolved": "https://registry.npmjs.org/@maplibre/vt-pbf/-/vt-pbf-4.3.2.tgz", "resolved": "https://registry.npmjs.org/@maplibre/vt-pbf/-/vt-pbf-4.3.3.tgz",
"integrity": "sha512-j6p0AdjvAR19Z3XaCysle7A4ZSo08tYOzxD0Y9NQylwPAkwJJeYub5b2eVucdeDh7erhv69DahoLOevDRERRUw==", "integrity": "sha512-dEe5XUd64RQbxNxy2OzIkJnwNDWjVmSXjCd0A7zLirm7QJ/WWbmtDFIkfsiM4yt1cplqzG6oSivRYeWx1SM1yg==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@mapbox/point-geometry": "^1.1.0", "@mapbox/point-geometry": "^1.1.0",
"@types/geojson": "^7946.0.16", "@types/geojson": "^7946.0.16",
"pbf": "^5.1.0" "pbf": "^5.1.2"
} }
}, },
"node_modules/@maplibre/vt-pbf/node_modules/pbf": { "node_modules/@maplibre/vt-pbf/node_modules/pbf": {
@@ -4674,9 +4674,9 @@
"license": "(MIT AND Zlib)" "license": "(MIT AND Zlib)"
}, },
"node_modules/maplibre-gl": { "node_modules/maplibre-gl": {
"version": "6.15.0", "version": "6.18.0",
"resolved": "https://registry.npmjs.org/maplibre-gl/-/maplibre-gl-6.15.0.tgz", "resolved": "https://registry.npmjs.org/maplibre-gl/-/maplibre-gl-6.18.0.tgz",
"integrity": "sha512-kxFetbvUHDOVaAP1CYb226Mdk2QhzIPddqM0xJTFD35wu78Mpd6NM7+H68ALjc6Oa0kAOX5EAdMKyvD2u3qfcg==", "integrity": "sha512-8ucT+RhJtEZGFvWGPioVQwvOPMAIuUehEgxl2dELw9aJmX4SpUi+OCHHAD33B9EuohNC7kC/gccJacUgTMQfQQ==",
"license": "BSD-3-Clause", "license": "BSD-3-Clause",
"dependencies": { "dependencies": {
"@mapbox/point-geometry": "^1.1.0", "@mapbox/point-geometry": "^1.1.0",
@@ -4684,9 +4684,9 @@
"@mapbox/unitbezier": "^1.0.0", "@mapbox/unitbezier": "^1.0.0",
"@mapbox/vector-tile": "^3.0.0", "@mapbox/vector-tile": "^3.0.0",
"@maplibre/geojson-vt": "^6.3.0", "@maplibre/geojson-vt": "^6.3.0",
"@maplibre/maplibre-gl-style-spec": "^26.4.4", "@maplibre/maplibre-gl-style-spec": "^26.6.0",
"@maplibre/mlt": "^1.3.0", "@maplibre/mlt": "^1.3.0",
"@maplibre/vt-pbf": "^4.3.2", "@maplibre/vt-pbf": "^4.3.3",
"@types/geojson": "^7946.0.16", "@types/geojson": "^7946.0.16",
"bidi-js": "^1.1.0", "bidi-js": "^1.1.0",
"earcut": "^3.2.4", "earcut": "^3.2.4",
+1 -1
View File
@@ -82,7 +82,7 @@
"gpx-wasm": "file:../wasm/pkg", "gpx-wasm": "file:../wasm/pkg",
"jszip": "^3.10.1", "jszip": "^3.10.1",
"mapillary-js": "^4.1.2", "mapillary-js": "^4.1.2",
"maplibre-gl": "^6.15.0", "maplibre-gl": "^6.18.0",
"sanitize-html": "^2.17.0", "sanitize-html": "^2.17.0",
"sortablejs": "^1.15.7" "sortablejs": "^1.15.7"
} }
+1 -2
View File
@@ -45,8 +45,7 @@ title: 文件和统计
### 树形布局 ### 树形布局
正如 [显示](./menu/view) 中所述,文件列表可切换为树形布局。此布局非常适合管理大量已打开的文件,文件将被组织成一个纵向列表并显示在地图右侧。 正如 [显示](./menu/view) 中所述,文件列表可切换为树形布局。此布局非常适合管理大量已打开的文件,文件将被组织成一个纵向列表并显示在地图右侧。在文件树中,展开可折叠部分可检查其中所包含的 [轨迹、分段、路线和兴趣点](./gpx) 等要素。
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.
[编辑](./menu/edit) 和 [工具](./toolbar) 亦可被用于文件内部要素。此外,拖拽内部要素可对其重新排序,或将它们移动到其他层级甚至另一个文件中。 [编辑](./menu/edit) 和 [工具](./toolbar) 亦可被用于文件内部要素。此外,拖拽内部要素可对其重新排序,或将它们移动到其他层级甚至另一个文件中。
+4 -6
View File
@@ -9,8 +9,7 @@ title: GPX 文件格式
# { title } # { title }
<a href="https://www.topografix.com/gpx.asp" target="_blank">GPX 文件格式</a> 是应用程序和 GPS 设备之间交换 GPS 数据的一种开放标准。它本质上由一系列 GPS 点组成,用以编码形成一条或多条轨迹,以及兴趣点(可选)。 <a href="https://www.topografix.com/gpx.asp" target="_blank">GPX 文件格式</a> 是应用程序和 GPS 设备之间交换 GPS 数据的一种开放标准。它本质上由一系列 GPS 点组成,用以编码形成一条或多条轨迹,以及兴趣点(可选)。这些连线可以储存为轨迹或路线。
These traces can be stored either as tracks or as routes.
还可以包含元数据,其中 **名称(name)** 和 **描述(description)** 字段对用户最有用。 还可以包含元数据,其中 **名称(name)** 和 **描述(description)** 字段对用户最有用。
@@ -26,14 +25,13 @@ GPX 文件通常只包含一条轨迹,且该轨迹仅有一个路段。不过
### <Route size="16" class="inline-block" style="margin-bottom: 2px" /> Routes ### <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). 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> <DocsNote>
Nowadays, most apps and GPS devices work perfectly well with tracks, even for navigation. 现在,大多数应用和 GPS 设备都与轨迹完全兼容,甚至用于导航。
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. 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> </DocsNote>
+3 -3
View File
@@ -37,7 +37,7 @@ Moreover, when the tree layout of the files list is enabled (see [Files and stat
### <Plus size="16" class="inline-block" style="margin-bottom: 2px" /> New route ### <Plus size="16" class="inline-block" style="margin-bottom: 2px" /> New route
Create a new route in the selected file. 在所选文件项中创建一条新路线。
<DocsNote> <DocsNote>
@@ -57,10 +57,10 @@ Create a new route in the selected file.
### <ArrowRightLeft size="16" class="inline-block" style="margin-bottom: 2px" /> Convert to route/track ### <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. 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" /> 全选 ### <FileStack size="16" class="inline-block" style="margin-bottom: 2px" /> 全选
+1 -1
View File
@@ -14,7 +14,7 @@ To use this tool, you need to [select](../files-and-stats) multiple files, [trac
- 若要生成一条连续轨迹,请选择 **合并为一条连续轨迹**; - 若要生成一条连续轨迹,请选择 **合并为一条连续轨迹**;
- The second option can be used to create or manage files with multiple [tracks, segments or routes](../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 and routes (or segments) from the selection. 并将所有内容存储在一个文件(或轨迹)中,请选择 **合并但保持轨迹和路线(或分段)独立**。
<DocsNote> <DocsNote>
+1 -1
View File
@@ -22,6 +22,6 @@ title: 裁剪和拆分
若要将轨迹拆分为两部分,请点击轨迹上显示的任意分割标记。若要在指定位置进行拆分,请将鼠标悬停在轨迹上,光标位置将出现剪刀图标,表明可在该处拆分。 若要将轨迹拆分为两部分,请点击轨迹上显示的任意分割标记。若要在指定位置进行拆分,请将鼠标悬停在轨迹上,光标位置将出现剪刀图标,表明可在该处拆分。
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). 支持将轨迹拆分为两个 GPX 文件,或将它们作为不同的 [轨迹或分段](../gpx) 保留在同一个文件中。
<DocsImage src="tools/split" alt="鼠标悬停在轨迹上时,光标将变为剪刀式样" /> <DocsImage src="tools/split" alt="鼠标悬停在轨迹上时,光标将变为剪刀式样" />
+42 -42
View File
@@ -9,42 +9,42 @@
}, },
"menu": { "menu": {
"new_file": "新建文件", "new_file": "新建文件",
"new_route_file": "New route file", "new_route_file": "新建路线文件",
"new_track": "新建轨迹", "new_track": "新建轨迹",
"new_route": "New route", "new_route": "新路线",
"convert_to_route": "Convert to route", "convert_to_route": "转换为路径",
"convert_to_track": "Convert to track", "convert_to_track": "转换为轨迹",
"convert_to_routes": "Convert to route file", "convert_to_routes": "转换为路径文件",
"convert_to_tracks": "Convert to track file", "convert_to_tracks": "转换为轨迹文件",
"new_segment": "新建路段", "new_segment": "新建路段",
"open": "打开...", "open": "打开...",
"open_folder": "Open folder...", "open_folder": "打开文件夹……",
"explorer": "Explorer", "explorer": "资源管理器",
"explorer_menu": { "explorer_menu": {
"open": "Open", "open": "打开",
"new_file": "New file...", "new_file": "新建文件……",
"new_route_file": "New route file...", "new_route_file": "新建路线文件……",
"new_folder": "New folder...", "new_folder": "新建文件夹……",
"rename": "Rename...", "rename": "重命名……",
"reveal_finder": "Reveal in Finder", "reveal_finder": "在 Finder 中查看",
"reveal": "Reveal in file explorer", "reveal": "在资源管理器中显示文件",
"delete_failed": "The files could not be moved to the trash." "delete_failed": "无法将文件移动到回收站。"
}, },
"workspace": "Workspace", "workspace": "工作区",
"save": "Save", "save": "保存",
"save_all": "Save all", "save_all": "全部保存",
"save_as": "Save as...", "save_as": "另存为……",
"close": "关闭", "close": "关闭",
"close_all": "关闭全部", "close_all": "关闭全部",
"close_folder": "Close folder", "close_folder": "关闭文件夹",
"reload": "Reload from disk", "reload": "从硬盘重新加载",
"discard": "Discard", "discard": "丢弃",
"cancel": "Cancel", "cancel": "取消",
"overwrite": "Overwrite", "overwrite": "覆盖",
"unsaved_title": "Unsaved changes", "unsaved_title": "未保存的更改",
"unsaved_description": "These files have changes that are not saved:", "unsaved_description": "这些文件的更改未保存:",
"overwrite_title": "Overwrite changes made elsewhere?", "overwrite_title": "覆盖其他地方的更改?",
"overwrite_description": "These files have changes, and were also changed on the disk. Overwrite what is on the disk, or reload it and lose your changes?", "overwrite_description": "这些文件有更改,也在磁盘上被更改。覆盖磁盘上的内容,或重新加载它并丢失您的更改?",
"duplicate": "创建副本", "duplicate": "创建副本",
"copy": "复制", "copy": "复制",
"paste": "粘贴", "paste": "粘贴",
@@ -102,9 +102,9 @@
"name": "名称", "name": "名称",
"description": "说明", "description": "说明",
"save": "保存", "save": "保存",
"rename_file": "Rename the file on disk", "rename_file": "重命名硬盘上的文件",
"name_taken": "A file with this name already exists in the folder.", "name_taken": "此文件夹中已存在具有该名称的文件。",
"rename_failed": "The file could not be renamed." "rename_failed": "无法重命名文件。"
}, },
"style": { "style": {
"button": "外观...", "button": "外观...",
@@ -468,8 +468,8 @@
"gpx": { "gpx": {
"file": "文件", "file": "文件",
"files": "文件", "files": "文件",
"route": "Route", "route": "路线",
"routes": "Routes", "routes": "路线",
"track": "轨迹", "track": "轨迹",
"tracks": "轨迹", "tracks": "轨迹",
"segment": "路段", "segment": "路段",
@@ -595,15 +595,15 @@
"enable_webgl2": "学习如何在浏览器中启用 WebGL 2", "enable_webgl2": "学习如何在浏览器中启用 WebGL 2",
"page_not_found": "无法找到页面", "page_not_found": "无法找到页面",
"outdated": { "outdated": {
"title": "This page is out of date", "title": "此页面已过期",
"description": "Your files were saved by a newer version of gpx.studio, which this page cannot read. Reload the page to get the latest version.", "description": "你的文件已被新版本的 gpx.studio 保存,这个页面无法读取该文件。重新加载页面以获取最新版本的页面。",
"reload": "Reload" "reload": "重新加载"
}, },
"desktop": { "desktop": {
"update_available": "gpx.studio {version} is available", "update_available": "gpx.studio {version} 现已可用",
"update_restart": "Update and restart", "update_restart": "更新并重启",
"update_download": "Download", "update_download": "下载",
"update_installing": "Installing the update...", "update_installing": "正在安装更新……",
"update_failed": "The update could not be installed" "update_failed": "无法安装更新"
} }
} }