@turf/planepoint 7.0.0 → 7.1.0-alpha.70

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 CHANGED
@@ -4,24 +4,25 @@
4
4
 
5
5
  ## planepoint
6
6
 
7
- Takes a triangular plane as a [Polygon][1]
8
- and a [Point][2] within that triangle and returns the z-value
9
- at that point. The Polygon should have properties `a`, `b`, and `c`
7
+ Takes a triangular plane as a polygon and a point within that triangle, and
8
+ returns the z-value at that point.
9
+
10
+ The Polygon should have properties `a`, `b`, and `c`
10
11
  that define the values at its three corners. Alternatively, the z-values
11
12
  of each triangle point can be provided by their respective 3rd coordinate
12
13
  if their values are not provided as properties.
13
14
 
14
15
  ### Parameters
15
16
 
16
- * `point` **[Coord][3]** the Point for which a z-value will be calculated
17
- * `triangle` **[Feature][4]<[Polygon][5]>** a Polygon feature with three vertices
17
+ * `point` **[Coord][1]** the Point for which a z-value will be calculated
18
+ * `triangle` **[Feature][2]<[Polygon][3]>** a Polygon feature with three vertices
18
19
 
19
20
  ### Examples
20
21
 
21
22
  ```javascript
22
- var point = turf.point([-75.3221, 39.529]);
23
+ const point = turf.point([-75.3221, 39.529]);
23
24
  // "a", "b", and "c" values represent the values of the coordinates in order.
24
- var triangle = turf.polygon([[
25
+ const triangle = turf.polygon([[
25
26
  [-75.1221, 39.57],
26
27
  [-75.58, 39.18],
27
28
  [-75.97, 39.86],
@@ -32,26 +33,22 @@ var triangle = turf.polygon([[
32
33
  "c": 44
33
34
  });
34
35
 
35
- var zValue = turf.planepoint(point, triangle);
36
+ const zValue = turf.planepoint(point, triangle);
36
37
  point.properties.zValue = zValue;
37
38
 
38
39
  //addToMap
39
- var addToMap = [triangle, point];
40
+ const addToMap = [triangle, point];
40
41
  ```
41
42
 
42
- Returns **[number][6]** the z-value for `interpolatedPoint`
43
-
44
- [1]: https://tools.ietf.org/html/rfc7946#section-3.1.6
45
-
46
- [2]: https://tools.ietf.org/html/rfc7946#section-3.1.2
43
+ Returns **[number][4]** the z-value for `interpolatedPoint`
47
44
 
48
- [3]: https://tools.ietf.org/html/rfc7946#section-3.1.1
45
+ [1]: https://tools.ietf.org/html/rfc7946#section-3.1.1
49
46
 
50
- [4]: https://tools.ietf.org/html/rfc7946#section-3.2
47
+ [2]: https://tools.ietf.org/html/rfc7946#section-3.2
51
48
 
52
- [5]: https://tools.ietf.org/html/rfc7946#section-3.1.6
49
+ [3]: https://tools.ietf.org/html/rfc7946#section-3.1.6
53
50
 
54
- [6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
51
+ [4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
55
52
 
56
53
  <!-- 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. -->
57
54
 
@@ -1,34 +1,30 @@
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
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// index.ts
5
2
  var _invariant = require('@turf/invariant');
6
3
  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];
4
+ const coord = _invariant.getCoord.call(void 0, point);
5
+ const geom = _invariant.getGeom.call(void 0, triangle);
6
+ const coords = geom.coordinates;
7
+ const outer = coords[0];
11
8
  if (outer.length < 4)
12
9
  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));
10
+ const properties = triangle.type === "Feature" && triangle.properties || {};
11
+ const a = properties.a;
12
+ const b = properties.b;
13
+ const c = properties.c;
14
+ const x = coord[0];
15
+ const y = coord[1];
16
+ const x1 = outer[0][0];
17
+ const y1 = outer[0][1];
18
+ const z1 = a !== void 0 ? a : outer[0][2];
19
+ const x2 = outer[1][0];
20
+ const y2 = outer[1][1];
21
+ const z2 = b !== void 0 ? b : outer[1][2];
22
+ const x3 = outer[2][0];
23
+ const y3 = outer[2][1];
24
+ const z3 = c !== void 0 ? c : outer[2][2];
25
+ const 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
26
  return z;
