Geospatioal Query Operators
https://www.mongodb.com/docs/manual/reference/operator/query-geospatial/
GeoIntersects
Pada dokumen mongo :
{
<location field>: {
$geoIntersects: {
$geometry: {
type: "<GeoJSON object type>" ,
coordinates: [ <coordinates> ]
}
}
}
}
Query mongosh :
db.lokasi.find(
{
batas: {
$geoIntersects: {
$geometry: {
type: "Point" ,
coordinates: [ 107.57569081895566, -6.8735086203166285 ]
}
}
}
}
)
Implementasi Golang :
filter := bson.M{
"batas": bson.M{
"$geoIntersects": bson.M{
"$geometry": bson.M{
"type": "Point",
"coordinates": []float64{long, lat},
},
},
},
}