Socket
Socket
Sign inDemoInstall

@turf/destination

Package Overview
Dependencies
Maintainers
4
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@turf/destination - npm Package Compare versions

Comparing version 5.1.5 to 6.0.0

index.ts

38

index.js

@@ -0,6 +1,7 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//http://en.wikipedia.org/wiki/Haversine_formula
//http://www.movable-type.co.uk/scripts/latlong.html
import { getCoord } from '@turf/invariant';
import { point, lengthToRadians, degreesToRadians, radiansToDegrees, isObject } from '@turf/helpers';
var invariant_1 = require("@turf/invariant");
var helpers_1 = require("@turf/helpers");
/**

@@ -31,26 +32,17 @@ * Takes a {@link Point} and calculates the location of a destination point given a distance in degrees, radians, miles, or kilometers; and bearing in degrees. This uses the [Haversine formula](http://en.wikipedia.org/wiki/Haversine_formula) to account for global curvature.

function destination(origin, distance, bearing, options) {
// Optional parameters
options = options || {};
if (!isObject(options)) throw new Error('options is invalid');
var units = options.units;
var properties = options.properties;
if (options === void 0) { options = {}; }
// Handle input
var coordinates1 = getCoord(origin);
var longitude1 = degreesToRadians(coordinates1[0]);
var latitude1 = degreesToRadians(coordinates1[1]);
var bearing_rad = degreesToRadians(bearing);
var radians = lengthToRadians(distance, units);
var coordinates1 = invariant_1.getCoord(origin);
var longitude1 = helpers_1.degreesToRadians(coordinates1[0]);
var latitude1 = helpers_1.degreesToRadians(coordinates1[1]);
var bearing_rad = helpers_1.degreesToRadians(bearing);
var radians = helpers_1.lengthToRadians(distance, options.units);
// Main
var latitude2 = Math.asin(Math.sin(latitude1) * Math.cos(radians) +
Math.cos(latitude1) * Math.sin(radians) * Math.cos(bearing_rad));
var longitude2 = longitude1 + Math.atan2(Math.sin(bearing_rad) * Math.sin(radians) * Math.cos(latitude1),
Math.cos(radians) - Math.sin(latitude1) * Math.sin(latitude2));
var lng = radiansToDegrees(longitude2);
var lat = radiansToDegrees(latitude2);
return point([lng, lat], properties);
var longitude2 = longitude1 + Math.atan2(Math.sin(bearing_rad) * Math.sin(radians) * Math.cos(latitude1), Math.cos(radians) - Math.sin(latitude1) * Math.sin(latitude2));
var lng = helpers_1.radiansToDegrees(longitude2);
var lat = helpers_1.radiansToDegrees(latitude2);
return helpers_1.point([lng, lat], options.properties);
}
export default destination;
exports.default = destination;
{
"name": "@turf/destination",
"version": "5.1.5",
"version": "6.0.0",
"description": "turf destination module",
"main": "main.js",
"module": "main.es.js",
"types": "index.d.ts",
"main": "index",
"files": [
"index.js",
"index.d.ts",
"main.js",
"main.es.js"
"index.ts"
],
"scripts": {
"pretest": "rollup -c ../../rollup.config.js",
"test": "node -r @std/esm test.js",
"posttest": "node -r @std/esm ../../scripts/validate-es5-dependencies.js",
"bench": "node -r @std/esm bench.js",
"prepare": "tsc",
"pretest": "tsc",
"test": "node test.js",
"bench": "node bench.js",
"docs": "node ../../scripts/generate-readmes"

@@ -40,8 +36,7 @@ },

"devDependencies": {
"@std/esm": "*",
"@turf/truncate": "^5.1.5",
"@turf/truncate": "*",
"benchmark": "*",
"glob": "*",
"load-json-file": "*",
"rollup": "*",
"typescript": "*",
"tape": "*",

@@ -51,9 +46,5 @@ "write-json-file": "*"

"dependencies": {
"@turf/helpers": "^5.1.5",
"@turf/invariant": "^5.1.5"
},
"@std/esm": {
"esm": "js",
"cjs": true
"@turf/helpers": "6.x",
"@turf/invariant": "6.x"
}
}
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