GPS 纠偏,点距

妈的,这么个技术点都成香馍馍了,人家老早把算法私下颁布了啊(呵呵,我们公司好像10多年也没搞定,也是我来搞定的,不过不是我写的,我抄来的,写过游戏的直觉是对的,估计也是sin一类的);

百度的二次偏移不支持,需要再次运算,以下算法为一次偏移纠偏运算(比如bing,google都只是一次偏移);

上个图证明是OK的哈,图中的是silverlight bingmap ——

代码继续往下——

 1     internal class EvilTransform
 2     {
 3         private const double pi = 3.14159265358979324;
 4
 5         //
 6         // Krasovsky 1940
 7         //
 8         // a = 6378245.0, 1/f = 298.3
 9         // b = a * (1 - f)
10         // ee = (a^2 - b^2) / a^2;
11         private const double a = 6378245.0;
12         private const double ee = 0.00669342162296594323;
13
14         //
15         // World Geodetic System ==> Mars Geodetic System
16         public static void Transform(double wgLat, double wgLon, out double mgLat, out double mgLon)
17         {
18             if (OutOfChina(wgLat, wgLon))
19             {
20                 mgLat = wgLat;
21                 mgLon = wgLon;
22                 return;
23             }
24             double dLat = TransformLat(wgLon - 105.0, wgLat - 35.0);
25             double dLon = TransformLon(wgLon - 105.0, wgLat - 35.0);
26             double radLat = wgLat/180.0*pi;
27             double magic = Math.Sin(radLat);
28             magic = 1 - ee*magic*magic;
29             double sqrtMagic = Math.Sqrt(magic);
30             dLat = (dLat*180.0)/((a*(1 - ee))/(magic*sqrtMagic)*pi);
31             dLon = (dLon*180.0)/(a/sqrtMagic*Math.Cos(radLat)*pi);
32             mgLat = wgLat + dLat;
33             mgLon = wgLon + dLon;
34         }
35
36         private static bool OutOfChina(double lat, double lon)
37         {
38             if (lon < 72.004 || lon > 137.8347)
39                 return true;
40             if (lat < 0.8293 || lat > 55.8271)
41                 return true;
42             return false;
43         }
44
45         private static double TransformLat(double x, double y)
46         {
47             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));
48             ret += (20.0*Math.Sin(6.0*x*pi) + 20.0*Math.Sin(2.0*x*pi))*2.0/3.0;
49             ret += (20.0*Math.Sin(y*pi) + 40.0*Math.Sin(y/3.0*pi))*2.0/3.0;
50             ret += (160.0*Math.Sin(y/12.0*pi) + 320*Math.Sin(y*pi/30.0))*2.0/3.0;
51             return ret;
52         }
53
54         private static double TransformLon(double x, double y)
55         {
56             double ret = 300.0 + x + 2.0*y + 0.1*x*x + 0.1*x*y + 0.1*Math.Sqrt(Math.Abs(x));
57             ret += (20.0*Math.Sin(6.0*x*pi) + 20.0*Math.Sin(2.0*x*pi))*2.0/3.0;
58             ret += (20.0*Math.Sin(x*pi) + 40.0*Math.Sin(x/3.0*pi))*2.0/3.0;
59             ret += (150.0*Math.Sin(x/12.0*pi) + 300.0*Math.Sin(x/30.0*pi))*2.0/3.0;
60             return ret;
61         }
62     }

在来个算两点距离的(二维平面,不算三维的z哈)

 1 public struct EarthPoint
 2     {
 3         public const double Ea = 6378137; // 赤道半径 WGS84标准参考椭球中的地球长半径(单位:m)
 4         public const double Eb = 6356725; // 极半径
 5         public readonly double Ec;
 6         public readonly double Ed;
 7         public readonly double Jd;
 8         public readonly double Latidute;
 9         public readonly double Longitude;
10         public readonly double Wd;
11
12         public EarthPoint(double longitude, double latidute)
13         {
14             Longitude = longitude;
15             Latidute = latidute;
16             Jd = Longitude*Math.PI/180; //转换成角度
17             Wd = Latidute*Math.PI/180; //转换成角度
18             Ec = Eb + (Ea - Eb)*(90 - Latidute)/90;
19             Ed = Ec*Math.Cos(Wd);
20         }
21
22         public double Distance(EarthPoint point)
23         {
24             double dx = (point.Jd - Jd)*Ed;
25             double dy = (point.Wd - Wd)*Ec;
26             return Math.Sqrt(dx*dx + dy*dy);
27         }
28
29         public static double GetDistance(
30             double latidute1,
31             double longitude1,
32             double latidute2,
33             double longitude2)
34         {
35             var p1 = new EarthPoint(longitude1, latidute1);
36             var p2 = new EarthPoint(longitude2, latidute2);
37             return p1.Distance(p2);
38         }
39     }
时间: 2024-07-28 16:27:48

