Anda harus menyimpan data lokasi Anda seperti skema ini:
{"loc":
{"coordinates":[
[
[1.0,1.0],
[1.0,10.0],
[10.0,10.0],
[10.0,1.0],
[1.0,1.0]
]
],
"type":"Polygon"
}
}
lalu kirim $geoIntersects
pertanyaan
db.polygons.find({"loc":{"$geoIntersects":{"$geometry":{"type":"Point", "coordinates":[x, y]}}}}