feat(logging): show live distance & bearing when logging a contact - #233
Merged
Merged
Conversation
The landing page promises "distance and bearing instantly", but the logging form never computed either, and contacts logged via the form were stored with a null `distance` (only ADIF-imported QSOs carried one). Add a pure, client-safe Maidenhead/great-circle utility (`src/lib/grid.ts`) and wire it into the new-contact form: - `gridToLatLon` centers a 4- or 6-char locator (matching ContactLocationMap), `distanceKm` (haversine), `bearingDeg`, `compassPoint`, `gridPath`, `kmToMiles`. - The Path card now shows the great-circle distance (km + mi) and bearing (degrees + 16-point compass) from the operator's home grid to the contact, updating live as the grid/coords resolve from a QRZ lookup or manual entry. - The rounded distance is sent in the create payload and persisted, so it round-trips through ADIF export and is available to awards/stats. `Contact.create` now accepts and stores `distance` (previously dropped). Tested: 15 new pure-function unit tests (tests/grid.spec.ts) covering grid parsing, cardinal bearings, a one-degree equatorial arc, and a known transatlantic path. typecheck, lint, and build all pass. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Jul 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The Nextlog landing page promises operators "name, grid, DXCC, distance and bearing instantly" — but the logging form never actually computed distance or bearing. Worse, contacts logged through the form were persisted with a
NULLdistance; only ADIF-imported QSOs ever carried the value, so form-logged contacts exported an empty<DISTANCE>field and were invisible to any distance-based stat.Solution
Add a small, pure, client-safe Maidenhead + great-circle utility and wire it into the new-contact form.
src/lib/grid.ts(new, no server imports — safe for the browser bundle, mirroring@/lib/bands):gridToLatLon(grid)— centers a 4- or 6-character locator, using the exact centeringContactLocationMapalready uses so the map pin and the readout agree.distanceKm(haversine, R=6371),bearingDeg(initial great-circle bearing, 0–360),compassPoint(16-point label),gridPath(grid→grid convenience),kmToMiles,isValidGrid.src/app/new-contact/page.tsx:src/models/Contact.ts:Contact.createnow accepts and persistsdistance(it was silently dropped before). The column already existed and is read by ADIF export, so form-logged contacts now round-trip a distance through export and are available to awards/stats.Testing
tests/grid.spec.ts— 15 pure-function unit tests covering grid validation, square/subsquare centering (checked against real city locations), a zero-distance and a one-degree equatorial arc (~111 km), the four cardinal bearings, compass labeling, and a known FN31→IO91 transatlantic path (~5500 km, NE).npm run typecheck— cleannpm run lint— clean (no new warnings)npm run build— succeedsbands,frequency-to-band) alongside the new ones — all green.Notes / follow-up
currentUser.grid_locator), matching the Path map's origin. When no home grid is set, the readout is simply hidden.distancecolumn already existed), no API-shape change beyond an additional optionaldistancefield on the create body.🤖 Generated with Claude Code