Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@turf/bbox-polygon

Package Overview
Dependencies
Maintainers
7
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@turf/bbox-polygon - npm Package Compare versions

Comparing version 6.5.0 to 7.0.0-alpha.0

21

dist/es/index.js

@@ -19,19 +19,18 @@ import { polygon } from "@turf/helpers";

*/
export default function bboxPolygon(bbox, options) {
if (options === void 0) { options = {}; }
export default function bboxPolygon(bbox, options = {}) {
// Convert BBox positions to Numbers
// No performance loss for including Number()
// https://github.com/Turfjs/turf/issues/1119
var west = Number(bbox[0]);
var south = Number(bbox[1]);
var east = Number(bbox[2]);
var north = Number(bbox[3]);
const west = Number(bbox[0]);
const south = Number(bbox[1]);
const east = Number(bbox[2]);
const north = Number(bbox[3]);
if (bbox.length === 6) {
throw new Error("@turf/bbox-polygon does not support BBox with 6 positions");
}
var lowLeft = [west, south];
var topLeft = [west, north];
var topRight = [east, north];
var lowRight = [east, south];
return polygon([[lowLeft, lowRight, topRight, topLeft, lowLeft]], options.properties, { bbox: bbox, id: options.id });
const lowLeft = [west, south];
const topLeft = [west, north];
const topRight = [east, north];
const lowRight = [east, south];
return polygon([[lowLeft, lowRight, topRight, topLeft, lowLeft]], options.properties, { bbox, id: options.id });
}

@@ -1,2 +0,3 @@

import { BBox, Feature, Id, Polygon, Properties } from "@turf/helpers";
import { BBox, Feature, Polygon, GeoJsonProperties } from "geojson";
import { Id } from "@turf/helpers";
/**

@@ -19,5 +20,5 @@ * Takes a bbox and returns an equivalent {@link Polygon|polygon}.

*/
export default function bboxPolygon<P = Properties>(bbox: BBox, options?: {
export default function bboxPolygon<P = GeoJsonProperties>(bbox: BBox, options?: {
properties?: P;
id?: Id;
}): Feature<Polygon, P>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var helpers_1 = require("@turf/helpers");
const helpers_1 = require("@turf/helpers");
/**

@@ -21,20 +21,19 @@ * Takes a bbox and returns an equivalent {@link Polygon|polygon}.

*/
function bboxPolygon(bbox, options) {
if (options === void 0) { options = {}; }
function bboxPolygon(bbox, options = {}) {
// Convert BBox positions to Numbers
// No performance loss for including Number()
// https://github.com/Turfjs/turf/issues/1119
var west = Number(bbox[0]);
var south = Number(bbox[1]);
var east = Number(bbox[2]);
var north = Number(bbox[3]);
const west = Number(bbox[0]);
const south = Number(bbox[1]);
const east = Number(bbox[2]);
const north = Number(bbox[3]);
if (bbox.length === 6) {
throw new Error("@turf/bbox-polygon does not support BBox with 6 positions");
}
var lowLeft = [west, south];
var topLeft = [west, north];
var topRight = [east, north];
var lowRight = [east, south];
return helpers_1.polygon([[lowLeft, lowRight, topRight, topLeft, lowLeft]], options.properties, { bbox: bbox, id: options.id });
const lowLeft = [west, south];
const topLeft = [west, north];
const topRight = [east, north];
const lowRight = [east, south];
return helpers_1.polygon([[lowLeft, lowRight, topRight, topLeft, lowLeft]], options.properties, { bbox, id: options.id });
}
exports.default = bboxPolygon;
{
"name": "@turf/bbox-polygon",
"version": "6.5.0",
"version": "7.0.0-alpha.0",
"description": "turf bbox-polygon module",

@@ -59,5 +59,6 @@ "author": "Turf Authors",

"dependencies": {
"@turf/helpers": "^6.5.0"
"@turf/helpers": "^7.0.0-alpha.0",
"tslib": "^2.3.0"
},
"gitHead": "5375941072b90d489389db22b43bfe809d5e451e"
"gitHead": "0edc4c491b999e5ace770a61e1cf549f7c004189"
}

@@ -9,11 +9,12 @@ # @turf/bbox-polygon

**Parameters**
### Parameters
- `bbox` **[BBox][2]** extent in [minX, minY, maxX, maxY] order
- `options` **[Object][3]** Optional parameters (optional, default `{}`)
- `options.properties` **Properties** Translate properties to Polygon (optional, default `{}`)
- `options.id` **([string][4] \| [number][5])** Translate Id to Polygon (optional, default `{}`)
* `bbox` **[BBox][2]** extent in \[minX, minY, maxX, maxY] order
* `options` **[Object][3]** Optional parameters (optional, default `{}`)
**Examples**
* `options.properties` **Properties** Translate properties to Polygon (optional, default `{}`)
* `options.id` **([string][4] | [number][5])** Translate Id to Polygon (optional, default `{}`)
### Examples
```javascript

@@ -28,3 +29,3 @@ var bbox = [0, 0, 10, 10];

Returns **[Feature][6]&lt;[Polygon][7]>** a Polygon representation of the bounding box
Returns **[Feature][6]<[Polygon][7]>** a Polygon representation of the bounding box

@@ -31,0 +32,0 @@ [1]: https://tools.ietf.org/html/rfc7946#section-3.1.6

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