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

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

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    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);
    }
  • 相关阅读:
    CAP理论中的P到底是个什么意思?
    网络分区是什么
    SQL中的where条件,在数据库中提取与应用浅析
    golang 数据库开发神器 sqlx使用指南
    2017-07-08( bzip2 bunzip mount)
    2017-07-07(zip unzip gzip gunzip)
    2017-07-06(grep man apropos )
    2017-07-05 (whereis which find)
    001
    009-变量测试
  • 原文地址:https://www.cnblogs.com/kobe8/p/3716096.html
Copyright © 2011-2022 走看看