a geographic extent object
Last updated 4 years ago by tmcw .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @mapbox/extent 
SYNC missed versions from official npm registry.

Build Status


A simple geographical extent.



Create a new extent object

extent([w, s, e, n])

Create a new extent object, given bounds as an array.

extent.include([lon, lat])

Expand the extent to include a lon, lat point.

extent.union([w, s, e, n] or other extent)

Expand the extent to include another extent.

extent.equals([w, s, e, n] or other extent)

Whether this extent is exactly equal to another.


Get the extent's value. null if no points have been included yet. Order is [WSEN] to match the GeoJSON standard.


Get the centerpoint of the extent as a [longitude, latitude] array.


Get the extent as a GeoJSON Polygon geometry object.

extent.contains([lon, lat])

Returns true if this extent contains the given point, and false if not. Points on the boundary of the extent are considered to be contained. If the extent is invalid, returns null.


Returns a function that evaluates whether points are contained in the extent - same behavior as .contains([lon, lat]). This pre-compiles the function with the current extent values, yielding a roughly 3x speedup.

Current Tags

  • 0.4.0                                ...           latest (4 years ago)

1 Versions

  • 0.4.0                                ...           4 years ago

Copyright 2014 - 2016 © taobao.org |