fix(grayline): Remove edge closure logic that created unwanted box

The edge closure was creating an incorrect polygon connecting
across the bottom of the map. Reverted to simple polygon creation
between upper and lower segments.

Need different approach for wrapping.
pull/106/head
trancen 1 day ago
parent 31a813a488
commit 6081c9c910

@ -631,44 +631,9 @@ export function useLayer({ enabled = false, opacity = 0.5, map = null }) {
const lowerSeg = lowerSegments[i]; const lowerSeg = lowerSegments[i];
if (upperSeg.length > 1 && lowerSeg.length > 1) { if (upperSeg.length > 1 && lowerSeg.length > 1) {
// Get the longitude range for this segment
const segLons = upperSeg.map(p => p[1]);
const segMinLon = Math.min(...segLons);
const segMaxLon = Math.max(...segLons);
// Create polygon from upper segment + reversed lower segment // Create polygon from upper segment + reversed lower segment
let enhancedZone = [...upperSeg, ...lowerSeg.reverse()]; // This creates a closed shape between the two lines
const enhancedZone = [...upperSeg, ...lowerSeg.slice().reverse()];
// If this segment is at a map edge (near ±180°), close it properly
// by extending to the map bounds
const isWestEdge = segMinLon < -170; // Near -180°
const isEastEdge = segMaxLon > 170; // Near +180°
if (isWestEdge || isEastEdge) {
// Get the latitude range
const lats = enhancedZone.map(p => p[0]);
const maxLat = Math.max(...lats);
const minLat = Math.min(...lats);
// Close the polygon by adding corner points at the map edge
if (isWestEdge) {
// Add corners at -180°
const firstLat = enhancedZone[0][0];
const lastLat = enhancedZone[enhancedZone.length - 1][0];
enhancedZone.push([lastLat, -180]);
enhancedZone.push([maxLat, -180]);
enhancedZone.push([firstLat, -180]);
}
if (isEastEdge) {
// Add corners at +180°
const firstLat = enhancedZone[0][0];
const lastLat = enhancedZone[enhancedZone.length - 1][0];
enhancedZone.push([lastLat, 180]);
enhancedZone.push([maxLat, 180]);
enhancedZone.push([firstLat, 180]);
}
}
// Debug: Show longitude range of this polygon // Debug: Show longitude range of this polygon
const polyLons = enhancedZone.map(p => p[1]); const polyLons = enhancedZone.map(p => p[1]);
@ -679,9 +644,7 @@ export function useLayer({ enabled = false, opacity = 0.5, map = null }) {
upperPoints: upperSeg.length, upperPoints: upperSeg.length,
lowerPoints: lowerSeg.length, lowerPoints: lowerSeg.length,
totalPolygonPoints: enhancedZone.length, totalPolygonPoints: enhancedZone.length,
lonRange: `${polyMinLon.toFixed(1)} to ${polyMaxLon.toFixed(1)}`, lonRange: `${polyMinLon.toFixed(1)} to ${polyMaxLon.toFixed(1)}`
isWestEdge,
isEastEdge
}); });
const enhancedPoly = L.polygon(enhancedZone, { const enhancedPoly = L.polygon(enhancedZone, {

Loading…
Cancel
Save

Powered by TurnKey Linux.