@turf/angle
Advanced tools
Comparing version
30
index.js
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
} | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var bearing_1 = require("@turf/bearing"); | ||
var rhumb_bearing_1 = require("@turf/rhumb-bearing"); | ||
var bearing_1 = __importDefault(require("@turf/bearing")); | ||
var helpers_1 = require("@turf/helpers"); | ||
var rhumb_bearing_1 = __importDefault(require("@turf/rhumb-bearing")); | ||
/** | ||
@@ -25,11 +28,15 @@ * Finds the angle formed by two adjacent segments defined by 3 points. The result will be the (positive clockwise) | ||
// Optional Parameters | ||
if (!helpers_1.isObject(options)) | ||
throw new Error('options is invalid'); | ||
if (!helpers_1.isObject(options)) { | ||
throw new Error("options is invalid"); | ||
} | ||
// Validation | ||
if (!startPoint) | ||
throw new Error('startPoint is required'); | ||
if (!midPoint) | ||
throw new Error('midPoint is required'); | ||
if (!endPoint) | ||
throw new Error('endPoint is required'); | ||
if (!startPoint) { | ||
throw new Error("startPoint is required"); | ||
} | ||
if (!midPoint) { | ||
throw new Error("midPoint is required"); | ||
} | ||
if (!endPoint) { | ||
throw new Error("endPoint is required"); | ||
} | ||
// Rename to shorter variables | ||
@@ -44,6 +51,7 @@ var A = startPoint; | ||
// Explementary angle | ||
if (options.explementary === true) | ||
if (options.explementary === true) { | ||
return 360 - angleAO; | ||
} | ||
return angleAO; | ||
} | ||
exports.default = angle; |
{ | ||
"name": "@turf/angle", | ||
"version": "6.0.0", | ||
"version": "6.0.1", | ||
"description": "turf angle module", | ||
"main": "index", | ||
"types": "index.d.ts", | ||
"files": [ | ||
"index.js", | ||
"index.ts" | ||
"index.d.ts" | ||
], | ||
@@ -43,3 +44,5 @@ "scripts": { | ||
"tape": "*", | ||
"write-json-file": "*" | ||
"write-json-file": "*", | ||
"tslint": "*", | ||
"@types/tape": "*" | ||
}, | ||
@@ -46,0 +49,0 @@ "dependencies": { |
@@ -12,8 +12,8 @@ # @turf/angle | ||
- `startPoint` **[Coord](https://tools.ietf.org/html/rfc7946#section-3.1.1)** Start Point Coordinates | ||
- `midPoint` **[Coord](https://tools.ietf.org/html/rfc7946#section-3.1.1)** Mid Point Coordinates | ||
- `endPoint` **[Coord](https://tools.ietf.org/html/rfc7946#section-3.1.1)** End Point Coordinates | ||
- `options` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Optional parameters (optional, default `{}`) | ||
- `options.explementary` **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Returns the explementary angle instead (360 - angle) (optional, default `false`) | ||
- `options.mercator` **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** if calculations should be performed over Mercator or WGS84 projection (optional, default `false`) | ||
- `startPoint` **[Coord][1]** Start Point Coordinates | ||
- `midPoint` **[Coord][1]** Mid Point Coordinates | ||
- `endPoint` **[Coord][1]** End Point Coordinates | ||
- `options` **[Object][2]** Optional parameters (optional, default `{}`) | ||
- `options.explementary` **[boolean][3]** Returns the explementary angle instead (360 - angle) (optional, default `false`) | ||
- `options.mercator` **[boolean][3]** if calculations should be performed over Mercator or WGS84 projection (optional, default `false`) | ||
@@ -27,4 +27,12 @@ **Examples** | ||
Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** Angle between the provided points, or its explementary. | ||
Returns **[number][4]** Angle between the provided points, or its explementary. | ||
[1]: https://tools.ietf.org/html/rfc7946#section-3.1.1 | ||
[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object | ||
[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean | ||
[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number | ||
<!-- This file is automatically generated. Please don't edit it directly: | ||
@@ -31,0 +39,0 @@ if you find an error, edit the source file (likely index.js), and re-run |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
64
14.29%0
-100%7488
-9.57%11
22.22%77
-13.48%