@turf/center
Advanced tools
Comparing version 5.0.4 to 5.1.0
@@ -8,3 +8,5 @@ import { AllGeoJSON, Feature, Point, Properties } from '@turf/helpers'; | ||
features: AllGeoJSON, | ||
properties?: Properties | ||
options?: { | ||
properties?: Properties | ||
} | ||
): Feature<Point>; |
15
index.js
import bbox from '@turf/bbox'; | ||
import { point } from '@turf/helpers'; | ||
import { point, isObject } from '@turf/helpers'; | ||
@@ -9,3 +9,4 @@ /** | ||
* @param {GeoJSON} geojson GeoJSON to be centered | ||
* @param {Object} [properties={}] an Object that is used as the {@link Feature}'s properties | ||
* @param {Object} [options={}] Optional parameters | ||
* @param {Object} [options.properties={}] an Object that is used as the {@link Feature}'s properties | ||
* @returns {Feature<Point>} a Point feature at the absolute center point of all input features | ||
@@ -26,3 +27,11 @@ * @example | ||
*/ | ||
function center(geojson, properties) { | ||
function center(geojson, options) { | ||
// Optional parameters | ||
options = options || {}; | ||
if (!isObject(options)) throw new Error('options is invalid'); | ||
var properties = options.properties; | ||
// Input validation | ||
if (!geojson) throw new Error('geojson is required'); | ||
var ext = bbox(geojson); | ||
@@ -29,0 +38,0 @@ var x = (ext[0] + ext[2]) / 2; |
13
main.js
@@ -13,3 +13,4 @@ 'use strict'; | ||
* @param {GeoJSON} geojson GeoJSON to be centered | ||
* @param {Object} [properties={}] an Object that is used as the {@link Feature}'s properties | ||
* @param {Object} [options={}] Optional parameters | ||
* @param {Object} [options.properties={}] an Object that is used as the {@link Feature}'s properties | ||
* @returns {Feature<Point>} a Point feature at the absolute center point of all input features | ||
@@ -30,3 +31,11 @@ * @example | ||
*/ | ||
function center(geojson, properties) { | ||
function center(geojson, options) { | ||
// Optional parameters | ||
options = options || {}; | ||
if (!helpers.isObject(options)) { throw new Error('options is invalid'); } | ||
var properties = options.properties; | ||
// Input validation | ||
if (!geojson) { throw new Error('geojson is required'); } | ||
var ext = bbox(geojson); | ||
@@ -33,0 +42,0 @@ var x = (ext[0] + ext[2]) / 2; |
{ | ||
"name": "@turf/center", | ||
"version": "5.0.4", | ||
"version": "5.1.0", | ||
"description": "turf center module", | ||
"main": "main", | ||
"module": "index", | ||
"jsnext:main": "index", | ||
"main": "main.js", | ||
"module": "main.mjs", | ||
"types": "index.d.ts", | ||
@@ -12,3 +11,4 @@ "files": [ | ||
"index.d.ts", | ||
"main.js" | ||
"main.js", | ||
"main.mjs" | ||
], | ||
@@ -18,3 +18,4 @@ "scripts": { | ||
"test": "node -r @std/esm test.js", | ||
"bench": "node -r @std/esm bench.js" | ||
"bench": "node -r @std/esm bench.js", | ||
"docs": "node ../../scripts/generate-readmes" | ||
}, | ||
@@ -41,3 +42,4 @@ "repository": { | ||
"@std/esm": "*", | ||
"@turf/meta": "^5.0.4", | ||
"@turf/bbox-polygon": "^5.1.0", | ||
"@turf/meta": "^5.1.0", | ||
"benchmark": "*", | ||
@@ -47,2 +49,3 @@ "glob": "*", | ||
"rollup": "*", | ||
"rollup-plugin-buble": "*", | ||
"tape": "*", | ||
@@ -52,4 +55,4 @@ "write-json-file": "*" | ||
"dependencies": { | ||
"@turf/bbox": "^5.0.4", | ||
"@turf/helpers": "^5.0.4" | ||
"@turf/bbox": "^5.1.0", | ||
"@turf/helpers": "^5.1.0" | ||
}, | ||
@@ -56,0 +59,0 @@ "@std/esm": { |
@@ -7,8 +7,9 @@ # @turf/center | ||
Takes a [Feature](http://geojson.org/geojson-spec.html#feature-objects) or [FeatureCollection](http://geojson.org/geojson-spec.html#feature-collection-objects) and returns the absolute center point of all features. | ||
Takes a [Feature](https://tools.ietf.org/html/rfc7946#section-3.2) or [FeatureCollection](https://tools.ietf.org/html/rfc7946#section-3.3) and returns the absolute center point of all features. | ||
**Parameters** | ||
- `geojson` **[GeoJSON](http://geojson.org/geojson-spec.html#geojson-objects)** GeoJSON to be centered | ||
- `properties` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** an Object that is used as the [Feature](http://geojson.org/geojson-spec.html#feature-objects)'s properties (optional, default `{}`) | ||
- `geojson` **[GeoJSON](https://tools.ietf.org/html/rfc7946#section-3)** GeoJSON to be centered | ||
- `options` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Optional parameters (optional, default `{}`) | ||
- `options.properties` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** an Object that is used as the [Feature](https://tools.ietf.org/html/rfc7946#section-3.2)'s properties (optional, default `{}`) | ||
@@ -32,3 +33,3 @@ **Examples** | ||
Returns **[Feature](http://geojson.org/geojson-spec.html#feature-objects)<[Point](http://geojson.org/geojson-spec.html#point)>** a Point feature at the absolute center point of all input features | ||
Returns **[Feature](https://tools.ietf.org/html/rfc7946#section-3.2)<[Point](https://tools.ietf.org/html/rfc7946#section-3.1.2)>** a Point feature at the absolute center point of all input features | ||
@@ -35,0 +36,0 @@ <!-- This file is automatically generated. Please don't edit it directly: |
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
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
8824
7
124
58
10
Updated@turf/bbox@^5.1.0
Updated@turf/helpers@^5.1.0