我有一个2D数组
int[][] data = new int[720][720];
dataReader.read(data);
数据中的每个插槽都包含该特定坐标的值。时隙的位置(例如数据[5] [5]用于获得纬度/经度)。
我尝试通过执行以下操作来获取位置:
我有以下信息:
LL_lat = 28.33346126086149 // lower-left lat
LL_lon = 30.757889519059812 // lower-left lon
LR_lat = 28.633821527352005 // lower-right lat
LR_lon = 39.242110331928565 // lower-right lon
UL_lat = 35.52560518009779 // upper-left lat
UL_lon = 30.757889519059812 // upper-left lon
UR_lat = 35.52560518009781 // upper-right lat
UR_lon = 39.242110331928565 // upper-right lon
projdef = +proj=merc +a=6371000 +lat_0=0 +lon_0=0
xscale = 1111.1099999999517 // Size in meters for X for each cell in the array
xsize = 720 // array size X
yscale = 1088.97060116836 // size in meters for Y for each cell in the array
ysize = 720 // array size Y
我有这两个功能:
public static double calculateLatitude(double distance, double startPointLat) {
return startPointLat + (distance * (360 / ((Math.PI * 2) * 6357)));
}
public static double calculateLongitude(double distance, double lat, double startPointLon) {
return startPointLon + distance * 360 / (Math.PI * 2 * 6400 * Math.sin(Math.toRadians(90 - lat)));
}
我基本上通过cellX * xscale
计算距离并将其与起点lat一起传递给纬度函数,我选择了4点中的任何点(表示正方形区域)< /强>
但是坐标非常不正确,可能会误算一些东西?
有更好的计算方法或错误吗?
数组和计算:
for (int i = 0; i < arrayData.length; i++) {
for (int j = 0; j < arrayData[0].length; j++) {
int val = arrayData[i][j];
double distX = i * xscale;
double distY = j * yscale;
double lat = RadarPhysics.calculateLatitude(distX, startPointLat);
double lon = RadarPhysics.calculateLongitude(distY, lat, startPointLat);
GeoLocation loc = new GeoLocation(lat, lon);
System.out.println(loc.toString());
}
}