Objective-csearch具有半径的位置

是否有一个库为Objective-C,将允许我指定半径和位置,以及位置列表,并告诉我哪些位置在该半径内? 谢谢。

如果你有CLLocations那么类似这样的工作:

// Given NSArray *locations as an array of CLLocation* that you wish to filter // and given a radius... CLLocationDistance radius = kSomeRadius; // and given a target you want to test against... CLLocation* target = [[CLLocation alloc] initWithLatitude:someLat longitude:someLon]; NSArray *locationsWithinRadius = [locations objectsAtIndexes: [locations indexesOfObjectsPassingTest: ^BOOL(id obj, NSUInteger idx, BOOL *stop) { return [(CLLocation*)obj distanceFromLocation:target] < radius; }]]; [target release]; 

当然还有其他的方法可以做到这一点。 这只是一个方法。

希望有所帮助。