Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 如何在ObjCMongoDB中进行地理空间查询_Iphone_Objective C_Mongodb_Objcmongodb - Fatal编程技术网

Iphone 如何在ObjCMongoDB中进行地理空间查询

Iphone 如何在ObjCMongoDB中进行地理空间查询,iphone,objective-c,mongodb,objcmongodb,Iphone,Objective C,Mongodb,Objcmongodb,我试图在ObjCMongoDB中实现此查询: db.<collection>.find( { loc : { $near : { $geometry : { type : "Point" , coordinates : [ -121.9 , 37.5 ] } , $maxDistance : 10000 } } } ) MongoKeyedPredicate *pre

我试图在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);
    }