Skip to content

描述 ​

接收作为多边形的三角形平面和该三角形内的点,返回该点的 z 值。

Polygon 应具有 a、b 和 c 属性,定义其三个角的值。或者,如果未提供属性,每个三角形点的 z 值可以通过其第 3 个坐标提供。

参数 ​

名称类型描述
pointCoord待计算 z 值的 Point
triangleFeature<Polygon>具有三个顶点的 Polygon 要素

返回值 ​

number interpolatedPoint 的 z 值

示例 ​

javascript
const point = turf.point([-75.3221, 39.529]);
// "a", "b", "c" 值按顺序表示坐标的值。
const triangle = turf.polygon(
  [
    [
      [-75.1221, 39.57],
      [-75.58, 39.18],
      [-75.97, 39.86],
      [-75.1221, 39.57],
    ],
  ],
  {
    a: 11,
    b: 122,
    c: 44,
  },
);

const zValue = turf.planepoint(point, triangle);
point.properties.zValue = zValue;

安装 ​

javascript
$ npm install @turf/planepoint

import { planepoint } from "@turf/planepoint";
const result = planepoint(...);
javascript
$ npm install @turf/turf

import * as turf from "@turf/turf";
const result = turf.planepoint(...);