@turf/planepoint 7.0.0-alpha.1 → 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 +37 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.ts +12 -0
- package/dist/esm/index.d.mts +12 -0
- package/dist/esm/index.mjs +37 -0
- package/dist/esm/index.mjs.map +1 -0
- package/index.d.ts +4 -1
- package/package.json +26 -20
- package/dist/es/index.js +0 -77
- package/dist/es/package.json +0 -1
- package/dist/js/index.js +0 -80
package/README.md
CHANGED
|
@@ -53,26 +53,21 @@ Returns **[number][6]** the z-value for `interpolatedPoint`
|
|
|
53
53
|
|
|
54
54
|
[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
|
55
55
|
|
|
56
|
-
<!-- This file is automatically generated. Please don't edit it directly
|
|
57
|
-
if you find an error, edit the source file (likely index.js), and re-run
|
|
58
|
-
./scripts/generate-readmes in the turf project. -->
|
|
56
|
+
<!-- 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. -->
|
|
59
57
|
|
|
60
58
|
---
|
|
61
59
|
|
|
62
|
-
This module is part of the [Turfjs project](
|
|
63
|
-
module collection dedicated to geographic algorithms. It is maintained in the
|
|
64
|
-
[Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create
|
|
65
|
-
PRs and issues.
|
|
60
|
+
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.
|
|
66
61
|
|
|
67
62
|
### Installation
|
|
68
63
|
|
|
69
|
-
Install this module individually:
|
|
64
|
+
Install this single module individually:
|
|
70
65
|
|
|
71
66
|
```sh
|
|
72
67
|
$ npm install @turf/planepoint
|
|
73
68
|
```
|
|
74
69
|
|
|
75
|
-
Or install the
|
|
70
|
+
Or install the all-encompassing @turf/turf module that includes all modules as functions:
|
|
76
71
|
|
|
77
72
|
```sh
|
|
78
73
|
$ npm install @turf/turf
|
|
@@ -0,0 +1,37 @@
|
|
|
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 _invariant = require('@turf/invariant');
|
|
6
|
+
function planepoint(point, triangle) {
|
|
7
|
+
var coord = _invariant.getCoord.call(void 0, point);
|
|
8
|
+
var geom = _invariant.getGeom.call(void 0, triangle);
|
|
9
|
+
var coords = geom.coordinates;
|
|
10
|
+
var outer = coords[0];
|
|
11
|
+
if (outer.length < 4)
|
|
12
|
+
throw new Error("OuterRing of a Polygon must have 4 or more Positions.");
|
|
13
|
+
var properties = triangle.properties || {};
|
|
14
|
+
var a = properties.a;
|
|
15
|
+
var b = properties.b;
|
|
16
|
+
var c = properties.c;
|
|
17
|
+
var x = coord[0];
|
|
18
|
+
var y = coord[1];
|
|
19
|
+
var x1 = outer[0][0];
|
|
20
|
+
var y1 = outer[0][1];
|
|
21
|
+
var z1 = a !== void 0 ? a : outer[0][2];
|
|
22
|
+
var x2 = outer[1][0];
|
|
23
|
+
var y2 = outer[1][1];
|
|
24
|
+
var z2 = b !== void 0 ? b : outer[1][2];
|
|
25
|
+
var x3 = outer[2][0];
|
|
26
|
+
var y3 = outer[2][1];
|
|
27
|
+
var z3 = c !== void 0 ? c : outer[2][2];
|
|
28
|
+
var z = (z3 * (x - x1) * (y - y2) + z1 * (x - x2) * (y - y3) + z2 * (x - x3) * (y - y1) - z2 * (x - x1) * (y - y3) - z3 * (x - x2) * (y - y1) - z1 * (x - x3) * (y - y2)) / ((x - x1) * (y - y2) + (x - x2) * (y - y3) + (x - x3) * (y - y1) - (x - x1) * (y - y3) - (x - x2) * (y - y1) - (x - x3) * (y - y2));
|
|
29
|
+
return z;
|
|
30
|
+
}
|
|
31
|
+
__name(planepoint, "planepoint");
|
|
32
|
+
var turf_planepoint_default = planepoint;
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
exports.default = turf_planepoint_default; exports.planepoint = planepoint;
|
|
37
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../index.js"],"names":[],"mappings":";;;;AAAA,SAAS,UAAU,eAAe;AAkClC,SAAS,WAAW,OAAO,UAAU;AAEnC,MAAI,QAAQ,SAAS,KAAK;AAC1B,MAAI,OAAO,QAAQ,QAAQ;AAC3B,MAAI,SAAS,KAAK;AAClB,MAAI,QAAQ,OAAO,CAAC;AACpB,MAAI,MAAM,SAAS;AACjB,UAAM,IAAI,MAAM,uDAAuD;AACzE,MAAI,aAAa,SAAS,cAAc,CAAC;AACzC,MAAI,IAAI,WAAW;AACnB,MAAI,IAAI,WAAW;AACnB,MAAI,IAAI,WAAW;AAGnB,MAAI,IAAI,MAAM,CAAC;AACf,MAAI,IAAI,MAAM,CAAC;AACf,MAAI,KAAK,MAAM,CAAC,EAAE,CAAC;AACnB,MAAI,KAAK,MAAM,CAAC,EAAE,CAAC;AACnB,MAAI,KAAK,MAAM,SAAY,IAAI,MAAM,CAAC,EAAE,CAAC;AACzC,MAAI,KAAK,MAAM,CAAC,EAAE,CAAC;AACnB,MAAI,KAAK,MAAM,CAAC,EAAE,CAAC;AACnB,MAAI,KAAK,MAAM,SAAY,IAAI,MAAM,CAAC,EAAE,CAAC;AACzC,MAAI,KAAK,MAAM,CAAC,EAAE,CAAC;AACnB,MAAI,KAAK,MAAM,CAAC,EAAE,CAAC;AACnB,MAAI,KAAK,MAAM,SAAY,IAAI,MAAM,CAAC,EAAE,CAAC;AACzC,MAAI,KACD,MAAM,IAAI,OAAO,IAAI,MACpB,MAAM,IAAI,OAAO,IAAI,MACrB,MAAM,IAAI,OAAO,IAAI,MACrB,MAAM,IAAI,OAAO,IAAI,MACrB,MAAM,IAAI,OAAO,IAAI,MACrB,MAAM,IAAI,OAAO,IAAI,SACrB,IAAI,OAAO,IAAI,OACd,IAAI,OAAO,IAAI,OACf,IAAI,OAAO,IAAI,OACf,IAAI,OAAO,IAAI,OACf,IAAI,OAAO,IAAI,OACf,IAAI,OAAO,IAAI;AAEpB,SAAO;AACT;AAxCS;AA2CT,IAAO,0BAAQ","sourcesContent":["import { getCoord, getGeom } from \"@turf/invariant\";\n\n/**\n * Takes a triangular plane as a {@link Polygon}\n * and a {@link Point} within that triangle and returns the z-value\n * at that point. The Polygon should have properties `a`, `b`, and `c`\n * that define the values at its three corners. Alternatively, the z-values\n * of each triangle point can be provided by their respective 3rd coordinate\n * if their values are not provided as properties.\n *\n * @name planepoint\n * @param {Coord} point the Point for which a z-value will be calculated\n * @param {Feature<Polygon>} triangle a Polygon feature with three vertices\n * @returns {number} the z-value for `interpolatedPoint`\n * @example\n * var point = turf.point([-75.3221, 39.529]);\n * // \"a\", \"b\", and \"c\" values represent the values of the coordinates in order.\n * var triangle = turf.polygon([[\n * [-75.1221, 39.57],\n * [-75.58, 39.18],\n * [-75.97, 39.86],\n * [-75.1221, 39.57]\n * ]], {\n * \"a\": 11,\n * \"b\": 122,\n * \"c\": 44\n * });\n *\n * var zValue = turf.planepoint(point, triangle);\n * point.properties.zValue = zValue;\n *\n * //addToMap\n * var addToMap = [triangle, point];\n */\nfunction planepoint(point, triangle) {\n // Normalize input\n var coord = getCoord(point);\n var geom = getGeom(triangle);\n var coords = geom.coordinates;\n var outer = coords[0];\n if (outer.length < 4)\n throw new Error(\"OuterRing of a Polygon must have 4 or more Positions.\");\n var properties = triangle.properties || {};\n var a = properties.a;\n var b = properties.b;\n var c = properties.c;\n\n // Planepoint\n var x = coord[0];\n var y = coord[1];\n var x1 = outer[0][0];\n var y1 = outer[0][1];\n var z1 = a !== undefined ? a : outer[0][2];\n var x2 = outer[1][0];\n var y2 = outer[1][1];\n var z2 = b !== undefined ? b : outer[1][2];\n var x3 = outer[2][0];\n var y3 = outer[2][1];\n var z3 = c !== undefined ? c : outer[2][2];\n var z =\n (z3 * (x - x1) * (y - y2) +\n z1 * (x - x2) * (y - y3) +\n z2 * (x - x3) * (y - y1) -\n z2 * (x - x1) * (y - y3) -\n z3 * (x - x2) * (y - y1) -\n z1 * (x - x3) * (y - y2)) /\n ((x - x1) * (y - y2) +\n (x - x2) * (y - y3) +\n (x - x3) * (y - y1) -\n (x - x1) * (y - y3) -\n (x - x2) * (y - y1) -\n (x - x3) * (y - y2));\n\n return z;\n}\n\nexport { planepoint };\nexport default planepoint;\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Feature, Polygon } from 'geojson';
|
|
2
|
+
import { Coord } from '@turf/helpers';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* http://turfjs.org/docs/#planepoint
|
|
6
|
+
*/
|
|
7
|
+
declare function planepoint(
|
|
8
|
+
point: Coord,
|
|
9
|
+
triangle: Feature<Polygon> | Polygon
|
|
10
|
+
): number;
|
|
11
|
+
|
|
12
|
+
export { planepoint as default, planepoint };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Feature, Polygon } from 'geojson';
|
|
2
|
+
import { Coord } from '@turf/helpers';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* http://turfjs.org/docs/#planepoint
|
|
6
|
+
*/
|
|
7
|
+
declare function planepoint(
|
|
8
|
+
point: Coord,
|
|
9
|
+
triangle: Feature<Polygon> | Polygon
|
|
10
|
+
): number;
|
|
11
|
+
|
|
12
|
+
export { planepoint as default, planepoint };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// index.js
|
|
5
|
+
import { getCoord, getGeom } from "@turf/invariant";
|
|
6
|
+
function planepoint(point, triangle) {
|
|
7
|
+
var coord = getCoord(point);
|
|
8
|
+
var geom = getGeom(triangle);
|
|
9
|
+
var coords = geom.coordinates;
|
|
10
|
+
var outer = coords[0];
|
|
11
|
+
if (outer.length < 4)
|
|
12
|
+
throw new Error("OuterRing of a Polygon must have 4 or more Positions.");
|
|
13
|
+
var properties = triangle.properties || {};
|
|
14
|
+
var a = properties.a;
|
|
15
|
+
var b = properties.b;
|
|
16
|
+
var c = properties.c;
|
|
17
|
+
var x = coord[0];
|
|
18
|
+
var y = coord[1];
|
|
19
|
+
var x1 = outer[0][0];
|
|
20
|
+
var y1 = outer[0][1];
|
|
21
|
+
var z1 = a !== void 0 ? a : outer[0][2];
|
|
22
|
+
var x2 = outer[1][0];
|
|
23
|
+
var y2 = outer[1][1];
|
|
24
|
+
var z2 = b !== void 0 ? b : outer[1][2];
|
|
25
|
+
var x3 = outer[2][0];
|
|
26
|
+
var y3 = outer[2][1];
|
|
27
|
+
var z3 = c !== void 0 ? c : outer[2][2];
|
|
28
|
+
var z = (z3 * (x - x1) * (y - y2) + z1 * (x - x2) * (y - y3) + z2 * (x - x3) * (y - y1) - z2 * (x - x1) * (y - y3) - z3 * (x - x2) * (y - y1) - z1 * (x - x3) * (y - y2)) / ((x - x1) * (y - y2) + (x - x2) * (y - y3) + (x - x3) * (y - y1) - (x - x1) * (y - y3) - (x - x2) * (y - y1) - (x - x3) * (y - y2));
|
|
29
|
+
return z;
|
|
30
|
+
}
|
|
31
|
+
__name(planepoint, "planepoint");
|
|
32
|
+
var turf_planepoint_default = planepoint;
|
|
33
|
+
export {
|
|
34
|
+
turf_planepoint_default as default,
|
|
35
|
+
planepoint
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../index.js"],"sourcesContent":["import { getCoord, getGeom } from \"@turf/invariant\";\n\n/**\n * Takes a triangular plane as a {@link Polygon}\n * and a {@link Point} within that triangle and returns the z-value\n * at that point. The Polygon should have properties `a`, `b`, and `c`\n * that define the values at its three corners. Alternatively, the z-values\n * of each triangle point can be provided by their respective 3rd coordinate\n * if their values are not provided as properties.\n *\n * @name planepoint\n * @param {Coord} point the Point for which a z-value will be calculated\n * @param {Feature<Polygon>} triangle a Polygon feature with three vertices\n * @returns {number} the z-value for `interpolatedPoint`\n * @example\n * var point = turf.point([-75.3221, 39.529]);\n * // \"a\", \"b\", and \"c\" values represent the values of the coordinates in order.\n * var triangle = turf.polygon([[\n * [-75.1221, 39.57],\n * [-75.58, 39.18],\n * [-75.97, 39.86],\n * [-75.1221, 39.57]\n * ]], {\n * \"a\": 11,\n * \"b\": 122,\n * \"c\": 44\n * });\n *\n * var zValue = turf.planepoint(point, triangle);\n * point.properties.zValue = zValue;\n *\n * //addToMap\n * var addToMap = [triangle, point];\n */\nfunction planepoint(point, triangle) {\n // Normalize input\n var coord = getCoord(point);\n var geom = getGeom(triangle);\n var coords = geom.coordinates;\n var outer = coords[0];\n if (outer.length < 4)\n throw new Error(\"OuterRing of a Polygon must have 4 or more Positions.\");\n var properties = triangle.properties || {};\n var a = properties.a;\n var b = properties.b;\n var c = properties.c;\n\n // Planepoint\n var x = coord[0];\n var y = coord[1];\n var x1 = outer[0][0];\n var y1 = outer[0][1];\n var z1 = a !== undefined ? a : outer[0][2];\n var x2 = outer[1][0];\n var y2 = outer[1][1];\n var z2 = b !== undefined ? b : outer[1][2];\n var x3 = outer[2][0];\n var y3 = outer[2][1];\n var z3 = c !== undefined ? c : outer[2][2];\n var z =\n (z3 * (x - x1) * (y - y2) +\n z1 * (x - x2) * (y - y3) +\n z2 * (x - x3) * (y - y1) -\n z2 * (x - x1) * (y - y3) -\n z3 * (x - x2) * (y - y1) -\n z1 * (x - x3) * (y - y2)) /\n ((x - x1) * (y - y2) +\n (x - x2) * (y - y3) +\n (x - x3) * (y - y1) -\n (x - x1) * (y - y3) -\n (x - x2) * (y - y1) -\n (x - x3) * (y - y2));\n\n return z;\n}\n\nexport { planepoint };\nexport default planepoint;\n"],"mappings":";;;;AAAA,SAAS,UAAU,eAAe;AAkClC,SAAS,WAAW,OAAO,UAAU;AAEnC,MAAI,QAAQ,SAAS,KAAK;AAC1B,MAAI,OAAO,QAAQ,QAAQ;AAC3B,MAAI,SAAS,KAAK;AAClB,MAAI,QAAQ,OAAO,CAAC;AACpB,MAAI,MAAM,SAAS;AACjB,UAAM,IAAI,MAAM,uDAAuD;AACzE,MAAI,aAAa,SAAS,cAAc,CAAC;AACzC,MAAI,IAAI,WAAW;AACnB,MAAI,IAAI,WAAW;AACnB,MAAI,IAAI,WAAW;AAGnB,MAAI,IAAI,MAAM,CAAC;AACf,MAAI,IAAI,MAAM,CAAC;AACf,MAAI,KAAK,MAAM,CAAC,EAAE,CAAC;AACnB,MAAI,KAAK,MAAM,CAAC,EAAE,CAAC;AACnB,MAAI,KAAK,MAAM,SAAY,IAAI,MAAM,CAAC,EAAE,CAAC;AACzC,MAAI,KAAK,MAAM,CAAC,EAAE,CAAC;AACnB,MAAI,KAAK,MAAM,CAAC,EAAE,CAAC;AACnB,MAAI,KAAK,MAAM,SAAY,IAAI,MAAM,CAAC,EAAE,CAAC;AACzC,MAAI,KAAK,MAAM,CAAC,EAAE,CAAC;AACnB,MAAI,KAAK,MAAM,CAAC,EAAE,CAAC;AACnB,MAAI,KAAK,MAAM,SAAY,IAAI,MAAM,CAAC,EAAE,CAAC;AACzC,MAAI,KACD,MAAM,IAAI,OAAO,IAAI,MACpB,MAAM,IAAI,OAAO,IAAI,MACrB,MAAM,IAAI,OAAO,IAAI,MACrB,MAAM,IAAI,OAAO,IAAI,MACrB,MAAM,IAAI,OAAO,IAAI,MACrB,MAAM,IAAI,OAAO,IAAI,SACrB,IAAI,OAAO,IAAI,OACd,IAAI,OAAO,IAAI,OACf,IAAI,OAAO,IAAI,OACf,IAAI,OAAO,IAAI,OACf,IAAI,OAAO,IAAI,OACf,IAAI,OAAO,IAAI;AAEpB,SAAO;AACT;AAxCS;AA2CT,IAAO,0BAAQ;","names":[]}
|
package/index.d.ts
CHANGED
|
@@ -4,7 +4,10 @@ import { Coord } from "@turf/helpers";
|
|
|
4
4
|
/**
|
|
5
5
|
* http://turfjs.org/docs/#planepoint
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
declare function planepoint(
|
|
8
8
|
point: Coord,
|
|
9
9
|
triangle: Feature<Polygon> | Polygon
|
|
10
10
|
): number;
|
|
11
|
+
|
|
12
|
+
export { planepoint };
|
|
13
|
+
export default planepoint;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/planepoint",
|
|
3
|
-
"version": "7.0.0-alpha.
|
|
3
|
+
"version": "7.0.0-alpha.110+1411d63a7",
|
|
4
4
|
"description": "turf planepoint module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,40 +23,46 @@
|
|
|
23
23
|
"point",
|
|
24
24
|
"interpolation"
|
|
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
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
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
|
+
}
|
|
34
41
|
}
|
|
35
42
|
},
|
|
36
|
-
"types": "index.d.ts",
|
|
37
43
|
"sideEffects": false,
|
|
38
44
|
"files": [
|
|
39
45
|
"dist",
|
|
40
46
|
"index.d.ts"
|
|
41
47
|
],
|
|
42
48
|
"scripts": {
|
|
43
|
-
"bench": "tsx bench.
|
|
44
|
-
"build": "
|
|
45
|
-
"docs": "tsx ../../scripts/generate-readmes",
|
|
46
|
-
"test": "npm-run-all test:*",
|
|
47
|
-
"test:tape": "tsx test.
|
|
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",
|
|
48
54
|
"test:types": "tsc --esModuleInterop --noEmit --strict types.ts"
|
|
49
55
|
},
|
|
50
56
|
"devDependencies": {
|
|
51
|
-
"benchmark": "
|
|
52
|
-
"npm-run-all": "
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"tsx": "
|
|
57
|
+
"benchmark": "^2.1.4",
|
|
58
|
+
"npm-run-all": "^4.1.5",
|
|
59
|
+
"tape": "^5.7.2",
|
|
60
|
+
"tsup": "^8.0.1",
|
|
61
|
+
"tsx": "^4.6.2"
|
|
56
62
|
},
|
|
57
63
|
"dependencies": {
|
|
58
|
-
"@turf/helpers": "^7.0.0-alpha.
|
|
59
|
-
"@turf/invariant": "^7.0.0-alpha.
|
|
64
|
+
"@turf/helpers": "^7.0.0-alpha.110+1411d63a7",
|
|
65
|
+
"@turf/invariant": "^7.0.0-alpha.110+1411d63a7"
|
|
60
66
|
},
|
|
61
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "1411d63a74c275c9216fe48e9d3cb2d48a359068"
|
|
62
68
|
}
|
package/dist/es/index.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { getCoord, getGeom } from '@turf/invariant';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Takes a triangular plane as a {@link Polygon}
|
|
5
|
-
* and a {@link Point} within that triangle and returns the z-value
|
|
6
|
-
* at that point. The Polygon should have properties `a`, `b`, and `c`
|
|
7
|
-
* that define the values at its three corners. Alternatively, the z-values
|
|
8
|
-
* of each triangle point can be provided by their respective 3rd coordinate
|
|
9
|
-
* if their values are not provided as properties.
|
|
10
|
-
*
|
|
11
|
-
* @name planepoint
|
|
12
|
-
* @param {Coord} point the Point for which a z-value will be calculated
|
|
13
|
-
* @param {Feature<Polygon>} triangle a Polygon feature with three vertices
|
|
14
|
-
* @returns {number} the z-value for `interpolatedPoint`
|
|
15
|
-
* @example
|
|
16
|
-
* var point = turf.point([-75.3221, 39.529]);
|
|
17
|
-
* // "a", "b", and "c" values represent the values of the coordinates in order.
|
|
18
|
-
* var triangle = turf.polygon([[
|
|
19
|
-
* [-75.1221, 39.57],
|
|
20
|
-
* [-75.58, 39.18],
|
|
21
|
-
* [-75.97, 39.86],
|
|
22
|
-
* [-75.1221, 39.57]
|
|
23
|
-
* ]], {
|
|
24
|
-
* "a": 11,
|
|
25
|
-
* "b": 122,
|
|
26
|
-
* "c": 44
|
|
27
|
-
* });
|
|
28
|
-
*
|
|
29
|
-
* var zValue = turf.planepoint(point, triangle);
|
|
30
|
-
* point.properties.zValue = zValue;
|
|
31
|
-
*
|
|
32
|
-
* //addToMap
|
|
33
|
-
* var addToMap = [triangle, point];
|
|
34
|
-
*/
|
|
35
|
-
function planepoint(point, triangle) {
|
|
36
|
-
// Normalize input
|
|
37
|
-
var coord = getCoord(point);
|
|
38
|
-
var geom = getGeom(triangle);
|
|
39
|
-
var coords = geom.coordinates;
|
|
40
|
-
var outer = coords[0];
|
|
41
|
-
if (outer.length < 4)
|
|
42
|
-
throw new Error("OuterRing of a Polygon must have 4 or more Positions.");
|
|
43
|
-
var properties = triangle.properties || {};
|
|
44
|
-
var a = properties.a;
|
|
45
|
-
var b = properties.b;
|
|
46
|
-
var c = properties.c;
|
|
47
|
-
|
|
48
|
-
// Planepoint
|
|
49
|
-
var x = coord[0];
|
|
50
|
-
var y = coord[1];
|
|
51
|
-
var x1 = outer[0][0];
|
|
52
|
-
var y1 = outer[0][1];
|
|
53
|
-
var z1 = a !== undefined ? a : outer[0][2];
|
|
54
|
-
var x2 = outer[1][0];
|
|
55
|
-
var y2 = outer[1][1];
|
|
56
|
-
var z2 = b !== undefined ? b : outer[1][2];
|
|
57
|
-
var x3 = outer[2][0];
|
|
58
|
-
var y3 = outer[2][1];
|
|
59
|
-
var z3 = c !== undefined ? c : outer[2][2];
|
|
60
|
-
var z =
|
|
61
|
-
(z3 * (x - x1) * (y - y2) +
|
|
62
|
-
z1 * (x - x2) * (y - y3) +
|
|
63
|
-
z2 * (x - x3) * (y - y1) -
|
|
64
|
-
z2 * (x - x1) * (y - y3) -
|
|
65
|
-
z3 * (x - x2) * (y - y1) -
|
|
66
|
-
z1 * (x - x3) * (y - y2)) /
|
|
67
|
-
((x - x1) * (y - y2) +
|
|
68
|
-
(x - x2) * (y - y3) +
|
|
69
|
-
(x - x3) * (y - y1) -
|
|
70
|
-
(x - x1) * (y - y3) -
|
|
71
|
-
(x - x2) * (y - y1) -
|
|
72
|
-
(x - x3) * (y - y2));
|
|
73
|
-
|
|
74
|
-
return z;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export default planepoint;
|
package/dist/es/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"module"}
|
package/dist/js/index.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var invariant = require('@turf/invariant');
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Takes a triangular plane as a {@link Polygon}
|
|
7
|
-
* and a {@link Point} within that triangle and returns the z-value
|
|
8
|
-
* at that point. The Polygon should have properties `a`, `b`, and `c`
|
|
9
|
-
* that define the values at its three corners. Alternatively, the z-values
|
|
10
|
-
* of each triangle point can be provided by their respective 3rd coordinate
|
|
11
|
-
* if their values are not provided as properties.
|
|
12
|
-
*
|
|
13
|
-
* @name planepoint
|
|
14
|
-
* @param {Coord} point the Point for which a z-value will be calculated
|
|
15
|
-
* @param {Feature<Polygon>} triangle a Polygon feature with three vertices
|
|
16
|
-
* @returns {number} the z-value for `interpolatedPoint`
|
|
17
|
-
* @example
|
|
18
|
-
* var point = turf.point([-75.3221, 39.529]);
|
|
19
|
-
* // "a", "b", and "c" values represent the values of the coordinates in order.
|
|
20
|
-
* var triangle = turf.polygon([[
|
|
21
|
-
* [-75.1221, 39.57],
|
|
22
|
-
* [-75.58, 39.18],
|
|
23
|
-
* [-75.97, 39.86],
|
|
24
|
-
* [-75.1221, 39.57]
|
|
25
|
-
* ]], {
|
|
26
|
-
* "a": 11,
|
|
27
|
-
* "b": 122,
|
|
28
|
-
* "c": 44
|
|
29
|
-
* });
|
|
30
|
-
*
|
|
31
|
-
* var zValue = turf.planepoint(point, triangle);
|
|
32
|
-
* point.properties.zValue = zValue;
|
|
33
|
-
*
|
|
34
|
-
* //addToMap
|
|
35
|
-
* var addToMap = [triangle, point];
|
|
36
|
-
*/
|
|
37
|
-
function planepoint(point, triangle) {
|
|
38
|
-
// Normalize input
|
|
39
|
-
var coord = invariant.getCoord(point);
|
|
40
|
-
var geom = invariant.getGeom(triangle);
|
|
41
|
-
var coords = geom.coordinates;
|
|
42
|
-
var outer = coords[0];
|
|
43
|
-
if (outer.length < 4)
|
|
44
|
-
throw new Error("OuterRing of a Polygon must have 4 or more Positions.");
|
|
45
|
-
var properties = triangle.properties || {};
|
|
46
|
-
var a = properties.a;
|
|
47
|
-
var b = properties.b;
|
|
48
|
-
var c = properties.c;
|
|
49
|
-
|
|
50
|
-
// Planepoint
|
|
51
|
-
var x = coord[0];
|
|
52
|
-
var y = coord[1];
|
|
53
|
-
var x1 = outer[0][0];
|
|
54
|
-
var y1 = outer[0][1];
|
|
55
|
-
var z1 = a !== undefined ? a : outer[0][2];
|
|
56
|
-
var x2 = outer[1][0];
|
|
57
|
-
var y2 = outer[1][1];
|
|
58
|
-
var z2 = b !== undefined ? b : outer[1][2];
|
|
59
|
-
var x3 = outer[2][0];
|
|
60
|
-
var y3 = outer[2][1];
|
|
61
|
-
var z3 = c !== undefined ? c : outer[2][2];
|
|
62
|
-
var z =
|
|
63
|
-
(z3 * (x - x1) * (y - y2) +
|
|
64
|
-
z1 * (x - x2) * (y - y3) +
|
|
65
|
-
z2 * (x - x3) * (y - y1) -
|
|
66
|
-
z2 * (x - x1) * (y - y3) -
|
|
67
|
-
z3 * (x - x2) * (y - y1) -
|
|
68
|
-
z1 * (x - x3) * (y - y2)) /
|
|
69
|
-
((x - x1) * (y - y2) +
|
|
70
|
-
(x - x2) * (y - y3) +
|
|
71
|
-
(x - x3) * (y - y1) -
|
|
72
|
-
(x - x1) * (y - y3) -
|
|
73
|
-
(x - x2) * (y - y1) -
|
|
74
|
-
(x - x3) * (y - y2));
|
|
75
|
-
|
|
76
|
-
return z;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
module.exports = planepoint;
|
|
80
|
-
module.exports.default = planepoint;
|