不清楚你所说的“不起作用”是什么意思,但是从我所看到的代码可以得出两个输入点sw和ne。然而,它将在两极和国际日期变更线附近断裂。
产生合理外观输出的简单测试程序:
public class LatLonBoundBox {
public static class MapCoord {
final double lat;
final double lon;
public MapCoord(double lat, double lon) {
this.lat=lat;
this.lon=lon;
}
@Override
public String toString() {
return "MapCoord [lat=" + lat + ", lon=" + lon + "]";
}
}
/**
* @param args
*/
public static void main(String[] args) {
double range = 1.0;
double inLat = 51.350801;
double inLong = -0.251850;
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);
System.out.println(min);
System.out.println(max);
}
}