0

I am working on iphone application where i need to find the points between 2 latitude and longitude

I had used:-

CLLocation* newlocation = [[CLLocation alloc] initWithLatitude:19.0759837 longitude:72.8776559];
 CLLocation* oldLocation = [[CLLocation alloc] initWithLatitude:19.075655999999999 longitude:72.87979];
            float kilo1=[newlocation getDistanceFrom:oldLocation]/1000;    

            CLLocationDistance distance = [newlocation distanceFromLocation:oldLocation];

And Checked the googleulr:- url

The distance from getDistanceFrom and distanceFromLocation function are:0.227512KM But in webservice it is showing the distance:0.300000

As there is alot of diference between this two result can any one suggest me which one is to be followed? According to me the result of webservice is right. But i cant use the webservice for finding the distance of 100points.As it is not feasible, Can anyone help me how do i get correct value

Thanks in advance

ios developer
  • 3,363
  • 3
  • 51
  • 111

2 Answers2

2

You are getting air distance using iPhone GPS(getDistanceFrom) and Driving distance using web service(URL provided by you).So Both are accurate but distance type are different.

Dhaval Panchal
  • 2,529
  • 1
  • 25
  • 36
  • Thanks for the reply.I was trying to find out that thing only that y it is showing two different distance..I accepted ur answer – ios developer Jul 07 '12 at 07:50
0

CLLocation gives the correct and accurate results as it is used by other applications of iPhone and you can see the results of it in your navigation app of iPhone which gives your accurate location. While web service can give false results or near by location's detail.

Sanchit Paurush
  • 6,114
  • 17
  • 68
  • 107
  • Thanks for the quick reply.But i am able to find the reason is CLOCATION is showing some faulty result.As the apple maps are not supporting turn by turn navigation.(It is supported in IOS6).So native funtion is calculating the stright distance between two points while google webservice is showingthe distance in turn byturn navigation so it is showing proper. – ios developer Jul 04 '12 at 11:28
  • 1
    Well in that case you have to use google maps api for it. But it doesn't provides the accuracy. – Sanchit Paurush Jul 04 '12 at 12:11
  • I do hav e some latitude and longitude which shows the distance 0.006894 while in realtime the distance between this points are nearly 3KM – ios developer Jul 06 '12 at 05:50
  • @shweta Ok thats great. If you know everything then go with your idea. – Sanchit Paurush Jul 06 '12 at 06:00