美文网首页
百度坐标转高德章

百度坐标转高德章

作者: zzchsppy | 来源:发表于2016-05-06 16:28 被阅读34次

    +(CLLocationCoordinate2D) GCJ02ToBd09:(CLLocationCoordinate2D) gcj{

    const double x_pi = 3.14159265358979324 * 3000.0 / 180.0;

    double x = gcj.longitude, y = gcj.latitude;

    double z = sqrt(x * x + y * y) + 0.00002 * sin(y * x_pi);

    double theta = atan2(y, x) + 0.000003 * cos(x * x_pi);

    double lon = z * cos(theta) + 0.0065;

    double lat = z * sin(theta) + 0.006;

    return CLLocationCoordinate2DMake(lat, lon);

    }

    +(CLLocationCoordinate2D) Bd09ToGCJ02:(CLLocationCoordinate2D )bd

    {

    const

    double x_pi = 3.14159265358979324 * 3000.0 / 180.0;

    double x = bd.longitude - 0.0065, y = bd.latitude - 0.006;

    double z = sqrt(x * x + y * y) - 0.00002 * sin(y * x_pi);

    double theta = atan2(y, x) - 0.000003 * cos(x * x_pi);

    CLLocationCoordinate2D reslt = CLLocationCoordinate2DMake(z * sin(theta), z * cos(theta));

    return reslt;

    }

    相关文章

      网友评论

          本文标题:百度坐标转高德章

          本文链接:https://www.haomeiwen.com/subject/yssjrttx.html