GPS坐标转换代码_第1页
GPS坐标转换代码_第2页
GPS坐标转换代码_第3页
GPS坐标转换代码_第4页
GPS坐标转换代码_第5页
已阅读5页,还剩4页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、经纬度BL换算到高斯平面直角坐标XY (高斯投影正算)的源码及算法收藏新一篇:C#的6种常用集合类大比拼|旧一篇:Silverlight中使用图片及常见问题、经纬度BL换算到高斯平面直角坐标XY (高斯投影正算)的源码及算法/ GaussBL2xy.cpp : Defines the ent ry point for the console application./# includestdafx.h # includemath.h # includeCo orTrans.h # includeusing namespace std;void main(int ar gc, cha r* ar

2、 gv)double MyL0 =108; 中央子午线double MyB =33.44556666; /33 du 44 fen 55.6666 miaodouble MyL =109.22334444; /3 度带,109 d 22 m 33.4444 sPrjPoint_K rasovsky MyPrj;MyPrj.SetLO(MyLO);MyPrj.SetBL(MyB, MyL);double OutMyX;结果应该大致是double OutMyX;double OutMyY;OutMyXMyPrj.x;正算结果:北坐标xOutMyYOutMyXMyPrj.x;正算结果:北坐标xOut

3、MyYMyPrj.y;/结果:东坐标y/反算/double InputMyX = 3736714.783;如果是独立计算,应该给出中央子午线L0double InputMyY =627497.303;MyPrj.Setxy(InputMyX, InputMyY);MyPrj.GetBL(&MyPrj.B, &MyPrj.L); 把计算出的BL的弧度值换算为dms形式double OutputMyB;double OutputMyL;OutputMyB = MyPrj.B;反算结果:BOutputMyL = MyPrj.L;反算结果:L分析表明,此程序的结果和Coord4.2的转换结果是一样的,

