📄 survey.cpp
字号:
if(m_caltf.GetLength()==10)
{
m_oldmap=GetOldThFormNewTh(m_caltf);
m_newmap=m_caltf;
SetNewTfCalLL(m_caltf,&Sb,&Wl,&Nb,&El);
}
}
if (atol(SetBLC)==1000000) { sel = 0;}
else if(atol(SetBLC)==500000) { sel = 1;}
else if(atol(SetBLC)==250000) { sel = 2;}
else if(atol(SetBLC)==100000) { sel = 3;}
else if(atol(SetBLC)==50000) { sel = 4;}
else if(atol(SetBLC)==25000) { sel = 5;}
else if(atol(SetBLC)==10000) { sel = 6;}
else if(atol(SetBLC)==5000) { sel = 7;}
else {return FALSE;}
double jd=0,wd=0;
//Sb,El 左上角
jd=Deg(Sb-0.01);wd=Deg(El+0.01);
if(sel>=1&&sel<=2) { stroldtf=GetThCalLat(jd,wd,sel); }
else if(sel>=4&&sel<=5) { stroldtf=GetThCalLatEF(jd,wd,sel); }
else { stroldtf=GetThCalLatADGH(jd,wd,sel);}
eltf1=stroldtf;
//第二幅
jd=Deg(Sb);wd=Deg(El);
if(sel>=1&&sel<=2) { stroldtf=GetThCalLat(jd,wd,sel); }
else if(sel>=4&&sel<=5) { stroldtf=GetThCalLatEF(jd,wd,sel); }
else { stroldtf=GetThCalLatADGH(jd,wd,sel);}
eltf2=stroldtf;
//第四幅
jd=Deg(Sb-0.01);wd=Deg(Wl+0.01);
if(sel>=1&&sel<=2) { stroldtf=GetThCalLat(jd,wd,sel); }
else if(sel>=4&&sel<=5) { stroldtf=GetThCalLatEF(jd,wd,sel); }
else { stroldtf=GetThCalLatADGH(jd,wd,sel);}
eltf4=stroldtf;
//第三幅
jd=Deg(Nb);wd=Deg(El);
if(sel>=1&&sel<=2) { stroldtf=GetThCalLat(jd,wd,sel); }
else if(sel>=4&&sel<=5) { stroldtf=GetThCalLatEF(jd,wd,sel); }
else { stroldtf=GetThCalLatADGH(jd,wd,sel);}
eltf3=stroldtf;
//第五幅
jd=Deg(Nb);wd=Deg(Wl);
if(sel>=1&&sel<=2) { stroldtf=GetThCalLat(jd,wd,sel); }
else if(sel>=4&&sel<=5) { stroldtf=GetThCalLatEF(jd,wd,sel); }
else { stroldtf=GetThCalLatADGH(jd,wd,sel);}
eltf5=stroldtf;
//第7幅
jd=Deg(Sb+0.01);wd=Deg(Wl-0.01);
if(sel>=1&&sel<=2) { stroldtf=GetThCalLat(jd,wd,sel); }
else if(sel>=4&&sel<=5) { stroldtf=GetThCalLatEF(jd,wd,sel); }
else { stroldtf=GetThCalLatADGH(jd,wd,sel);}
eltf7=stroldtf;
//第8幅
jd=Deg(Nb+0.01);wd=Deg(Wl-0.01);
if(sel>=1&&sel<=2) { stroldtf=GetThCalLat(jd,wd,sel); }
else if(sel>=4&&sel<=5) { stroldtf=GetThCalLatEF(jd,wd,sel); }
else { stroldtf=GetThCalLatADGH(jd,wd,sel);}
eltf8=stroldtf;
//第6幅
jd=Deg(Sb-0.01);wd=Deg(Wl-0.01);
if(sel>=1&&sel<=2) { stroldtf=GetThCalLat(jd,wd,sel); }
else if(sel>=4&&sel<=5) { stroldtf=GetThCalLatEF(jd,wd,sel); }
else { stroldtf=GetThCalLatADGH(jd,wd,sel);}
eltf6=stroldtf;
return TRUE;
/*
WriteGridDate(Sb,El,1);
WriteGridDate(Nb,El,2);
WriteGridDate(Nb,Wl,3);
WriteGridDate(Sb,Wl,4);
*/
}
/////////////////////////坐标旋转计算方法一///////////////////////
//坐标转换公式 X=Ax+By+C
//------------ Y=Ay-Bx+F '计算参数 相当于ARC/INFO中的Transfrom用法
////////////////////////////////////////////////////
BOOL CSurvey::TransTwoContrlXy(typePoint old1,typePoint old2,typePoint new1,typePoint new2,double* s1,double* s2,double* s3,double* s4)
{
double d_x=0, d_y=0;
double T_x=0, T_y=0;
double Fenm =0,d_xx =0;
double d_yy=0;
//ReDim S(4)
//On Error Resume Next
d_x = old2.x - old1.x ;// Point2.X - Point1.X
d_y = old2.y - old1.y ;// Point2.Y - Point1.Y
T_x = new2.x - new1.x ;// Trans2.X - Trans1.X
T_y = new2.y - new1.y ;//Trans2.Y - Trans1.Y
Fenm = d_x*d_x + d_y*d_y;
if(Fenm==0)
return FALSE;
d_xx = T_x * d_x + T_y * d_y;
*s1 = d_xx / Fenm; //'参数方程中===A
d_yy = T_x * d_y - T_y * d_x;
*s2 = d_yy / Fenm; //'参数方程中===B
*s3 = new1.x-((*s1)*old1.x + (*s2)*old1.y); //Trans1.X - (S(1) * Point1.X + S(2) * Point1.Y) '参数方程中===C
*s4 = new1.y-((*s1)*old1.y - (*s2)*old1.x); //Trans1.Y - (S(1) * Point1.Y - S(2) * Point1.X) '参数方程中===F
return TRUE;
}
void CSurvey::TransXy(typePoint oldpoint,typePoint* newpoint,double s1,double s2,double s3,double s4) //坐标转换
{
newpoint->x=s1*oldpoint.x + s2*oldpoint.y + s3; //.X = CS(1) * Point1.X + CS(2) * Point1.Y + CS(3)
newpoint->y=s1*oldpoint.y - s2*oldpoint.x + s4;//Point_New.Y = CS(1) * Point1.Y - CS(2) * Point1.X + CS(4)
return;
}
//==============================================================
//公里格网计算 //计算直线的交点
BOOL CSurvey::CalLineCut(struct typePoint point1,struct typePoint point2,double GridData,double* GetData,bool bfxy) //计算直线的交点
{
double k=0, b=0;
double pa , pb;
double GridDataOther;
if((point2.x-point1.x)!=0)
{ k = (point2.y-point1.y)/(point2.x-point1.x); }
else
{ k = 999999; }
if((point2.x-point1.x)!=0)
{
pa = point2.x * point1.y;
pb = point1.x * point2.y;
b = (pa - pb) / (point2.x-point1.x);
}
else
{ b = 999999; }
if(bfxy) //用X计算Y坐标
{
if( k == 999999 ) //无法计算
{ return FALSE; }
else
{
GridDataOther = k * GridData + b;
if(GridDataOther < point2.y && GridDataOther > point1.y)
{ /*return TRUE;*/}
else
{ return FALSE;}
}
}
else //用Y计算X坐标
{
if( k == 999999 )
{
GridDataOther = point1.x;
//return TRUE;
}
else if( k == 0) //无法计算
{ return FALSE;}
else
{
GridDataOther = (GridData - b) / k;
if( GridDataOther < point2.x && GridDataOther > point1.x )
{ /*return TRUE;*/}
else
{ return FALSE;}
}
}
*GetData = GridDataOther;
return TRUE;
}
void CSurvey::ExportKilometreGridMapInof(CString filename,CString tkcode,CString lcode) ////输出公里格网Mapinfo
{
struct typePoint Point1;
struct typePoint Point2;
double SetGridData;
double GetGridData;
bool bfxy;
long j=0;
CString Strport;
CString strgd;
BOOL reSet;
long basicData;
CString midfilename;
midfilename=filename.Left(filename.GetLength()-3)+"mid";
//'计算公里格网
CStdioFile n_File;
CStdioFile n_Filemid;
CFileException e;
if(!n_File.Open(filename,CFile::modeCreate|CFile::modeWrite,&e))
{ return;}
if(!n_Filemid.Open(midfilename,CFile::modeCreate|CFile::modeWrite,&e))
{ return;}
Strport="Version 300\n"; //Mapinfo文件头
n_File.WriteString(Strport);
Strport.Format("Charset %cWindowsSimpChinese%c\n",34,34);
n_File.WriteString(Strport);
Strport.Format("Coordsys NonEarth\n");
n_File.WriteString(Strport);
Strport.Format(" Units %cmi%c\n",34,34);
n_File.WriteString(Strport);
double sminx=0,sminy=0;
double smaxx=0,smaxy=0;
BOOL bf=GetMaxMinData(&sminx,&sminy,&smaxx,&smaxy);
Strport.Format(" Bounds %c%.6f, %.6f%c %c%.6f, %.6f%c\n",40,sminx,sminy,41,40,smaxx,smaxy,41);
n_File.WriteString(Strport);
n_File.WriteString("Columns 1\n");
n_File.WriteString(" CODE integer\n");
n_File.WriteString("Data\n");
n_File.WriteString("\n");
int cl=0;
//double dataport;
n_File.WriteString("pline 5\n");
for(j=0;j<4;j++)
{
Strport.Format("%.6f %.6f\n",point54[j].x,point54[j].y);
n_File.WriteString(Strport);
}
Strport.Format("%.6f %.6f\n",point54[0].x,point54[0].y);
n_File.WriteString(Strport);
n_File.WriteString(" Pen(1, 2, 0)\n");
n_Filemid.WriteString(tkcode+"\n"); //文件
//'以X为整数计算Y
bfxy = true;
int k=1;
basicData = (long)ceil(point54[0].x / 1000) * 1000;
for(j = basicData;j<=(long)floor(point54[2].x);j+=1000)
{
SetGridData = j;
k++;
if(point54[3].y < point54[2].y)
{
Point1 = point54[3]; //坐标复制
Point2 = point54[2];
}
else
{
Point1 = point54[2]; //'坐标复制
Point2 = point54[3];
}
reSet = CalLineCut(Point1, Point2, SetGridData, &GetGridData, bfxy);
if(!reSet)
{
Point1 = point54[3]; //'坐标复制
Point2 = point54[0];
reSet = CalLineCut(Point1, Point2, SetGridData, &GetGridData, bfxy);
if(!reSet)
{
Point1 = point54[2]; //'坐标复制
Point2 = point54[1];
reSet = CalLineCut(Point1, Point2, SetGridData, &GetGridData, bfxy);
//if(reSet)
//{
// Strport.Format("%d,%.8f\n",(int)SetGridData,GetGridData);
// n_File.WriteString(Strport);
//}
}
}
Strport.Format("line %.6f %.6f",SetGridData,GetGridData);
if( point54[0].y < point54[1].y)
{
Point1 = point54[0]; //'坐标复制
Point2 = point54[1];
}
else
{
Point1 = point54[1]; //'坐标复制
Point2 = point54[0];
}
reSet = CalLineCut(Point1, Point2, SetGridData, &GetGridData, bfxy);
if(!reSet)
{
Point1 = point54[3]; //'坐标复制
Point2 = point54[0];
reSet = CalLineCut(Point1, Point2, SetGridData, &GetGridData, bfxy);
if(!reSet)
{
Point1 = point54[2]; //'坐标复制
Point2 = point54[1];
reSet = CalLineCut(Point1, Point2, SetGridData, &GetGridData, bfxy);
//if(reSet)
//{
// Strport.Format("%d,%.8f\n",(int)SetGridData,GetGridData);
// n_File.WriteString(Strport);
//}
}
}
strgd.Format(" %.6f %6f",SetGridData,GetGridData);//,point54[j].y);
Strport=Strport+strgd+"\n";
n_File.WriteString(Strport);
n_File.WriteString(" Pen(1, 2, 0)\n");
n_Filemid.WriteString(lcode+"\n");
}
//'以Y为整数计算X
bfxy = false;
basicData = (long)ceil(point54[3].y / 1000) * 1000 ;
for( j = basicData ;j<= (long)floor(point54[1].y);j+=1000)
{
SetGridData = j;
k++;
if( point54[3].x > point54[0].x )
{
Point1 = point54[0]; Point2 = point54[3];
}
else
{
Point1 = point54[3]; Point2 = point54[0];
}
reSet = CalLineCut(Point1, Point2, SetGridData, &GetGridData, bfxy);
if(!reSet)
{
if( point54[0].x < point54[1].x )
{
Point1 = point54[0]; Point2 = point54[1];
}
else
{
Point1 = point54[1]; Point2 = point54[0];
}
reSet = CalLineCut(Point1, Point2, SetGridData, &GetGridData, bfxy);
if(!reSet)
{
if( point54[2].x < point54[3].x )
{
Point1 = point54[2]; Point2 = point54[3];
}
else
{
Point1 = point54[3]; Point2 = point54[2];
}
reSet = CalLineCut(Point1, Point2, SetGridData, &GetGridData, bfxy);
}
}
Strport.Format("line %.6f %.6f",GetGridData,SetGridData);
if( point54[1].x > point54[2].x )
{
Point1 = point54[2]; Point2 = point54[1];
}
else
{
Point1 = point54[1]; Point2 = point54[2];
}
reSet = CalLineCut(Point1, Point2, SetGridData, &GetGridData, bfxy);
if(!reSet)
{
if( point54[0].x < point54[1].x )
{
Point1 = point54[0]; Point2 = point54[1];
}
else
{
Point1 = point54[1]; Point2 = point54[0];
}
reSet = CalLineCut(Point1, Point2, SetGridData, &GetGridData, bfxy);
if(!reSet)
{
if( point54[2].x < point54[3].x )
{
Point1 = point54[2]; Point2 = point54[3];
}
else
{
Point1 = point54[3]; Point2 = point54[2];
}
reSet = CalLineCut(Point1, Point2, SetGridData, &GetGridData, bfxy);
}
}
strgd.Format(" %.6f %6f",GetGridData,SetGridData);
Strport=Strport+strgd+"\n";
n_File.WriteString(Strport);
n_File.WriteString(" Pen(1, 2, 0)\n");
n_Filemid.WriteString(lcode+"\n");
}
}
void CSurvey::ExportKilometreGrid(CString filename,CString tkcode,CString lcode) //输出公里格网
{
struct typePoint Point1;
struct typePoint Point2;
double SetGridData;
double GetGridData;
//Dim StrFileName As String
bool bfxy;
long j=0;
CString Strport;
CString strgd;
BOOL reSet;
long basicData;
//'计算54公里格网
CStdioFile n_File;
CFileException e;
if(!n_File.Open(filename,CFile::modeCreate|CFile::modeWrite,&e))
{ return;}
Strport="EXP 0 "+filename+"\n"; //E00文件头
n_File.WriteString(Strport);
n_File.WriteString("ARC 3\n"); //ARC属性 3双精度
Strport.Format("%10i%10s%10i%10i%10i%10i%10i",1,tkcode,0,0,0,0,5);
Strport+="\n";
int cl=0;
double dataport;
n_File.WriteString(Strport);
//n_File.WriteString("501\n");
for(j=0;j<4;j++)
{
cl=ExData(point54[j].x,&dataport);
Strport.Format("%17.14fE+0%i",dataport,cl);//,point54[j].y);
cl=ExData(point54[j].y,&dataport);
strgd.Format("%17.14fE+0%i",dataport,cl);//,point54[j].y);
Strport=Strport+strgd+"\n";
n_File.WriteString(Strport);
}
cl=ExData(point54[0].x,&dataport);
Strport.Format("%17.14fE+0%i",dataport,cl);//,point54[j].y);
cl=ExData(point54[0].y,&dataport);
strgd.Format("%17.14fE+0%i",dataport,cl);//,point54[j].y);
Strport=Strport+strgd+"\n";
n_File.WriteString(Strport);
//'以X为整数计算Y
bfxy = true;
int k=1;
basicData = (long)ceil(point54[0].x / 1000) * 1000;
for(j = basicData;j<=(long)floor(point54[2].x);j+=1000)
{
SetGridData = j;
k++;
Strport.Format("%10i%10s%10i%10i%10i%10i%10i",k,lcode,0,0,0,0,2);
Strport+="\n";
n_File.WriteString(Strport);
if(point54[3].y < point54[2].y)
{
Point1 = point54[3]; //坐标复制
Point2 = point54[2];
}
else
{
Point1 = point54[2]; //'坐标复制
Point2 = point54[3];
}
reSet = CalLineCut(Point1, Point2, SetGridData, &GetGridData, bfxy);
if(!reSet)
{
Point1 = point54[3]; //'坐标复制
Point2 = point54[0];
reSet = CalLineCut(Point1, Point2, SetGridData, &GetGridData, bfxy);
if(!reSet)
{
Point1 = point54[2]; //'坐标复制
Point2 = point54[1];
reSet = CalLineCut(Point1, Point2, SetGridData, &GetGridData, bfxy);
//if(reSet)
//{
// Strport.Format("%d,%.8f\n",(int)SetGridData,GetGridData);
// n_File.WriteString(Strport);
//}
}
}
cl=ExData(SetGridData,&dataport);
Strport.Format("%17.14fE+0%i",dataport,cl);//,point54[j].y);
cl=ExData(GetGridData,&dataport);
strgd.Format("%17.14fE+0%i",dataport,cl);//,point54[j].y);
Strport=Strport+strgd+"\n";
n_File.WriteString(Strport);
if( point54[0].y < point54[1].y)
{
Point1 = point54[0]; //'坐标复制
Point2 = point54[1];
}
else
{
Point1 = point54[1]; //'坐标复制
Point2 = point54[0];
}
reSet = CalLineCut(Point1, Point2, SetGridData, &GetGridData, bfxy);
if(!reSet)
{
Point1 = point54[3]; //'坐标复制
Point2 = point54[0];
reSet = CalLineCut(Point1, Point2, SetGridData, &GetGridData, bfxy);
if(!reSet)
{
Point1 = point54[2]; //'坐标复制
Point2 = point54[1];
reSet = CalLineCut(Point1, Point2, SetGridData, &GetGridData, bfxy);
//if(reSet)
//{
// Strport.Format("%d,%.8f\n",(int)SetGridData,GetGridData);
// n_File.WriteString(Strport);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -