Comparing version 0.6.0 to 0.7.0
{ | ||
"name": "bbox-fns", | ||
"version": "0.6.0", | ||
"version": "0.7.0", | ||
"description": "Light-weight JavaScript Bounding Box Utility Functions", | ||
@@ -21,3 +21,3 @@ "main": "index.js", | ||
"f": "npm run format", | ||
"format": "npx prettier --arrow-parens=avoid --trailing-comma=none --write *.js", | ||
"format": "npx prettier --arrow-parens=avoid --trailing-comma=none --write *.js */*.js", | ||
"test": "node test.js" | ||
@@ -39,3 +39,6 @@ }, | ||
}, | ||
"homepage": "https://github.com/DanielJDufour/bbox-fns#readme" | ||
"homepage": "https://github.com/DanielJDufour/bbox-fns#readme", | ||
"dependencies": { | ||
"preciso": "^0.11.0" | ||
} | ||
} |
@@ -18,2 +18,3 @@ # bbox-fns: work in progress | ||
- [intersect](#intersect) | ||
- [merge](#merge) | ||
- [polygon](#polygon) | ||
@@ -106,2 +107,13 @@ - [reproject](#reproject) | ||
### merge | ||
```js | ||
import merge from "bbox-fns/merge.js"; | ||
const western_hemisphere = [-180, -90, 0, 90]; | ||
const eastern_hemisphere = [0, -90, 180, 90]; | ||
const bboxes = [western_hemisphere, eastern_hemisphere]; | ||
merge(bboxes); | ||
[-180, -90, 180, 90] // bbox for the whole globe | ||
``` | ||
### polygon | ||
@@ -162,1 +174,14 @@ Create GeoJSON-Like Polygon from a Bounding Box | ||
This library borrows the names of some similar [Turf.js](https://turfjs.org/) functions, but it does not borrow the internal code. | ||
### advanced usage | ||
#### precise functions | ||
In order to avoid floating point arithmetic errors, you can use the precise version of these functions where numbers are represented as strings. | ||
```js | ||
import preciseDensePolygon from "bbox-fns/precise/dense-polygon.js"; | ||
preciseDensePolygon(bbox, { density: 100 }); // add 100 points to each side | ||
preciseDensePolygon(bbox, { density: [359, 179] }); // add 359 points to top and bottom, and 179 points to the left and right | ||
[ | ||
[ '-180', '80' ], [ '-180', '79' ], [ '-180', '78' ], [ '-180', '77' ], /* ... */, [ '-180', '80' ] | ||
] | ||
``` |
18669
184
1
+ Addedpreciso@^0.11.0
+ Addedpreciso@0.11.1(transitive)