$ show mapbox/geo-viewport
This is a minimal Node.js library for converting geographic bounding boxes into centerpoint/zoom pairs for static map images, and vice versa. It wraps the @mapbox/sphericalmercator library to perform Mercator projection calculations, caching SphericalMercator instances by tile size and antimeridian flag for performance. The library exposes two functions: 'viewport' computes the center and zoom that best fits a bounding box within given pixel dimensions, and 'bounds' computes the bounding box from a centerpoint, zoom, and dimensions. It supports adjustable tile sizes (default 256) and optional float zooms. The code is well-structured and covered by tests, but the library is simple and does not contain independently reusable subcomponents. It is currently in a stale maintenance state with no recent updates.