30
27
  }
31
- __name(planepoint, "planepoint");
32
28
  var turf_planepoint_default = planepoint;
33
29
 
34
30
 
@@ -1 +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"]}
1
+ {"version":3,"sources":["../../index.ts"],"names":[],"mappings":";AACA,SAAS,UAAU,eAAe;AAoClC,SAAS,WACP,OACA,UACQ;AAER,QAAM,QAAQ,SAAS,KAAK;AAC5B,QAAM,OAAO,QAAQ,QAAQ;AAC7B,QAAM,SAAS,KAAK;AACpB,QAAM,QAAQ,OAAO,CAAC;AACtB,MAAI,MAAM,SAAS;AACjB,UAAM,IAAI,MAAM,uDAAuD;AACzE,QAAM,aAAc,SAAS,SAAS,aAAa,SAAS,cAAe,CAAC;AAC5E,QAAM,IAAI,WAAW;AACrB,QAAM,IAAI,WAAW;AACrB,QAAM,IAAI,WAAW;AAGrB,QAAM,IAAI,MAAM,CAAC;AACjB,QAAM,IAAI,MAAM,CAAC;AACjB,QAAM,KAAK,MAAM,CAAC,EAAE,CAAC;AACrB,QAAM,KAAK,MAAM,CAAC,EAAE,CAAC;AACrB,QAAM,KAAK,MAAM,SAAY,IAAI,MAAM,CAAC,EAAE,CAAC;AAC3C,QAAM,KAAK,MAAM,CAAC,EAAE,CAAC;AACrB,QAAM,KAAK,MAAM,CAAC,EAAE,CAAC;AACrB,QAAM,KAAK,MAAM,SAAY,IAAI,MAAM,CAAC,EAAE,CAAC;AAC3C,QAAM,KAAK,MAAM,CAAC,EAAE,CAAC;AACrB,QAAM,KAAK,MAAM,CAAC,EAAE,CAAC;AACrB,QAAM,KAAK,MAAM,SAAY,IAAI,MAAM,CAAC,EAAE,CAAC;AAC3C,QAAM,KACH,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;AAGA,IAAO,0BAAQ","sourcesContent":["import { Feature, Polygon } from \"geojson\";\nimport { getCoord, getGeom } from \"@turf/invariant\";\nimport { Coord } from \"@turf/helpers\";\n\n/**\n * Takes a triangular plane as a polygon and a point within that triangle, and\n * returns the z-value at that point.\n *\n * 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 * const point = turf.point([-75.3221, 39.529]);\n * // \"a\", \"b\", and \"c\" values represent the values of the coordinates in order.\n * const 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 * const zValue = turf.planepoint(point, triangle);\n * point.properties.zValue = zValue;\n *\n * //addToMap\n * const addToMap = [triangle, point];\n */\nfunction planepoint(\n point: Coord,\n triangle: Feature<Polygon> | Polygon\n): number {\n // Normalize input\n const coord = getCoord(point);\n const geom = getGeom(triangle);\n const coords = geom.coordinates;\n const outer = coords[0];\n if (outer.length < 4)\n throw new Error(\"OuterRing of a Polygon must have 4 or more Positions.\");\n const properties = (triangle.type === \"Feature\" && triangle.properties) || {};\n const a = properties.a;\n const b = properties.b;\n const c = properties.c;\n\n // Planepoint\n const x = coord[0];\n const y = coord[1];\n const x1 = outer[0][0];\n const y1 = outer[0][1];\n const z1 = a !== undefined ? a : outer[0][2];\n const x2 = outer[1][0];\n const y2 = outer[1][1];\n const z2 = b !== undefined ? b : outer[1][2];\n const x3 = outer[2][0];\n const y3 = outer[2][1];\n const z3 = c !== undefined ? c : outer[2][2];\n const 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"]}
@@ -2,11 +2,38 @@ import { Feature, Polygon } from 'geojson';
2
2
  import { Coord } from '@turf/helpers';
3
3
 
