📄 gausscompute.cpp
字号:
// GaussCompute.cpp : implementation file
//
#include "stdafx.h"
#include "DateConvert.h"
#include "GaussCompute.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// GaussCompute dialog
GaussCompute::GaussCompute(CWnd* pParent /*=NULL*/)
: CDialog(GaussCompute::IDD, pParent)
{
//{{AFX_DATA_INIT(GaussCompute)
m_centerlinenum = 0.0;
m_usercenterline = FALSE;
m_coordsys = 0;
m_bandwidth = 0;
m_hd = 0;
//}}AFX_DATA_INIT
}
void GaussCompute::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(GaussCompute)
DDX_Text(pDX, IDC_CENTERLINENUM, m_centerlinenum);
DDV_MinMaxDouble(pDX, m_centerlinenum, 0., 360.);
DDX_Check(pDX, IDC_USERCENTERLINE, m_usercenterline);
DDX_Radio(pDX, IDC_RADIO54, m_coordsys);
DDX_Radio(pDX, IDC_RADIO6, m_bandwidth);
DDX_Radio(pDX, IDC_RADIO6_6, m_hd);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(GaussCompute, CDialog)
//{{AFX_MSG_MAP(GaussCompute)
ON_BN_CLICKED(IDC_GSFS, OnGsfs)
ON_BN_CLICKED(IDC_GSZS, OnGszs)
ON_BN_CLICKED(IDC_USERCENTERLINE, OnUsercenterline)
ON_BN_CLICKED(IDC_HDCAL, OnHdcal)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// GaussCompute message handlers
void GaussCompute::OnGsfs()
{
// TODO: Add your control notification handler code here
Fcalaculate();
}
void GaussCompute::OnGszs()
{
// TODO: Add your control notification handler code here
Zcalaculate();
}
void GaussCompute::OnUsercenterline()
{
// TODO: Add your control notification handler code here
if(m_bandwidth==FALSE)
m_bandwidth=TRUE;
else if(m_bandwidth==TRUE)
m_bandwidth=FALSE;
}
void GaussCompute::Ellipsecomputer(int n)
{
if(n==0) {a=6378245.000;f=0.003352329869;}
if(n==1) {a=6378140.000;f=0.003352813178;}
if(n==2) {a=6378137.000;f=0.003352810671;}
e=sqrt(2*f-f*f);
b=a-a*f;
e2=sqrt(a*a/(b*b)-1);
c=a*a/b;
}
bool GaussCompute::Zcalaculate()
{
UpdateData(TRUE);
int i,k,n,m,j;
double t,q,N,L0,x[200],y[200],X,B1,B,L,l;
Ellipsecomputer(m_coordsys);
//数据读取
CStdioFile fp;
CStdioFile f32;CFileException e32;
CFileDialog FileDlg(TRUE,NULL,"*.*",OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
"坐标正算数据文件(*.*)|*.txt|所有文件(*.*)|*.*||");
FileDlg.m_ofn.lpstrTitle="打开数据文件";
if(FileDlg.DoModal()==IDOK)
{
CString StrFile=FileDlg.GetPathName();
if(!fp.Open(StrFile,
CFile::modeRead|CFile::typeText,NULL))
{
AfxMessageBox("数据文件不存在或数据文件错!",MB_OK|MB_ICONSTOP,0);
fp.Close();
return FALSE;
}
CString buff;
for(i=1;;i++)
{
fp.ReadString(buff);
k=sscanf(buff,"%lf%lf",&B,&L);//B,L
if(k!=2&&k!=-1)
{
fp.Close();
return FALSE;
}
if(k==-1)
break;
//取中央子午线和投影带
if(m_usercenterline==TRUE)
{
L0=m_centerlinenum;
n=0;
}
else
{
if(m_bandwidth==1)
{
for(n=1;;n++)
{
if(fabs(L-3*n)<=1.3)
break;
}
L0=3*n;
}
if(m_bandwidth==0)
{
for(n=1;;n++)
{
if(fabs(L-(6*n-3)<=3))
break;
}
L0=n*6-3;
}
}
//用
l=angle_r(L)-angle_r(L0);
B1=B;
B=angle_r(B);//角度化为弧度;
L=angle_r(L);//角度化为弧度;
B1=int(B1)+(int(B1*100)-int(B1)*100)/60.0+(B1*10000-int(B1*100)*100)/3600.0;
X=c*(B1/57.2957795131*(1-3./4.*e2*e2+45./64.*e2*e2*e2*e2-175./256.*e2*e2*e2*e2*e2*e2+11025./16384.*e2*e2*e2*e2*e2*e2*e2*e2)+((-3./4.*e2*e2+45./64.*e2*e2*e2*e2-175./256.*e2*e2*e2*e2*e2*e2+11025./16384.*e2*e2*e2*e2*e2*e2*e2*e2)*cos(B)+(15./32.*e2*e2*e2*e2-175./384.*e2*e2*e2*e2*e2*e2+675./8192.*e2*e2*e2*e2*e2*e2*e2*e2)*cos(B)*cos(B)*cos(B)+(-35./96.*e2*e2*e2*e2*e2*e2+735./2048.*e2*e2*e2*e2*e2*e2*e2*e2)*cos(B)*cos(B)*cos(B)*cos(B)*cos(B)*cos(B)*cos(B)*cos(B)+315./1024.*e2*e2*e2*e2*e2*e2*e2*e2*cos(B)*cos(B)*cos(B)*cos(B)*cos(B)*cos(B)*cos(B))*sin(B));
// X=6367558.4969*B1/57.2957795131-(32140.4048-(135.3303-(0.7092-0.0041*cos(B)*cos(B))*cos(B)*cos(B))*cos(B)*cos(B))*sin(B)*cos(B);
t=tan(B);q=cos(B)*e2;N=a/(sqrt(1-e*e*sin(B)*sin(B)));
x[i]=X+l*l/2*N*sin(B)*cos(B)+l*l*l*l/24*N*sin(B)*cos(B)*cos(B)*cos(B)*(5-t*t+9*q*q+4*q*q*q*q)+l*l*l*l*l*l/720*N*sin(B)*cos(B)*cos(B)*cos(B)*cos(B)*cos(B)*(61-58*t*t+t*t*t*t);
y[i]=l*N*cos(B)+l*l*l/6*N*cos(B)*cos(B)*cos(B)*(1-t*t+q*q)+l*l*l*l*l/120*N*cos(B)*cos(B)*cos(B)*cos(B)*cos(B)*(5-18*t*t+t*t*t*t+14*q*q-58*q*q*t*t);
y[i]=y[i]+500000;
for(k=1;;k++)
{
y[i]=y[i]/10;
if(y[i]>=0&&y[i]<1) break;
}
y[i]=n+y[i];
for(m=1;m<=k;m++) y[i]=y[i]*10;
j=i;
}
fp.Close();
prompt();
CFileDialog FileDlgSave(NULL,NULL,"*.txt",OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_CREATEPROMPT,
"坐标正算结果数据文件名(*.txt)|*.txt|所有文件(*.*)|*.*||");
FileDlgSave.m_ofn.lpstrTitle="保存数据文件";
if(FileDlgSave.DoModal()==IDOK)
{
CString Str=FileDlgSave.GetPathName();
if(!f32.Open(Str,CFile::modeCreate|CFile::modeWrite
|CFile::typeText,&e32))
{
CString errorMessage="文件"+Str+"不能创建!";
AfxMessageBox(errorMessage,MB_OK|MB_ICONSTOP,0);
f32.Close();
return FALSE;
}
CString strBuffer;
for(i=1;i<=j;i++)
{
strBuffer.Format("x[%d]=%16.6lfm y[%d]=%16.6lfm\n",i,x[i],i,y[i]);
f32.WriteString(strBuffer);
}
}
f32.Close();
}
return TRUE;
}
bool GaussCompute::Fcalaculate()
{
UpdateData(TRUE);
int i,k,m,n,j;
double x,y,Bf,p,tf,qf,Nf,Mf,p1,B[200],L[200];
double dBf,xx,a1,l;
Ellipsecomputer(m_coordsys);
CStdioFile fp;
CStdioFile f32;
CFileException e32;
CFileDialog FileDlg(TRUE,NULL,"*.*",OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
"坐标反算数据文件(*.*)|*.txt|所有文件(*.*)|*.*||");
FileDlg.m_ofn.lpstrTitle="打开数据文件";
if(FileDlg.DoModal()==IDOK)
{
CString StrFile=FileDlg.GetPathName();
if(!fp.Open(StrFile,
CFile::modeRead|CFile::typeText,NULL))
{
AfxMessageBox("数据文件不存在或数据文件错!",MB_OK|MB_ICONSTOP,0);
fp.Close();
return FALSE;
}
CString buff;
for(i=1;;i++)
{
fp.ReadString(buff);
k=sscanf(buff,"%lf%lf",&x,&y);
if(k!=2&&k!=-1)
{
fp.Close();
return FALSE;
}
if(k==-1) break;
if(m_usercenterline==TRUE)
y=y-500000;
//////////////在这里只能认为带号是一个两位数
else
{
for(m=1;;m++)
{
y=y/10;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -