modules/polygon/src/cut-by-mercator-bounds.js
// vertex closest to the pole.
vertex closest to the pole.
vertex closest to the pole .
function insertPoleVertices(
  positions,
  size,
  startIndex,
  endIndex,
  maxLatitude = DEFAULT_MAX_LATITUDE
) {
  const firstLng = positions[startIndex];
  const lastLng = positions[endIndex - size];
  if (Math.abs(firstLng - lastLng) > 180) {
    const p = getPointAtIndex(positions, 0, size, startIndex);
    p[0] += Math.round((lastLng - firstLng) / 360) * 360;
    push(positions, p);
    p[1] = Math.sign(p[1]) * maxLatitude;
    push(positions, p);
    p[0] = firstLng;
    push(positions, p);
  }
}
function insertPoleVertices ( positions , size , startIndex , endIndex , maxLatitude = DEFAULT_MAX_LATITUDE ) { const firstLng = positions [ startIndex ] ; const lastLng = positions [ endIndex - size ] ; if ( Math . abs ( firstLng - lastLng ) > 180 ) { const p = getPointAtIndex ( positions , 0 , size , startIndex ) ; p [ 0 ] += Math . round ( ( lastLng - firstLng ) / 360 ) * 360 ; push ( positions , p ) ; p [ 1 ] = Math . sign ( p [ 1 ] ) * maxLatitude ; push ( positions , p ) ; p [ 0 ] = firstLng ; push ( positions , p ) ; } }
vertex closest to the pole.
vertex closest to the pole .
// Check if the ring contains a pole // The ring does not make a round trip // Add the nearest pole to the vertices so that the polygon tesselates correctly // Copy the first vertex to the world of the last vertex // Project the copied vertex to the edge of the map // Project the first vertex to the edge of the map