@turf/bbox-polygon
Advanced tools
Comparing version 6.5.0 to 7.0.0-alpha.0
@@ -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]<[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 |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8075
68
2
96
1
+ Addedtslib@^2.3.0
+ Added@turf/helpers@7.1.0(transitive)
+ Added@types/geojson@7946.0.14(transitive)
+ Addedtslib@2.8.1(transitive)
- Removed@turf/helpers@6.5.0(transitive)
Updated@turf/helpers@^7.0.0-alpha.0