https://github.com/deniscarriere/bbox-dateline
Modifies a BBox to fit within 180° longitude & 90° latitude.
https://github.com/deniscarriere/bbox-dateline
bbox geojson geospatial
Last synced: 8 months ago
JSON representation
Modifies a BBox to fit within 180° longitude & 90° latitude.
- Host: GitHub
- URL: https://github.com/deniscarriere/bbox-dateline
- Owner: DenisCarriere
- License: mit
- Created: 2017-03-13T17:25:41.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-02T17:16:30.000Z (about 9 years ago)
- Last Synced: 2025-03-20T23:14:44.261Z (about 1 year ago)
- Topics: bbox, geojson, geospatial
- Language: JavaScript
- Homepage:
- Size: 65.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# BBox Date Line
[](https://travis-ci.org/DenisCarriere/bbox-dateline)
[](https://badge.fury.io/js/bbox-dateline)
[](https://raw.githubusercontent.com/DenisCarriere/bbox-dateline/master/LICENSE)
[](https://coveralls.io/github/DenisCarriere/bbox-dateline?branch=master)
[](https://github.com/feross/standard)
> Modifies a BBox to fit within 180° longitude & 90° latitude.
## Install
```bash
$ yarn add bbox-dateline
```
## Usage
```javascript
const dateline = require('bbox-dateline')
dateline.bbox([190, 100, -200, -120])
//= [-170, -80, 160, 60]
```
## API
#### Table of Contents
- [bbox](#bbox)
- [center](#center)
- [latitude](#latitude)
- [longitude](#longitude)
### bbox
Modifies a BBox to fit within the bounds of the International Date Line.
**Parameters**
- `bbox` **(BBox | FeatureCollection | Feature<any>)** BBox [west, south, east, north] or GeoJSON Feature
**Examples**
```javascript
dateline.bbox([190, 100, -200, -120])
//= [-170, -80, 160, 60]
```
Returns **BBox** valid BBox extent
### center
Modifies a Center to fit within the bounds of the International Date Line.
**Parameters**
- `coord` **(\[[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number), [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)] | BBox | FeatureCollection | Feature<any>)** Center [lng, lat], BBox [west, south, east, south] or GeoJSON Feature
**Examples**
```javascript
dateline.center([190, 100])
//= [-170, -80]
```
Returns **\[[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number), [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** valid center coordinate
### latitude
Modifies a Latitude to fit within +/-90 degrees.
**Parameters**
- `lat` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** latitude to modify
**Examples**
```javascript
dateline.latitude(100)
//= -80
```
Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** modified latitude
### longitude
Modifies a Longitude to fit within +/-180 degrees.
**Parameters**
- `lng` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** longitude to modify
**Examples**
```javascript
dateline.longitude(190)
//= -170
```
Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** modified longitude