Link to home
Create AccountLog in
Avatar of fsyed
fsyed

asked on

Need help doing a search via postal/zip code, and address using Objective-C, and SQLite

Dear fellow iPhone developers:

I am trying to develop an iPhone app that will show the user, the closest specialty restaurants to where they are using Objective-C I want my app to mirror the following app:

www.timmyme.com

which shows the user the closest "Tim Horton's" coffee shop to him/her.  One option it offers, is that it allows the user to do a search by postal/zip code to find the closest locations to that particular postal/zip code.  How is this implemented?  I will be having a sqlite database table that will have the following columns:

-name
-street address
-city
-province/state
-postal/zip code
-phone number
-country
-latitude
-longitude

How can one implement a search via postal/zip code using a sqlite database, and also, how can one implement a search by address?  I am using a navigation based application, and would also like to know how to trigger this search by clicking on a button.  Where would the button code be placed?

Thanks again for your time, and patience.
SOLUTION
Avatar of F. Dominicus
F. Dominicus
Flag of Germany image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of fsyed
fsyed

ASKER

Thanks for reply.  My problem is not so much with setting up the database in SQLite.  Here are the specifics of the issue:

1.  A table to have my locations, as well as their corresponding lat/lon co-ordinates.
2.  Another table to hold all postal/zip codes, and their corresponding lat/lon co-ordinates.
 
So when a user submits a postal/zip code, the first thing the app should do is check against table 2 and retrieve the corresponding lat/lon co-ordinates, and then calculate the distances between it, and the ones in the first table.  Am I correct so far?
 
If I am correct, then I have two follow up questions:
 
1.  Wouldn't table 2 be quite large?  Especially if it is to hold ALL postal/zip codes, and their respective co-ordinates since the user can be anywhere.  Is this something that would hinder performance?  Just wondering.
 
2.  After finding the relevant lat/lon co-ordinates for the user's postal/zip code, is there a way that I can retrieve only those postal/zip codes that are "relevant" or near the users given location instead of calculating the distance between the user, and ALL locations in the first table?  I am asking this because it seems that this could be an issue on performance, considering that the first table may have thousands of locations, and to calculate all the distances between the pairs of co-ordinates, and THEN retrieve only those close to the user, seems like overkill.  Is there a better, more efficient way of doing this?

Thanks again for your help.
ASKER CERTIFIED SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of fsyed

ASKER

Thanks for that last post, I had never thought of that as a possibility, but I can see how that approach would definitely work!

Thanks for your time, and patience!