• 大小: 861KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-19
  • 语言: 其他
  • 标签: 坐标转换  

资源简介

GPS单点定位程序设计大地坐标和空间直角坐标之间的相互转换

资源截图

代码片段和文件信息

#include
#include
using namespace std;
#define M_PI 3.1415926
typedef struct tagCRDCARTESIAN
{
double x;
double y;
double z;
}CRDCARTESIAN;
typedef CRDCARTESIAN *PCRDCARTESIAN;
typedef struct tagCRDGEODETIC
{
double longitude;
double latitude;
double height;
}CRDGEODETIC;

typedef CRDGEODETIC *PCRDGEODETIC;
void DMS_RAD(double DMSdouble *Rad)
{
int DegMin;
double Sec;
Deg=(int)DMS;
Min=(int)((DMS-Deg)*100);
Sec=((DMS-Deg)*100-Min)*100;
*Rad=(Deg+Min/60.0+Sec/3600.0)/180.0*M_PI;
return;
}
void RAD_DMS(double Raddouble *DMS)
{
int DegMin;
double Sec;
double ARAM;
AR=Rad;
if (Rad<0)
AR=-Rad;
AR=AR+1.0e-10;
AR=AR*180.0/M_PI;
Deg=(int)AR;
AM=(AR-Deg)*60.0;
Min=(int)AM;
Sec=(AM-Min)*60;
*DMS=Deg+Min/100.0+Sec/10000.0;
if(Rad<0)
*DMS=-*DMS;

return;
}
bool CRDCARTESIANtoCRDGEODETIC(PCRDCARTESIAN pccPCRDGEODETIC pcgdouble dSemiMajorAxisdouble dFlattening)
{
double B0RN;
double B_L_;
double X=pcc->x;
double Y=pcc->y;
double Z=pcc->z;

R=sqrt(X*X+Y*Y);
B0=atan2(ZR);

while (1)
{
N=dSemiMajorAxis/sqrt(1.0-dFlattening*(2-dFlattening)*sin(B0)*sin(B0));
B_=atan2(Z+N*dFlattening*(2-dFlattening)*sin(B0)R);
if(fabs(B_-B0)<1.0e-10)
break;
B0=B_;
}
L_=atan2(YX);
pcg->height=R/cos(B_)-N;

RAD_DMS(B_&pcg->latitude);
RAD_DMS(L_&pcg->longitude);
return true;
}
bool CRDGEODETICtoCRDCARTESEAN(PCRDGEODETIC pcgPCRDCARTESIAN pccdouble dSemiMajorAxisdouble dFlattening)
{
double N;
double B_L_;

double B=pcg->latitude;
double L=pcg->longitude;
double H=pcg->height;

DMS_RAD(B&B_);
DMS_RAD(L&L_);
N=dSemiMajorAxis/sqrt(1.0-dFlattening*(2-dFlattening)*sin(B_)*sin(B_));
pcc->x=(N+H)*cos(B_)*cos(L_);
pcc->y=(N+H)*cos(B_)*sin(L_);
pcc->z=(N*(1.0-dFlattening*(2-dFlattening))+H)*sin(B_);
return true;
}
void main()
{
PCRDCARTESIAN  pcc=new CRDCARTESIAN;
PCRDGEODETIC  pcg=new CRDGEODETIC;
//B=30.31.40.23    L=114.21.20.51 h=41
double rad;
rad=(30*3600+31*60+40.23)/3600;
pcg->latitude=rad;
rad=(114*3600+21*60+20.51)/3600;
pcg->height=41;
pcg->longitude=rad;

double dSemiMajorAxis=6378137;
double dFlatning=1/298.257223563;

cout<
cout<<“转换前已知的大地坐标:“< cout<<“H(高度)=“<height<<“   “<<“L(经度)=“<longitude<<“   “<<“B(纬度)=“<latitude<
CRDGEODETICtoCRDCARTESEAN(pcg pcc dSemiMajorAxisdFlatning);

cout< cout<<“转换后的空间直角坐标:“;
cout<<“x=“<x<<“   “<<“y=“<y<<“   “<<“z=“<z<<“   “<

CRDCARTESIANtoCRDGEODETIC(pccpcgdSemiMajorAxisdFlatning);

cout< cout<<“由转换后的空间直角坐标xyz还原成大地坐标:“< cout<<“H(高度)=“<height<<“   “<<“L(经度)=“<longitude<<“   “<<“B(纬度)=“<latitude< cout<
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       2892  2011-01-04 17:19  坐标转换\2.cpp

     文件       4584  2011-01-04 16:43  坐标转换\2.dsp

     文件        527  2011-01-04 16:43  坐标转换\2.dsw

     文件      41984  2011-01-09 20:10  坐标转换\2.ncb

     文件        864  2011-01-04 19:49  坐标转换\2.plg

     文件     528459  2011-01-04 19:49  坐标转换\Debug\2.exe

     文件     786348  2011-01-04 19:49  坐标转换\Debug\2.ilk

     文件     158300  2011-01-04 17:19  坐标转换\Debug\2.obj

     文件    2011076  2011-01-04 16:55  坐标转换\Debug\2.pch

     文件    1082368  2011-01-04 17:19  坐标转换\Debug\2.pdb

     文件      82944  2011-01-04 19:49  坐标转换\Debug\vc60.idb

     文件     110592  2011-01-04 17:19  坐标转换\Debug\vc60.pdb

     文件      53760  2011-01-09 20:10  坐标转换\2.opt

     目录          0  2011-01-09 20:09  坐标转换\Debug

     目录          0  2011-01-09 20:09  坐标转换

----------- ---------  ---------- -----  ----

              4864698                    15


评论

共有 条评论