Find intersection of two Locations

被刻印的时光 ゝ 提交于 2019-12-08 17:41:51

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/31250558/find-intersection-of-two-locations

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!