WGS84,GCJ02, BD09座標轉換

2021-07-23 19:22:08 字數 2717 閱讀 3483

public

class gps

public

double

getwglat()

public

void

setwglat(double wglat)

public

double

getwglon()

public

void

setwglon(double wglon)

@override

public string tostring()

}

/**

* 各地圖api座標系統比較與轉換;

* wgs84座標系:即地球座標系,國際上通用的座標系。裝置一般包含gps晶元或者北斗晶元獲取的經緯度為wgs84地理座標系,

* 谷歌地圖採用的是wgs84地理座標系(中國範圍除外);

* gcj02座標系:即火星座標系,是由中國國家測繪局制訂的地理資訊系統的座標系統。由wgs84座標係經加密後的座標系。

* 搜狗座標系、圖吧座標系等,估計也是在gcj02基礎上加密而成的。 chenhua

*/public

class

positionutil

double dlat = transformlat(lon - 105.0, lat - 35.0);

double dlon = transformlon(lon - 105.0, lat - 35.0);

double radlat = lat / 180.0 * 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) * pi);

dlon = (dlon * 180.0) / (a / sqrtmagic * math.cos(radlat) * pi);

double mglat = lat + dlat;

double mglon = lon + dlon;

return

new gps(mglat, mglon);

}/**

* * 火星座標系 (gcj-02) to 84 * *@param lon *@param lat *@return

* */

public

static gps gcj_to_gps84(double lat, double lon)

/***

*@param gg_lat

*@param gg_lon

*/public

static gps gcj02_to_bd09(double gg_lat, double gg_lon)

/*** bd_lat *@param bd_lon *@return

*/public

static gps bd09_to_gcj02(double bd_lat, double bd_lon)

/*** (bd-09)-->84

*@param bd_lat

*@param bd_lon

*@return

*/public

static gps bd09_to_gps84(double bd_lat, double bd_lon)

public

static

boolean

outofchina(double lat, double lon)

public

static gps transform(double lat, double lon)

double dlat = transformlat(lon - 105.0, lat - 35.0);

double dlon = transformlon(lon - 105.0, lat - 35.0);

double radlat = lat / 180.0 * 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) * pi);

dlon = (dlon * 180.0) / (a / sqrtmagic * math.cos(radlat) * pi);

double mglat = lat + dlat;

double mglon = lon + dlon;

return

new gps(mglat, mglon);

}public

static

double

transformlat(double x, double y)

public

static

double

transformlon(double x, double y)

public

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地理座標系。谷歌地圖採用的...