GPS坐标转换代码 下载本文

内容发布更新时间 : 2024/11/18 10:36:32星期一 下面是文章的全部内容请认真阅读。

经纬度BL换算到高斯平面直角坐标XY(高斯投影正算)的源码及算法 收藏

新一篇: C#的6种常用集合类大比拼 | 旧一篇: Silverlight中使用图片及常见问题

一、

经纬度BL换算到高斯平面直角坐标XY(高斯投影正算)的源码及算法

// GaussBL2xy.cpp : Defines the entry point for the console application. //

#include \#include \#include \#include

using namespace std;

void main(int argc, char* argv[]) {

double MyL0 = 108; //中央子午线

double MyB = 33.44556666; //33 du 44 fen 55.6666 miao double MyL = 109.22334444; //3度带,109 d 22 m 33.4444 s

PrjPoint_Krasovsky MyPrj; MyPrj.SetL0(MyL0); MyPrj.SetBL(MyB, MyL);

double OutMyX; //结果应该大致是:3736714.783, 627497.303 double OutMyY;

OutMyX = MyPrj.x; //正算结果: 北坐标x OutMyY = MyPrj.y; //结果:东坐标y

//////////////////反算////////////////////////////////////////

double InputMyX = 3736714.783; //如果是独立计算,应该给出中央子午线L0 double InputMyY = 627497.303; MyPrj.Setxy(InputMyX, InputMyY);

MyPrj.GetBL(&MyPrj.B, &MyPrj.L); //把计算出的BL的弧度值换算为dms形式 double OutputMyB; double OutputMyL;

OutputMyB = MyPrj.B; //反算结果:B OutputMyL = MyPrj.L; //反算结果:L

//分析表明,此程序的结果和Coord4.2的转换结果是一样的,只差到毫米级 //原程序有几个问题,1.Pi的值不对。2.SetBL中多了两行错误代码 }

double Dms2Rad(double Dms) {

double Degree, Miniute; double Second; int Sign; double Rad; if(Dms > = 0) Sign = 1; else

Sign = -1; Dms = fabs(Dms); Degree = floor(Dms);

Miniute = floor(fmod(Dms * 100.0, 100.0)); Second = fmod(Dms * 10000.0, 100.0);

Rad = Sign * (Degree + Miniute / 60.0 + Second / 3600.0) * PI / 1

80.0;

return Rad; }

double Rad2Dms(double Rad) {

double Degree, Miniute; double Second; int Sign; double Dms; if(Rad > = 0) Sign = 1; else

Sign = -1;

Rad = fabs(Rad * 180.0 / PI); Degree = floor(Rad);

Miniute = floor(fmod(Rad * 60.0, 60.0)); Second = fmod(Rad * 3600.0, 60.0);

Dms = Sign * (Degree + Miniute / 100.0 + Second / 10000.0); return 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 * sin(4 * B) + A4 * sin(6 * B); sinB = sin(B);