/ / Mongodb Geo Boundary - javascript, node.js, mongodb

Mongodb Geo Boundary - javascript, node.js, mongodb

Supposons que j'ai un polygone

[
[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]

]

Cela est enregistré dans mongodb databae.

Maintenant, mon objectif est de vérifier deux points ou plus à la fois, ceux qui se trouvent sous cette limite? Cela fonctionne bien pour la vérification ponctuelle.

Réponses:

0 pour la réponse № 1

essaye ça: point dans le polygone

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]