Skip to content

Fix FIT round-trip fidelity and add enum name mapping - #5

Merged
trasch merged 2 commits into
mainfrom
fix/fit-roundtrip-and-enum-mapping
Aug 11, 2026
Merged

trasch merged 2 commits into
mainfrom
fix/fit-roundtrip-and-enum-mapping

Conversation

@trasch

@trasch trasch commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes several correctness bugs in the FIT decoder/encoder and makes the FIT → GeoJSON → FIT round-trip content-preserving.

Changes

Decoder

  • Added missing base types (uint8z, uint16z, uint32z, byte, sint64, uint64, uint64z) that previously fell through to a wrong default.

Profile

  • Corrected MesgNum values (e.g. lap was 9, now 19).
  • Regenerated all field metadata (field numbers, scales, offsets, base types) from the FIT spec for file_id, record, lap, session, event, activity, device_info.

Round-trip fidelity

  • FITCoder.read now emits laps and events as their own Features (previously dropped), and fully populates fit_device/fit_activity.
  • FITCoder.write uses a generic profile-driven encoder so every field round-trips (verified: 0 differences vs the original via the Garmin Python SDK).
  • Timestamps are converted to ISO8601 in the GeoJSON and back to FIT timestamps on encode.

Enum name mapping

  • Added FIT.name(for:value:) value → name lookup with field-name aliases (e.g. trigger → session_trigger).
  • Removed dead FITManufacturer/FITSportType enums.

Tests

  • Added TestData/sample.fit fixture and SampleFITDecodeTests covering decode, round-trip, and enum mapping.
  • All 57 tests pass.

- Fix FITProfile message numbers and field metadata to match the FIT spec
- Add missing decoder base types (uint8z, uint16z, uint32z, byte, 64-bit)
- Make FIT->GeoJSON->FIT round-trip content-preserving via a generic
  profile-driven encoder (laps/events/device_info no longer dropped)
- Convert timestamps to ISO8601 in GeoJSON and back on encode
- Add FIT enum value->name lookup (FIT.name) with field-name aliases
- Add sample FIT test fixture and comprehensive decode/round-trip tests
@trasch trasch self-assigned this Aug 11, 2026
@trasch trasch added enhancement New feature or request bug Something isn't working labels Aug 11, 2026
@trasch
trasch merged commit a440527 into main Aug 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant