@mapbox/extent

0.4.0 • Public • Published

Build Status

extent

A simple geographical extent.

api

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.

extent.bbox()

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

extent.center()

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

extent.polygon()

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.

extent.contains()

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.

Package Sidebar

Install

npm i @mapbox/extent

Weekly Downloads

220,667

Version

0.4.0

License

ISC

Last publish

Collaborators

  • mbx-npm-ci-production
  • mbx-npm-ci-staging
  • mbx-npm-advanced-actions-production
  • mbx-npm-advanced-actions-staging
  • mbx-npm-09-production
  • mbx-npm-08-production
  • mbx-npm-07-production
  • mbx-npm-06-production
  • mbx-npm-05-production
  • mbx-npm-04-production
  • mbx-npm-03-production
  • mbx-npm-02-production
  • mbx-npm-01-production
  • mbx-npm-02-staging
  • mapbox-npm-01
  • mapbox-npm-02
  • mapbox-npm-07
  • mapbox-npm-03
  • mapbox-npm-04
  • mapbox-npm-09
  • mapbox-npm-05
  • mapbox-npm-06
  • mapbox-npm-08
  • mapbox-npm-advanced-actions
  • mapbox-npm-ci
  • mapbox-npm
  • mapbox-admin
  • mapbox-machine-user