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 6161527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:29:44+00:00 2026-05-23T21:29:44+00:00

I am writing an application which has ca. 7000 european restaurants in the database

  • 0

I am writing an application which has ca. 7000 european restaurants in the database and I want to show a list of the nearest ones to the user, for example all of them which are in a radius of 5km to the user.

I could do the search on the server but it then requires internet. Is it possible to save the data on the iPhone and query the database? I can’t find any references for something like that in core data or iPhones SQLite.

Do I really need to program it myself with Pythagoras and stuff and calculate the distance to every restaurant on every query? Or is there some other way?

[update] I’d like to use it like I do already on the server (but to do it on the iPhone): SELECT * FROM restaurants WHERE ST_Distance_Sphere(geo, ST_GeomFromText(POINT(55.98767 57.12345), -1)) < 5000

I want the user to be able to find a restaurant even if she has no internet connection, for example when you’re in a foreign country.

  • 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-05-23T21:29:45+00:00Added an answer on May 23, 2026 at 9:29 pm

    Read up on latitude and longitude calculations. Latitude an longitude are themselves distances expressed as arcs upon a spherical surface. If you have a database of locations expressed by latitude and longitude, then you can perform a fetch to find only those records that fall within a few degrees latitude north and south and a few degrees longitude east and west of the users current location.

    So you would end up with a predicate that would be something like (psuedo-code):

    latitude >= (currentLatitude-aFewMinutesOfArc)
    AND
    latitude <= (currentLatitude+aFewMinutesOfArc)
    AND
    longitude >= (currentLongitude-aFewMinutesOfArc)
    AND
    longitude >= (currentLongitude+aFewMinutesOfArc)
    

    … this would create a logical box which would return all restaurant records that fell within the box. Then if you needed to calculate the exact distances you would only have to perform calculation on a handful of records out of the 7,000 you have.

    I would recommend reading up on Location Services because it provides a lot of tools for handling location calculations.

    As to whether to use plain SQL or Core Data, check out this previous answer on the subject. In brief, if you already know the C SQL api and your data is simple, large and static, then SQL is a good choice. If you can take time to learn Core Data and your data is complex and dynamic, then Core Data is the better choice regardless of the size of the data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a WPF application which has a main canvas area, where the user
I am writing an application which has an authenticity mechanism, using HMAC-sha1, plus a
I am writing a server application which has a large amount of source code.
I'm writing an application which will involve interaction with the database. The application will
I'm writing an application which has two classes that provide basically the same functionality
I'm writing a java application which has to communicate with has to communicate with
I'm writing a MATLAB application which has many functions spread over different files. I
I'm trying to learn how to design an application which has several different user
We are currently writing an application which is split into multiple projects/modules. For example,
Abstract I am writing an application which has a few object caches. The way

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.