turf-destination
Advanced tools
Comparing version 0.0.5 to 1.0.0
26
index.js
//http://en.wikipedia.org/wiki/Haversine_formula | ||
//http://www.movable-type.co.uk/scripts/latlong.html | ||
var point = require('turf-point') | ||
var point = require('turf-point'); | ||
module.exports = function (point1, distance, bearing, units) { | ||
var coordinates1 = point1.geometry.coordinates | ||
var longitude1 = toRad(coordinates1[0]) | ||
var latitude1 = toRad(coordinates1[1]) | ||
var bearing_rad = toRad(bearing) | ||
var coordinates1 = point1.geometry.coordinates; | ||
var longitude1 = toRad(coordinates1[0]); | ||
var latitude1 = toRad(coordinates1[1]); | ||
var bearing_rad = toRad(bearing); | ||
var R = 0 | ||
var R = 0; | ||
switch (units) { | ||
case 'miles': | ||
R = 3960 | ||
R = 3960; | ||
break | ||
case 'kilometers': | ||
R = 6373 | ||
R = 6373; | ||
break | ||
case 'degrees': | ||
R = 57.2957795 | ||
R = 57.2957795; | ||
break | ||
case 'radians': | ||
R = 1 | ||
R = 1; | ||
break | ||
@@ -32,11 +32,11 @@ } | ||
return point(toDeg(longitude2), toDeg(latitude2)) | ||
return point(toDeg(longitude2), toDeg(latitude2)); | ||
}; | ||
function toRad(degree) { | ||
return degree * Math.PI / 180 | ||
return degree * Math.PI / 180; | ||
} | ||
function toDeg(rad) { | ||
return rad * 180 / Math.PI | ||
return rad * 180 / Math.PI; | ||
} |
{ | ||
"name": "turf-destination", | ||
"version": "0.0.5", | ||
"version": "1.0.0", | ||
"description": "turf destination module", | ||
@@ -28,8 +28,9 @@ "main": "index.js", | ||
"devDependencies": { | ||
"tape": "^2.13.3", | ||
"turf-distance": "^0.1.4" | ||
"benchmark": "^1.0.0", | ||
"tape": "^3.0.3", | ||
"turf-distance": "^0.1.5" | ||
}, | ||
"dependencies": { | ||
"turf-point": "^0.1.1" | ||
"turf-point": "^1.2.0" | ||
} | ||
} |
turf-destination | ||
============= | ||
[![build status](https://secure.travis-ci.org/Turfjs/turf-destination.png)](http://travis-ci.org/Turfjs/turf-destination) | ||
@@ -17,3 +18,3 @@ Calculates the destination point given one point feature, distance in degrees, radians, miles, or kilometers, and bearing in degrees. This uses the haversine formula to account for global curvature. | ||
|point1|point feature| | ||
|distance|point feature| | ||
|distance|distance units| | ||
|bearing|number (-180 - 180)| | ||
@@ -20,0 +21,0 @@ |units|'miles' or 'kilometers'| |
20
test.js
@@ -1,4 +0,4 @@ | ||
var test = require('tape') | ||
var distance = require('turf-distance') | ||
var destination = require('./') | ||
var test = require('tape'); | ||
var distance = require('turf-distance'); | ||
var destination = require('./'); | ||
@@ -9,9 +9,9 @@ test('destination', function(t){ | ||
"geometry": {"type": "Point", "coordinates": [-75.0, 39.0]} | ||
} | ||
var dist = 100 | ||
var bear = 180 | ||
}; | ||
var dist = 100; | ||
var bear = 180; | ||
var pt2 = destination(pt1, dist, bear, 'kilometers') | ||
t.ok(pt2, 'should return a point') | ||
t.end() | ||
}) | ||
var pt2 = destination(pt1, dist, bear, 'kilometers'); | ||
t.ok(pt2, 'should return a point'); | ||
t.end(); | ||
}); |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
5470
8
68
0
43
3
1
1
+ Addedminimist@1.2.8(transitive)
+ Addedturf-point@1.2.1(transitive)
- Removedminimist@0.2.4(transitive)
- Removedturf-point@0.1.6(transitive)
Updatedturf-point@^1.2.0