Skip to content

fix(adif): export/import coordinates as standard ADIF LAT/LON - #234

Merged
patrickrb merged 1 commit into
mainfrom
optio/task-2b9ec513-1d9b-4600-b6fd-0d33e59f7f39
Jul 24, 2026
Merged

fix(adif): export/import coordinates as standard ADIF LAT/LON#234
patrickrb merged 1 commit into
mainfrom
optio/task-2b9ec513-1d9b-4600-b6fd-0d33e59f7f39

Conversation

@patrickrb

Copy link
Copy Markdown
Owner

Problem

Nextlog round-tripped contact coordinates through non-standard lat_n / lon_w fields carrying raw decimal degrees. This is broken interop on two fronts:

  • No other software uses those field names. LoTW/TQSL, Cloudlog, N1MM, and GridTracker all read/write the standard ADIF LAT / LON fields. Importing an ADIF file from any of them left latitude/longitude null, so those contacts never got coordinates (breaking mapping).
  • Decimal degrees aren't valid ADIF anyway. The ADIF "Location" data type is XDDD MM.MMM (hemisphere letter, 3-digit degrees, decimal minutes), e.g. N040 26.500. Nextlog's exported coordinates were unreadable by external tools even where the field name matched.

Solution

Emit and parse the spec-correct LAT / LON fields, converting to/from signed decimal degrees:

  • New pure helper adifCoordToDecimal('N040 26.500')40.44167 (S/W hemispheres negative; rejects malformed input and minutes ≥ 60).
  • New pure helper decimalToAdifCoord(40.44167, 'lat')'N040 26.500' (zero-padded degrees/minutes, correct hemisphere per axis).
  • Export now writes <lat:11>N040 26.500 / <lon:11>W073 58.000 instead of the old decimal lat_n/lon_w. An exact 0 (equator / prime meridian) is now emitted too.
  • Import reads standard lat/lon, and still accepts the legacy lat_n/lon_w decimal fields as a fallback so files previously exported by Nextlog keep round-tripping (backwards compatible).

No schema change — contacts.latitude/longitude remain decimal degrees; only the ADIF wire format changed.

Testing

  • npm run typecheck — clean
  • npm run lint — clean
  • npm run build — compiles successfully
  • npx playwright test tests/adif-generate.spec.ts — 19 passed, including new coverage:
    • adifCoordToDecimal: four hemispheres, origin, case/whitespace tolerance, malformed-input rejection
    • decimalToAdifCoord: padded formatting + decimal→ADIF→decimal round-trip within ~1 m
    • generateAdif: emits standard LAT/LON, drops the legacy field names, omits coordinates when absent

Future follow-up

  • The DB-touching import path (insertAdifRecord) is covered indirectly via the pure helpers; a full integration test would need the Playwright DB fixture.
  • The LAT/LON precision is MM.MMM (~1 m), matching ADIF's canonical example — sufficient for grid-derived coordinates.

🤖 Generated with Claude Code

Nextlog round-tripped contact coordinates through non-standard `lat_n`/
`lon_w` fields carrying raw decimal degrees. No other logger (LoTW/TQSL,
Cloudlog, N1MM, GridTracker) emits or reads those fields, and decimal
degrees aren't valid ADIF for the Location data type — so imported ADIF
never populated coordinates and exported coordinates were unreadable
elsewhere, silently breaking mapping interop.

Emit and parse the spec-correct `LAT`/`LON` fields in `XDDD MM.MMM`
form (hemisphere letter + degrees + minutes), converting to/from signed
decimal degrees via new pure helpers `adifCoordToDecimal` /
`decimalToAdifCoord`. Import still accepts the legacy `lat_n`/`lon_w`
decimal fields as a fallback so previously-exported Nextlog files keep
round-tripping. An exact 0 (equator/prime meridian) now exports too.

Adds pure-function tests for both helpers (all four hemispheres, origin,
malformed input, decimal↔ADIF round-trip) and generateAdif coverage for
the new LAT/LON output.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 24, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nodelog Ready Ready Preview, Comment Jul 24, 2026 12:06am

Request Review

@patrickrb
patrickrb merged commit 4f7a25e into main Jul 24, 2026
5 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.

1 participant