views:

264

answers:

1

If i want to divide world in four quadrants and make regions in these quadrants and wanna find the distance from my location to a point in the region I am standing, how is it possible in iPhone using objective c? Or any other solution possible

+1  A: 

if you some how calculate the Latitude and Longitude of these 2 points then you can find the distance between two points using Harvesian Method.

**Haversine formula:

R = earth’s radius (mean radius = 6,371km)
Δlat = lat2− lat1
Δlong = long2− long1
a = sin²(Δlat/2) + cos(lat1).cos(lat2).sin²(Δlong/2)
c = 2.atan2(√a, √(1−a))
d = R.c**
S M Kamran
angles need to be in radians
S M Kamran
But its a tedious search in the database of a big area. I want to divide large area in small regions so search is optimal
Hab, is that the reason your'e dividing it into four quadrants? What if the other point is outside of your current quadrant?
Jon Limjap
Suppose i am on the edge of one region, will implement a condition for this purpose to search in my adjacent region till say within 10 miles
You can find the Latitude and Longitude points for intersections points of imaginary axis this way you can divide the sphere in four quadrants...
S M Kamran
then also keep track of the center point for each quadrant... After that given two points you only need to calculate the radius from the center of that quadrant for two points and just add these to find the distance.
S M Kamran
However, your calculation need to look after the direction as well since you are treating a sphere as a flat surface
S M Kamran