I am using $geoWithin
for circle, and i am not getting expected result. There are two collections,one for users
and second for items
. I am setting radius and coordinates for item. so i have to find a users within that coordinates and radius.
User collection
{
"_id" : NumberLong(25287),
"_class" : "com.samepinch.domain.user.User",
"name":"XYZ",
"location" : [
74.866247,
31.63336
]
}
Item collection
{
"_id" : NumberLong(46603),
"itemName" : "Chandigarh",
"categoryName" : "TRAVELLING",
"location" : {
"_id" : null,
"longitude" : 77.15319738236303,
"latitude" : 28.434568229025803,
"radius" : 29153.88048637637
}
}
as according to item coordinates and user coordinates,there is approx 500 km distance between two places.
Query
db.users.find({ location: { $geoWithin: { $center: [ [77.15319738236303,28.434568229025803], 29153.88048637637/3963.2] } } } ).count()
According to $geoWithin,user should not show,but it is showing. If i am doing something wrong,please help me.
Thanks
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…