假设我有一个多边形
[
[22.592477,88.395223],
[22.580589,88.401060],
[22.562281,88.408098],
[22.558001,88.411703],
[22.576389,88.422689],
[22.585107,88.435821],
[22.600955,88.424577],
[22.602936,88.413333],
[22.592477,88.395223]
]
保存在mongodb databae。
现在我的目标是一次检查两个或更多点,是那个边界下的点吗?它适用于单点检查。
答案 0 :(得分:0)
const inside = require('point-in-polygon')
const polygon = [
[22.592477, 88.395223],
[22.580589, 88.401060],
[22.562281, 88.408098],
[22.558001, 88.411703],
[22.576389, 88.422689],
[22.585107, 88.435821],
[22.600955, 88.424577],
[22.602936, 88.413333],
[22.592477, 88.395223]
]
const pointOne = [ 22.562281, 88.408098 ]
const pointTwo = [ 4.9, 1.2 ]
console.dir([
inside(pointOne, polygon),
inside(pointTwo, polygon)
]) // output: [true, false]