1

我正在尝试在 ObjCMongoDB 中实现此查询:

db.<collection>.find( { loc : 
    { $near : 
        { $geometry : 
            { type : "Point" , 
            coordinates : [ -121.9 , 37.5 ] } , 
            $maxDistance : 10000 
} } } )

但是,我没有收到任何查询(我应该什么时候)。不知道我做错了什么。这是我的尝试:

    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);
    }
4

0 回答 0