zoukankan      html  css  js  c++  java
  • 百度经纬度和google经纬度互转

    百度地图的坐标转换,由于百度地图在GCJ02协议的基础上又做了一次处理,变为 BD09协议的坐标,以下是坐标的转化方式,可以方便和其他平台转化

    27     private const double x_pi = 3.14159265358979324 * 3000.0 / 180.0;

    /// <summary>

    /// 中国正常坐标系GCJ02协议的坐标,转到 百度地图对应的 BD09 协议坐标

    /// </summary>

    /// <param name="lat">维度</param>

    /// <param name="lng">经度</param>

    public static void Convert_GCJ02_To_BD09(ref double lat,ref double lng)

    {

    double x = lng, y = lat;

    double z =Math.Sqrt(x * x + y * y) + 0.00002 * Math.Sin(y * x_pi);

    double theta = Math.Atan2(y, x) + 0.000003 * Math.Cos(x * x_pi);

    lng = z * Math.Cos(theta) + 0.0065;

    lat = z * Math.Sin(theta) + 0.006;

    }

    /// <summary>

    /// 百度地图对应的 BD09 协议坐标,转到 中国正常坐标系GCJ02协议的坐标

    /// </summary>

    /// <param name="lat">维度</param>

    /// <param name="lng">经度</param>

    public static void Convert_BD09_To_GCJ02(ref double lat, ref double lng)

    {

    double x = lng - 0.0065, y = lat - 0.006;

    double z = Math.Sqrt(x * x + y * y) - 0.00002 * Math.Sin(y * x_pi);

    double theta = Math.Atan2(y, x) - 0.000003 * Math.Cos(x * x_pi);

    lng = z * Math.Cos(theta);

    lat = z * Math.Sin(theta);

    }

  • 相关阅读:
    你知道require是什么吗?
    jQuery类库的设计
    多线程下载图片
    多线程与CPU和多线程与GIL
    一个python小爬虫
    一个方格表的问题
    使用django发布带图片的网页(上)
    uWSGI+Django+nginx(下)
    uWSGI+Django (中)
    Linux下安装Python3的django并配置mysql作为django默认数据库(转载)
  • 原文地址:https://www.cnblogs.com/wyBlog117/p/5308147.html
Copyright © 2011-2022 走看看