/** * LocationPanel Component * Displays DE and DX location info with grid squares and sun times */ import React from 'react'; import { calculateGridSquare, calculateBearing, calculateDistance, getMoonPhase, getMoonPhaseEmoji } from '../utils/geo.js'; export const LocationPanel = ({ config, dxLocation, deSunTimes, dxSunTimes, currentTime }) => { const deGrid = calculateGridSquare(config.location.lat, config.location.lon); const dxGrid = calculateGridSquare(dxLocation.lat, dxLocation.lon); const bearing = calculateBearing(config.location.lat, config.location.lon, dxLocation.lat, dxLocation.lon); const distance = calculateDistance(config.location.lat, config.location.lon, dxLocation.lat, dxLocation.lon); const moonPhase = getMoonPhase(currentTime); const moonEmoji = getMoonPhaseEmoji(moonPhase); return (
◎ LOCATIONS
{/* DE Location */}
DE: {config.callsign} {deGrid}
{config.location.lat.toFixed(4)}°, {config.location.lon.toFixed(4)}°
☀ {deSunTimes.sunrise} / {deSunTimes.sunset} UTC
{/* DX Location */}
DX Target {dxGrid}
{dxLocation.lat.toFixed(4)}°, {dxLocation.lon.toFixed(4)}°
☀ {dxSunTimes.sunrise} / {dxSunTimes.sunset} UTC
{/* Path Info */}
BEARING
{bearing.toFixed(0)}°
DISTANCE
{distance.toFixed(0)} km
{/* Moon Phase */}
{moonEmoji} {moonPhase < 0.25 ? 'Waxing' : moonPhase < 0.5 ? 'Waxing' : moonPhase < 0.75 ? 'Waning' : 'Waning'} {' '} {Math.round(moonPhase * 100)}%
); }; export default LocationPanel;