質問でこれを正しく行う方法をほぼ定義しました。必要なのは、ユーザーの座標を Web サービスに渡すことです。Web サービスまたはストアド プロシージャは、近くのものだけに結果をフィルター処理するロジックを実装する必要があります。アドバイスが必要な特定の部分がある場合は、明確にしてください。
ここでの面倒な作業は、データベース エンジンに任せるべきです。mySQL では、次のようなものを使用します。
SELECT ((ACOS(SIN($lat * PI() / 180) * SIN(lat * PI() / 180) +
COS($lat * PI() / 180) * COS(lat * PI() / 180) * COS(($lon - lon) *
PI() / 180)) * 180 / PI()) * 60 * 1.1515) AS distance
FROM members
HAVING distance<='10' ORDER BY distance ASC
パラメータを使用した JSON の get リクエストの AFNetworking コードを次に示します (これは最も関連性の高いコードのスニペットであり、スタンドアロンでは実行されません)。
NSString *latString = [NSString stringWithFormat:@"%f", lastLocation.coordinate.latitude];
NSString *lonString = [NSString stringWithFormat:@"%f", lastLocation.coordinate.longitude];
NSString *accString = [NSString stringWithFormat:@"%f", lastLocation.horizontalAccuracy];
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:[defaults valueForKeyPath:@"sessionRP"] , @"sessionRP", [defaults valueForKeyPath:@"partnerID"], @"pid", appointment.scheduleRowPointer, @"srp", latString, @"lat", lonString, @"long", status, @"stat", @"0", @"cached", accString, @"acc", nil];
NSMutableURLRequest *request = [httpClient requestWithMethod:@"GET" path:myPath parameters:params];
[request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {