1. 已知圆心的经纬度和半径,如何求圆周上任意一点的经纬度?
分析:
设 地球的半径为 r_earth, r_lat, 圆的经纬度分别为: longitude, latitude; 圆的半径为 r, 我们可以算出和圆心处于同一纬度上的坐标;其实我们只要算出经度差 degree 就可以了;
1) 圆心同一纬度所在的半径 为 r_lat = Cos (latitude) * r_earth;
2) 可以将半径 r 约等于 看做一个弧度,即地球上圆周上的一小段;得到以下等式:
r / (2 PI * r_lat) = radius / 2 PI
radius = r / r_lat;
将radius 换成 degree, degree = 180* r / PI * r_lat;
即: degree = 180 * Cos (latitude) * r / r_earth * PI
private static LatLng toRadiusLatLng(LatLng center, double radius) {
double radiusAngle = Math.toDegrees(radius / RADIUS_OF_EARTH_METERS)
/ Math.cos(Math.toRadians(center.latitude));
return new LatLng(center.latitude, center.longitude + radiusAngle);
}
2. 根据地球上任意两点的经纬度计算两点间的距离?
private static double toRadiusMeters(LatLng center, LatLng radius) {
float[] result = new float[1];
Location.distanceBetween(center.latitude, center.longitude, radius.latitude, radius.longitude, result);
return result[0];
}
3. 在地图上画轨迹图时,怎么计算代表车辆的 “图标” 的角度?
待续...