Skip to content

[BUG] Valid coordinates at latitude 0 and/or longitude 0 are treated as missing in multiple places #729

@on6zq

Description

@on6zq

There appears to be a cross-cutting bug where valid coordinates on the equator (lat = 0) or prime meridian (lon = 0) are treated as absent because the code uses JavaScript truthiness checks instead of explicit null/number checks.

As a result, legitimate locations such as:

  • 0, 10
  • 10, 0
  • 0, 0

can fail in multiple parts of the app.

Root cause

Several code paths use patterns like:

if (lat && lon) { ... }

or:

if (!location?.lat || !location?.lon) return;

Since 0 is falsy in JavaScript, these checks reject valid coordinates.

Examples found

src/hooks/app/useDXLocation.js

if (parsed.lat && parsed.lon) return parsed;

src/hooks/useWeather.js

if (!location?.lat || !location?.lon) return;

src/components/SettingsPanel.jsx

if (lat && lon) {
  const grid = calculateGridSquare(lat, lon);
  setGridSquare(grid);
  setConfigLocator(grid);
}

src/App.jsx

return wsjtx.decodes.filter((d) => d.lat && d.lon && d.timestamp >= ageCutoff);

src/DockableApp.jsx

if (spot.lat && spot.lon) {
  handleDXChange({ lat: spot.lat, lon: spot.lon });
}

src/layouts/ModernLayout.jsx

if (r.lat && r.lon) handleDXChange({ lat: r.lat, lon: r.lon });

src/components/PSKReporterPanel.jsx

cursor: report.lat && report.lon ? 'pointer' : 'default',

Likely user-visible effects

Depending on which code path is hit, valid zero-valued coordinates may:

  • fail to restore from saved DX location
  • prevent weather from loading
  • prevent locator/grid recalculation
  • make spots/reports/decodes non-clickable
  • prevent DX target updates
  • cause inconsistent UI behavior for valid map/report positions on the equator or prime meridian

Expected behavior

Latitude 0 and longitude 0 should be treated as valid numeric coordinates everywhere.

Actual behavior

Any logic using truthiness treats 0 as missing, causing valid coordinates to be ignored.

Suggested fix

Replace truthiness checks with explicit coordinate validation, for example:

lat != null && lon != null

or, where numeric validation is appropriate:

Number.isFinite(lat) && Number.isFinite(lon)

This seems to affect multiple files, so it may be worth doing a repo-wide audit for patterns such as:

  • if (lat && lon)
  • if (!lat || !lon)
  • if (location?.lat && location?.lon)
  • if (!location?.lat || !location?.lon)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions