@turf/midpoint 7.1.0-alpha.7 → 7.1.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 +13 -14
- package/dist/cjs/index.cjs +4 -4
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +17 -1
- package/dist/esm/index.d.ts +17 -1
- package/dist/esm/index.js +4 -4
- package/dist/esm/index.js.map +1 -1
- package/package.json +11 -7
package/README.md
CHANGED
|
@@ -4,36 +4,35 @@
|
|
|
4
4
|
|
|
5
5
|
## midpoint
|
|
6
6
|
|
|
7
|
-
Takes two
|
|
8
|
-
|
|
7
|
+
Takes two points and returns a point midway between them. The midpoint is
|
|
8
|
+
calculated geodesically, meaning the curvature of the earth is taken into
|
|
9
|
+
account.
|
|
9
10
|
|
|
10
11
|
### Parameters
|
|
11
12
|
|
|
12
|
-
* `point1` **[Coord][
|
|
13
|
-
* `point2` **[Coord][
|
|
13
|
+
* `point1` **[Coord][1]** first point
|
|
14
|
+
* `point2` **[Coord][1]** second point
|
|
14
15
|
|
|
15
16
|
### Examples
|
|
16
17
|
|
|
17
18
|
```javascript
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
const point1 = turf.point([144.834823, -37.771257]);
|
|
20
|
+
const point2 = turf.point([145.14244, -37.830937]);
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
const midpoint = turf.midpoint(point1, point2);
|
|
22
23
|
|
|
23
24
|
//addToMap
|
|
24
|
-
|
|
25
|
+
const addToMap = [point1, point2, midpoint];
|
|
25
26
|
midpoint.properties['marker-color'] = '#f00';
|
|
26
27
|
```
|
|
27
28
|
|
|
28
|
-
Returns **[Feature][
|
|
29
|
+
Returns **[Feature][2]<[Point][3]>** a point midway between `pt1` and `pt2`
|
|
29
30
|
|
|
30
|
-
[1]: https://tools.ietf.org/html/rfc7946#section-3.1.
|
|
31
|
+
[1]: https://tools.ietf.org/html/rfc7946#section-3.1.1
|
|
31
32
|
|
|
32
|
-
[2]: https://tools.ietf.org/html/rfc7946#section-3.
|
|
33
|
+
[2]: https://tools.ietf.org/html/rfc7946#section-3.2
|
|
33
34
|
|
|
34
|
-
[3]: https://tools.ietf.org/html/rfc7946#section-3.2
|
|
35
|
-
|
|
36
|
-
[4]: https://tools.ietf.org/html/rfc7946#section-3.1.2
|
|
35
|
+
[3]: https://tools.ietf.org/html/rfc7946#section-3.1.2
|
|
37
36
|
|
|
38
37
|
<!-- 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. -->
|
|
39
38
|
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// index.
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// index.ts
|
|
2
2
|
var _bearing = require('@turf/bearing');
|
|
3
3
|
var _destination = require('@turf/destination');
|
|
4
4
|
var _distance = require('@turf/distance');
|
|
5
5
|
function midpoint(point1, point2) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const dist = _distance.distance.call(void 0, point1, point2);
|
|
7
|
+
const heading = _bearing.bearing.call(void 0, point1, point2);
|
|
8
|
+
const midpoint2 = _destination.destination.call(void 0, point1, dist / 2, heading);
|
|
9
9
|
return midpoint2;
|
|
10
10
|
}
|
|
11
11
|
var turf_midpoint_default = midpoint;
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../index.
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"names":["midpoint"],"mappings":";AACA,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAC5B,SAAS,gBAAgB;AAsBzB,SAAS,SAAS,QAAe,QAA+B;AAC9D,QAAM,OAAO,SAAS,QAAQ,MAAM;AACpC,QAAM,UAAU,QAAQ,QAAQ,MAAM;AACtC,QAAMA,YAAW,YAAY,QAAQ,OAAO,GAAG,OAAO;AAEtD,SAAOA;AACT;AAGA,IAAO,wBAAQ","sourcesContent":["import { Feature, Point } from \"geojson\";\nimport { bearing } from \"@turf/bearing\";\nimport { destination } from \"@turf/destination\";\nimport { distance } from \"@turf/distance\";\nimport { Coord } from \"@turf/helpers\";\n\n/**\n * Takes two points and returns a point midway between them. The midpoint is\n * calculated geodesically, meaning the curvature of the earth is taken into\n * 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 * const point1 = turf.point([144.834823, -37.771257]);\n * const point2 = turf.point([145.14244, -37.830937]);\n *\n * const midpoint = turf.midpoint(point1, point2);\n *\n * //addToMap\n * const addToMap = [point1, point2, midpoint];\n * midpoint.properties['marker-color'] = '#f00';\n */\nfunction midpoint(point1: Coord, point2: Coord): Feature<Point> {\n const dist = distance(point1, point2);\n const heading = bearing(point1, point2);\n const midpoint = destination(point1, dist / 2, heading);\n\n return midpoint;\n}\n\nexport { midpoint };\nexport default midpoint;\n"]}
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -2,7 +2,23 @@ import { Feature, Point } from 'geojson';
|
|
|
2
2
|
import { Coord } from '@turf/helpers';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Takes two points and returns a point midway between them. The midpoint is
|
|
6
|
+
* calculated geodesically, meaning the curvature of the earth is taken into
|
|
7
|
+
* 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
|
+
* const point1 = turf.point([144.834823, -37.771257]);
|
|
15
|
+
* const point2 = turf.point([145.14244, -37.830937]);
|
|
16
|
+
*
|
|
17
|
+
* const midpoint = turf.midpoint(point1, point2);
|
|
18
|
+
*
|
|
19
|
+
* //addToMap
|
|
20
|
+
* const addToMap = [point1, point2, midpoint];
|
|
21
|
+
* midpoint.properties['marker-color'] = '#f00';
|
|
6
22
|
*/
|
|
7
23
|
declare function midpoint(point1: Coord, point2: Coord): Feature<Point>;
|
|
8
24
|
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -2,7 +2,23 @@ import { Feature, Point } from 'geojson';
|
|
|
2
2
|
import { Coord } from '@turf/helpers';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Takes two points and returns a point midway between them. The midpoint is
|
|
6
|
+
* calculated geodesically, meaning the curvature of the earth is taken into
|
|
7
|
+
* 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
|
+
* const point1 = turf.point([144.834823, -37.771257]);
|
|
15
|
+
* const point2 = turf.point([145.14244, -37.830937]);
|
|
16
|
+
*
|
|
17
|
+
* const midpoint = turf.midpoint(point1, point2);
|
|
18
|
+
*
|
|
19
|
+
* //addToMap
|
|
20
|
+
* const addToMap = [point1, point2, midpoint];
|
|
21
|
+
* midpoint.properties['marker-color'] = '#f00';
|
|
6
22
|
*/
|
|
7
23
|
declare function midpoint(point1: Coord, point2: Coord): Feature<Point>;
|
|
8
24
|
|
package/dist/esm/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
// index.
|
|
1
|
+
// index.ts
|
|
2
2
|
import { bearing } from "@turf/bearing";
|
|
3
3
|
import { destination } from "@turf/destination";
|
|
4
4
|
import { distance } from "@turf/distance";
|
|
5
5
|
function midpoint(point1, point2) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const dist = distance(point1, point2);
|
|
7
|
+
const heading = bearing(point1, point2);
|
|
8
|
+
const midpoint2 = destination(point1, dist / 2, heading);
|
|
9
9
|
return midpoint2;
|
|
10
10
|
}
|
|
11
11
|
var turf_midpoint_default = midpoint;
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../index.
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"sourcesContent":["import { Feature, Point } from \"geojson\";\nimport { bearing } from \"@turf/bearing\";\nimport { destination } from \"@turf/destination\";\nimport { distance } from \"@turf/distance\";\nimport { Coord } from \"@turf/helpers\";\n\n/**\n * Takes two points and returns a point midway between them. The midpoint is\n * calculated geodesically, meaning the curvature of the earth is taken into\n * 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 * const point1 = turf.point([144.834823, -37.771257]);\n * const point2 = turf.point([145.14244, -37.830937]);\n *\n * const midpoint = turf.midpoint(point1, point2);\n *\n * //addToMap\n * const addToMap = [point1, point2, midpoint];\n * midpoint.properties['marker-color'] = '#f00';\n */\nfunction midpoint(point1: Coord, point2: Coord): Feature<Point> {\n const dist = distance(point1, point2);\n const heading = bearing(point1, point2);\n const midpoint = destination(point1, dist / 2, heading);\n\n return midpoint;\n}\n\nexport { midpoint };\nexport default midpoint;\n"],"mappings":";AACA,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAC5B,SAAS,gBAAgB;AAsBzB,SAAS,SAAS,QAAe,QAA+B;AAC9D,QAAM,OAAO,SAAS,QAAQ,MAAM;AACpC,QAAM,UAAU,QAAQ,QAAQ,MAAM;AACtC,QAAMA,YAAW,YAAY,QAAQ,OAAO,GAAG,OAAO;AAEtD,SAAOA;AACT;AAGA,IAAO,wBAAQ;","names":["midpoint"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/midpoint",
|
|
3
|
-
"version": "7.1.0
|
|
3
|
+
"version": "7.1.0",
|
|
4
4
|
"description": "turf midpoint module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"license": "MIT",
|
|
@@ -53,17 +53,21 @@
|
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/benchmark": "^2.1.5",
|
|
56
|
+
"@types/tape": "^4.2.32",
|
|
56
57
|
"benchmark": "^2.1.4",
|
|
57
58
|
"npm-run-all": "^4.1.5",
|
|
58
59
|
"tape": "^5.7.2",
|
|
59
60
|
"tsup": "^8.0.1",
|
|
60
|
-
"tsx": "^4.6.2"
|
|
61
|
+
"tsx": "^4.6.2",
|
|
62
|
+
"typescript": "^5.2.2"
|
|
61
63
|
},
|
|
62
64
|
"dependencies": {
|
|
63
|
-
"@turf/bearing": "^7.1.0
|
|
64
|
-
"@turf/destination": "^7.1.0
|
|
65
|
-
"@turf/distance": "^7.1.0
|
|
66
|
-
"@turf/helpers": "^7.1.0
|
|
65
|
+
"@turf/bearing": "^7.1.0",
|
|
66
|
+
"@turf/destination": "^7.1.0",
|
|
67
|
+
"@turf/distance": "^7.1.0",
|
|
68
|
+
"@turf/helpers": "^7.1.0",
|
|
69
|
+
"@types/geojson": "^7946.0.10",
|
|
70
|
+
"tslib": "^2.6.2"
|
|
67
71
|
},
|
|
68
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "68915eeebc9278bb40dec3f1034499698a0561ef"
|
|
69
73
|
}
|