找到最接近地理坐标的地块质量 [英] Find land mass nearest to a geo coordinate
问题描述
- 如果您的位置位于一个多边形中,那么它位于海上,通过遍历内部和外部边界上的点来找到最近的一个点, a href =https://en.wikipedia.org/wiki/Haversine_formula =nofollow noreferrer> Haversine Formula 。这将是陆地上最近的点。
- 如果您的位置不在多边形中,那么您已经在陆地上,请执行直接反向地理编码。
试想一下,这个世界有点像是从游戏外交委员会那里获得的。
现在将海域合并为更大的多边形与岛屿的孔。
如果你不在海上,你必须在土地上吗?
As part of a developer challenge, I am trying to determine the land mass closest to a given coordinate. Obviously, if the point is on land, I use reverse geocoding and can get details. The problem is that if the point is in a body of water, especially oceans, it often won't return anything (Google, Nokia, Bing). I'd like to know that a point 3 miles off the coast of California is 3 miles from USA, or x miles from Japan, y miles from South Korea when a point is reasonably near more than one country. Is there any service that provides this information?
- Take a KML file of the world's Maine Regions
- Simplify it down to a minimum number of rough polygons.
- Take your location, does it lie within one of the polygons?
- If your location lies with a polygon, then it is at sea, iterate though the points on the inner and outer boundary to find the nearest one using the Haversine Formula. This will be the nearest point on land.
- If your location does not lies with a polygon, you are already on land, do a direct reverse geocode.
Just imagine the world is a bit like the board from the game Diplomacy
Now coalesce the sea areas into larger polygons with holes for islands. If you're not at sea you must be on the land right?
这篇关于找到最接近地理坐标的地块质量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!