I'm trying to create a method that given a latitude and longitude and range (in miles or km) returns the NE and SW corners of a bounding box?
I had a function that I found somewhere but after some testing it doesn't seem to work( see below):
double latrange=range/69.172;
double longrange=Math.abs(range/(Math.cos(inLat) *69.172));
double minlat=inLat-latrange;
double maxlat=inLat+latrange;
double minlon=inLong-longrange;
double maxlon=inLong+longrange;
MapCoord min = new MapCoord(minlat,minlon);
MapCoord max = new MapCoord(maxlat,maxlon);
MapCoord [] rs = new MapCoord[2];
rs[0] = min;
rs[1] = max;
return rs;