boundsOfPaths
The smallest latitude and longitude box holding every vertex of every path and every edge between neighbouring vertices of one path, each edge taken the short way round the globe (the way a path is drawn and measured). Used to fit the map to a polygon, a line or a feature with several parts.
This is a function exported by @mapcairn/core, checked against version 0.2.0.
Signature
import { boundsOfPaths } from "@mapcairn/core";
function boundsOfPaths(paths: readonly (readonly LatLng[])[]): Bounds | undefined;
Parameters
paths(readonly (readonly LatLng[])[]): The rings and lines of a shape. A ring repeats its first vertex at the end, as GeoJSON does; no edge joins two paths.
Returns
Bounds | undefined: undefined when no point has finite coordinates.
Remarks
Longitude is a circle, so the box is the circle less its widest
gap that no vertex or edge covers. A shape wider than half the globe with
few vertices is therefore boxed on the side its edges cover, which
boundsOfPoints cannot know from vertices alone. A shape that
covers the whole circle, such as a ring round a pole, gives a west of
-180 and an east of 180. Otherwise the box has the form of
boundsOfPoints: west inside [-180, 180) and east not before it,
past 180 across the antimeridian. An edge of exactly half the globe has
no short way and is taken eastward, as it is drawn and measured. Latitudes are clamped to valid
coordinates, and an edge is a straight step in latitude.