@turf/destination 7.2.0 → 7.3.0
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 -2
- package/dist/cjs/index.cjs +5 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +5 -2
- package/dist/esm/index.js.map +1 -1
- package/package.json +14 -11
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ This uses the [Haversine formula][2] to account for global curvature.
|
|
|
15
15
|
* `bearing` **[number][4]** ranging from -180 to 180
|
|
16
16
|
* `options` **[Object][5]** Optional parameters (optional, default `{}`)
|
|
17
17
|
|
|
18
|
-
* `options.units` **
|
|
18
|
+
* `options.units` **Units** Supports all valid Turf [Units][6] (optional, default `'kilometers'`)
|
|
19
19
|
* `options.properties` **[Object][5]** Translate properties to Point (optional, default `{}`)
|
|
20
20
|
|
|
21
21
|
### Examples
|
|
@@ -46,7 +46,7 @@ Returns **[Feature][7]<[Point][1]>** destination point
|
|
|
46
46
|
|
|
47
47
|
[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
|
48
48
|
|
|
49
|
-
[6]: https://
|
|
49
|
+
[6]: https://turfjs.org/docs/api/types/Units
|
|
50
50
|
|
|
51
51
|
[7]: https://tools.ietf.org/html/rfc7946#section-3.2
|
|
52
52
|
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -21,11 +21,14 @@ function destination(origin, distance, bearing, options = {}) {
|
|
|
21
21
|
);
|
|
22
22
|
const lng = _helpers.radiansToDegrees.call(void 0, longitude2);
|
|
23
23
|
const lat = _helpers.radiansToDegrees.call(void 0, latitude2);
|
|
24
|
+
if (coordinates1[2] !== void 0) {
|
|
25
|
+
return _helpers.point.call(void 0, [lng, lat, coordinates1[2]], options.properties);
|
|
26
|
+
}
|
|
24
27
|
return _helpers.point.call(void 0, [lng, lat], options.properties);
|
|
25
28
|
}
|
|
26
|
-
var
|
|
29
|
+
var index_default = destination;
|
|
27
30
|
|
|
28
31
|
|
|
29
32
|
|
|
30
|
-
exports.default =
|
|
33
|
+
exports.default = index_default; exports.destination = destination;
|
|
31
34
|
//# sourceMappingURL=index.cjs.map
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/turf/turf/packages/turf-destination/dist/cjs/index.cjs","../../index.ts"],"names":[],"mappings":"AAAA;ACGA;AAEE;AACA;AACA;AACA;AAAA,wCAEK;AACP,4CAAyB;AA4BzB,SAAS,WAAA,CACP,MAAA,EACA,QAAA,EACA,OAAA,EACA,QAAA,EAGI,CAAC,CAAA,EACc;AAEnB,EAAA,MAAM,aAAA,EAAe,iCAAA,MAAe,CAAA;AACpC,EAAA,MAAM,WAAA,EAAa,uCAAA,YAAiB,CAAa,CAAC,CAAC,CAAA;AACnD,EAAA,MAAM,UAAA,EAAY,uCAAA,YAAiB,CAAa,CAAC,CAAC,CAAA;AAClD,EAAA,MAAM,WAAA,EAAa,uCAAA,OAAwB,CAAA;AAC3C,EAAA,MAAM,QAAA,EAAU,sCAAA,QAAgB,EAAU,OAAA,CAAQ,KAAK,CAAA;AAGvD,EAAA,MAAM,UAAA,EAAY,IAAA,CAAK,IAAA;AAAA,IACrB,IAAA,CAAK,GAAA,CAAI,SAAS,EAAA,EAAI,IAAA,CAAK,GAAA,CAAI,OAAO,EAAA,EACpC,IAAA,CAAK,GAAA,CAAI,SAAS,EAAA,EAAI,IAAA,CAAK,GAAA,CAAI,OAAO,EAAA,EAAI,IAAA,CAAK,GAAA,CAAI,UAAU;AAAA,EACjE,CAAA;AACA,EAAA,MAAM,WAAA,EACJ,WAAA,EACA,IAAA,CAAK,KAAA;AAAA,IACH,IAAA,CAAK,GAAA,CAAI,UAAU,EAAA,EAAI,IAAA,CAAK,GAAA,CAAI,OAAO,EAAA,EAAI,IAAA,CAAK,GAAA,CAAI,SAA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,EAAI,IAAA,CAAK,GAAA,CAAI,SAAS,CAAA;AAAA,IAC7D,IAAA,CAAK,GAAA,CAAI,OAAO,EAAA,EAAI,IAAA,CAAK,GAAA,CAAI,SAAS,EAAA,EAAI,IAAA,CAAK,GAAA,CAAI,SAAS;AAAA,EAC9D,CAAA;AACF,EAAA,MAAM,IAAA,EAAM,uCAAA,UAA2B,CAAA;AACvC,EAAA,MAAM,IAAA,EAAM,uCAAA,SAA0B,CAAA;AACtC,EAAA,GAAA,CAAI,YAAA,CAAa,CAAC,EAAA,IAAM,KAAA,CAAA,EAAW;AACjC,IAAA,OAAO,4BAAA,CAAO,GAAA,EAAK,GAAA,EAAK,YAAA,CAAa,CAAC,CAAC,CAAA,EAAG,OAAA,CAAQ,UAAU,CAAA;AAAA,EAC9D;AACA,EAAA,OAAO,4BAAA,CAAO,GAAA,EAAK,GAAG,CAAA,EAAG,OAAA,CAAQ,UAAU,CAAA;AAC7C;AAGA,IAAO,cAAA,EAAQ,WAAA;AD9Cf;AACE;AACA;AACF,mEAAC","file":"/home/runner/work/turf/turf/packages/turf-destination/dist/cjs/index.cjs","sourcesContent":[null,"// http://en.wikipedia.org/wiki/Haversine_formula\n// http://www.movable-type.co.uk/scripts/latlong.html\nimport { Feature, Point, GeoJsonProperties } from \"geojson\";\nimport {\n Coord,\n degreesToRadians,\n lengthToRadians,\n point,\n radiansToDegrees,\n Units,\n} from \"@turf/helpers\";\nimport { getCoord } from \"@turf/invariant\";\n\n/**\n * Takes a {@link Point} and calculates the location of a destination point given a distance in\n * degrees, radians, miles, or kilometers; and bearing in degrees.\n * This uses the [Haversine formula](http://en.wikipedia.org/wiki/Haversine_formula) to account for global curvature.\n *\n * @function\n * @param {Coord} origin starting point\n * @param {number} distance distance from the origin point\n * @param {number} bearing ranging from -180 to 180\n * @param {Object} [options={}] Optional parameters\n * @param {Units} [options.units='kilometers'] Supports all valid Turf {@link https://turfjs.org/docs/api/types/Units Units}\n * @param {Object} [options.properties={}] Translate properties to Point\n * @returns {Feature<Point>} destination point\n * @example\n * var point = turf.point([-75.343, 39.984]);\n * var distance = 50;\n * var bearing = 90;\n * var options = {units: 'miles'};\n *\n * var destination = turf.destination(point, distance, bearing, options);\n *\n * //addToMap\n * var addToMap = [point, destination]\n * destination.properties['marker-color'] = '#f00';\n * point.properties['marker-color'] = '#0f0';\n */\nfunction destination<P extends GeoJsonProperties = GeoJsonProperties>(\n origin: Coord,\n distance: number,\n bearing: number,\n options: {\n units?: Units;\n properties?: P;\n } = {}\n): Feature<Point, P> {\n // Handle input\n const coordinates1 = getCoord(origin);\n const longitude1 = degreesToRadians(coordinates1[0]);\n const latitude1 = degreesToRadians(coordinates1[1]);\n const bearingRad = degreesToRadians(bearing);\n const radians = lengthToRadians(distance, options.units);\n\n // Main\n const latitude2 = Math.asin(\n Math.sin(latitude1) * Math.cos(radians) +\n Math.cos(latitude1) * Math.sin(radians) * Math.cos(bearingRad)\n );\n const longitude2 =\n longitude1 +\n Math.atan2(\n Math.sin(bearingRad) * Math.sin(radians) * Math.cos(latitude1),\n Math.cos(radians) - Math.sin(latitude1) * Math.sin(latitude2)\n );\n const lng = radiansToDegrees(longitude2);\n const lat = radiansToDegrees(latitude2);\n if (coordinates1[2] !== undefined) {\n return point([lng, lat, coordinates1[2]], options.properties);\n }\n return point([lng, lat], options.properties);\n}\n\nexport { destination };\nexport default destination;\n"]}
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -11,7 +11,7 @@ import { Coord, Units } from '@turf/helpers';
|
|
|
11
11
|
* @param {number} distance distance from the origin point
|
|
12
12
|
* @param {number} bearing ranging from -180 to 180
|
|
13
13
|
* @param {Object} [options={}] Optional parameters
|
|
14
|
-
* @param {
|
|
14
|
+
* @param {Units} [options.units='kilometers'] Supports all valid Turf {@link https://turfjs.org/docs/api/types/Units Units}
|
|
15
15
|
* @param {Object} [options.properties={}] Translate properties to Point
|
|
16
16
|
* @returns {Feature<Point>} destination point
|
|
17
17
|
* @example
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { Coord, Units } from '@turf/helpers';
|
|
|
11
11
|
* @param {number} distance distance from the origin point
|
|
12
12
|
* @param {number} bearing ranging from -180 to 180
|
|
13
13
|
* @param {Object} [options={}] Optional parameters
|
|
14
|
-
* @param {
|
|
14
|
+
* @param {Units} [options.units='kilometers'] Supports all valid Turf {@link https://turfjs.org/docs/api/types/Units Units}
|
|
15
15
|
* @param {Object} [options.properties={}] Translate properties to Point
|
|
16
16
|
* @returns {Feature<Point>} destination point
|
|
17
17
|
* @example
|
package/dist/esm/index.js
CHANGED
|
@@ -21,11 +21,14 @@ function destination(origin, distance, bearing, options = {}) {
|
|
|
21
21
|
);
|
|
22
22
|
const lng = radiansToDegrees(longitude2);
|
|
23
23
|
const lat = radiansToDegrees(latitude2);
|
|
24
|
+
if (coordinates1[2] !== void 0) {
|
|
25
|
+
return point([lng, lat, coordinates1[2]], options.properties);
|
|
26
|
+
}
|
|
24
27
|
return point([lng, lat], options.properties);
|
|
25
28
|
}
|
|
26
|
-
var
|
|
29
|
+
var index_default = destination;
|
|
27
30
|
export {
|
|
28
|
-
|
|
31
|
+
index_default as default,
|
|
29
32
|
destination
|
|
30
33
|
};
|
|
31
34
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../index.ts"],"sourcesContent":["// http://en.wikipedia.org/wiki/Haversine_formula\n// http://www.movable-type.co.uk/scripts/latlong.html\nimport { Feature, Point, GeoJsonProperties } from \"geojson\";\nimport {\n Coord,\n degreesToRadians,\n lengthToRadians,\n point,\n radiansToDegrees,\n Units,\n} from \"@turf/helpers\";\nimport { getCoord } from \"@turf/invariant\";\n\n/**\n * Takes a {@link Point} and calculates the location of a destination point given a distance in\n * degrees, radians, miles, or kilometers; and bearing in degrees.\n * This uses the [Haversine formula](http://en.wikipedia.org/wiki/Haversine_formula) to account for global curvature.\n *\n * @function\n * @param {Coord} origin starting point\n * @param {number} distance distance from the origin point\n * @param {number} bearing ranging from -180 to 180\n * @param {Object} [options={}] Optional parameters\n * @param {
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"sourcesContent":["// http://en.wikipedia.org/wiki/Haversine_formula\n// http://www.movable-type.co.uk/scripts/latlong.html\nimport { Feature, Point, GeoJsonProperties } from \"geojson\";\nimport {\n Coord,\n degreesToRadians,\n lengthToRadians,\n point,\n radiansToDegrees,\n Units,\n} from \"@turf/helpers\";\nimport { getCoord } from \"@turf/invariant\";\n\n/**\n * Takes a {@link Point} and calculates the location of a destination point given a distance in\n * degrees, radians, miles, or kilometers; and bearing in degrees.\n * This uses the [Haversine formula](http://en.wikipedia.org/wiki/Haversine_formula) to account for global curvature.\n *\n * @function\n * @param {Coord} origin starting point\n * @param {number} distance distance from the origin point\n * @param {number} bearing ranging from -180 to 180\n * @param {Object} [options={}] Optional parameters\n * @param {Units} [options.units='kilometers'] Supports all valid Turf {@link https://turfjs.org/docs/api/types/Units Units}\n * @param {Object} [options.properties={}] Translate properties to Point\n * @returns {Feature<Point>} destination point\n * @example\n * var point = turf.point([-75.343, 39.984]);\n * var distance = 50;\n * var bearing = 90;\n * var options = {units: 'miles'};\n *\n * var destination = turf.destination(point, distance, bearing, options);\n *\n * //addToMap\n * var addToMap = [point, destination]\n * destination.properties['marker-color'] = '#f00';\n * point.properties['marker-color'] = '#0f0';\n */\nfunction destination<P extends GeoJsonProperties = GeoJsonProperties>(\n origin: Coord,\n distance: number,\n bearing: number,\n options: {\n units?: Units;\n properties?: P;\n } = {}\n): Feature<Point, P> {\n // Handle input\n const coordinates1 = getCoord(origin);\n const longitude1 = degreesToRadians(coordinates1[0]);\n const latitude1 = degreesToRadians(coordinates1[1]);\n const bearingRad = degreesToRadians(bearing);\n const radians = lengthToRadians(distance, options.units);\n\n // Main\n const latitude2 = Math.asin(\n Math.sin(latitude1) * Math.cos(radians) +\n Math.cos(latitude1) * Math.sin(radians) * Math.cos(bearingRad)\n );\n const longitude2 =\n longitude1 +\n Math.atan2(\n Math.sin(bearingRad) * Math.sin(radians) * Math.cos(latitude1),\n Math.cos(radians) - Math.sin(latitude1) * Math.sin(latitude2)\n );\n const lng = radiansToDegrees(longitude2);\n const lat = radiansToDegrees(latitude2);\n if (coordinates1[2] !== undefined) {\n return point([lng, lat, coordinates1[2]], options.properties);\n }\n return point([lng, lat], options.properties);\n}\n\nexport { destination };\nexport default destination;\n"],"mappings":";AAGA;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,gBAAgB;AA4BzB,SAAS,YACP,QACA,UACA,SACA,UAGI,CAAC,GACc;AAEnB,QAAM,eAAe,SAAS,MAAM;AACpC,QAAM,aAAa,iBAAiB,aAAa,CAAC,CAAC;AACnD,QAAM,YAAY,iBAAiB,aAAa,CAAC,CAAC;AAClD,QAAM,aAAa,iBAAiB,OAAO;AAC3C,QAAM,UAAU,gBAAgB,UAAU,QAAQ,KAAK;AAGvD,QAAM,YAAY,KAAK;AAAA,IACrB,KAAK,IAAI,SAAS,IAAI,KAAK,IAAI,OAAO,IACpC,KAAK,IAAI,SAAS,IAAI,KAAK,IAAI,OAAO,IAAI,KAAK,IAAI,UAAU;AAAA,EACjE;AACA,QAAM,aACJ,aACA,KAAK;AAAA,IACH,KAAK,IAAI,UAAU,IAAI,KAAK,IAAI,OAAO,IAAI,KAAK,IAAI,SAAS;AAAA,IAC7D,KAAK,IAAI,OAAO,IAAI,KAAK,IAAI,SAAS,IAAI,KAAK,IAAI,SAAS;AAAA,EAC9D;AACF,QAAM,MAAM,iBAAiB,UAAU;AACvC,QAAM,MAAM,iBAAiB,SAAS;AACtC,MAAI,aAAa,CAAC,MAAM,QAAW;AACjC,WAAO,MAAM,CAAC,KAAK,KAAK,aAAa,CAAC,CAAC,GAAG,QAAQ,UAAU;AAAA,EAC9D;AACA,SAAO,MAAM,CAAC,KAAK,GAAG,GAAG,QAAQ,UAAU;AAC7C;AAGA,IAAO,gBAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/destination",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.3.0",
|
|
4
4
|
"description": "turf destination module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
|
+
"contributors": [
|
|
7
|
+
"Pavel Rozvora <@prozvora>"
|
|
8
|
+
],
|
|
6
9
|
"license": "MIT",
|
|
7
10
|
"bugs": {
|
|
8
11
|
"url": "https://github.com/Turfjs/turf/issues"
|
|
@@ -53,24 +56,24 @@
|
|
|
53
56
|
"test:tape": "tsx test.ts"
|
|
54
57
|
},
|
|
55
58
|
"devDependencies": {
|
|
56
|
-
"@turf/truncate": "
|
|
59
|
+
"@turf/truncate": "7.3.0",
|
|
57
60
|
"@types/benchmark": "^2.1.5",
|
|
58
|
-
"@types/tape": "^
|
|
61
|
+
"@types/tape": "^5.8.1",
|
|
59
62
|
"benchmark": "^2.1.4",
|
|
60
|
-
"glob": "^
|
|
63
|
+
"glob": "^11.0.2",
|
|
61
64
|
"load-json-file": "^7.0.1",
|
|
62
65
|
"npm-run-all": "^4.1.5",
|
|
63
66
|
"tape": "^5.9.0",
|
|
64
|
-
"tsup": "^8.
|
|
65
|
-
"tsx": "^4.19.
|
|
66
|
-
"typescript": "^5.
|
|
67
|
-
"write-json-file": "^
|
|
67
|
+
"tsup": "^8.4.0",
|
|
68
|
+
"tsx": "^4.19.4",
|
|
69
|
+
"typescript": "^5.8.3",
|
|
70
|
+
"write-json-file": "^6.0.0"
|
|
68
71
|
},
|
|
69
72
|
"dependencies": {
|
|
70
|
-
"@turf/helpers": "
|
|
71
|
-
"@turf/invariant": "
|
|
73
|
+
"@turf/helpers": "7.3.0",
|
|
74
|
+
"@turf/invariant": "7.3.0",
|
|
72
75
|
"@types/geojson": "^7946.0.10",
|
|
73
76
|
"tslib": "^2.8.1"
|
|
74
77
|
},
|
|
75
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "9f58a103e8f9a587ab640307ed03ba5233913ddd"
|
|
76
79
|
}
|