fix(grayline): Fix Enhanced DX Zone to wrap across date line

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
pull/106/head
trancen 1 day ago
parent ffd8a8ce4c
commit 0f4c5fc23a

@ -563,25 +563,74 @@ export function useLayer({ enabled = false, opacity = 0.5, map = null }) {
// Only create polygon if we have valid points // Only create polygon if we have valid points
if (enhancedUpper.length > 2 && enhancedLower.length > 2) { if (enhancedUpper.length > 2 && enhancedLower.length > 2) {
// Create polygon for enhanced zone // Split both upper and lower lines at date line
const enhancedZone = [...enhancedUpper, ...enhancedLower.reverse()]; const upperSegments = splitAtDateLine(enhancedUpper);
const enhancedPoly = L.polygon(enhancedZone, { const lowerSegments = splitAtDateLine(enhancedLower);
color: '#ffaa00',
fillColor: '#ffaa00', // For each upper segment, find corresponding lower segment and create polygon
fillOpacity: opacity * 0.15, // If there's only one segment in each, create single polygon
weight: 1, if (upperSegments.length === 1 && lowerSegments.length === 1) {
opacity: opacity * 0.3 // No date line crossing - create single polygon
}); const enhancedZone = [...upperSegments[0], ...lowerSegments[0].reverse()];
enhancedPoly.bindPopup(` const enhancedPoly = L.polygon(enhancedZone, {
<div style="font-family: 'JetBrains Mono', monospace;"> color: '#ffaa00',
<b> Enhanced DX Zone</b><br> fillColor: '#ffaa00',
Best HF propagation window<br> fillOpacity: opacity * 0.15,
±5° from terminator<br> weight: 1,
Ideal for long-distance contacts opacity: opacity * 0.3
</div> });
`); enhancedPoly.bindPopup(`
enhancedPoly.addTo(map); <div style="font-family: 'JetBrains Mono', monospace;">
newLayers.push(enhancedPoly); <b> Enhanced DX Zone</b><br>
Best HF propagation window<br>
±5° from terminator<br>
Ideal for long-distance contacts
</div>
`);
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(`
<div style="font-family: 'JetBrains Mono', monospace;">
<b> Enhanced DX Zone</b><br>
Best HF propagation window<br>
±5° from terminator<br>
Ideal for long-distance contacts
</div>
`);
enhancedPoly.addTo(map);
newLayers.push(enhancedPoly);
}
});
}
} }
} }

Loading…
Cancel
Save

Powered by TurnKey Linux.