Skip to main content
Version: 7.2.0

midpoint

描述

¥Description

获取两个点并返回它们中间的一个点。中点采用测地线法计算,这意味着要考虑地球的曲率。

¥Takes two points and returns a point midway between them. The midpoint is calculated geodesically, meaning the curvature of the earth is taken into account.

参数

¥Parameters

名称类型描述
point1坐标系第一个点
point2坐标系第二个点

返回

¥Returns

特性<> pt1pt2 中间的点

¥Feature<Point> a point midway between pt1 and pt2

示例

¥Examples

const point1 = turf.point([144.834823, -37.771257]);
const point2 = turf.point([145.14244, -37.830937]);

const midpoint = turf.midpoint(point1, point2);

安装

¥Installation

$ npm install @turf/midpoint

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

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