Skip to main content

Function: geographicBounds()

geographicBounds(outline, projectTo4326): Bounds

Defined in: geographic-bounds.ts:26

The WGS84 bounds of a ring of points in a CRS, such as an image's corners.

Longitudes are unwrapped by walking the ring from each point to the next, so a ring across the antimeridian is bounded the short way: west is in [-180°, 180°), and east can run past 180°, as MapLibre's fitBounds accepts. A ring that goes all the way around the world gets -180° to 180°. Latitudes are kept within -90° to 90°, which a global grid whose cells are centered on the poles reaches past.

Two limits:

  • The walk stops at the last point, without the edge back to the first, so a ring around a pole isn't bounded correctly.
  • Latitudes come from the points alone, so an edge that curves past them, such as a box's top edge in a conic projection, can reach past the bounds. Add points along such an edge to cover it.

Parameters​

outline​

Point[]

The ring's points in the CRS, in order around it.

projectTo4326​

ProjectionFunction

Projects a point of the CRS to longitude and latitude.

Returns​

Bounds

[west, south, east, north] in degrees.