LBS 座標型別轉換(C )

2021-09-03 07:44:30 字數 4508 閱讀 7177

wgs84座標系:即地球座標系,國際上通用的座標系。裝置一般包含gps晶元或者北斗晶元獲取的經緯度為wgs84地理座標系,谷歌地圖採用的是wgs84地理座標系(中國範圍除外);

gcj02座標系:即火星座標系,是由中國國家測繪局制訂的地理資訊系統的座標系統。由wgs84座標係經加密後的座標系。谷歌中國地圖和高德地圖採用的是gcj02地理座標系;

public

class

gpscoordinate

///

/// 座標型別

///

public

enum

gps_type

///

/// 座標轉換

///

/// 緯度

/// 經度

/// 舊座標系

/// 新座標系

///

public

static gps gpstonewgps

(double lat, double lon,

gps_type oldtyle,

gps_type newtype)

return gs;

}///

/// 座標轉換

///

/// 緯度

/// 經度

/// 轉換型別(enum lbs_type)

///

public

static gps gpstonewgps

(double lat, double lon,

lbs_type type)

return gs;

}///

/// 座標轉換

///

/// 緯度

/// 經度

/// gps

public

static gps gpstonewgps

(double lat, double lon, string type)

return gs;

}///

/// 座標轉換

/// wgs84 to 火星座標系 (gcj-02):當返回null是標識座標

///

/// 緯度

/// 經度

/// gps

public

static gps gpstonewgps

(double lat, double lon, int type)

return gs;

} #endregion

#region 座標轉化

///

///wgs84==>>gcj-02

///

private

static gps wgs84_to_gcj02

(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

newgps

(mglat, mglon);}

///

/// gcj-02==>>wgs84

///

private

static gps gcj02_to_wgs84

(double lat, double lon)

///

/// gcj-02==>>bd-09

///

private

static gps gcj02_to_bd09

(double gg_lat, double gg_lon)

///

/// bd-09==>>gcj-02

///

private

static gps bd09_to_gcj02

(double bd_lat, double bd_lon)

///

/// (bd-09)==>>wgs84

///

private

static gps bd09_to_wgs84

(double bd_lat, double bd_lon)

///

/// wgs84==>>(bd-09)

///

///

///

///

private

static gps wgs84_to_bd09

(double bd_lat, double bd_lon)

#endregion

#region 公共方法

///

/// 是否在中國內

///

///

///

///

public

static bool outofchina

(double lat, double lon)

private

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

newgps

(mglat, mglon);}

private

static double transformlat

(double x, double y)

private

static double transformlon

(double x, double y)

#endregion

}

public

class

gpspublic

gps(double wglat, double wglon)

public double getwglat()

public

void

setwglat

(double wglat)

public double getwglon()

public

void

setwglon

(double wglon)

public string tostring()

}

mysql型別轉換c 型別轉換 C 型別轉換

一 簡介 型別轉換 把資料從一種型別轉換另一種型別 我們要求等號兩邊參與運算子必須型別一致,如果不一致,滿足下列條件會發生自動型別轉換或者隱式型別轉換。1.兩種型別相容 例如 int和double 相容 都是數字型別 2.目標型別大於源型別 double int 顯示型別轉換 1.兩種型別相相容 i...

c 座標系互相轉換

各種座標系的各種轉換 public class tempgps public class gps wgs 84 to gcj 02 public void gcj encrypt var t this.delta new tempgps glng t.tlng lng glat t.tlat lat...

單個點座標座標轉換

需要js版本可以移步coordtransform lng 128.543 lat 37.065 result3 wgs84 to gcj02 lng,lat wgs84座標系 火星座標系 result4 gcj02 to wgs84 lng,lat 火星座標系 wgs84座標系 中文位址到火星座標系...