4
4
  /**
5
- * http://turfjs.org/docs/#planepoint
5
+ * Takes a triangular plane as a polygon and a point within that triangle, and
6
+ * returns the z-value at that point.
7
+ *
8
+ * 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
+ * const point = turf.point([-75.3221, 39.529]);
19
+ * // "a", "b", and "c" values represent the values of the coordinates in order.
20
+ * const 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
+ * const zValue = turf.planepoint(point, triangle);
32
+ * point.properties.zValue = zValue;
33
+ *
34
+ * //addToMap
35
+ * const addToMap = [triangle, point];
6
36
  */
7
- declare function planepoint(
8
- point: Coord,
9
- triangle: Feature<Polygon> | Polygon
10
- ): number;
37
+ declare function planepoint(point: Coord, triangle: Feature<Polygon> | Polygon): number;
11
38
 
12
39
  export { planepoint as default, planepoint };
@@ -2,11 +2,38 @@ import { Feature, Polygon } from 'geojson';
2
2
  import { Coord } from '@turf/helpers';
3
3
 
4
4
  /**
5
- * http://turfjs.org/docs/#planepoint
5
+ * Takes a triangular plane as a polygon and a point within that triangle, and
6
+ * returns the z-value at that point.
7
+ *
8
+ * 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
+ * const point = turf.point([-75.3221, 39.529]);
19
+ * // "a", "b", and "c" values represent the values of the coordinates in order.
20
+ * const 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
+ * const zValue = turf.planepoint(point, triangle);
32
+ * point.properties.zValue = zValue;
33
+ *
34
+ * //addToMap
35
+ * const addToMap = [triangle, point];
6
36
  */
7
- declare function planepoint(
8
- point: Coord,
9
- triangle: Feature<Polygon> | Polygon
10
- ): number;
37
+ declare function planepoint(point: Coord, triangle: Feature<Polygon> | Polygon): number;
11
38
 
12
39
  export { planepoint as default, planepoint };
package/dist/esm/index.js CHANGED
@@ -1,34 +1,30 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
-
4
- // index.js
1
+ // index.ts
5
2
  import { getCoord, getGeom } from "@turf/invariant";
6
3
  function planepoint(point, triangle) {
7
- var coord = getCoord(point);
8
- var geom = getGeom(triangle);
9
- var coords = geom.coordinates;
10
- var outer = coords[0];
4
+ const coord = getCoord(point);
5
+ const geom = getGeom(triangle);
6
+ const coords = geom.coordinates;
7
+ const outer = coords[0];
11
8
  if (outer.length < 4)
12
9
  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));
10
+ const properties = triangle.type === "Feature" && triangle.properties || {};
11
+ const a = properties.a;
12
+ const b = properties.b;
13
+ const c = properties.c;
14
+ const x = coord[0];
15
+ const y = coord[1];
16
+ const x1 = outer[0][0];
17
+ const y1 = outer[0][1];
18
+ const z1 = a !== void 0 ? a : outer[0][2];
19
+ const x2 = outer[1][0];
20
+ const y2 = outer[1][1];
21
+ const z2 = b !== void 0 ? b : outer[1][2];
22
+ const x3 = outer[2][0];
23
+ const y3 = outer[2][1];
24
+ const z3 = c !== void 0 ? c : outer[2][2];
25
+ const 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
26
  return z;
30
27
  }
31
- __name(planepoint, "planepoint");
32
28
  var turf_planepoint_default = planepoint;
33
29
  export {
34
30
  turf_planepoint_default as default,
@@ -1 +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":[]}
1
+ {"version":3,"sources":["../../index.ts"],"sourcesContent":["import { Feature, Polygon } from \"geojson\";\nimport { getCoord, getGeom } from \"@turf/invariant\";\nimport { Coord } from \"@turf/helpers\";\n\n/**\n * Takes a triangular plane as a polygon and a point within that triangle, and\n * returns the z-value at that point.\n *\n * 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 * const point = turf.point([-75.3221, 39.529]);\n * // \"a\", \"b\", and \"c\" values represent the values of the coordinates in order.\n * const 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 * const zValue = turf.planepoint(point, triangle);\n * point.properties.zValue = zValue;\n *\n * //addToMap\n * const addToMap = [triangle, point];\n */\nfunction planepoint(\n point: Coord,\n triangle: Feature<Polygon> | Polygon\n): number {\n // Normalize input\n const coord = getCoord(point);\n const geom = getGeom(triangle);\n const coords = geom.coordinates;\n const outer = coords[0];\n if (outer.length < 4)\n throw new Error(\"OuterRing of a Polygon must have 4 or more Positions.\");\n const properties = (triangle.type === \"Feature\" && triangle.properties) || {};\n const a = properties.a;\n const b = properties.b;\n const c = properties.c;\n\n // Planepoint\n const x = coord[0];\n const y = coord[1];\n const x1 = outer[0][0];\n const y1 = outer[0][1];\n const z1 = a !== undefined ? a : outer[0][2];\n const x2 = outer[1][0];\n const y2 = outer[1][1];\n const z2 = b !== undefined ? b : outer[1][2];\n const x3 = outer[2][0];\n const y3 = outer[2][1];\n const z3 = c !== undefined ? c : outer[2][2];\n const 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":";AACA,SAAS,UAAU,eAAe;AAoClC,SAAS,WACP,OACA,UACQ;AAER,QAAM,QAAQ,SAAS,KAAK;AAC5B,QAAM,OAAO,QAAQ,QAAQ;AAC7B,QAAM,SAAS,KAAK;AACpB,QAAM,QAAQ,OAAO,CAAC;AACtB,MAAI,MAAM,SAAS;AACjB,UAAM,IAAI,MAAM,uDAAuD;AACzE,QAAM,aAAc,SAAS,SAAS,aAAa,SAAS,cAAe,CAAC;AAC5E,QAAM,IAAI,WAAW;AACrB,QAAM,IAAI,WAAW;AACrB,QAAM,IAAI,WAAW;AAGrB,QAAM,IAAI,MAAM,CAAC;AACjB,QAAM,IAAI,MAAM,CAAC;AACjB,QAAM,KAAK,MAAM,CAAC,EAAE,CAAC;AACrB,QAAM,KAAK,MAAM,CAAC,EAAE,CAAC;AACrB,QAAM,KAAK,MAAM,SAAY,IAAI,MAAM,CAAC,EAAE,CAAC;AAC3C,QAAM,KAAK,MAAM,CAAC,EAAE,CAAC;AACrB,QAAM,KAAK,MAAM,CAAC,EAAE,CAAC;AACrB,QAAM,KAAK,MAAM,SAAY,IAAI,MAAM,CAAC,EAAE,CAAC;AAC3C,QAAM,KAAK,MAAM,CAAC,EAAE,CAAC;AACrB,QAAM,KAAK,MAAM,CAAC,EAAE,CAAC;AACrB,QAAM,KAAK,MAAM,SAAY,IAAI,MAAM,CAAC,EAAE,CAAC;AAC3C,QAAM,KACH,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;AAGA,IAAO,0BAAQ;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turf/planepoint",
3
- "version": "7.0.0",
3
+ "version": "7.1.0-alpha.70+948cdafaf",
4
4
  "description": "turf planepoint module",
5
5
  "author": "Turf Authors",
6
6
  "license": "MIT",
@@ -53,15 +53,20 @@
53
53
  "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts"
54
54
  },
55
55
  "devDependencies": {
56
+ "@types/benchmark": "^2.1.5",
57
+ "@types/tape": "^4.2.32",
56
58
  "benchmark": "^2.1.4",
57
59
  "npm-run-all": "^4.1.5",
58
60
  "tape": "^5.7.2",
59
61
  "tsup": "^8.0.1",
60
- "tsx": "^4.6.2"
62
+ "tsx": "^4.6.2",
63
+ "typescript": "^5.2.2"
61
64
  },
62
65
  "dependencies": {
63
- "@turf/helpers": "^7.0.0",
64
- "@turf/invariant": "^7.0.0"
66
+ "@turf/helpers": "^7.1.0-alpha.70+948cdafaf",
67
+ "@turf/invariant": "^7.1.0-alpha.70+948cdafaf",
68
+ "@types/geojson": "^7946.0.10",
69
+ "tslib": "^2.6.2"
65
70
  },
66
- "gitHead": "3d3a7917025fbabe191dbddbc89754b86f9c7739"
71
+ "gitHead": "948cdafaf70606d2e27fcc79973fa48ee1182067"
67
72
  }