百度地图转腾讯地图

  1. package  *.util;
     
    /**
     * Created by huangbao on 2018/1/27.
     *
     *
     */
     
    public class LatLonUtil {
     
     
     
     
     public static void main(String[] args){
    //     LAT 113.04449543968454
    //
    //     LON 33.26440080499105
     
         //33.271128731125714,113.05042546525881
     
         System.out.print(map_tx2bd(113.04449543968454,33.26440080499105));
     }
        /**
         * 坐标转换,腾讯地图转换成百度地图坐标
         * @param lat 腾讯纬度
         * @param lon 腾讯经度
         * @return 返回结果:经度,纬度
         */
        public static  double[] map_tx2bd(double lat, double lon){
            double bd_lat;
            double bd_lon;
            double x_pi=3.14159265358979324;
            double x = lon, 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);
            bd_lon = z * Math.cos(theta) + 0.0065;
            bd_lat = z * Math.sin(theta) + 0.006;
     
            System.out.println("bd_lat:"+bd_lat);
            System.out.println("bd_lon:"+bd_lon);
     
            return new double[]{bd_lat,bd_lon};
        }
     
     
        /**
         * 坐标转换,百度地图坐标转换成腾讯地图坐标
         * @param lat  百度坐标纬度
         * @param lon  百度坐标经度
         * @return 返回结果:纬度,经度
         */
        public static double[] map_bd2tx(double lat, double lon){
            double tx_lat;
            double tx_lon;
            double x_pi=3.14159265358979324;
            double x = lon - 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);
            tx_lon = z * Math.cos(theta);
            tx_lat = z * Math.sin(theta);
            return new double[]{tx_lat,tx_lon};
        }
    }

转载出处:https://blog.csdn.net/forebe/article/details/79184243

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值