Skip to main content
Version: 7.3.0

booleanPointOnLine

描述

🌐 Description

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

🌐 Returns true if a point is on a line. Accepts a optional parameter to ignore the start and end vertices of the linestring.

参数

🌐 Parameters

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

返回

🌐 Returns

boolean true/false

示例

🌐 Examples

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

安装

🌐 Installation

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

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

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