我正在创建Android应用程序,需要在位图上绘制折线。我得到了像
这样的坐标 X: Y:
57.567177, 25.383375
57.567391, 25.384218
57.568717, 25.382321
57.568159, 25.382033
然后我需要将它们转换为像素坐标。到目前为止,我所做的就是使用此代码在px的两点之间转换长度
public double KoordToMeters(double lat1, double lon1, double lat2, double lon2){ // generally used geo measurement function
double R = 6378.137; // Radius of earth in KM
double dLat = lat2 * Math.PI / 180 - lat1 * Math.PI / 180;
double dLon = lon2 * Math.PI / 180 - lon1 * Math.PI / 180;
double a = Math.sin(dLat/2) * Math.sin(dLat/2) +
Math.cos(lat1 * Math.PI / 180) * Math.cos(lat2 * Math.PI / 180) *
Math.sin(dLon/2) * Math.sin(dLon/2);
double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
double d = R * c;
return d * 1000; // meters
}
public double MeterstoPx(double Meters, int scale){ //Scale 10000
double Px;
Meters = Meters / scale;
Px = Meters / 0.0002645833; //Got this number as 1m=0.0002645833px
return Px;
}
我不确定是否需要获取像素坐标。我使用的是10000,这就是为什么我要进行Meters = Meters / scale;