如何计算从“A”位置到“B”位置的路线
- 需要有位置“A”和“B”的纬度/经度
- 获取
GeodeticCalculator
类的实例
- 称呼
setStartingGeographicPoint()
- 称呼
setDestinationGeographicPoint()
- 称呼
getAzimuth()
- 从方位角转换为十进制度
如何从位置“A”开始计算航位推算位置“X”
- 需要有位置'A'的纬度/经度
- 需要在方位角上有船舶的当前航向
- 需要有以米为单位的行驶距离(或将其计算为速度 * 时间)
- 获取
GeodeticCalculator
类的实例
- 称呼
setStartingGeographicPoint()
- 称呼
setDirection()
- 称呼
getDestinationGeographicPoint()
以下是我需要自己实现的一些简单的单位转换方法。方位角有点混乱。方位角范围从 -180 到 +180,随着方向“角度”沿顺时针方向增加,该值增加。所以-180是南,-90是西,0是真北,+90是东,+180也是南。
public static final double KNOTS_PER_MPS = 1.9438444924406;
public static final double MPS_PER_KNOT = 0.514444444444444;
public static double metersPerSecondToKnots(double speedInMetersPerSecond) {
return speedInMetersPerSecond * KNOTS_PER_MPS;
}
public static double knotsToMetersPerSecond(double speedInKnots) {
return speedInKnots * MPS_PER_KNOT;
}
public static double courseInDegreesToAzimuth(double courseInDegrees) {
Validate.isTrue(courseInDegrees >= 0.0 && courseInDegrees <= 360.0);
double azimuth;
if (courseInDegrees > 180.0) {
azimuth = -180.0 + (courseInDegrees - 180.0);
} else {
azimuth = courseInDegrees;
}
return azimuth;
}
public static double azimuthToCourseInDegrees(double azimuth) {
Validate.isTrue(azimuth >= -180.0 && azimuth <= 180.0);
double courseInDegrees;
if (azimuth < 0.0) {
courseInDegrees = 360.0 + azimuth;
} else {
courseInDegrees = azimuth;
}
return courseInDegrees;
}