Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

@turf/transform-rotate

Package Overview
Dependencies
8
Maintainers
6
Versions
29
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 6.2.0-alpha.2 to 6.2.0-alpha.3

dist/es/package.json

49

dist/es/index.js

@@ -31,33 +31,34 @@ import centroid from '@turf/centroid';

function transformRotate(geojson, angle, options) {
// Optional parameters
options = options || {};
if (!isObject(options)) throw new Error('options is invalid');
var pivot = options.pivot;
var mutate = options.mutate;
// Optional parameters
options = options || {};
if (!isObject(options)) throw new Error("options is invalid");
var pivot = options.pivot;
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');
// Input validation
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;
// Shortcut no-rotation
if (angle === 0) return geojson;
// Use centroid of GeoJSON if pivot is not provided
if (!pivot) pivot = centroid(geojson);
// Use centroid of GeoJSON if pivot is not provided
if (!pivot) pivot = centroid(geojson);
// Clone geojson to avoid side effects
if (mutate === false || mutate === undefined) geojson = clone(geojson);
// Clone geojson to avoid side effects
if (mutate === false || mutate === undefined) geojson = clone(geojson);
// Rotate each coordinate
coordEach(geojson, function (pointCoords) {
var initialAngle = rhumbBearing(pivot, pointCoords);
var finalAngle = initialAngle + angle;
var distance = rhumbDistance(pivot, pointCoords);
var newCoords = getCoords(rhumbDestination(pivot, distance, finalAngle));
pointCoords[0] = newCoords[0];
pointCoords[1] = newCoords[1];
});
return geojson;
// Rotate each coordinate
coordEach(geojson, function (pointCoords) {
var initialAngle = rhumbBearing(pivot, pointCoords);
var finalAngle = initialAngle + angle;
var distance = rhumbDistance(pivot, pointCoords);
var newCoords = getCoords(rhumbDestination(pivot, distance, finalAngle));
pointCoords[0] = newCoords[0];
pointCoords[1] = newCoords[1];
});
return geojson;
}
export default transformRotate;

@@ -35,34 +35,34 @@ 'use strict';

function transformRotate(geojson, angle, options) {
// Optional parameters
options = options || {};
if (!helpers.isObject(options)) throw new Error('options is invalid');
var pivot = options.pivot;
var mutate = options.mutate;
// Optional parameters
options = options || {};
if (!helpers.isObject(options)) throw new Error("options is invalid");
var pivot = options.pivot;
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');
// Input validation
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;
// Shortcut no-rotation
if (angle === 0) return geojson;
// Use centroid of GeoJSON if pivot is not provided
if (!pivot) pivot = centroid(geojson);
// Use centroid of GeoJSON if pivot is not provided
if (!pivot) pivot = centroid(geojson);
// Clone geojson to avoid side effects
if (mutate === false || mutate === undefined) geojson = clone(geojson);
// Clone geojson to avoid side effects
if (mutate === false || mutate === undefined) geojson = clone(geojson);
// Rotate each coordinate
meta.coordEach(geojson, function (pointCoords) {
var initialAngle = rhumbBearing(pivot, pointCoords);
var finalAngle = initialAngle + angle;
var distance = rhumbDistance(pivot, pointCoords);
var newCoords = invariant.getCoords(rhumbDestination(pivot, distance, finalAngle));
pointCoords[0] = newCoords[0];
pointCoords[1] = newCoords[1];
});
return geojson;
// Rotate each coordinate
meta.coordEach(geojson, function (pointCoords) {
var initialAngle = rhumbBearing(pivot, pointCoords);
var finalAngle = initialAngle + angle;
var distance = rhumbDistance(pivot, pointCoords);
var newCoords = invariant.getCoords(rhumbDestination(pivot, distance, finalAngle));
pointCoords[0] = newCoords[0];
pointCoords[1] = newCoords[1];
});
return geojson;
}
module.exports = transformRotate;
module.exports.default = transformRotate;

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

import { AllGeoJSON, Coord } from '@turf/helpers';
import { AllGeoJSON, Coord } from "@turf/helpers";

@@ -7,8 +7,8 @@ /**

export default function transformRotate<T extends AllGeoJSON>(
geojson: T,
angle: number,
options?: {
pivot?: Coord,
mutate?: boolean
}
): T;
geojson: T,
angle: number,
options?: {
pivot?: Coord;
mutate?: boolean;
}
): T;
{
"name": "@turf/transform-rotate",
"version": "6.2.0-alpha.2",
"version": "6.2.0-alpha.3",
"description": "turf transform-rotate module",

@@ -30,2 +30,6 @@ "author": "Turf Authors",

"module": "dist/es/index.js",
"exports": {
"import": "./dist/es/index.js",
"require": "./dist/js/index.js"
},
"types": "index.d.ts",

@@ -38,13 +42,12 @@ "sideEffects": false,

"scripts": {
"bench": "npm-run-all prepare bench:run",
"bench:run": "node bench.js",
"bench": "node -r esm bench.js",
"build": "rollup -c ../../rollup.config.js && echo '{\"type\":\"module\"}' > dist/es/package.json",
"docs": "node ../../scripts/generate-readmes",
"posttest": "node -r esm ../../scripts/validate-es5-dependencies.js",
"prepare": "rollup -c ../../rollup.config.js",
"test": "npm-run-all prepare test:*",
"test": "npm-run-all test:*",
"test:tape": "node -r esm test.js",
"test:types": "tsc --noEmit types.ts"
"test:types": "tsc --esModuleInterop --noEmit types.ts"
},
"devDependencies": {
"@turf/truncate": "^6.2.0-alpha.2",
"@turf/truncate": "^6.2.0-alpha.3",
"benchmark": "*",

@@ -58,12 +61,12 @@ "load-json-file": "*",

"dependencies": {
"@turf/centroid": "^6.2.0-alpha.2",
"@turf/clone": "^6.2.0-alpha.2",
"@turf/helpers": "^6.2.0-alpha.2",
"@turf/invariant": "^6.2.0-alpha.2",
"@turf/meta": "^6.2.0-alpha.2",
"@turf/rhumb-bearing": "^6.2.0-alpha.2",
"@turf/rhumb-destination": "^6.2.0-alpha.2",
"@turf/rhumb-distance": "^6.2.0-alpha.2"
"@turf/centroid": "^6.2.0-alpha.3",
"@turf/clone": "^6.2.0-alpha.3",
"@turf/helpers": "^6.2.0-alpha.3",
"@turf/invariant": "^6.2.0-alpha.3",
"@turf/meta": "^6.2.0-alpha.3",
"@turf/rhumb-bearing": "^6.2.0-alpha.3",
"@turf/rhumb-destination": "^6.2.0-alpha.3",
"@turf/rhumb-distance": "^6.2.0-alpha.3"
},
"gitHead": "23d5cb91d77e0c1e2e903a2252f525797f1d0d09"
"gitHead": "dce9edfc705352e8cb9e0083c9330ba0e8d77409"
}
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc