Skip to content

描述 ​

如果点在线上则返回 true。接受可选参数以忽略线段的起点和终点顶点。

参数 ​

名称类型描述
ptCoordGeoJSON Point
lineFeature<LineString>GeoJSON LineString
options?Object可选参数 (默认 {})
options.ignoreEndVertices?boolean是否忽略起点和终点顶点。(默认 false)
options.epsilon?number用于与叉积结果比较的小数。适用于处理浮点数坐标(如经纬度)

返回值 ​

boolean true/false

示例 ​

javascript
var pt = turf.point([0, 0]);
var line = turf.lineString([
  [-1, -1],
  [1, 1],
  [1.5, 2.2],
]);
var isPointOnLine = turf.booleanPointOnLine(pt, line);
//=true

安装 ​

javascript
$ npm install @turf/boolean-point-on-line

import { booleanPointOnLine } from "@turf/boolean-point-on-line";
const result = booleanPointOnLine(...);
javascript
$ npm install @turf/turf

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