BoundingBox around a geo coordinate

烂漫一生 提交于 2019-12-24 01:28:01

问题


I am currently playing a bit with Android and GPS tracking and so forth.

I found out, that I have to call the OSM API with the corner points of the bounding I want to get POIs for example. I would like to achieve, that I get my current cooredinates from the handset (which allready works) and then get some pois from OSM for the bounding box where my current position is the center.

I could imagine a function like that:

public Map getBoundingBox(Double long, Double lat, int meters);

BUT I do not have any idea how to calculate this bounding box. Could someone give me some hints please?

cheers, christian


回答1:


I assume that long and lat are given in seconds.

First, you need to calculate width of the rectangle in seconds. One second is 30.9 meters on the equator, for other latitudes, multiply by cos(lat), so to convert it to seconds you do the following:

double widthSeconds = meters / (30.9 * cos(lat));

Second, knowing the center of the box, it's easy to calculate the coordinates of corners:


EDIT: the example above works for Europe and Asia. For other locations, directions of coordinate axes may be different.



来源:https://stackoverflow.com/questions/17955800/boundingbox-around-a-geo-coordinate

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