Skip to content

fix(gpx): output valid <wpt> tag for home waypoint (resolves #20)#31

Merged
nerdCopter merged 3 commits into
masterfrom
20251213_FIX_ISSUE_20
Dec 13, 2025
Merged

fix(gpx): output valid <wpt> tag for home waypoint (resolves #20)#31
nerdCopter merged 3 commits into
masterfrom
20251213_FIX_ISSUE_20

Conversation

@nerdCopter
Copy link
Copy Markdown
Owner

@nerdCopter nerdCopter commented Dec 13, 2025

Summary

Validation

  • .gpx file successfully tested in Google Maps.
  • All tests and formatting checks pass.

Closes #20.

Summary by CodeRabbit

  • New Features
    • GPX exports now include a Home waypoint when home coordinates are present, placed before track data for clearer navigation context.
  • Tests
    • Added tests covering Home waypoint presence, formatting, precision, and edge cases (empty or multiple home coordinates).

✏️ Tip: You can customize this high-level summary in your review settings.

- Remove underscore prefix from home_coordinates parameter (now used)
- Add home position waypoint to GPX files using first available H frame
- Waypoint includes name, symbol (Flag), and description for mapping tools
- Home coordinates are rendered before track segment for proper GPX structure
- Provides visual reference point in GPS mapping applications
- Backward compatible: waypoints are optional in GPX 1.1 spec

Resolves #20
- Add missing closing bracket to <wpt> tag in GPX export
- Home waypoint now produces valid XML, fixing Google Maps and GPX tool import errors
- Resolves #20
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Dec 13, 2025

📝 Walkthrough

Walkthrough

Replaces the unused _home_coordinates parameter with home_coordinates in export_to_gpx and adds conditional logic to emit a GPX <wpt> Home waypoint when at least one home coordinate is present; adds tests for waypoint presence, formatting, and edge cases.

Changes

Cohort / File(s) Summary
GPX export & tests
src/export.rs, tests/*
Rename _home_coordinateshome_coordinates in export_to_gpx, add conditional emission of a <wpt> Home waypoint (lat/lon, name/sym/type) before track data, update doc comments, and add tests covering presence/absence, precision, multiple/empty home coords, and GPX structure validation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Changes concentrated in one core file plus new/updated tests.
  • Review should check XML emission formatting, coordinate precision, and test coverage.
  • Pay attention to: export_to_gpx signature change, correct use of the first home coordinate, and test assertions for GPX structure/precision.

Possibly related issues

Possibly related PRs

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: fixing GPX output by adding a valid home waypoint tag, directly addressing the issue.
Linked Issues check ✅ Passed The PR implements the core Phase 1 requirement from issue #20: replacing the underscore parameter, emitting a home waypoint with proper XML structure when home coordinates exist, and adding comprehensive tests for the feature.
Out of Scope Changes check ✅ Passed All changes are directly related to the linked issue #20 objective of adding home waypoint support to GPX exports; no unrelated modifications detected.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 20251213_FIX_ISSUE_20

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7e34ffe and 574de15.

📒 Files selected for processing (1)
  • src/export.rs (4 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
src/**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

src/**/*.rs: Do not remove or modify comments unless the related code is changed
Only add comments that explain code functionality; no AI instructional comments
Never embed or call external binaries from Rust code
Ensure cargo build --release has no errors or warnings
Only commit if cargo clippy --all-targets --all-features -- -D warnings passes
Only commit if cargo fmt --all -- --check passes
Only commit if cargo test --verbose passes
Only commit if cargo build --release passes with no errors or warnings
BEFORE ANY CODE CHANGES: Always run cargo clippy --all-targets --all-features -- -D warnings to catch ALL issues
BEFORE ANY CODE CHANGES: Always run cargo fmt --all -- --check to ensure formatting compliance
If cargo fmt --all -- --check fails, IMMEDIATELY run cargo fmt --all to fix formatting
Code must pass cargo fmt --all -- --check without any formatting issues
Never skip clippy checks or formatting checks. Never allow warnings to pass
ALWAYS run cargo fmt --all after making ANY code changes before moving to next steps
After running cargo fmt --all, ALWAYS verify with cargo fmt --all -- --check before proceeding

Files:

  • src/export.rs
src/{parser/**/*.rs,export.rs}

📄 CodeRabbit inference engine (AGENTS.md)

Parser modules should be placed in src/parser/ and export functions in src/export.rs for sharing between library and CLI

Files:

  • src/export.rs
src/{export.rs,lib.rs}

📄 CodeRabbit inference engine (AGENTS.md)

The CSV output must precisely match the format and header order of blackbox_decode CSV files

Files:

  • src/export.rs
{src/**/*.rs,Cargo.toml}

📄 CodeRabbit inference engine (AGENTS.md)

{src/**/*.rs,Cargo.toml}: Only commit if cargo test --features=cli --verbose passes
All feature combinations must compile without errors

Files:

  • src/export.rs
🧠 Learnings (3)
📓 Common learnings
Learnt from: nerdCopter
Repo: nerdCopter/bbl_parser PR: 2
File: LICENSE_COMMERCIAL:1-4
Timestamp: 2025-08-29T19:52:05.099Z
Learning: nerdCopter prefers to avoid publishing personal information in license files for privacy and security reasons, as they are an individual maintainer rather than a company.
Learnt from: nerdCopter
Repo: nerdCopter/bbl_parser PR: 2
File: README.md:520-521
Timestamp: 2025-08-29T19:53:41.354Z
Learning: nerdCopter uses AGPL-3.0-or-later licensing for the bbl_parser project with a dual-licensing approach that includes a separate commercial license option.
Learnt from: nerdCopter
Repo: nerdCopter/bbl_parser PR: 2
File: CONTRIBUTING.md:9-14
Timestamp: 2025-08-21T20:25:45.741Z
Learning: nerdCopter prefers to keep CLA language general using "project maintainer" rather than specifying a legal entity name, as they are an individual maintainer without an associated company.
Learnt from: nerdCopter
Repo: nerdCopter/bbl_parser PR: 2
File: LICENSE_COMMERCIAL:0-0
Timestamp: 2025-08-29T20:15:04.624Z
Learning: nerdCopter prefers clear positive indicators (✅) when describing fixes rather than using ❌ symbols which can be confusing when describing what was corrected in a positive context.
📚 Learning: 2025-12-13T15:51:00.137Z
Learnt from: CR
Repo: nerdCopter/bbl_parser PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-13T15:51:00.137Z
Learning: Applies to src/main.rs : CLI (`src/main.rs`) should use library export functions (`export_to_csv`, `export_to_gpx`, `export_to_event`) with CLI-specific status messages

Applied to files:

  • src/export.rs
📚 Learning: 2025-12-13T15:51:00.137Z
Learnt from: CR
Repo: nerdCopter/bbl_parser PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-13T15:51:00.137Z
Learning: Applies to src/lib.rs : Public API must expose: `parse_bbl_file()`, `parse_bbl_bytes()`, `BBLLog`, `ExportOptions`, `export_to_csv()`, `export_to_gpx()`, `export_to_event()`, conversion utilities, parser helpers

Applied to files:

  • src/export.rs
🧬 Code graph analysis (1)
src/export.rs (1)
src/types/log.rs (2)
  • new (26-38)
  • new (77-82)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Build Release Binaries (windows-latest, bbl_parser-windows-x64, target/release/bbl_parser.exe)
  • GitHub Check: Build Release Binaries (ubuntu-latest, bbl_parser-linux-x64, target/release/bbl_parser)
  • GitHub Check: Build Release Binaries (macos-latest, bbl_parser-macos-x64, target/release/bbl_parser)
🔇 Additional comments (5)
src/export.rs (5)

351-358: LGTM!

Documentation clearly explains the new home_coordinates parameter and the home waypoint feature behavior.


368-368: LGTM!

Correctly removed the underscore prefix since the parameter is now actively used.


398-409: LGTM!

The home waypoint implementation is correct and produces valid GPX 1.1 XML:

  • Safe Option handling with .first() prevents panics on empty slices
  • 7 decimal places provides ~1cm precision, appropriate for GPS coordinates
  • Proper XML structure with correct indentation and nesting

This addresses the issue #20 requirement and the previous review comment about missing tests.


517-849: Excellent test coverage addressing all review concerns.

The tests comprehensively validate:

  • Waypoint presence with valid coordinates
  • Coordinate precision (7 decimal places)
  • Empty home coordinates case
  • XML structure and element ordering
  • Negative coordinate handling
  • Multiple home coordinates (only first used)
  • Empty GPS coordinates early return
  • Existing satellite count filtering behavior

This directly addresses the previous review comment requesting tests for the home waypoint feature.


476-515: Well-structured test helper and comprehensive test coverage.

The export_gpx_and_read helper function properly isolates tests using TempDir and enables clean assertions on GPX output. The test suite covers all the cases flagged in the previous review:

  1. Home waypoint presence when coordinates exist
  2. Proper XML structure and formatting
  3. 7 decimal place coordinate precision
  4. Absence of waypoint when home_coordinates is empty

The tempfile dev-dependency is correctly configured in Cargo.toml, and the helper function implementation matches the specification with proper error handling and resource cleanup.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 820ad97 and 7e34ffe.

📒 Files selected for processing (1)
  • src/export.rs (3 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
src/**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

src/**/*.rs: Do not remove or modify comments unless the related code is changed
Only add comments that explain code functionality; no AI instructional comments
Never embed or call external binaries from Rust code
Ensure cargo build --release has no errors or warnings
Only commit if cargo clippy --all-targets --all-features -- -D warnings passes
Only commit if cargo fmt --all -- --check passes
Only commit if cargo test --verbose passes
Only commit if cargo build --release passes with no errors or warnings
BEFORE ANY CODE CHANGES: Always run cargo clippy --all-targets --all-features -- -D warnings to catch ALL issues
BEFORE ANY CODE CHANGES: Always run cargo fmt --all -- --check to ensure formatting compliance
If cargo fmt --all -- --check fails, IMMEDIATELY run cargo fmt --all to fix formatting
Code must pass cargo fmt --all -- --check without any formatting issues
Never skip clippy checks or formatting checks. Never allow warnings to pass
ALWAYS run cargo fmt --all after making ANY code changes before moving to next steps
After running cargo fmt --all, ALWAYS verify with cargo fmt --all -- --check before proceeding

Files:

  • src/export.rs
src/{parser/**/*.rs,export.rs}

📄 CodeRabbit inference engine (AGENTS.md)

Parser modules should be placed in src/parser/ and export functions in src/export.rs for sharing between library and CLI

Files:

  • src/export.rs
src/{export.rs,lib.rs}

📄 CodeRabbit inference engine (AGENTS.md)

The CSV output must precisely match the format and header order of blackbox_decode CSV files

Files:

  • src/export.rs
{src/**/*.rs,Cargo.toml}

📄 CodeRabbit inference engine (AGENTS.md)

{src/**/*.rs,Cargo.toml}: Only commit if cargo test --features=cli --verbose passes
All feature combinations must compile without errors

Files:

  • src/export.rs
🧠 Learnings (3)
📓 Common learnings
Learnt from: nerdCopter
Repo: nerdCopter/bbl_parser PR: 2
File: LICENSE_COMMERCIAL:1-4
Timestamp: 2025-08-29T19:52:05.099Z
Learning: nerdCopter prefers to avoid publishing personal information in license files for privacy and security reasons, as they are an individual maintainer rather than a company.
Learnt from: nerdCopter
Repo: nerdCopter/bbl_parser PR: 2
File: README.md:520-521
Timestamp: 2025-08-29T19:53:41.354Z
Learning: nerdCopter uses AGPL-3.0-or-later licensing for the bbl_parser project with a dual-licensing approach that includes a separate commercial license option.
Learnt from: nerdCopter
Repo: nerdCopter/bbl_parser PR: 2
File: CONTRIBUTING.md:9-14
Timestamp: 2025-08-21T20:25:45.741Z
Learning: nerdCopter prefers to keep CLA language general using "project maintainer" rather than specifying a legal entity name, as they are an individual maintainer without an associated company.
Learnt from: nerdCopter
Repo: nerdCopter/bbl_parser PR: 2
File: LICENSE_COMMERCIAL:0-0
Timestamp: 2025-08-29T20:15:04.624Z
Learning: nerdCopter prefers clear positive indicators (✅) when describing fixes rather than using ❌ symbols which can be confusing when describing what was corrected in a positive context.
📚 Learning: 2025-12-13T15:51:00.137Z
Learnt from: CR
Repo: nerdCopter/bbl_parser PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-13T15:51:00.137Z
Learning: Applies to src/main.rs : CLI (`src/main.rs`) should use library export functions (`export_to_csv`, `export_to_gpx`, `export_to_event`) with CLI-specific status messages

Applied to files:

  • src/export.rs
📚 Learning: 2025-12-13T15:51:00.137Z
Learnt from: CR
Repo: nerdCopter/bbl_parser PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-13T15:51:00.137Z
Learning: Applies to src/lib.rs : Public API must expose: `parse_bbl_file()`, `parse_bbl_bytes()`, `BBLLog`, `ExportOptions`, `export_to_csv()`, `export_to_gpx()`, `export_to_event()`, conversion utilities, parser helpers

Applied to files:

  • src/export.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Build Release Binaries (macos-latest, bbl_parser-macos-x64, target/release/bbl_parser)
  • GitHub Check: Build Release Binaries (ubuntu-latest, bbl_parser-linux-x64, target/release/bbl_parser)
  • GitHub Check: Build Release Binaries (windows-latest, bbl_parser-windows-x64, target/release/bbl_parser.exe)
🔇 Additional comments (2)
src/export.rs (2)

351-357: LGTM! Clear documentation of the home waypoint feature.

The updated parameter documentation and new Features section accurately describe the functionality. The documentation is concise and helpful for users of this API.


368-368: LGTM! Parameter now actively used.

Correctly removes the underscore prefix since home_coordinates is now used in the implementation. This aligns with Rust conventions.

Comment thread src/export.rs
@nerdCopter nerdCopter merged commit 1f4b22d into master Dec 13, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhancement: Add GPS home waypoint to GPX export

1 participant