Skip to content

fix(gpx): short-arc longitude across the date line; strict gap policy - #4

Merged
joepetjr merged 2 commits into
mainfrom
fix/st-antimeridian-and-gap-strict
Oct 1, 2026
Merged

joepetjr merged 2 commits into
mainfrom
fix/st-antimeridian-and-gap-strict

Conversation

@joepetjr

Copy link
Copy Markdown
Contributor

Summary

  • ST-1. TrackIndex.position_at interpolated longitude as a plain number. A leg from 179 to -179 came out at 0, on the other side of the planet. Longitude now follows the shorter arc and is wrapped into [-180, 180]. Ordinary legs and endpoints are unchanged.
  • ST-2. Adds an opt-in strict gap policy. With strict=True, max_gap_min bounds the span between the two bracketing points, so a capture inside a long hole in the track is refused however close it sits to one end. Captures before the first or after the last point are refused.
  • Adds fix_at(), which returns TrackFix(lat, lon, inferred). inferred is False only when the time equals a logged point.
  • README documents both policies.

Plan units: ST-1, ST-2 (portfolio remediation 2026-09-29).

Compatibility

The default is unchanged. strict=False keeps the old nearest-endpoint rule, position_at still returns a tuple, and the default window is still 90 minutes.

Design decisions to review

  • Strict mode is opt-in, so no consumer changes behavior by upgrading.
  • The inferred flag lives on the new fix_at, not on position_at, to avoid breaking v0.1.0 callers.
  • The midpoint of 179 to -179 is returned as +180.0. The closed range is kept so a logged 180.0 is never rewritten.
  • No --strict flag on the command line tool. Consumers pick the mode in code.

Test plan

  • ST-1: midpoint both directions, quarter points, endpoint identity, a 100 degree step that does not cross the line. Three were red before the change, with midpoint 0.0 instead of 180.0.
  • ST-2: a three hour gap queried near both ends and mid-gap under both policies, end-of-track refusal, exact-point acceptance, the inferred flag.
  • Full suite locally: 97 passed. ruff check . and ruff format --check . clean.

Acceptance

  • Both date-line midpoint cases stay near the line, and ordinary tracks and endpoints stay correct: parametrized midpoint test, endpoint test, non-crossing test.
  • A three hour gap queried near an endpoint is refused under strict and documented under legacy: test_strict_mode_refuses_a_capture_inside_a_gap_wider_than_the_limit, test_legacy_mode_places_a_capture_near_an_endpoint_of_a_three_hour_gap, README policy section.

@joepetjr
joepetjr merged commit 362d35a into main Oct 1, 2026
4 checks passed
@joepetjr
joepetjr deleted the fix/st-antimeridian-and-gap-strict branch October 1, 2026 22:19
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.

1 participant