Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@turf/bearing

Package Overview
Dependencies
Maintainers
4
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@turf/bearing - npm Package Compare versions

Comparing version 3.10.0 to 3.13.0

35

index.js

@@ -11,2 +11,3 @@ var getCoord = require('@turf/invariant').getCoord;

* @param {Feature<Point>} end ending Point
* @param {boolean} [final=false] calculates the final bearing if true
* @returns {number} bearing in decimal degrees

@@ -35,14 +36,8 @@ * @example

*
* var points = {
* "type": "FeatureCollection",
* "features": [point1, point2]
* };
*
* //=points
*
* var bearing = turf.bearing(point1, point2);
*
* //=bearing
*/
module.exports = function (start, end) {
function bearing(start, end, final) {
if (final === true) return calculateFinalBearing(start, end);
var degrees2radians = Math.PI / 180;

@@ -61,5 +56,21 @@ var radians2degrees = 180 / Math.PI;

var bearing = radians2degrees * Math.atan2(a, b);
var bear = radians2degrees * Math.atan2(a, b);
return bearing;
};
return bear;
}
/**
* Calculates Final Bearing
*
* @param {Feature<Point>} start starting Point
* @param {Feature<Point>} end ending Point
* @returns {number} bearing
*/
function calculateFinalBearing(start, end) {
// Swap start & end
var bear = bearing(end, start);
bear = (bear + 180) % 360;
return bear;
}
module.exports = bearing;
{
"name": "@turf/bearing",
"version": "3.10.0",
"version": "3.13.0",
"description": "turf bearing module",
"main": "index.js",
"types": "index.d.ts",
"files": [
"index.js",
"index.d.ts"
],
"scripts": {
"test": "tape test.js"
"test": "node test.js",
"bench": "node bench.js"
},

@@ -23,10 +29,12 @@ "repository": {

"homepage": "https://github.com/Turfjs/turf",
"dependencies": {
"@turf/invariant": "^3.10.0"
},
"devDependencies": {
"@turf/destination": "^3.13.0",
"@turf/helpers": "^3.13.0",
"benchmark": "^1.0.0",
"tape": "^3.5.0"
"tape": "^3.5.0",
"write-json-file": "^2.0.0"
},
"types": "index.d.ts"
"dependencies": {
"@turf/invariant": "^3.13.0"
}
}

@@ -11,2 +11,3 @@ # @turf/bearing

- `end` **[Feature](http://geojson.org/geojson-spec.html#feature-objects)&lt;[Point](http://geojson.org/geojson-spec.html#point)>** ending Point
- `final` **\[[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** calculates the final bearing if true (optional, default `false`)

@@ -37,11 +38,3 @@ **Examples**

var points = {
"type": "FeatureCollection",
"features": [point1, point2]
};
//=points
var bearing = turf.bearing(point1, point2);
//=bearing

@@ -52,2 +45,13 @@ ```

# calculateFinalBearing
Calculates Final Bearing
**Parameters**
- `start` **[Feature](http://geojson.org/geojson-spec.html#feature-objects)&lt;[Point](http://geojson.org/geojson-spec.html#point)>** starting Point
- `end` **[Feature](http://geojson.org/geojson-spec.html#feature-objects)&lt;[Point](http://geojson.org/geojson-spec.html#point)>** ending Point
Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** bearing
<!-- This file is automatically generated. Please don't edit it directly:

@@ -54,0 +58,0 @@ if you find an error, edit the source file (likely index.js), and re-run

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc