将距离(海里)转换为度数(纬度/长度)

时间:2013-02-06 06:29:53

标签: java geolocation google-earth degrees openmap

我在模拟中有实体,其初始位置和路径是使用十进制度的Java的代码。我需要缩放传感器半径(以海里为单位)和速度(海里/小时)以匹配十进制度数。目的是在OpenMap和Google Earth中可视化SIM。

我见过How to convert Distance(miles) to degrees?,但那里的建议不起作用。

任何帮助表示赞赏!我认为它将涉及使用大圆距离公式......但不能完全得到它。

1 个答案:

答案 0 :(得分:1)

艾德威廉姆斯'航空公式http://williams.best.vwh.net/avform.htm是一个很好的,可以访问的地方。我经常提到http://movable-type.co.uk/scripts/latlong.html

我猜你需要某种矢量(你的问题有点不清楚)。

我使用(在C而不是Java中)来计算固定径向距离是:

void polarToLatLong(double lat, double lon, double dist, double radial,
   double *outlat, double *outlon) {
   if (!dist) { // distance zero, so just return the point
      *outlat = lat;
      *outlon = lon;
   }
   else if (lat > 89.9999) { // North Pole singularity. Dist is in NM.
      *outlat = 90 - dist / 60;
      *outlon = fmod(radial + 180) - 180;
   }
   else { // normal case
      double sinlat, coslon;
      dist /= 3442; // = Earth's radius in nm (not WGS84!)
      sinlat = Sin(lat) * cos(dist) + Cos(lat) * sin(dist) * Cos(radial);
      *outlat = Arcsin(sinlat);
      coslon = (cos(dist) - Sin(lat) * sinlat) / (Cos(lat) * Cos(*outlat));
      *outlon = lon + (Sin(radial) >= 0 : -1 : 1) * Arccos(coslon);
   }
}

在上面的代码Sin()中,大写字母S只是sin()度的包装器:

#define CLAMP(a,x,b) MIN(MAX(a, x), b) // GTK+ GLib version slightly different
double Sin(double deg)   {return sin(deg * (PI / 180));} // wrappers for degrees
double Cos(double deg)   {return cos(deg * (PI / 180));}
double Arcsin(double x)  {return asin(CLAMP(-1, x, 1)) * (180 / PI);}
double Arccos(double x)  {return acos(CLAMP(-1, x, 1)) * (180 / PI);}
相关问题