## 地图坐标转换 -- 火星坐标与GPS坐标

（1）可视化 GPS 路径

（2） 坐标格式

1.） ddd.ddddd， 度 . 度的十进制小数部分（5位）例如：31.12035º
2.） ddd.mm.mmm，度 . 分 . 分的十进制小数部分（3位）例如 31º10.335'
3.)   ddd.mm.ss, 度 . 分 . 秒 例如 31º12'42"

public Point(double longitude, double latitude )
{
int degree = (int)(longitude);
this.longitude = (longitude - degree) * 100 / 60 + degree;

degree = (int)(latitude);
this.latitude = (latitude - degree) *100 / 60 + degree;

}

（3）坐标纠偏

convertor.translate(pointArr, 3, 5, translateCallback)

        public static Point Baidu2Mars(Point a)
{
Point b = new Point();
double x = a.longitude - 0.0065;
double y= a.latitude - 0.006;

double z = Math.Sqrt(x * x + y * y) - 0.00002 * Math.Sin(y * Math.PI / 180);
double theta = Math.Atan2(y, x) - 0.000003 * Math.Cos(x * Math.PI / 180);

b.longitude = z * Math.Cos(theta);
b.latitude = z * Math.Sin(theta);
return b;
}

public static Point Mars2Baidu(Point a){
Point b = new Point();
double x = a.longitude;
double y= a.latitude;

double z = Math.Sqrt(x * x + y * y) + 0.00002 * Math.Sin(y * Math.PI / 180);
double theta = Math.Atan2(y, x) + 0.000003 * Math.Cos(x * Math.PI / 180);

b.longitude = z * Math.Cos(theta) + 0.0065;
b.latitude = z * Math.Sin(theta) + 0.006;
return b;
}

        public static double Degree2Radian(double degree)
{
double radian = degree * Math.PI / 180;
}

//http://www.movable-type.co.uk/scripts/latlong.html
public static double Distance(Point a, Point b)
{
double R = 6371000;

double deltaPhi = Degree2Radian(a.latitude - b.latitude);
double deltaLam = Degree2Radian(a.longitude - b.longitude);

double aa = Math.Sin(deltaPhi / 2) * Math.Sin(deltaPhi / 2) + Math.Cos(phi1) * Math.Cos(phi2) * Math.Sin(deltaLam / 2) * Math.Sin(deltaLam / 2);

double c = 2 * Math.Atan2(Math.Sqrt(aa), Math.Sqrt(1 - aa));

double d = R * c;

return d;
}

posted on 2016-03-31 20:04  leavingseason  阅读(44725)  评论(4编辑  收藏  举报

Bye!