资源简介
代码内含测试数据;主体程序都包括在内。如果要为自己所用,只须作少许修改~~
代码片段和文件信息
// GKprojection.cpp : 定义控制台应用程序的入口点。
//
#include “stdafx.h“
#include “math.h“
#define pi 3.141592653
double Torad(double);
double Todouble(double);
int _tmain(int argc _TCHAR* argv[])
{
int model;
printf(“高斯投影正算请输入1,反算请输入2\n“);
scanf(“%d“&model);
if(model==1)
{
printf(“高斯投影正算\nunder WGS-84六度带\n测试数据:B=22.155898294,L=111.285215387\n“);
double a=6378137f=0.00335281066474;
double B=22.155898294L=111.285215387;
B=Torad(B);
double l=L-(int(L/6)*6+3);
int n=int(L/6)+1;
l=Torad(l);
double e2=-f*f+2*f;
double m0=a*(1-e2);
double m2=3*e2*m0/2;
double m4=5*e2*m2/4;
double m6=7*e2*m4/6;
double m8=9*e2*m6/8;
double a0=m0+m2/2+3*m4/8+5*m6/16+35*m8/128;
double a2=m2/2+m4/2+15*m6/32+7*m8/16;
double a4=m4/8+3*m6/16+7*m8/32;
double a6=m6/32+m8/16;
double a8=m8/128;
double X=a0*B-a2*sin(2*B)/2+a4*sin(4*B)/4-a6*sin(6*B)/6+a8*sin(8*B)/8;
double W=sqrt(1-e2*sin(B)*sin(B));
double N=a/W;
double ep2=e2/(1-e2);
double ita2=ep2*cos(B)*cos(B);
double t=tan(B);
double temp1=5-t*t+9*ita2+4*ita2*ita2;
double temp2=61-58*t*t+pow(t4);
double temp3=1-t*t+ita2;
double temp4=5-18*t*t+pow(t4)+14*ita2-58*t*t*ita2;
double x=X+N*sin(B)*cos(B)*l*l/2+N*sin(B)*pow(cos(B)3)*temp1*pow(l4)/24+N*sin(B)*pow(cos(B)5)*temp2*pow(l6)/720;
double y=N*cos(B)*l+N*pow(cos(B)3)*temp3*pow(l3)/6+N*pow(cos(B)5)*temp4*pow(l5)/120;
y=500000+y;
printf(“计算结果x=%fy=%d%f\n“xny);
}
else
{
printf(“高斯投影反算\nunder CGCS2000六度带\n测试数据:x=2562083.2708y=19512837.2851\n“);
double a=6378137;
double f=1/298.257222101;
double e2=-f*f+2*f;
double x=2562083.2708;
double y=19512837.2851;
int Y=int(
评论
共有 条评论