From 0f4c5fc23a0da44aa73da7ed2c79ff51fde7d02d Mon Sep 17 00:00:00 2001 From: trancen Date: Tue, 3 Feb 2026 21:08:38 +0000 Subject: [PATCH] fix(grayline): Fix Enhanced DX Zone to wrap across date line MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Enhanced DX Zone polygon was not wrapping across the ±180° date line. Solution: - Split both upper (+5°) and lower (-5°) twilight lines at date line - Match corresponding segments by longitude overlap - Create separate polygons for each matched segment pair - Falls back to single polygon when no date line crossing occurs Result: Enhanced DX Zone now wraps continuously across the entire map --- src/plugins/layers/useGrayLine.js | 87 ++++++++++++++++++++++++------- 1 file changed, 68 insertions(+), 19 deletions(-) diff --git a/src/plugins/layers/useGrayLine.js b/src/plugins/layers/useGrayLine.js index 6ba37c9..719815b 100644 --- a/src/plugins/layers/useGrayLine.js +++ b/src/plugins/layers/useGrayLine.js @@ -563,25 +563,74 @@ export function useLayer({ enabled = false, opacity = 0.5, map = null }) { // Only create polygon if we have valid points if (enhancedUpper.length > 2 && enhancedLower.length > 2) { - // Create polygon for enhanced zone - const enhancedZone = [...enhancedUpper, ...enhancedLower.reverse()]; - const enhancedPoly = L.polygon(enhancedZone, { - color: '#ffaa00', - fillColor: '#ffaa00', - fillOpacity: opacity * 0.15, - weight: 1, - opacity: opacity * 0.3 - }); - enhancedPoly.bindPopup(` -
- ⭐ Enhanced DX Zone
- Best HF propagation window
- ±5° from terminator
- Ideal for long-distance contacts -
- `); - enhancedPoly.addTo(map); - newLayers.push(enhancedPoly); + // Split both upper and lower lines at date line + const upperSegments = splitAtDateLine(enhancedUpper); + const lowerSegments = splitAtDateLine(enhancedLower); + + // For each upper segment, find corresponding lower segment and create polygon + // If there's only one segment in each, create single polygon + if (upperSegments.length === 1 && lowerSegments.length === 1) { + // No date line crossing - create single polygon + const enhancedZone = [...upperSegments[0], ...lowerSegments[0].reverse()]; + const enhancedPoly = L.polygon(enhancedZone, { + color: '#ffaa00', + fillColor: '#ffaa00', + fillOpacity: opacity * 0.15, + weight: 1, + opacity: opacity * 0.3 + }); + enhancedPoly.bindPopup(` +
+ ⭐ Enhanced DX Zone
+ Best HF propagation window
+ ±5° from terminator
+ Ideal for long-distance contacts +
+ `); + enhancedPoly.addTo(map); + newLayers.push(enhancedPoly); + } else { + // Date line crossing - create multiple polygons + // Match segments by their longitude ranges + upperSegments.forEach((upperSeg, i) => { + // Find matching lower segment with similar longitude range + const upperLons = upperSeg.map(p => p[1]); + const upperMinLon = Math.min(...upperLons); + const upperMaxLon = Math.max(...upperLons); + + // Find lower segment that overlaps with this upper segment + const matchingLowerSeg = lowerSegments.find(lowerSeg => { + const lowerLons = lowerSeg.map(p => p[1]); + const lowerMinLon = Math.min(...lowerLons); + const lowerMaxLon = Math.max(...lowerLons); + + // Check for longitude overlap + return (lowerMinLon <= upperMaxLon && lowerMaxLon >= upperMinLon) || + (upperMinLon <= lowerMaxLon && upperMaxLon >= lowerMinLon); + }); + + if (matchingLowerSeg && matchingLowerSeg.length > 1) { + const enhancedZone = [...upperSeg, ...matchingLowerSeg.reverse()]; + const enhancedPoly = L.polygon(enhancedZone, { + color: '#ffaa00', + fillColor: '#ffaa00', + fillOpacity: opacity * 0.15, + weight: 1, + opacity: opacity * 0.3 + }); + enhancedPoly.bindPopup(` +
+ ⭐ Enhanced DX Zone
+ Best HF propagation window
+ ±5° from terminator
+ Ideal for long-distance contacts +
+ `); + enhancedPoly.addTo(map); + newLayers.push(enhancedPoly); + } + }); + } } }