public class gps
public double getwglat()
public void setwglat(double wglat)
public double getwglon()
public void setwglon(double wglon)
@override
public string tostring() }
1/**
2* 各地圖api座標系統比較與轉換;
3* wgs84座標系:即地球座標系,國際上通用的座標系。裝置一般包含gps晶元或者北斗晶元獲取的經緯度為wgs84地理座標系,
4* 谷歌地圖採用的是wgs84地理座標系(中國範圍除外);
5* gcj02座標系:即火星座標系,是由中國國家測繪局制訂的地理資訊系統的座標系統。由wgs84座標係經加密後的座標系。67
* 搜狗座標系、圖吧座標系等,估計也是在gcj02基礎上加密而成的。 chenhua8*/
9public
class positionutil
28double dlat = transformlat(lon -
105.0, lat -
35.0);
29double dlon = transformlon(lon -
105.0, lat -
35.0);
30double radlat = lat /
180.0 * pi;
31double magic = math.sin(radlat);
32 magic =
1 - ee * magic * magic;
33double sqrtmagic = math.sqrt(magic);
34 dlat = (dlat *
180.0) / ((a * (
1 - ee)) / (magic * sqrtmagic) * pi);
35 dlon = (dlon *
180.0) / (a / sqrtmagic * math.cos(radlat) * pi);
36double mglat = lat + dlat;
37double mglon = lon + dlon;
38return
new gps(mglat, mglon);
39 }
4041/**42
* * 火星座標系 (gcj-02) to 84 * * @param lon * @param lat * @return
43*
*/44
public
static gps gcj_to_gps84(
double lat,
double lon)
5051/**52
53*
54* @param gg_lat
55* @param gg_lon
56*/
57public
static gps gcj02_to_bd09(
double gg_lat,
double gg_lon)
6566/**67
68* bd_lat * @param bd_lon * @return
69*/
70public
static gps bd09_to_gcj02(
double bd_lat,
double bd_lon)
7879/**80
* (bd-09)-->84
81* @param bd_lat
82* @param bd_lon
83* @return
84*/
85public
static gps bd09_to_gps84(
double bd_lat,
double bd_lon)
9394public
static boolean outofchina(
double lat,
double lon)
101102public
static gps transform(
double lat,
double lon)
106double dlat = transformlat(lon -
105.0, lat -
35.0);
107double dlon = transformlon(lon -
105.0, lat -
35.0);
108double radlat = lat /
180.0 * pi;
109double magic = math.sin(radlat);
110 magic =
1 - ee * magic * magic;
111double sqrtmagic = math.sqrt(magic);
112 dlat = (dlat *
180.0) / ((a * (
1 - ee)) / (magic * sqrtmagic) * pi);
113 dlon = (dlon *
180.0) / (a / sqrtmagic * math.cos(radlat) * pi);
114double mglat = lat + dlat;
115double mglon = lon + dlon;
116return
new gps(mglat, mglon);
117 }
118119public
static
double transformlat(
double x,
double y)
127128public
static
double transformlon(
double x,
double y)
137138public
static
void main(string args)
WGS84,GCJ02, BD09座標轉換
public class gps public double getwglat public void setwglat double wglat public double getwglon public void setwglon double wglon override public str...
WGS84,GCJ02, BD09座標轉換
public class gps public double getwglat public void setwglat double wglat public double getwglon public void setwglon double wglon override public str...
WGS 84座標系轉GCJ02座標系
最近用到某個定位介面,返回的是wsg 84座標系下的經緯度資訊,但專案前端使用的是高德地圖,發現位置有偏移。需要進行座標轉換才能正常顯示。各地圖api座標系統比較 wgs84座標系 即地球座標系,國際上通用的座標系。裝置一般包含gps晶元或者北斗晶元獲取的經緯度為wgs84地理座標系。谷歌地圖採用的...