#include #include "stdafx.h"#include <windows.h>#include <windowsx.h>#include "resource.h"#include "MainDlg.h"#include <math.h>#include <stdio.h>BOOL WINAPI Main_Proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {switch(uMsg){HANDLE_MSG(hWnd, WM_INITDIALOG, Main_OnInitDialog);HANDLE_MSG(hWnd, WM_COMMAND, Main_OnCommand);HANDLE_MSG(hWnd,WM_CLOSE, Main_OnClose);}return FALSE;}BOOL Main_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam){return TRUE;}void Main_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify){double a=0;double e2=0;switch(id){case IDC_B1:{a=6378245.0000;e2=0.00669342162297;if(a==0){MessageBox(hwnd,TEXT("请选择坐标系"),TEXT("警告"),MB_OK);}else{TCHAR stre1[256];TCHAR stre11[256];TCHAR stre111[256];GetDlgItemText(hwnd,IDC_E1,stre1,sizeof(stre1)); GetDlgItemText(hwnd,IDC_E11,stre11,sizeof(stre11)); GetDlgItemText(hwnd,IDC_E111,stre111,sizeof(stre111));double L1 = atof(stre1);double L11 = atof(stre11);double L111 = atof(stre111);double L = L1+(L11/60)+(L111/3600);TCHAR stre2[256];TCHAR stre22[256];TCHAR stre222[256];GetDlgItemText(hwnd,IDC_E2,stre2,sizeof(stre2)); GetDlgItemText(hwnd,IDC_E22,stre22,sizeof(stre22)); GetDlgItemText(hwnd,IDC_E222,stre222,sizeof(stre222)); double B2 = atof(stre2);double B22 = atof(stre22);double B222 = atof(stre222);double B = B2+(B22/60)+(B222/3600);TCHAR stre3[256];GetDlgItemText(hwnd,IDC_E3,stre3,sizeof(stre3)); double H = atof(stre3);double sinB = sin((B/180)*3.1415926535897932385); double sinL = sin((L/180)*3.1415926535897932385); double cosB = cos((B/180)*3.1415926535897932385); double cosL = cos((L/180)*3.1415926535897932385); double sin2B=sinB*sinB;double w = double(sqrt(1-e2*sin2B));double n=a/w;double X = (n+H)*cosB*cosL;double Y = (n+H)*cosB*sinL;double Z = (n*(1-e2)+H)*sinB;int x = (int)X;int x1=100000*(X-x);int y = (int)Y;int y1=100000*(Y-y);int z = (int)Z;int z1=100000*(Z-z);TCHAR strx[256];wsprintf(strx,"%i",x);SetDlgItemText(hwnd,IDC_E4,strx);TCHAR strx1[256];wsprintf(strx1,"%i",x1);SetDlgItemText(hwnd,IDC_D1,strx1);TCHAR stry[256];wsprintf(stry,"%i",y);SetDlgItemText(hwnd,IDC_E5,stry);TCHAR stry1[256];wsprintf(stry1,"%i",y1);SetDlgItemText(hwnd,IDC_D2,stry1);TCHAR strz[256];wsprintf(strz,"%i",z);SetDlgItemText(hwnd,IDC_E6,strz);TCHAR strz1[256];wsprintf(strz1,"%i",z1);SetDlgItemText(hwnd,IDC_D3,strz1);}break;}case IDC_B2:{a=6378140.0000;e2=0.00669438499959;if(a==0){MessageBox(hwnd,TEXT("请选择坐标系"),TEXT("警告"),MB_OK);}else{TCHAR stre1[256];TCHAR stre11[256];TCHAR stre111[256];GetDlgItemText(hwnd,IDC_E1,stre1,sizeof(stre1)); GetDlgItemText(hwnd,IDC_E11,stre11,sizeof(stre11)); GetDlgItemText(hwnd,IDC_E111,stre111,sizeof(stre111));double L1 = atof(stre1);double L11 = atof(stre11);double L111 = atof(stre111);double L = L1+(L11/60)+(L111/3600);TCHAR stre2[256];TCHAR stre22[256];TCHAR stre222[256];GetDlgItemText(hwnd,IDC_E2,stre2,sizeof(stre2)); GetDlgItemText(hwnd,IDC_E22,stre22,sizeof(stre22)); GetDlgItemText(hwnd,IDC_E222,stre222,sizeof(stre222)); double B2 = atof(stre2);double B22 = atof(stre22);double B222 = atof(stre222);double B = B2+(B22/60)+(B222/3600);TCHAR stre3[256];GetDlgItemText(hwnd,IDC_E3,stre3,sizeof(stre3)); double H = atof(stre3);double sinB = sin((B/180)*3.1415926535897932385); double sinL = sin((L/180)*3.1415926535897932385); double cosB = cos((B/180)*3.1415926535897932385); double cosL = cos((L/180)*3.1415926535897932385); double sin2B=sinB*sinB;double w = double(sqrt(1-e2*sin2B));double n=a/w;double X = (n+H)*cosB*cosL;double Y = (n+H)*cosB*sinL;double Z = (n*(1-e2)+H)*sinB;int x = (int)X;int x1=100000*(X-x);int y = (int)Y;int y1=100000*(Y-y);int z = (int)Z;int z1=100000*(Z-z);TCHAR strx[256];wsprintf(strx,"%i",x);SetDlgItemText(hwnd,IDC_E4,strx);TCHAR strx1[256];wsprintf(strx1,"%i",x1);SetDlgItemText(hwnd,IDC_D1,strx1);TCHAR stry[256];wsprintf(stry,"%i",y);SetDlgItemText(hwnd,IDC_E5,stry);TCHAR stry1[256];wsprintf(stry1,"%i",y1);SetDlgItemText(hwnd,IDC_D2,stry1);TCHAR strz[256];wsprintf(strz,"%i",z);SetDlgItemText(hwnd,IDC_E6,strz);TCHAR strz1[256];wsprintf(strz1,"%i",z1);SetDlgItemText(hwnd,IDC_D3,strz1);}break;}case IDC_B3:{a=6378137.0000;e2=0.00669438002290;if(a==0){MessageBox(hwnd,TEXT("请选择坐标系"),TEXT("警告"),MB_OK);}else{TCHAR stre1[256];TCHAR stre11[256];TCHAR stre111[256];GetDlgItemText(hwnd,IDC_E1,stre1,sizeof(stre1)); GetDlgItemText(hwnd,IDC_E11,stre11,sizeof(stre11)); GetDlgItemText(hwnd,IDC_E111,stre111,sizeof(stre111));double L1 = atof(stre1);double L11 = atof(stre11);double L111 = atof(stre111);double L = L1+(L11/60)+(L111/3600);TCHAR stre2[256];TCHAR stre22[256];TCHAR stre222[256];GetDlgItemText(hwnd,IDC_E2,stre2,sizeof(stre2)); GetDlgItemText(hwnd,IDC_E22,stre22,sizeof(stre22)); GetDlgItemText(hwnd,IDC_E222,stre222,sizeof(stre222)); double B2 = atof(stre2);double B22 = atof(stre22);double B222 = atof(stre222);double B = B2+(B22/60)+(B222/3600);TCHAR stre3[256];GetDlgItemText(hwnd,IDC_E3,stre3,sizeof(stre3)); double H = atof(stre3);double sinB = sin((B/180)*3.1415926535897932385); double sinL = sin((L/180)*3.1415926535897932385); double cosB = cos((B/180)*3.1415926535897932385); double cosL = cos((L/180)*3.1415926535897932385); double sin2B=sinB*sinB;double w = double(sqrt(1-e2*sin2B));double n=a/w;double X = (n+H)*cosB*cosL;double Y = (n+H)*cosB*sinL;double Z = (n*(1-e2)+H)*sinB;int x = (int)X;int x1=100000*(X-x);int y = (int)Y;int y1=100000*(Y-y);int z = (int)Z;int z1=100000*(Z-z);TCHAR strx[256];wsprintf(strx,"%i",x);SetDlgItemText(hwnd,IDC_E4,strx);TCHAR strx1[256];wsprintf(strx1,"%i",x1);SetDlgItemText(hwnd,IDC_D1,strx1);TCHAR stry[256];wsprintf(stry,"%i",y);SetDlgItemText(hwnd,IDC_E5,stry);TCHAR stry1[256];wsprintf(stry1,"%i",y1);SetDlgItemText(hwnd,IDC_D2,stry1);TCHAR strz[256];wsprintf(strz,"%i",z);SetDlgItemText(hwnd,IDC_E6,strz);TCHAR strz1[256];wsprintf(strz1,"%i",z1);SetDlgItemText(hwnd,IDC_D3,strz1);}break;}case IDC_B4:{a=6378245.0000;e2=0.00669342162297;if(a==0){MessageBox(hwnd,TEXT("请选择坐标系"),TEXT("警告"),MB_OK);}else{TCHAR stre1[256];TCHAR stre2[256];TCHAR stre3[256];GetDlgItemText(hwnd,IDC_C1,stre1,sizeof(stre1));GetDlgItemText(hwnd,IDC_C2,stre2,sizeof(stre2));GetDlgItemText(hwnd,IDC_C3,stre3,sizeof(stre3));double X = atof(stre1);double Y = atof(stre2);double Z = atof(stre3);double L;double H;double s = 0.0000002;double i = 0.0000002;double c1=1/sqrt(X*X+Y*Y);double c=c1;double B=atan(Z*c1);double b=0;for(i;;i+=s){ b=B+i;double tanb = tan(b);double c2 = a*e2*tanb;double c3 = sqrt(1+tanb*tanb-e2*tanb*tanb);double c4 = Z+c2/c3;double c5=tanb-c1*c4;double c6=sqrt(c5*c5);if(c6<=s){ break;}}double b2 = b*180/3.1415926;int B1 = (int)b2;int b3 = (b2- B1)*60;int B2 = 60*((b2-B1)*60-b3);int b4 = 100*(60*((b2-B1)*60-b3)-B2);TCHAR strs1[256];wsprintf(strs1,"%i",B1);SetDlgItemText(hwnd,IDC_C7,strs1);TCHAR strs2[256];wsprintf(strs2,"%i",b3);SetDlgItemText(hwnd,IDC_C8,strs2);TCHAR strs3[256];wsprintf(strs3,"%i",B2);SetDlgItemText(hwnd,IDC_C9,strs3);TCHAR strd1[256];wsprintf(strd1,"%i",b4);SetDlgItemText(hwnd,IDC_D5,strd1);L=atan(Y/X);double L2 = L*180/3.1415926;int L1 = (int)L2;int L3 = (L2- L1)*60;int L4 = 60*((L2-L1)*60-L3);int L5 = 100*(60*((L2-L1)*60-L3)-L4);TCHAR strs4[256];wsprintf(strs4,"%i",L1);SetDlgItemText(hwnd,IDC_C4,strs4);TCHAR strs5[256];wsprintf(strs5,"%i",L3);SetDlgItemText(hwnd,IDC_C5,strs5);TCHAR strs6[256];wsprintf(strs6,"%i",L4);SetDlgItemText(hwnd,IDC_C6,strs6);TCHAR strd2[256];wsprintf(strd2,"%i",L5);SetDlgItemText(hwnd,IDC_D4,strd2);double h1=sqrt(X*X+Y*Y);double h2=cos(b);H=sqrt(X*X+Y*Y)/cos(b)-a/sqrt(1-e2*sin(b)*sin(b));int h3=(int)H;int h4=10000*(H-h3);TCHAR strs7[256];wsprintf(strs7,"%i",h3);SetDlgItemText(hwnd,IDC_C10,strs7);TCHAR strd3[256];wsprintf(strd3,"%i",h4);SetDlgItemText(hwnd,IDC_D6,strd3);}}break;case IDC_B5:{a=6378140.0000;e2=0.00669438499959;if(a==0){MessageBox(hwnd,TEXT("请选择坐标系"),TEXT("警告"),MB_OK);}else{TCHAR stre1[256];TCHAR stre2[256];TCHAR stre3[256];GetDlgItemText(hwnd,IDC_C1,stre1,sizeof(stre1));GetDlgItemText(hwnd,IDC_C2,stre2,sizeof(stre2));GetDlgItemText(hwnd,IDC_C3,stre3,sizeof(stre3));double X = atof(stre1);double Y = atof(stre2);double Z = atof(stre3);double L;double H;double s = 0.0000002;double i = 0.0000002;double c1=1/sqrt(X*X+Y*Y);double c=c1;double B=atan(Z*c1);double b=0;for(i;;i+=s){ b=B+i;double tanb = tan(b);double c2 = a*e2*tanb;double c3 = sqrt(1+tanb*tanb-e2*tanb*tanb);double c4 = Z+c2/c3;double c5=tanb-c1*c4;double c6=sqrt(c5*c5);if(c6<=s){ break;}}double b2 = b*180/3.1415926;int B1 = (int)b2;int b3 = (b2- B1)*60;int B2 = 60*((b2-B1)*60-b3);TCHAR strs1[256];wsprintf(strs1,"%i",B1);SetDlgItemText(hwnd,IDC_C7,strs1);TCHAR strs2[256];wsprintf(strs2,"%i",b3);SetDlgItemText(hwnd,IDC_C8,strs2);TCHAR strs3[256];wsprintf(strs3,"%i",B2);SetDlgItemText(hwnd,IDC_C9,strs3);L=atan(Y/X);double L2 = L*180/3.1415926;int L1 = (int)L2;int L3 = (L2- L1)*60;int L4 = 60*((L2-L1)*60-L3);int L5 = 100*(60*((L2-L1)*60-L3)-L4);TCHAR strs4[256];wsprintf(strs4,"%i",L1);SetDlgItemText(hwnd,IDC_C4,strs4);TCHAR strs5[256];wsprintf(strs5,"%i",L3);SetDlgItemText(hwnd,IDC_C5,strs5);TCHAR strs6[256];wsprintf(strs6,"%i",L4);SetDlgItemText(hwnd,IDC_C6,strs6);TCHAR strd2[256];wsprintf(strd2,"%i",L5);SetDlgItemText(hwnd,IDC_D4,strd2);double h1=sqrt(X*X+Y*Y);double h2=cos(b);H=sqrt(X*X+Y*Y)/cos(b)-a/sqrt(1-e2*sin(b)*sin(b)); int h3=(int)H;int h4=10000*(H-h3);TCHAR strs7[256];wsprintf(strs7,"%i",h3);SetDlgItemText(hwnd,IDC_C10,strs7);TCHAR strd3[256];wsprintf(strd3,"%i",h4);SetDlgItemText(hwnd,IDC_D6,strd3);}}case IDC_B6:{a=6378137.0000;e2=0.00669438002290;if(a==0){MessageBox(hwnd,TEXT("请选择坐标系"),TEXT("警告"),MB_OK);}else{TCHAR stre1[256];TCHAR stre2[256];TCHAR stre3[256];GetDlgItemText(hwnd,IDC_C1,stre1,sizeof(stre1));GetDlgItemText(hwnd,IDC_C2,stre2,sizeof(stre2));GetDlgItemText(hwnd,IDC_C3,stre3,sizeof(stre3));double X = atof(stre1);double Y = atof(stre2);double Z = atof(stre3);double L;double H;double s = 0.0000002;double i = 0.0000002;double c1=1/sqrt(X*X+Y*Y);double c=c1;double B=atan(Z*c1);double b=0;for(i;;i+=s){ b=B+i;double tanb = tan(b);double c2 = a*e2*tanb;double c3 = sqrt(1+tanb*tanb-e2*tanb*tanb);double c4 = Z+c2/c3;double c5=tanb-c1*c4;double c6=sqrt(c5*c5);if(c6<=s){ break;}}double b2 = b*180/3.1415926;int B1 = (int)b2;int b3 = (b2- B1)*60;int B2 = 60*((b2-B1)*60-b3);TCHAR strs1[256];wsprintf(strs1,"%i",B1);SetDlgItemText(hwnd,IDC_C7,strs1);TCHAR strs2[256];wsprintf(strs2,"%i",b3);SetDlgItemText(hwnd,IDC_C8,strs2);TCHAR strs3[256];wsprintf(strs3,"%i",B2);SetDlgItemText(hwnd,IDC_C9,strs3);L=atan(Y/X);double L2 = L*180/3.1415926;int L1 = (int)L2;int L3 = (L2- L1)*60;int L4 = 60*((L2-L1)*60-L3);int L5 = 100*(60*((L2-L1)*60-L3)-L4);TCHAR strs4[256];wsprintf(strs4,"%i",L1);SetDlgItemText(hwnd,IDC_C4,strs4);TCHAR strs5[256];wsprintf(strs5,"%i",L3);SetDlgItemText(hwnd,IDC_C5,strs5);TCHAR strs6[256];wsprintf(strs6,"%i",L4);SetDlgItemText(hwnd,IDC_C6,strs6);TCHAR strd2[256];wsprintf(strd2,"%i",L5);SetDlgItemText(hwnd,IDC_D4,strd2);double h1=sqrt(X*X+Y*Y);double h2=cos(b);H=sqrt(X*X+Y*Y)/cos(b)-a/sqrt(1-e2*sin(b)*sin(b)); int h3=(int)H;int h4=10000*(H-h3);TCHAR strs7[256];wsprintf(strs7,"%i",h3);SetDlgItemText(hwnd,IDC_C10,strs7);TCHAR strd3[256];wsprintf(strd3,"%i",h4);SetDlgItemText(hwnd,IDC_D6,strd3);}}}}void Main_OnClose(HWND hwnd){EndDialog(hwnd, 0);}。大地坐标与大地空间坐标转换工具