Comparing version 0.12.1 to 0.13.0
@@ -10,2 +10,3 @@ "use_strict"; | ||
const booleanIntersects = require("./boolean-intersects.js"); | ||
const booleanRectangle = require("./boolean-rectangle.js"); | ||
const calc = require("./calc.js"); | ||
@@ -22,2 +23,3 @@ const densePolygon = require("./dense-polygon.js"); | ||
const validate = require("./validate.js"); | ||
const preciseValidate = require("./precise/validate.js"); | ||
@@ -32,2 +34,3 @@ const bboxfns = { | ||
booleanIntersects, | ||
booleanRectangle, | ||
calc, | ||
@@ -43,3 +46,4 @@ densePolygon, | ||
scale, | ||
validate | ||
validate, | ||
preciseValidate | ||
}; | ||
@@ -46,0 +50,0 @@ |
{ | ||
"name": "bbox-fns", | ||
"version": "0.12.1", | ||
"version": "0.13.0", | ||
"description": "Light-weight JavaScript Bounding Box Utility Functions", | ||
@@ -15,2 +15,3 @@ "main": "index.js", | ||
"boolean-intersects.js", | ||
"boolean-rectangle.js", | ||
"calc.js", | ||
@@ -27,2 +28,3 @@ "dense-polygon.js", | ||
"precise/reproject.js", | ||
"precise/validate.js", | ||
"validate.js" | ||
@@ -29,0 +31,0 @@ ], |
@@ -17,2 +17,3 @@ # bbox-fns: work in progress | ||
- [booleanIntersects](#booleanIntersects) | ||
- [booleanRectangle](#booleanRectangle) | ||
- [calc](#calc) | ||
@@ -117,2 +118,34 @@ - [densePolygon](#densePolygon) | ||
### booleanRectangle | ||
Checks if coordinates represent a rectangular bounding box | ||
```js | ||
import booleanRectangle from "bbox-fns/boolean-rectangle.js"; | ||
// rectangle for the globe bbox [-180, -90, 180, 90] | ||
const coords = [ | ||
[ -180, 90 ], | ||
[ -180, -90 ], | ||
[ 0, -90 ], | ||
[ 0, 90 ], | ||
[ -180, 90 ] | ||
]; | ||
booleanRectangle(coords); | ||
true | ||
// extra points that don't affect shape | ||
const denseCoords = [ | ||
[ -180, 90 ], | ||
[ -180, 0 ], | ||
[ -180, -90 ], | ||
[ -90, -90 ], | ||
[ 0, -90 ], | ||
[ 0, 0 ], | ||
[ 0, 90 ], | ||
[ -90, 90 ], | ||
[ -180, 90 ] | ||
]; | ||
booleanRectangle(denseCoords); | ||
true | ||
``` | ||
### intersect | ||
@@ -119,0 +152,0 @@ ```js |
@@ -9,2 +9,4 @@ "use strict"; | ||
function validate(bbox) { | ||
if (!Array.isArray(bbox)) return false; | ||
if (bbox.length !== 4) return false; | ||
@@ -11,0 +13,0 @@ |
33166
25
573
293