多多色-多人伦交性欧美在线观看-多人伦精品一区二区三区视频-多色视频-免费黄色视屏网站-免费黄色在线

國內最全IT社區平臺 聯系我們 | 收藏本站
阿里云優惠2
您當前位置:首頁 > php開源 > 綜合技術 > 百度坐標轉換gps坐標工具類

百度坐標轉換gps坐標工具類

來源:程序員人生   發布時間:2015-05-06 09:04:39 閱讀次數:4832次

百度坐標和標準的gps坐標有偏差,這里提供1個百度坐標轉換為gps坐標的工具類。

package com.smarteye.baidumap; import com.baidu.location.BDLocation; public class GlobalTool { public final static double a = 6378245.0; public final static double ee = 0.00669342162296594323; // 判斷坐標是不是在中國 public static boolean outOfChina(BDLocation bdLocation) { double lat = bdLocation.getLatitude(); double lon = bdLocation.getLongitude(); if (lon < 72.004 || lon > 137.8347) return true; if (lat < 0.8293 || lat > 55.8271) return true; if ((119.962 < lon && lon < 121.750) && (21.586 < lat && lat < 25.463)) return true; return false; } public final static double x_pi = 3.14159265358979324 * 3000.0 / 180.0; public static BDLocation BAIDU_to_WGS84(BDLocation bdLocation) { if (outOfChina(bdLocation)) { return bdLocation; } double x = bdLocation.getLongitude() - 0.0065; double y = bdLocation.getLatitude() - 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); bdLocation.setLongitude(z * Math.cos(theta)); bdLocation.setLatitude(z * Math.sin(theta)); return GCJ02_to_WGS84(bdLocation); } public static BDLocation GCJ02_to_WGS84(BDLocation bdLocation) { if (outOfChina(bdLocation)) { return bdLocation; } BDLocation tmpLocation = new BDLocation(); tmpLocation.setLatitude(bdLocation.getLatitude()); tmpLocation.setLongitude(bdLocation.getLongitude()); BDLocation tmpLatLng = WGS84_to_GCJ02(tmpLocation); double tmpLat = 2 * bdLocation.getLatitude() - tmpLatLng.getLatitude(); double tmpLng = 2 * bdLocation.getLongitude() - tmpLatLng.getLongitude(); for (int i = 0; i < 0; ++i) { tmpLocation.setLatitude(bdLocation.getLatitude()); tmpLocation.setLongitude(bdLocation.getLongitude()); tmpLatLng = WGS84_to_GCJ02(tmpLocation); tmpLat = 2 * tmpLat - tmpLatLng.getLatitude(); tmpLng = 2 * tmpLng - tmpLatLng.getLongitude(); } bdLocation.setLatitude(tmpLat); bdLocation.setLongitude(tmpLng); return bdLocation; } public static BDLocation WGS84_to_GCJ02(BDLocation bdLocation) { if (outOfChina(bdLocation)) { return bdLocation; } double dLat = transformLat(bdLocation.getLongitude() - 105.0, bdLocation.getLatitude() - 35.0); double dLon = transformLon(bdLocation.getLongitude() - 105.0, bdLocation.getLatitude() - 35.0); double radLat = bdLocation.getLatitude() / 180.0 * Math.PI; double magic = Math.sin(radLat); magic = 1 - ee * magic * magic; double sqrtMagic = Math.sqrt(magic); dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * Math.PI); dLon = (dLon * 180.0) / (a / sqrtMagic * Math.cos(radLat) * Math.PI); bdLocation.setLatitude(bdLocation.getLatitude() + dLat); bdLocation.setLongitude(bdLocation.getLongitude() + dLon); return bdLocation; } public static double transformLat(double x, double y) { double ret = ⑴00.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt(Math.abs(x)); ret += (20.0 * Math.sin(6.0 * x * Math.PI) + 20.0 * Math.sin(2.0 * x * Math.PI)) * 2.0 / 3.0; ret += (20.0 * Math.sin(y * Math.PI) + 40.0 * Math.sin(y / 3.0 * Math.PI)) * 2.0 / 3.0; ret += (160.0 * Math.sin(y / 12.0 * Math.PI) + 320 * Math.sin(y * Math.PI / 30.0)) * 2.0 / 3.0; return ret; } public static double transformLon(double x, double y) { double ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.sqrt(Math.abs(x)); ret += (20.0 * Math.sin(6.0 * x * Math.PI) + 20.0 * Math.sin(2.0 * x * Math.PI)) * 2.0 / 3.0; ret += (20.0 * Math.sin(x * Math.PI) + 40.0 * Math.sin(x / 3.0 * Math.PI)) * 2.0 / 3.0; ret += (150.0 * Math.sin(x / 12.0 * Math.PI) + 300.0 * Math.sin(x / 30.0 * Math.PI)) * 2.0 / 3.0; return ret; } }


生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: 欧美成视频在线观看 | aa黄色片 | 最近中文在线中文 | 国产成人精品久久一区二区三区 | 国产亚洲欧美一区二区三区 | 亚洲欧美日韩综合久久久久 | 日本中文字幕永久在线 | 亚洲自拍偷拍小说 | 天天夜夜狠狠 | 欧美亚洲国产片在线观看 | 欧美黑人猛烈ⅹxxx 欧美黑人喷潮水xxxx | 久久久久久久久一次 | 狠狠操网 | 在线观看视频一区二区 | 69视频在线看| 亚洲欧美日韩国产精品久久 | 国产精品亚洲精品观看不卡 | 琪琪午夜伦埋影院77 | videosex久久麻豆 | 国产一国产一级毛片视频在线 | 亚洲精品不卡久久久久久 | 久久久无码精品亚洲日韩按摩 | 伊人久久综合成人网小说 | 国产成人短视频在线观看免费 | 日韩亚洲国产欧美精品 | 国产精品99久久久 | 美国一级大毛片 | a毛片全部播放免费视频完整18 | 手机在线观看视频 | 成人午夜精品网站在线观看 | 亚洲激情专区 | 中文字幕一区2区 | 亚洲色图 欧美 | 男人午夜天堂 | 在线国产小视频 | 欧美永久免费 | 7777精品伊人久久久大香线蕉 | 亚洲免费中文 | 欧美最猛黑人xxxx黑人猛交3p | 久久精品国产精品亚洲人人 | 女人的天堂网 |