New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bbox-fns

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bbox-fns - npm Package Compare versions

Comparing version 0.5.0 to 0.6.0

bbox-area.js

6

package.json
{
"name": "bbox-fns",
"version": "0.5.0",
"version": "0.6.0",
"description": "Light-weight JavaScript Bounding Box Utility Functions",

@@ -8,3 +8,7 @@ "main": "index.js",

"index.js",
"bbox-area.js",
"bbox-array.js",
"bbox-point.js",
"bbox-size.js",
"boolean-contains-point.js",
"boolean-intersects.js",

@@ -11,0 +15,0 @@ "dense-polygon.js",

# bbox-fns: work in progress
Super Light-weight JavaScript Bounding Box Utility Functions
## usage
### the bounding box

@@ -12,2 +10,22 @@ Bounding boxes, or rectangular extents, are represented as an array of 4 numbers:

## functions
- [bboxArea](#bboxArea)
- [bboxArray](#bboxArray)
- [bboxPoint](#bboxPoint)
- [booleanContainsPoint](#booleanContainsPoint)
- [booleanIntersects](#booleanIntersects)
- [densePolygon](#densePolygon)
- [intersect](#intersect)
- [polygon](#polygon)
- [reproject](#reproject)
### bboxArea
Calculate the area of a bounding box
```js
import bboxArea from "bbox-fns/bbox-area.js";
bboxArea([2, 3, 8, 9])
36 // (8 - 2) * (9 - 3)
```
### bboxArray

@@ -27,2 +45,41 @@ Calculate the bounding box of an array of points (aka "a polygon ring")

### bboxPoint
Convert a single [x, y] point into a bounding box of zero width and height;
```js
import bboxPoint from "bbox-fns/bbox-point.js";
bboxPoint([-180, 86.06126914660831]);
[-180, 86.06126914660831, -180, 86.06126914660831]
```
### bboxSize
Calculate the width and height of a bounding box
```js
import bboxSize from "bbox-fns/bbox-size.js";
bboxSize([-180, 84.48577680525165, -179, 86.06126914660831]);
[1, 1.5754923413566644]
```
### booleanContainsPoint
Check if a bounding box contains a point
```js
import booleanContainsPoint from "bbox-fns/boolean-contains-point.js";
const western_hemisphere = [-180, -90, 0, 90];
const eastern_hemisphere = [0, -90, 180, 90];
const hawaii = [-155.844437, 19.741755];
booleanContainsPoint(western_hemisphere, hawaii);
true
// point on boundary
booleanContainsPoint(western_hemisphere, [0, 0]);
true
// ignoring points on the exact edge
booleanContainsPoint(western_hemisphere, [0, 0], { exclusive: true });
false
```
### booleanIntersects

@@ -29,0 +86,0 @@ Checks if two bounding boxes have any intersection at all.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc