Skip to content

[BUG 695] Lightning layer is not using settable distance units#697

Merged
accius merged 1 commit intoaccius:Stagingfrom
alanhargreaves:lightning-units-fix
Mar 10, 2026
Merged

[BUG 695] Lightning layer is not using settable distance units#697
accius merged 1 commit intoaccius:Stagingfrom
alanhargreaves:lightning-units-fix

Conversation

@alanhargreaves
Copy link
Copy Markdown
Collaborator

What does this PR do?

Updated to use the global allUnits.dist for 'metric' vs 'imperlal' for distance display.

All comparisons are still done in km, but we display in the appropriate unit.

I also had to update the panel header to list the strike radius in both units, in order to have this fit, i had to override the font size down to 11px.

Addresses #695

Type of change

  • Bug fix
  • New feature
  • Performance improvement
  • Refactor / code cleanup
  • Documentation
  • Translation
  • Map layer plugin

How to test

  1. Set distance units to Imperial in the settings
  2. Bring up the lightning layer (hotkey 'L')
  3. Verify distances are listed in miles

Checklist

  • App loads without console errors
  • Tested in Dark, Light, and Retro themes
  • Responsive at different screen sizes (desktop + mobile)
  • If touching server.js: caches have TTLs and size caps (we serve 2,000+ concurrent users)
  • If adding an API route: includes caching and error handling
  • If adding a panel: wired into Modern, Classic, and Dockable layouts
  • No hardcoded colors — uses CSS variables (var(--accent-cyan), etc.)
  • No .bak, .old, console.log debug lines, or test scripts included

Screenshots (if visual change)

Before:
image

After:
image

…than just km.

All comparisons are still done in km, but we display in the appropriate unit.

I also had to update the panel header to list the strike radius in both units, in order to have this fit, i had to override the font size down to 11px.
@accius
Copy link
Copy Markdown
Owner

accius commented Mar 9, 2026

Approve with minor fixes. Good change overall, distances now respect unit preferences cleanly.

Three small things:

Line 835 still passes 'km' to calculateDistance which no longer accepts a unit parameter. Silently ignored but it's dead code:

// current
const distance = calculateDistance(stationLat, stationLon, strike.lat, strike.lon, 'km');
// should be
const distance = calculateDistance(stationLat, stationLon, strike.lat, strike.lon);

The nearby strikes header crams both units in and shrinks the font to compensate. Since allUnits is right there, just show the user's preference:

// current
`📍 Nearby Strikes(30km/18.6miles)`
// cleaner
`📍 Nearby Strikes (${allUnits.dist === 'metric' ? '30 km' : '18.6 mi'})`

Same applies to the "No strikes within 30km (18.6 miles)" string further down. Also missing a space before the parenthesis in Strikes(30km.

@alanhargreaves
Copy link
Copy Markdown
Collaborator Author

I tried that. It doesn't work as it's only evaluated when the Panel is created. If you change units, it doesn't change with you.

@accius accius merged commit b3023d3 into accius:Staging Mar 10, 2026
@alanhargreaves alanhargreaves deleted the lightning-units-fix branch March 15, 2026 22:44
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.

2 participants