4、只差到毫米级原程序有几个问题,1.Pi的值不对。2.SetBL中多了两行错误代码 double Dms2Rad(double Dms)double Degr ee, Miniute;double Second;int Sign;double Rad;if(Dms =0)Sign =1;elseSign = -1;Dms = fabs(Dms);Degree = flo or (Dms);Miniute = floo r(fmod(Dms *100.0,100.0);Second = fmod(Dms *10000.0,100.0);PI /1Rad = Sign * (Deg ree + Mi

5、niute / 60.0 + Second / PI /1retu rn Rad;double Rad2Dms(double Rad)double Degr ee, Miniute;double Second;int Sign;double Dms;if(Rad =0)Sign =1;elseSign = -1;Rad = fabs(Rad *180.0 / PI);Deg ree = floor (Rad);Miniute = floo r(fmod(Rad * 60.0, 60.0);Second = fmod(Rad * 3600.0, 60.0);Dms = Sign * (Deg r

6、ee + Miniute /100.0 + Second /retu rn Dms;/ Definition of PrjPoint/bool PrjPoint:BL2xy()double X, N, t, t2, m, m2, ng2;double sinB, cosB;X = A1 * B * 180.0 / PI + A2 * sin(2 * B) + A3 (4 * B) + A4 * sin(6 * B);10000.0);* sinsinB =引 n(B);10000.0);* sincosB = cos(B);t = tan(B);t2 = t * t;N = a / sqr t

7、(1 - e2 * sinB * sinB);m = cosB * (L - LO);m2 = m * m;ng2 = cosB * cosB * e2 / (1- e2);x,y的计算公式见孔祥元等主编武汉大学出版社2002年出版的控制测量学的第72页/书的的括号有问题,(和应该交换ng TOC o 1-5 h z x =X+N*t* (0.5 + (5 - t2+9 * ng2 + 4*ng2*ng2) / 24.0 + (61-58*t2+t2*t2) * m2 / 720.0)*m2) * m2);y =N*m*(1+ m2 * ( (1-t2+ ng2) / 6.0+m2 *( 5-

8、18* t2+ t2 * t2+14 *ng2- 58* ng2 * t2) /120.0);y +=500000;retu rn tr ue;bool PrjPoint:xy2BL()double sinB, cosB, t, t2, N ,ng2, V, yN;double pr eB0, B0;double eta;y -=500000;B0 = x / A1;dopr eB0=B0;B0 =B0 * PI/180.0;B0 =(x - (A2*sin(2* B0) + A3 * sin(4 * B0) + A4 *sin(6 * BO) / A1;eta = fabs(BO - pr

9、eBO);while(eta O.OOOOOOOO1);BO = BO * PI /180.0;B = Rad2Dms(B0);sinB = sin(B0);cosB = cos(B0);t = tan(B0);t2 = t * t;N = a / sqr t(1 - e2 * sinB * sinB);ng2 = cosB * cosB * e2 / (1 - e2);V = sqr t(1+ ng2);yN = y / N;B=BO-(yN *yN - (5 +3* t2+ng2 -9*ng2*t2)*yN* yN* yN *yN /12.O +(61 +9O * t2 +45* t2*t

10、2)*yN*yN*yN *yN* yN* yN /36O.O)* v *V * t/ 2;L=LO+ (yN-(1 + 2 *t2+ ng2)* yN*yN*yN/ 6.O+ (5+ 28 *t2 + 24* t2 * t2 +6 * ng2 +8 *ng2*t2)*yN*yN*yN *yN* yN/12O.O)/ cosB;ret urntr ue;bool PrjPoint:SetL0(double dLO)LO = Dms2Rad(dL0);retu rn tr ue;bool PrjPoint:SetBL(double dB, double dL)B = Dms2Rad(dB);L =

11、 Dms2Rad(dL);B = dB; /我靠,I wana say fuck/L = dL; /del it !BL2xy();retu rn tr ue;bool PrjPoint:GetBL(double *dB, double *dL)*dB = Rad2Dms(B);*dL = Rad2Dms(L);retu rn tr ue;bool PrjPoint:Setxy(double dx, double dy)x = dx;y = dy;xy2BL();retu rn tr ue;bool PrjPoint:Getxy(double *dx, double *dy)*dx =x;*d

12、y =y;ret urntr ue;/ Definition of PrjPoint_IUGG1975/PrjPoint_IUGG1975:PrjPoint_IUGG1975() 在类外定义构造成员函数,要加上类名和域限定符:a =6378140;f =298.257;e2 =1 - (f - 1) / f) * (f - 1) / f);e12= (f / (f -1) * (f / (f -1)-A1 =111133.0047;这几个A是什么意思?A2 =-16038.5282;A3 =16.8326;A4 =-0.0220;PrjPoint_IUGG1975:PrjPoint_IUGG1

13、975()析构函数,释放构造函数占用的内存/ Definition of PrjPoint_K rasovsky/PrjPoint_K rasovsky:PrjPoint_K rasovsky()a =6378245;f =298.3;e2 =1 - (f - 1) / f) * (f - 1) / f);e12= (f / (f -1) * (f / (f -1)-A1 =111134.8611;A2 =-16036.4803;A3 =16.8281;A4 =-0.0220;PrjPoint_K rasovsky:PrjPoint_K rasovsky()/Coo rTr ans.h 文件i

14、fndef _COORTRANS_H_INCLUDEDdefine _COORTRANS_H_INCLUDED#include stdafx.h include math.h const double PI =3.141592653589793;double Dms2Rad(double Dms);double Rad2Dms(double Rad);class PnPointpublic:double L0; /中央子午线经度doubleB,L; /大地坐标doublex,y; /高斯投影平面坐标public:bool BL2xy();bool xy2BL();pr otected:double a, f, e2, e12; / 基本椭球参数double A1, A2, A3, A4; /用于计算X的椭球参数public:boolSetL0(doubledL0);boolSetBL(doubledB,doubledL);boolGetBL(double*dB,double*dL);boolSetxy(doubledx,doubledy);boolGetxy(double*dx,double*dy);;PrjPoint,class PrjPoint_Krasovsky : virtual public

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论