2

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

Christian Rockrohr
  • 1,045
  • 1
  • 14
  • 29

1 Answers1

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:

enter image description here


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

Andrii Chernenko
  • 9,873
  • 7
  • 71
  • 89