GPS 纠偏,点距的相关文章

gps纠偏

演示示例代码:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Net.Security;using System.Security.Cryptography.X509Certificates;using System.Net;using System.IO;using System.IO.Compression;using System.Text.Regu

gps纠偏接口返回示例

演示示例代码: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net.Security; using System.Security.Cryptography.X509Certificates; using System.Net; using System.IO; using System.IO.Compression; using System

【转】几种现代GPS测量方法和技术

随着科技的发展,GPS测量技术和方法也在不断的改进和更新,目前用得最多的GPS测量技术方法有如下几种:静态和快速静态定位,差分GPS,RTK,网络RTK技术等等,下面将逐一介绍: 1.静态与快速静态定位技术 所谓静态定位,就是在进行 GPS 定位时,认为接收机的天线在整个观测进程中的位置是保持不变的.也就是说,在数据处理时,将接收机天线的位置作为一个不随时间的改变而改变的量.在测量 中,静态定位一般用于高精度的测量定位,其具体观测模式是多台接收机在不同的观测站上进行静止同步观测,观察时间有几分钟

GMAP谷歌地图的纠偏 保密算法

/** * gps纠偏算法,适用于google,高德体系的地图 * @author Administrator */ class Function_GpsCorrect { public static double pi = 3.14159265358979324; public static double a = 6378245.0; public static double ee = 0.00669342162296594323; public static double[] transfo

GIS开发离线地图应用-初识gis

最新公司需要做一个基于gis地图的应用系统,由于之前公司项目中的电子地图模块都是我开发的,所以这个新系统也自然让我先去了解如何开发,可以说做个简单的调研. 和之前的项目中开发的电子地图模块不同,这次是开发gis地图,是要显示真实的地理位置,能有gps定位功能的.而之前开发过的电子地图功能,都只是基于svg的矢量可配置地图(之前采用batik开发过C/S版,用raphael开发过B/S版,都在项目中正常使用). 下面描述下我开始开发前做的准备和了解工作,希望对首次接触并想要开发gis离线地图应用的

坐标转换——GCJ-02

WGS84(World Geodetic System 1984),是为GPS 全球定位系统 使用而建立的坐标系统GCJ-02,我国在WGS84的基础上加密得到BD-09,百度坐标在GCJ-02基础上,进行了BD-09二次加密火星坐标与百度坐标(GCJ-02----BD-09)转换国际经纬度坐标标准为WGS-84,国内必须至少使用国测局制定的GCJ-02,对地理位置进行首次加密.百度坐标在此基础上,进行了BD-09二次加密措施,更加保护了个人隐私.百度对外接口的坐标系并不是GPS采集的真实经纬度

HTML5 Geolocation实用性小调查

原文及代码请戳 http://appnext.mybluemix.net/Tracker.html 详细说明 本文中的代码来源于developWorkds上的这篇文章.不过,如果你仔细阅读过原文中的代码,就会发现其中有2处错误.一处是致命的错误导致距离计算结果变成NaN,另一处使得计算结果显示不正确.不过这两处已在此处的代码中修复了,有兴趣的同学可以比较一下源代码看看错误到底出在哪里.另外,本页面中的代码显示了Position对象中,HTML5定义的所有值,并且加入了一个计时器计算显示定位所耗时

高德百度坐标系转换方法

本文来自:http://blog.csdn.net/meegomeego/article/details/39927017 在开始这个题目之前,先给大家再次扫扫盲,扫的不是坐标系统的盲,而是我们国家所使用的坐标系统.大家都知道,美国GPS使用的是WGS84的坐标系统,以经纬度的形式来表示地球平面上的某一个位置,这应该是国际共识.但在我国,出于国家安全考虑,国内所有导航电子地图必须使用国家测绘局制定的加密坐标系统,即将一个真实的经纬度坐标加密成一个不正确的经纬度坐标,我们在业内将前者称之为地球坐标

iOS源码博文集锦3

iOS精选源码 高仿淘宝首页 登录动画 iOS高德二次封装,有定位,轨迹,语音实时导航,GPS纠偏..... 逗视iOS客户端MGDS_Swift 两句代码搞定转场动画 自定义刷新控件 已封装支持自定义的倒计时 语音识别,百度云,人工智能 完美的UIwebView 滑动菜单框左右页 slack menu slide 下拉栏1111.gif iOS优质博客 iOS开发之App主题切换完整解决方案(Swift版) 本篇博客就来介绍一下iOS App中主题切换的常规做法,当然本篇博客中只是提到了一种主