Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8841993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:51:18+00:00 2026-06-14T10:51:18+00:00

Currently i have an iPhone app for which is basically a city guide. It

  • 0

Currently i have an iPhone app for which is basically a city guide. It shows the user different things around them and lists them in order of distance.

At the moment the data for the app is in an online MySQL database, a php script then converts different parts of this database, such as banks, into XML documents, so i have an XML document for banks, one for bars etc. Each XML document has its own URL.

My iPhone app then reads the XML document from the URL, parses the XML document, and then using CoreLocation calculates the distance between each location in the XML document and the user, then puts the data into TableViews sorted by distance, with closest first. (It may be worth noting that each piece of data (bar, bank etc) in the database has coordinates attached).

This is working fine and there are no problems when there is up to a few hundred locations to parse and calculate distances. However once you start getting into the thousands it starts to take a long time.

Basically i am wondering if anyone knows a method where rather than downloading all the data then calculating distances i could send the phones GPS location to the server/database or whatever and then it returns the closest 20 locations which i could then parse and display as before.

I know this is a BIG question im not looking for someone to help me create everything i just need to know a method on how this can be done. Or if anyone has done anything similar to this.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T10:51:20+00:00Added an answer on June 14, 2026 at 10:51 am

    You’ve pretty much defined the method for doing this right in your question. What you need is to pass the user’s coordinates into the web service. The web service or stored procedure should implement the logic to filter the results to only things nearby. If there is a specific part of that you need advice on, please clarify.

    You should really let the database engine do the heavy lifting here. In mySQL you’d use something like this:

    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
    

    Here is some AFNetworking code for a get request for JSON with parameters NOTE (This is a snippet of the most relevant code and will not execute stand-alone):

    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) {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a multi-target iPhone app which currently includes a header file with constant
I have a iphone app which is enable to receive push notifications. Currently i
I currently have an ordered JSON string being passed into my iPhone app, which
I'm currently developing an iPhone app and so far things have worked out smoothly.
I am currently writing a multi-user social iPhone app which interfaces with a server.
I currently have an iPhone app that lets the users take video, upload it
I have a small iPhone app which has a button on the first view.
I'm currently working on an iPhone app and I have a library from a
Ok guys I am developing an iPhone app I have a Model class which
We have an iTrading iPhone app where we allow people to trade on different

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.