I'm trying to implement this query in ObjCMongoDB:
db.<collection>.find( { loc :
{ $near :
{ $geometry :
{ type : "Point" ,
coordinates : [ -121.9 , 37.5 ] } ,
$maxDistance : 10000
} } } )
However, I'm not receiving any queries (when I should) . Not sure what I'm doing wrong. Here's my attempt:
MongoKeyedPredicate *predicate = [MongoKeyedPredicate predicate];
NSValue *value = [NSValue valueWithCGPoint:CGPointMake(-121.9, 37.5)];
CGPoint point = [value CGPointValue];
CGFloat maxDistance = 10000;
[predicate keyPath:@"loc" isNearPoint:point maxDistance:maxDistance];
NSArray *results = [collection findWithPredicate:predicate error:&error];
for (BSONDocument *resultDoc in results) {
NSDictionary *result = [BSONDecoder decodeDictionaryWithDocument:resultDoc];
NSLog(@"fetch result: %@", result);
}