@turf/destination 4.5.2 → 4.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -9
- package/index.js +3 -11
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -14,14 +14,7 @@ Takes a [Point](http://geojson.org/geojson-spec.html#point) and calculates the l
|
|
|
14
14
|
**Examples**
|
|
15
15
|
|
|
16
16
|
```javascript
|
|
17
|
-
var point =
|
|
18
|
-
"type": "Feature",
|
|
19
|
-
"properties": {},
|
|
20
|
-
"geometry": {
|
|
21
|
-
"type": "Point",
|
|
22
|
-
"coordinates": [-75.343, 39.984]
|
|
23
|
-
}
|
|
24
|
-
};
|
|
17
|
+
var point = turf.point([-75.343, 39.984]);
|
|
25
18
|
var distance = 50;
|
|
26
19
|
var bearing = 90;
|
|
27
20
|
var units = 'miles';
|
|
@@ -29,9 +22,9 @@ var units = 'miles';
|
|
|
29
22
|
var destination = turf.destination(point, distance, bearing, units);
|
|
30
23
|
|
|
31
24
|
//addToMap
|
|
25
|
+
var addToMap = [point, destination]
|
|
32
26
|
destination.properties['marker-color'] = '#f00';
|
|
33
27
|
point.properties['marker-color'] = '#0f0';
|
|
34
|
-
var addToMap = [point, destination]
|
|
35
28
|
```
|
|
36
29
|
|
|
37
30
|
Returns **[Feature](http://geojson.org/geojson-spec.html#feature-objects)<[Point](http://geojson.org/geojson-spec.html#point)>** destination point
|
package/index.js
CHANGED
|
@@ -15,14 +15,7 @@ var distanceToRadians = helpers.distanceToRadians;
|
|
|
15
15
|
* @param {string} [units=kilometers] miles, kilometers, degrees, or radians
|
|
16
16
|
* @returns {Feature<Point>} destination point
|
|
17
17
|
* @example
|
|
18
|
-
* var point =
|
|
19
|
-
* "type": "Feature",
|
|
20
|
-
* "properties": {},
|
|
21
|
-
* "geometry": {
|
|
22
|
-
* "type": "Point",
|
|
23
|
-
* "coordinates": [-75.343, 39.984]
|
|
24
|
-
* }
|
|
25
|
-
* };
|
|
18
|
+
* var point = turf.point([-75.343, 39.984]);
|
|
26
19
|
* var distance = 50;
|
|
27
20
|
* var bearing = 90;
|
|
28
21
|
* var units = 'miles';
|
|
@@ -30,9 +23,9 @@ var distanceToRadians = helpers.distanceToRadians;
|
|
|
30
23
|
* var destination = turf.destination(point, distance, bearing, units);
|
|
31
24
|
*
|
|
32
25
|
* //addToMap
|
|
26
|
+
* var addToMap = [point, destination]
|
|
33
27
|
* destination.properties['marker-color'] = '#f00';
|
|
34
28
|
* point.properties['marker-color'] = '#0f0';
|
|
35
|
-
* var addToMap = [point, destination]
|
|
36
29
|
*/
|
|
37
30
|
module.exports = function (origin, distance, bearing, units) {
|
|
38
31
|
var degrees2radians = Math.PI / 180;
|
|
@@ -46,8 +39,7 @@ module.exports = function (origin, distance, bearing, units) {
|
|
|
46
39
|
|
|
47
40
|
var latitude2 = Math.asin(Math.sin(latitude1) * Math.cos(radians) +
|
|
48
41
|
Math.cos(latitude1) * Math.sin(radians) * Math.cos(bearing_rad));
|
|
49
|
-
var longitude2 = longitude1 + Math.atan2(Math.sin(bearing_rad) *
|
|
50
|
-
Math.sin(radians) * Math.cos(latitude1),
|
|
42
|
+
var longitude2 = longitude1 + Math.atan2(Math.sin(bearing_rad) * Math.sin(radians) * Math.cos(latitude1),
|
|
51
43
|
Math.cos(radians) - Math.sin(latitude1) * Math.sin(latitude2));
|
|
52
44
|
|
|
53
45
|
return point([radians2degrees * longitude2, radians2degrees * latitude2]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/destination",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.3",
|
|
4
4
|
"description": "turf destination module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -32,13 +32,13 @@
|
|
|
32
32
|
"homepage": "https://github.com/Turfjs/turf",
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"benchmark": "^2.1.4",
|
|
35
|
-
"glob": "
|
|
35
|
+
"glob": "7.1.2",
|
|
36
36
|
"load-json-file": "^2.0.0",
|
|
37
|
-
"tape": "
|
|
37
|
+
"tape": "4.8.0",
|
|
38
38
|
"write-json-file": "^2.0.0"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@turf/helpers": "^4.
|
|
42
|
-
"@turf/invariant": "^4.
|
|
41
|
+
"@turf/helpers": "^4.7.3",
|
|
42
|
+
"@turf/invariant": "^4.7.3"
|
|
43
43
|
}
|
|
44
44
|
}
|