harshalb
harshalb

Reputation: 6054

find nearest places in iPhone

Hello all iPhone developers,

I am developing an iPhone application.

In this application i want to find nearest places related to current CLLocation that I am getting from the iPhone device.

I have currently a database in different server .

I am accessing it via .NET web service.

In the database for testing purpose i have created some records with fields of latitude and longitude that I have taken from google maps.

Now ,My Question is that:

How can I determine that the location in the database is near by( within a range of kelometers) the current location ?

I have my options as below:

Upvotes: 0

Views: 1561

Answers (1)

npdoty
npdoty

Reputation: 4757

It's true, there are a lot of reverse geocoding services out there (Google, Yahoo!, GeoNames, etc.) to convert from a lat/lon pair to a street address.

But if you have lat/lon pairs in your database already, then I don't think you ever need to convert to a street address. Calculating distances is much easier if all your points are represented by lat/lon, you can use the Haversine formula.

And in fact, if your database natively supports spatial types (for example, MS SQL 2008 appears to), then you can push that calculation into the database layer and not have to worry about it. That seems like the right approach to me: have your iPhone app send lat/lon to your web service and have the database calculate the nearest points-of-interest.

Upvotes: 3

Related Questions