Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 05-30-2009, 05:46 PM   #1 (permalink)
New Member
 
Join Date: May 2009
Location: St. Louis, MO
Posts: 17
Newbie09 is on a distinguished road
Question Mileage between 2 zipcodes / cities

Hello,
I'm new to iPhone dev and Obj C. I am looking for a way to find the distance between 2 cities/zips. Calculating the distance based on Longitude/Latitude does not seem right. Is there any other MAP API that is available in Iphone SDK?

I do not want to display MapView in my App. I just need to find the distance

Thanks
Newbie09 is offline   Reply With Quote
Old 05-30-2009, 06:06 PM   #2 (permalink)
Registered Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
smasher will become famous soon enough
Default

Quote:
Originally Posted by Newbie09 View Post
Hello,
I'm new to iPhone dev and Obj C. I am looking for a way to find the distance between 2 cities/zips. Calculating the distance based on Longitude/Latitude does not seem right. Is there any other MAP API that is available in Iphone SDK?

I do not want to display MapView in my App. I just need to find the distance

Thanks
There is nothing in the SDK to convert a city or a zip to latitude/longitude, or to calculate distance between cities, zips, or locations.

You'll need your own database of cities or zip codes (eitehr online or stored in the app) to turn a city/zip into a lat/long. To get the distance between two nearby locations, you'll have to convert from lat/long to miles and then use the Pythagorean theorem - sqrt(dx*dx + dy*dy). You must convert to miles or km before you get the distance, because the number of miles in a degree differs based on location.

For points that are far apart (for example, LA to New York) you'll need to figure the great circle distance to account for the curve of the earth.
__________________

Free Games!
smasher is offline   Reply With Quote
Old 05-30-2009, 06:20 PM   #3 (permalink)
New Member
 
Join Date: May 2009
Location: St. Louis, MO
Posts: 17
Newbie09 is on a distinguished road
Angry

Quote:
Originally Posted by smasher View Post
There is nothing in the SDK to convert a city or a zip to latitude/longitude, or to calculate distance between cities, zips, or locations.

You'll need your own database of cities or zip codes (eitehr online or stored in the app) to turn a city/zip into a lat/long. To get the distance between two nearby locations, you'll have to convert from lat/long to miles and then use the Pythagorean theorem - sqrt(dx*dx + dy*dy). You must convert to miles or km before you get the distance, because the number of miles in a degree differs based on location.

For points that are far apart (for example, LA to New York) you'll need to figure the great circle distance to account for the curve of the earth.
Thanks Smasher. Why would Apple expect the developers to have their own database that has this information. If there are 10 apps in an iPhone that needs to calculate distance between 2 places, there will be 9 redundant instances of this DB (which is like 500k). I found this link interesting. This has information about how to obtain the DB

Perseverance Trumps Talent / Calculate the distance between two U.S. zip codes
Newbie09 is offline   Reply With Quote
Old 05-30-2009, 10:34 PM   #4 (permalink)
Registered Member
 
Join Date: Apr 2009
Posts: 103
WeatherMan is on a distinguished road
Default

I doubt very many apps on the app store needs zip to Long/Lat.

Also, they change quarterly (new zips, etc) so Apple would have to send down updates to every iphone.

500K is not that much.
WeatherMan is offline   Reply With Quote
Reply

Bookmarks

Tags
map, maps

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 344
5 members and 339 guests
givensur, ipodphone, jbro, mer10, yomo710
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,113
Posts: 402,881
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:10 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0