@turf/transform-rotate
Advanced tools
Comparing version 5.0.4 to 5.1.0
@@ -18,3 +18,3 @@ import centroid from '@turf/centroid'; | ||
* @param {Object} [options={}] Optional parameters | ||
* @param {Geometry|Feature<Point>|Array<number>} [options.pivot='centroid'] point around which the rotation will be performed | ||
* @param {Coord} [options.pivot='centroid'] point around which the rotation will be performed | ||
* @param {boolean} [options.mutate=false] allows GeoJSON input to be mutated (significant performance increase if true) | ||
@@ -21,0 +21,0 @@ * @returns {GeoJSON} the rotated GeoJSON feature |
14
main.js
@@ -22,3 +22,3 @@ 'use strict'; | ||
* @param {Object} [options={}] Optional parameters | ||
* @param {Geometry|Feature<Point>|Array<number>} [options.pivot='centroid'] point around which the rotation will be performed | ||
* @param {Coord} [options.pivot='centroid'] point around which the rotation will be performed | ||
* @param {boolean} [options.mutate=false] allows GeoJSON input to be mutated (significant performance increase if true) | ||
@@ -38,3 +38,3 @@ * @returns {GeoJSON} the rotated GeoJSON feature | ||
options = options || {}; | ||
if (!helpers.isObject(options)) throw new Error('options is invalid'); | ||
if (!helpers.isObject(options)) { throw new Error('options is invalid'); } | ||
var pivot = options.pivot; | ||
@@ -44,13 +44,13 @@ var mutate = options.mutate; | ||
// Input validation | ||
if (!geojson) throw new Error('geojson is required'); | ||
if (angle === undefined || angle === null || isNaN(angle)) throw new Error('angle is required'); | ||
if (!geojson) { throw new Error('geojson is required'); } | ||
if (angle === undefined || angle === null || isNaN(angle)) { throw new Error('angle is required'); } | ||
// Shortcut no-rotation | ||
if (angle === 0) return geojson; | ||
if (angle === 0) { return geojson; } | ||
// Use centroid of GeoJSON if pivot is not provided | ||
if (!pivot) pivot = centroid(geojson); | ||
if (!pivot) { pivot = centroid(geojson); } | ||
// Clone geojson to avoid side effects | ||
if (mutate === false || mutate === undefined) geojson = clone(geojson); | ||
if (mutate === false || mutate === undefined) { geojson = clone(geojson); } | ||
@@ -57,0 +57,0 @@ // Rotate each coordinate |
{ | ||
"name": "@turf/transform-rotate", | ||
"version": "5.0.4", | ||
"version": "5.1.0", | ||
"description": "turf transform-rotate 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" | ||
}, | ||
@@ -43,6 +44,7 @@ "repository": { | ||
"@std/esm": "*", | ||
"@turf/truncate": "^5.0.4", | ||
"@turf/truncate": "^5.1.0", | ||
"benchmark": "*", | ||
"load-json-file": "*", | ||
"rollup": "*", | ||
"rollup-plugin-buble": "*", | ||
"tape": "*", | ||
@@ -52,10 +54,10 @@ "write-json-file": "*" | ||
"dependencies": { | ||
"@turf/centroid": "^5.0.4", | ||
"@turf/clone": "^5.0.4", | ||
"@turf/helpers": "^5.0.4", | ||
"@turf/invariant": "^5.0.4", | ||
"@turf/meta": "^5.0.4", | ||
"@turf/rhumb-bearing": "^5.0.4", | ||
"@turf/rhumb-destination": "^5.0.4", | ||
"@turf/rhumb-distance": "^5.0.4" | ||
"@turf/centroid": "^5.1.0", | ||
"@turf/clone": "^5.1.0", | ||
"@turf/helpers": "^5.1.0", | ||
"@turf/invariant": "^5.1.0", | ||
"@turf/meta": "^5.1.0", | ||
"@turf/rhumb-bearing": "^5.1.0", | ||
"@turf/rhumb-destination": "^5.1.0", | ||
"@turf/rhumb-distance": "^5.1.0" | ||
}, | ||
@@ -62,0 +64,0 @@ "@std/esm": { |
@@ -12,6 +12,6 @@ # @turf/transform-rotate | ||
- `geojson` **[GeoJSON](http://geojson.org/geojson-spec.html#geojson-objects)** object to be rotated | ||
- `geojson` **[GeoJSON](https://tools.ietf.org/html/rfc7946#section-3)** object to be rotated | ||
- `angle` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** of rotation (along the vertical axis), from North in decimal degrees, negative clockwise | ||
- `options` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Optional parameters (optional, default `{}`) | ||
- `options.pivot` **([Geometry](http://geojson.org/geojson-spec.html#geometry) \| [Feature](http://geojson.org/geojson-spec.html#feature-objects)<[Point](http://geojson.org/geojson-spec.html#point)> | [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>)** point around which the rotation will be performed (optional, default `'centroid'`) | ||
- `options.pivot` **[Coord](https://tools.ietf.org/html/rfc7946#section-3.1.1)** point around which the rotation will be performed (optional, default `'centroid'`) | ||
- `options.mutate` **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** allows GeoJSON input to be mutated (significant performance increase if true) (optional, default `false`) | ||
@@ -31,3 +31,3 @@ | ||
Returns **[GeoJSON](http://geojson.org/geojson-spec.html#geojson-objects)** the rotated GeoJSON feature | ||
Returns **[GeoJSON](https://tools.ietf.org/html/rfc7946#section-3)** the rotated GeoJSON feature | ||
@@ -34,0 +34,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
13048
7
179
8
Updated@turf/centroid@^5.1.0
Updated@turf/clone@^5.1.0
Updated@turf/helpers@^5.1.0
Updated@turf/invariant@^5.1.0
Updated@turf/meta@^5.1.0
Updated@turf/rhumb-bearing@^5.1.0
Updated@turf/rhumb-distance@^5.1.0