@turf/midpoint 7.0.0-alpha.0 → 7.0.0-alpha.110
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 +4 -9
- package/dist/cjs/index.cjs +20 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.ts +9 -0
- package/dist/esm/index.d.mts +9 -0
- package/dist/esm/index.mjs +20 -0
- package/dist/esm/index.mjs.map +1 -0
- package/index.d.ts +4 -1
- package/package.json +28 -20
- package/dist/es/index.js +0 -31
- package/dist/es/package.json +0 -1
- package/dist/js/index.js +0 -40
package/README.md
CHANGED
|
@@ -35,26 +35,21 @@ Returns **[Feature][3]<[Point][4]>** a point midway between `pt1` and `pt2`
|
|
|
35
35
|
|
|
36
36
|
[4]: https://tools.ietf.org/html/rfc7946#section-3.1.2
|
|
37
37
|
|
|
38
|
-
<!-- This file is automatically generated. Please don't edit it directly
|
|
39
|
-
if you find an error, edit the source file (likely index.js), and re-run
|
|
40
|
-
./scripts/generate-readmes in the turf project. -->
|
|
38
|
+
<!-- This file is automatically generated. Please don't edit it directly. If you find an error, edit the source file of the module in question (likely index.js or index.ts), and re-run "yarn docs" from the root of the turf project. -->
|
|
41
39
|
|
|
42
40
|
---
|
|
43
41
|
|
|
44
|
-
This module is part of the [Turfjs project](
|
|
45
|
-
module collection dedicated to geographic algorithms. It is maintained in the
|
|
46
|
-
[Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create
|
|
47
|
-
PRs and issues.
|
|
42
|
+
This module is part of the [Turfjs project](https://turfjs.org/), an open source module collection dedicated to geographic algorithms. It is maintained in the [Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create PRs and issues.
|
|
48
43
|
|
|
49
44
|
### Installation
|
|
50
45
|
|
|
51
|
-
Install this module individually:
|
|
46
|
+
Install this single module individually:
|
|
52
47
|
|
|
53
48
|
```sh
|
|
54
49
|
$ npm install @turf/midpoint
|
|
55
50
|
```
|
|
56
51
|
|
|
57
|
-
Or install the
|
|
52
|
+
Or install the all-encompassing @turf/turf module that includes all modules as functions:
|
|
58
53
|
|
|
59
54
|
```sh
|
|
60
55
|
$ npm install @turf/turf
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// index.js
|
|
5
|
+
var _bearing = require('@turf/bearing');
|
|
6
|
+
var _destination = require('@turf/destination');
|
|
7
|
+
var _distance = require('@turf/distance');
|
|
8
|
+
function midpoint(point1, point2) {
|
|
9
|
+
var dist = _distance.distance.call(void 0, point1, point2);
|
|
10
|
+
var heading = _bearing.bearing.call(void 0, point1, point2);
|
|
11
|
+
var midpoint2 = _destination.destination.call(void 0, point1, dist / 2, heading);
|
|
12
|
+
return midpoint2;
|
|
13
|
+
}
|
|
14
|
+
__name(midpoint, "midpoint");
|
|
15
|
+
var turf_midpoint_default = midpoint;
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
exports.default = turf_midpoint_default; exports.midpoint = midpoint;
|
|
20
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../index.js"],"names":["midpoint"],"mappings":";;;;AAAA,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAC5B,SAAS,gBAAgB;AAoBzB,SAAS,SAAS,QAAQ,QAAQ;AAChC,MAAI,OAAO,SAAS,QAAQ,MAAM;AAClC,MAAI,UAAU,QAAQ,QAAQ,MAAM;AACpC,MAAIA,YAAW,YAAY,QAAQ,OAAO,GAAG,OAAO;AAEpD,SAAOA;AACT;AANS;AAST,IAAO,wBAAQ","sourcesContent":["import { bearing } from \"@turf/bearing\";\nimport { destination } from \"@turf/destination\";\nimport { distance } from \"@turf/distance\";\n\n/**\n * Takes two {@link Point|points} and returns a point midway between them.\n * The midpoint is calculated geodesically, meaning the curvature of the earth is taken into account.\n *\n * @name midpoint\n * @param {Coord} point1 first point\n * @param {Coord} point2 second point\n * @returns {Feature<Point>} a point midway between `pt1` and `pt2`\n * @example\n * var point1 = turf.point([144.834823, -37.771257]);\n * var point2 = turf.point([145.14244, -37.830937]);\n *\n * var midpoint = turf.midpoint(point1, point2);\n *\n * //addToMap\n * var addToMap = [point1, point2, midpoint];\n * midpoint.properties['marker-color'] = '#f00';\n */\nfunction midpoint(point1, point2) {\n var dist = distance(point1, point2);\n var heading = bearing(point1, point2);\n var midpoint = destination(point1, dist / 2, heading);\n\n return midpoint;\n}\n\nexport { midpoint };\nexport default midpoint;\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// index.js
|
|
5
|
+
import { bearing } from "@turf/bearing";
|
|
6
|
+
import { destination } from "@turf/destination";
|
|
7
|
+
import { distance } from "@turf/distance";
|
|
8
|
+
function midpoint(point1, point2) {
|
|
9
|
+
var dist = distance(point1, point2);
|
|
10
|
+
var heading = bearing(point1, point2);
|
|
11
|
+
var midpoint2 = destination(point1, dist / 2, heading);
|
|
12
|
+
return midpoint2;
|
|
13
|
+
}
|
|
14
|
+
__name(midpoint, "midpoint");
|
|
15
|
+
var turf_midpoint_default = midpoint;
|
|
16
|
+
export {
|
|
17
|
+
turf_midpoint_default as default,
|
|
18
|
+
midpoint
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../index.js"],"sourcesContent":["import { bearing } from \"@turf/bearing\";\nimport { destination } from \"@turf/destination\";\nimport { distance } from \"@turf/distance\";\n\n/**\n * Takes two {@link Point|points} and returns a point midway between them.\n * The midpoint is calculated geodesically, meaning the curvature of the earth is taken into account.\n *\n * @name midpoint\n * @param {Coord} point1 first point\n * @param {Coord} point2 second point\n * @returns {Feature<Point>} a point midway between `pt1` and `pt2`\n * @example\n * var point1 = turf.point([144.834823, -37.771257]);\n * var point2 = turf.point([145.14244, -37.830937]);\n *\n * var midpoint = turf.midpoint(point1, point2);\n *\n * //addToMap\n * var addToMap = [point1, point2, midpoint];\n * midpoint.properties['marker-color'] = '#f00';\n */\nfunction midpoint(point1, point2) {\n var dist = distance(point1, point2);\n var heading = bearing(point1, point2);\n var midpoint = destination(point1, dist / 2, heading);\n\n return midpoint;\n}\n\nexport { midpoint };\nexport default midpoint;\n"],"mappings":";;;;AAAA,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAC5B,SAAS,gBAAgB;AAoBzB,SAAS,SAAS,QAAQ,QAAQ;AAChC,MAAI,OAAO,SAAS,QAAQ,MAAM;AAClC,MAAI,UAAU,QAAQ,QAAQ,MAAM;AACpC,MAAIA,YAAW,YAAY,QAAQ,OAAO,GAAG,OAAO;AAEpD,SAAOA;AACT;AANS;AAST,IAAO,wBAAQ;","names":["midpoint"]}
|
package/index.d.ts
CHANGED
|
@@ -4,4 +4,7 @@ import { Coord } from "@turf/helpers";
|
|
|
4
4
|
/**
|
|
5
5
|
* http://turfjs.org/docs/#midpoint
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
declare function midpoint(point1: Coord, point2: Coord): Feature<Point>;
|
|
8
|
+
|
|
9
|
+
export { midpoint };
|
|
10
|
+
export default midpoint;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/midpoint",
|
|
3
|
-
"version": "7.0.0-alpha.
|
|
3
|
+
"version": "7.0.0-alpha.110+1411d63a7",
|
|
4
4
|
"description": "turf midpoint module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,39 +23,47 @@
|
|
|
23
23
|
"geojson",
|
|
24
24
|
"line"
|
|
25
25
|
],
|
|
26
|
-
"
|
|
27
|
-
"
|
|
26
|
+
"type": "commonjs",
|
|
27
|
+
"main": "dist/cjs/index.cjs",
|
|
28
|
+
"module": "dist/esm/index.mjs",
|
|
29
|
+
"types": "dist/cjs/index.d.ts",
|
|
28
30
|
"exports": {
|
|
29
31
|
"./package.json": "./package.json",
|
|
30
32
|
".": {
|
|
31
|
-
"import":
|
|
32
|
-
|
|
33
|
+
"import": {
|
|
34
|
+
"types": "./dist/esm/index.d.mts",
|
|
35
|
+
"default": "./dist/esm/index.mjs"
|
|
36
|
+
},
|
|
37
|
+
"require": {
|
|
38
|
+
"types": "./dist/cjs/index.d.ts",
|
|
39
|
+
"default": "./dist/cjs/index.cjs"
|
|
40
|
+
}
|
|
33
41
|
}
|
|
34
42
|
},
|
|
35
|
-
"types": "index.d.ts",
|
|
36
43
|
"sideEffects": false,
|
|
37
44
|
"files": [
|
|
38
45
|
"dist",
|
|
39
46
|
"index.d.ts"
|
|
40
47
|
],
|
|
41
48
|
"scripts": {
|
|
42
|
-
"bench": "
|
|
43
|
-
"build": "
|
|
44
|
-
"docs": "
|
|
45
|
-
"test": "npm-run-all test:*",
|
|
46
|
-
"test:tape": "
|
|
49
|
+
"bench": "tsx bench.ts",
|
|
50
|
+
"build": "tsup --config ../../tsup.config.ts",
|
|
51
|
+
"docs": "tsx ../../scripts/generate-readmes.ts",
|
|
52
|
+
"test": "npm-run-all --npm-path npm test:*",
|
|
53
|
+
"test:tape": "tsx test.ts"
|
|
47
54
|
},
|
|
48
55
|
"devDependencies": {
|
|
49
|
-
"benchmark": "
|
|
50
|
-
"npm-run-all": "
|
|
51
|
-
"
|
|
52
|
-
"
|
|
56
|
+
"benchmark": "^2.1.4",
|
|
57
|
+
"npm-run-all": "^4.1.5",
|
|
58
|
+
"tape": "^5.7.2",
|
|
59
|
+
"tsup": "^8.0.1",
|
|
60
|
+
"tsx": "^4.6.2"
|
|
53
61
|
},
|
|
54
62
|
"dependencies": {
|
|
55
|
-
"@turf/bearing": "^7.0.0-alpha.
|
|
56
|
-
"@turf/destination": "^7.0.0-alpha.
|
|
57
|
-
"@turf/distance": "^7.0.0-alpha.
|
|
58
|
-
"@turf/helpers": "^7.0.0-alpha.
|
|
63
|
+
"@turf/bearing": "^7.0.0-alpha.110+1411d63a7",
|
|
64
|
+
"@turf/destination": "^7.0.0-alpha.110+1411d63a7",
|
|
65
|
+
"@turf/distance": "^7.0.0-alpha.110+1411d63a7",
|
|
66
|
+
"@turf/helpers": "^7.0.0-alpha.110+1411d63a7"
|
|
59
67
|
},
|
|
60
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "1411d63a74c275c9216fe48e9d3cb2d48a359068"
|
|
61
69
|
}
|
package/dist/es/index.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import bearing from '@turf/bearing';
|
|
2
|
-
import destination from '@turf/destination';
|
|
3
|
-
import distance from '@turf/distance';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Takes two {@link Point|points} and returns a point midway between them.
|
|
7
|
-
* The midpoint is calculated geodesically, meaning the curvature of the earth is taken into account.
|
|
8
|
-
*
|
|
9
|
-
* @name midpoint
|
|
10
|
-
* @param {Coord} point1 first point
|
|
11
|
-
* @param {Coord} point2 second point
|
|
12
|
-
* @returns {Feature<Point>} a point midway between `pt1` and `pt2`
|
|
13
|
-
* @example
|
|
14
|
-
* var point1 = turf.point([144.834823, -37.771257]);
|
|
15
|
-
* var point2 = turf.point([145.14244, -37.830937]);
|
|
16
|
-
*
|
|
17
|
-
* var midpoint = turf.midpoint(point1, point2);
|
|
18
|
-
*
|
|
19
|
-
* //addToMap
|
|
20
|
-
* var addToMap = [point1, point2, midpoint];
|
|
21
|
-
* midpoint.properties['marker-color'] = '#f00';
|
|
22
|
-
*/
|
|
23
|
-
function midpoint(point1, point2) {
|
|
24
|
-
var dist = distance(point1, point2);
|
|
25
|
-
var heading = bearing(point1, point2);
|
|
26
|
-
var midpoint = destination(point1, dist / 2, heading);
|
|
27
|
-
|
|
28
|
-
return midpoint;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export default midpoint;
|
package/dist/es/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"module"}
|
package/dist/js/index.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var bearing = require('@turf/bearing');
|
|
4
|
-
var destination = require('@turf/destination');
|
|
5
|
-
var distance = require('@turf/distance');
|
|
6
|
-
|
|
7
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
-
|
|
9
|
-
var bearing__default = /*#__PURE__*/_interopDefaultLegacy(bearing);
|
|
10
|
-
var destination__default = /*#__PURE__*/_interopDefaultLegacy(destination);
|
|
11
|
-
var distance__default = /*#__PURE__*/_interopDefaultLegacy(distance);
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Takes two {@link Point|points} and returns a point midway between them.
|
|
15
|
-
* The midpoint is calculated geodesically, meaning the curvature of the earth is taken into account.
|
|
16
|
-
*
|
|
17
|
-
* @name midpoint
|
|
18
|
-
* @param {Coord} point1 first point
|
|
19
|
-
* @param {Coord} point2 second point
|
|
20
|
-
* @returns {Feature<Point>} a point midway between `pt1` and `pt2`
|
|
21
|
-
* @example
|
|
22
|
-
* var point1 = turf.point([144.834823, -37.771257]);
|
|
23
|
-
* var point2 = turf.point([145.14244, -37.830937]);
|
|
24
|
-
*
|
|
25
|
-
* var midpoint = turf.midpoint(point1, point2);
|
|
26
|
-
*
|
|
27
|
-
* //addToMap
|
|
28
|
-
* var addToMap = [point1, point2, midpoint];
|
|
29
|
-
* midpoint.properties['marker-color'] = '#f00';
|
|
30
|
-
*/
|
|
31
|
-
function midpoint(point1, point2) {
|
|
32
|
-
var dist = distance__default['default'](point1, point2);
|
|
33
|
-
var heading = bearing__default['default'](point1, point2);
|
|
34
|
-
var midpoint = destination__default['default'](point1, dist / 2, heading);
|
|
35
|
-
|
|
36
|
-
return midpoint;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
module.exports = midpoint;
|
|
40
|
-
module.exports.default = midpoint;
|