九色国产,午夜在线视频,新黄色网址,九九色综合,天天做夜夜做久久做狠狠,天天躁夜夜躁狠狠躁2021a,久久不卡一区二区三区

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
C#實(shí)現(xiàn)地圖坐標(biāo)系的轉(zhuǎn)換(WGS-84、GCJ-02、BD-09)

   WGS-84坐標(biāo)系:全球定位系統(tǒng)使用,GPS、北斗等

   GCJ-02坐標(biāo)系:中國地區(qū)使用,由WGS-84偏移而來

   BD-09坐標(biāo)系:百度專用,由GCJ-02偏移而來

  (PS:源于項(xiàng)目需求,本來是想讀圖片的經(jīng)緯度顯示在百度離線地圖上的。后來發(fā)現(xiàn)定位偏差太大,仔細(xì)一想,原來是圖片和百度使用的坐標(biāo)系不一樣。

 

  計(jì)算轉(zhuǎn)換部分 

    public class GPSChange    {        private const double pi = 3.14159265358979324;        private const double x_pi = 3.14159265358979324 * 3000.0 / 180.0;        //克拉索天斯基橢球體參數(shù)值        private const double a = 6378245.0;        //第一偏心率        private const double ee = 0.00669342162296594323;        /// <summary>        /// GCJ-02轉(zhuǎn)換BD-09        /// </summary>        /// <param name="gg_lat">緯度</param>        /// <param name="gg_lon">經(jīng)度</param>        /// <returns></returns>        public static GPSPoint GCJ02_to_BD09(double gg_lat, double gg_lon)        {            GPSPoint point = new GPSPoint();            double x = gg_lon, y = gg_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);            double bd_lon = z * Math.Cos(theta) + 0.0065;            double bd_lat = z * Math.Sin(theta) + 0.006;            point.SetLat(bd_lat);            point.SetLng(bd_lon);            return point;        }        /// <summary>        /// BD-09轉(zhuǎn)換GCJ-02        /// </summary>        /// <param name="bd_lat">緯度</param>        /// <param name="bd_lon">經(jīng)度</param>        /// <returns></returns>        public static GPSPoint BD09_to_GCJ02(double bd_lat, double bd_lon)        {            GPSPoint point = new GPSPoint();            double x = bd_lon - 0.0065, y = bd_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);            double gg_lon = z * Math.Cos(theta);            double gg_lat = z * Math.Sin(theta);            point.SetLat(gg_lat);            point.SetLng(gg_lon);            return point;        }        /// <summary>        /// WGS-84轉(zhuǎn)換GCJ-02        /// </summary>        /// <param name="wgLat">緯度</param>        /// <param name="wgLon">經(jīng)度</param>        /// <returns></returns>        public static GPSPoint WGS84_to_GCJ02(double wgLat, double wgLon)        {            GPSPoint point = new GPSPoint();            if (OutOfChina(wgLat, wgLon))            {                point.SetLat(wgLat);                point.SetLng(wgLon);                return point;            }            double dLat = TransformLat(wgLon - 105.0, wgLat - 35.0);            double dLon = TransformLon(wgLon - 105.0, wgLat - 35.0);            double radLat = wgLat / 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 lat = wgLat + dLat;            double lon = wgLon + dLon;            point.SetLat(lat);            point.SetLng(lon);            return point;        }        public static void Transform(double wgLat, double wgLon, double[] latlng)        {            if (OutOfChina(wgLat, wgLon))            {                latlng[0] = wgLat;                latlng[1] = wgLon;                return;            }            double dLat = TransformLat(wgLon - 105.0, wgLat - 35.0);            double dLon = TransformLon(wgLon - 105.0, wgLat - 35.0);            double radLat = wgLat / 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);            latlng[0] = wgLat + dLat;            latlng[1] = wgLon + dLon;        }        private static bool OutOfChina(double lat, double lon)        {            if (lon < 72.004 || lon > 137.8347)                return true;            if (lat < 0.8293 || lat > 55.8271)                return true;            return false;        }        private static double TransformLat(double x, double y)        {            double ret = -100.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 * pi) + 20.0 * Math.Sin(2.0 * x * pi)) * 2.0 / 3.0;            ret += (20.0 * Math.Sin(y * pi) + 40.0 * Math.Sin(y / 3.0 * pi)) * 2.0 / 3.0;            ret += (160.0 * Math.Sin(y / 12.0 * pi) + 320 * Math.Sin(y * pi / 30.0)) * 2.0 / 3.0;            return ret;        }        private 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 * pi) + 20.0 * Math.Sin(2.0 * x * pi)) * 2.0 / 3.0;            ret += (20.0 * Math.Sin(x * pi) + 40.0 * Math.Sin(x / 3.0 * pi)) * 2.0 / 3.0;            ret += (150.0 * Math.Sin(x / 12.0 * pi) + 300.0 * Math.Sin(x / 30.0 * pi)) * 2.0 / 3.0;            return ret;        }    }

   基礎(chǔ)類

    public class GPSPoint    {        private double lat;// 緯度        private double lng;// 經(jīng)度        public GPSPoint()        {        }        public GPSPoint(double lng, double lat)        {            this.lng = lng;            this.lat = lat;        }                public double GetLat()        {            return lat;        }        public void SetLat(double lat)        {            this.lat = lat;        }        public double GetLng()        {            return lng;        }        public void SetLng(double lng)        {            this.lng = lng;        }            }

 

 

本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
國內(nèi)各地圖API坐標(biāo)系統(tǒng)比較與轉(zhuǎn)換
WGS84,GCJ02, BD09坐標(biāo)轉(zhuǎn)換 (轉(zhuǎn))
數(shù)據(jù)清洗告一段落了
地球坐標(biāo),火星坐標(biāo),百度坐標(biāo)轉(zhuǎn)換
百度坐標(biāo)坐標(biāo)系之間的轉(zhuǎn)換(JS版代碼)
各類坐標(biāo)轉(zhuǎn)換不完全說明
更多類似文章 >>
生活服務(wù)
熱點(diǎn)新聞
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服