Reputation: 4688
I want to find the intersection points of two Locations in Android.
I don't want to consider cases where the circles as shown in the Figure don't intersect or are included or are completely overlapping.
My problem is that the Location is given in degree and the radius (accuracy) is given in meter. I do not know how to mix those Units.
In my case the environment is Android, but the Problem is not Android specific.
Upvotes: 7
Views: 2148
Reputation: 28727
You have to convert latitdue, longitude to a cartesian coordinate system, with unit meters.
This is done using a Cyclindrical equidistant projection with center latitude = (latitudeCircle1 + latCircle2) / 2.0.
(same for center longitude)
(http://mathworld.wolfram.com/CylindricalEquidistantProjection.html)
In the link above to get a meter based system you have yet to multiply with the constant "meterPerDegreeAtEquator" which is 40000000 / 360.0
Now you have coordinates x,y as you had in school.
Then you calculate the circle intersection points as learned in school, or as found somewhere on the web. E.g here: https://math.stackexchange.com/questions/256100/how-can-i-find-the-points-at-which-two-circles-intersect
Then you convert the cartesian intersection points back to lat, lon using the inverse projection.
This works for a distance between the two circles not more than 10-100km.
Note: Below common error, which I saw in the discussion with your sample code: Please note that x is related to longitude, and y to latitude. Although we say lat/long. In such transformation formulas you should use long,lat order in paramter names etc. See also Lat Long or Long Lat
Upvotes: 4