測繪程序設(shè)計(jì)-vc.net上機(jī)試驗(yàn)報(bào)告-平差程序設(shè)計(jì)_第1頁
測繪程序設(shè)計(jì)-vc.net上機(jī)試驗(yàn)報(bào)告-平差程序設(shè)計(jì)_第2頁
測繪程序設(shè)計(jì)-vc.net上機(jī)試驗(yàn)報(bào)告-平差程序設(shè)計(jì)_第3頁
測繪程序設(shè)計(jì)-vc.net上機(jī)試驗(yàn)報(bào)告-平差程序設(shè)計(jì)_第4頁
測繪程序設(shè)計(jì)-vc.net上機(jī)試驗(yàn)報(bào)告-平差程序設(shè)計(jì)_第5頁
已閱讀5頁,還剩9頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

...wd......wd......wd...?測繪程序設(shè)計(jì)(VC.net)?上機(jī)實(shí)驗(yàn)報(bào)告〔VisualC++.Net〕班級:測繪0901班學(xué)號:0405090204姓名:代婭琴2012年4月29日實(shí)驗(yàn)八平差程序設(shè)計(jì)根基實(shí)驗(yàn)?zāi)康?穩(wěn)固過程的定義與調(diào)用?穩(wěn)固類的創(chuàng)立與使用?穩(wěn)固間接平差模型及平差計(jì)算?掌握平差程序設(shè)計(jì)的基本技巧與步驟實(shí)驗(yàn)內(nèi)容水準(zhǔn)網(wǎng)平差程序設(shè)計(jì)。設(shè)計(jì)一個(gè)水準(zhǔn)網(wǎng)平差的程序,要求數(shù)據(jù)從文件中讀取,計(jì)算局部與界面無關(guān)。水準(zhǔn)網(wǎng)間接平差模型:計(jì)算例如:近似高程計(jì)算:水準(zhǔn)網(wǎng)平差計(jì)算一般步驟(1)讀取觀測數(shù)據(jù)和數(shù)據(jù);(2)計(jì)算未知點(diǎn)高程近似值;(3)列高差觀測值誤差方程;(4)根據(jù)水準(zhǔn)路線長度計(jì)算高差觀測值的權(quán);(5)組成法方程;(6)解法方程,求得未知點(diǎn)高程改正數(shù)及平差后高程值;(7)求高差觀測值殘差及平差后高差觀測值;(8)精度評定;(9)輸出平差結(jié)果。水準(zhǔn)網(wǎng)高程近似值計(jì)算算法輸入數(shù)據(jù)格式例如實(shí)驗(yàn)代碼:#pragmaonceclassLevelControlPoint{public: LevelControlPoint(void); ~LevelControlPoint(void);public: CStringstrName;//點(diǎn)名 CStringstrID;//點(diǎn)號floatH;boolflag;//標(biāo)記是否已經(jīng)計(jì)算出近似高程值,假設(shè)計(jì)算出那么為,否那么為};classCDhObs{public: CDhObs(void); ~CDhObs(void);public: LevelControlPoint*cpBackObj;//后視點(diǎn) LevelControlPoint*cpFrontObj;//前視點(diǎn)doubleObsValue;//高差值doubleDist;//測站的距離};#include"StdAfx.h"#include"LevelControlPoint.h"LevelControlPoint::LevelControlPoint(void){ strName=_T(""); strID=_T(""); H=0; flag=0;}LevelControlPoint::~LevelControlPoint(void){}CDhObs::CDhObs(void){}CDhObs::~CDhObs(void){}#pragmaonce#include"LevelControlPoint.h"#include"Matrix.h"classAdjustLevel{public: AdjustLevel(void); ~AdjustLevel(void);public: LevelControlPoint*m_pKnownPoint;//點(diǎn)數(shù)組intm_iKnownPointCount;//點(diǎn)個(gè)數(shù) LevelControlPoint*m_pUnknownPoint;//未知點(diǎn)數(shù)組intm_iUnknownPointCount;//未知點(diǎn)個(gè)數(shù) CDhObs*m_pDhObs;//高差觀測值數(shù)組intm_iDhObsCount;//高差觀測值個(gè)數(shù)public:voidSetKnownPointSize(intsize);//創(chuàng)立大小為size的點(diǎn)數(shù)組voidSetUnkonwnPointSize(intsize);//創(chuàng)立大小為size的未知點(diǎn)數(shù)組voidSetDhObsSize(intsize);//創(chuàng)立大小為size的觀測值數(shù)組boolLoadObsData(constCString&strFile);//讀入觀測文件 CString*SplitString(CStringstr,charsplit,int&iSubStrs);voidApproHeignt(void);//計(jì)算近似值private: LevelControlPoint*SearchKnownPointUsingID(CStringID); LevelControlPoint*SearchUnknownPointUsingID(CStringID); LevelControlPoint*SearchPointUsingID(CStringID);CMatrixLevleWeight(void);//計(jì)算權(quán)矩陣 public:voidFormErrorEquation(CMatrix&B,CMatrix&L);//組成誤差方程voidEquationCompute(CMatrix&x);//計(jì)算法方程voidAccuracy_Assessment(double&r0,CMatrix&Qxx);//精度評定voidCompAdjust(double&r0,CMatrixQx[]);};#include"StdAfx.h"#include"AdjustLevel.h"#include<locale.h>#include"LevelControlPoint.h"#include"math.h"AdjustLevel::AdjustLevel(void){ m_pKnownPoint=NULL;//點(diǎn)數(shù)組 m_iKnownPointCount=0;//點(diǎn)個(gè)數(shù) m_pUnknownPoint=NULL;//未知點(diǎn)數(shù)組 m_iUnknownPointCount=0;//未知點(diǎn)個(gè)數(shù) m_pDhObs=NULL;//高差觀測值數(shù)組 m_iDhObsCount=0;//高差觀測值個(gè)數(shù)}AdjustLevel::~AdjustLevel(void){if(m_pKnownPoint!=NULL) {delete[]m_pKnownPoint; m_pKnownPoint=NULL; }if(m_pUnknownPoint!=NULL) {delete[]m_pUnknownPoint; m_pUnknownPoint=NULL; }if(m_pDhObs!=NULL) {delete[]m_pDhObs; m_pDhObs=NULL; }}voidAdjustLevel::SetKnownPointSize(intsize){ m_pKnownPoint=newLevelControlPoint[size];//創(chuàng)立動態(tài)指針 m_iKnownPointCount=size;}voidAdjustLevel::SetUnkonwnPointSize(intsize){ m_pUnknownPoint=newLevelControlPoint[size]; m_iUnknownPointCount=size;}voidAdjustLevel::SetDhObsSize(intsize){ m_pDhObs=newCDhObs[size]; m_iDhObsCount=size;//高差觀測值個(gè)數(shù)}boolAdjustLevel::LoadObsData(constCString&strFile){ CStdioFilesf;if(!sf.Open(strFile,CFile::modeRead))returnfalse;//創(chuàng)立并翻開文件對象 CStringstrLine;boolbEOF=sf.ReadString(strLine);//讀取第一行,即點(diǎn)的數(shù)目 SetKnownPointSize(_ttoi(strLine));//根據(jù)點(diǎn)的數(shù)目,創(chuàng)立點(diǎn)數(shù)組;intn=0;for(inti=0;i<m_iKnownPointCount;i++)//讀取點(diǎn)的點(diǎn)名和高程值 { sf.ReadString(strLine); CString*pstrData=SplitString(strLine,',',n); m_pKnownPoint[i].strName=pstrData[0]; m_pKnownPoint[i].strID=pstrData[0]; m_pKnownPoint[i].H=_tstof(pstrData[1]); m_pKnownPoint[i].flag=1;//點(diǎn)不用平差,故將其的flag設(shè)置為delete[]pstrData; pstrData=NULL; } sf.ReadString(strLine);//讀取未知點(diǎn)的個(gè)數(shù) SetUnkonwnPointSize(_ttoi(strLine));//根據(jù)未知點(diǎn)的個(gè)數(shù)創(chuàng)立未知點(diǎn)數(shù)組 sf.ReadString(strLine);//讀取未知點(diǎn)的點(diǎn)名 CString*pstrData=SplitString(strLine,',',n);for(inti=0;i<m_iUnknownPointCount;i++)//將未知點(diǎn)的點(diǎn)名放入未知點(diǎn)數(shù)組 { m_pUnknownPoint[i].strName=pstrData[i]; m_pUnknownPoint[i].strID=pstrData[i]; m_pUnknownPoint[i].H=0;//未知點(diǎn)的高程值設(shè)置為 m_pUnknownPoint[i].flag=0;//還沒有求得近似高程,故其flag設(shè)置為 }if(pstrData!=NULL) {delete[]pstrData; pstrData=NULL; } sf.ReadString(strLine);//讀取觀測值的個(gè)數(shù) SetDhObsSize(_ttoi(strLine));//按照觀測值的大小,創(chuàng)立觀測值數(shù)組for(inti=0;i<m_iDhObsCount;i++)//分行讀取觀測值的數(shù)據(jù),將其存入觀測值數(shù)組 { sf.ReadString(strLine); CString*pstrData=SplitString(strLine,',',n); m_pDhObs[i].cpBackObj=SearchPointUsingID(pstrData[0]);//后視點(diǎn) m_pDhObs[i].cpFrontObj=SearchPointUsingID(pstrData[1]);//前視點(diǎn) m_pDhObs[i].HObsValue=_tstof(pstrData[2]);//高差觀測值 m_pDhObs[i].Dist=_tstof(pstrData[3]);//距離觀測值delete[]pstrData; pstrData=NULL; } sf.Close();return1;}CString*AdjustLevel::SplitString(CStringstr,charsplit,int&iSubStrs){intiPos=0;//分割符位置intiNums=0;//分割符的總數(shù)CStringstrTemp=str;CStringstrRight;//先計(jì)算子字符串的數(shù)量while(iPos!=-1){iPos=strTemp.Find(split);if(iPos==-1){break;}strRight=strTemp.Mid(iPos+1,str.GetLength());strTemp=strRight;iNums++;}if(iNums==0)//沒有找到分割符{//子字符串?dāng)?shù)就是字符串本身iSubStrs=1;returnNULL;}//子字符串?dāng)?shù)組iSubStrs=iNums+1;//子串的數(shù)量=分割符數(shù)量+1CString*pStrSplit;pStrSplit=newCString[iSubStrs];strTemp=str;CStringstrLeft;for(inti=0;i<iNums;i++){iPos=strTemp.Find(split);//左子串strLeft=strTemp.Left(iPos);//右子串strRight=strTemp.Mid(iPos+1,strTemp.GetLength());strTemp=strRight;pStrSplit[i]=strLeft;}pStrSplit[iNums]=strTemp;returnpStrSplit;}//LevelControlPoint*AdjustLevel::SearchKnownPointUsingID(CStringID){for(inti=0;i<m_iKnownPointCount;i++) {if(m_pKnownPoint[i].strID==ID) {return&m_pKnownPoint[i];} }returnNULL;}//LevelControlPoint*AdjustLevel::SearchUnknownPointUsingID(CStringID){for(inti=0;i<m_iUnknownPointCount;i++) {if(m_pUnknownPoint[i].strID==ID) {return&m_pUnknownPoint[i];} }returnNULL;}LevelControlPoint*AdjustLevel::SearchPointUsingID(CStringID){ LevelControlPoint*cp; cp=SearchKnownPointUsingID(ID);if(cp==NULL) cp=SearchUnknownPointUsingID(ID);returncp;}voidAdjustLevel::ApproHeignt(void)//用于計(jì)算高程近似值的函數(shù){for(inti=0;i<m_iUnknownPointCount;i++)//計(jì)算未知點(diǎn)高程值 {if(m_pUnknownPoint[i].flag!=1) {//先在未知點(diǎn)作為觀測值的前視點(diǎn)的情況for(intj=0;j<m_iDhObsCount;j++)//從觀測數(shù)組里找與未知點(diǎn)有關(guān)聯(lián)的點(diǎn) {//如果觀測值的前視點(diǎn)是未知點(diǎn)且其后視點(diǎn)已經(jīng)有高程值if((m_pDhObs[j].cpFrontObj->strID==m_pUnknownPoint[i].strID) &&m_pDhObs[j].cpBackObj->flag==1) {//前視點(diǎn)=后視點(diǎn)-高差/*m_pUnknownPoint[i].H=m_pDhObs[i].cpBackObj->H-m_pDhObs[i].ObsValue;*/ m_pUnknownPoint[i].H=m_pDhObs[j].cpBackObj->H+m_pDhObs[j].HObsValue; m_pUnknownPoint[i].flag=1;break; } }if(m_pUnknownPoint[i].flag!=1)//如果經(jīng)過上一步驟未知點(diǎn)仍沒有計(jì)算出近似值 {for(intj=0;j<m_iDhObsCount;j++)//從觀測數(shù)組里找與未知點(diǎn)有關(guān)聯(lián)的點(diǎn) {//如果觀測值的后視點(diǎn)是未知點(diǎn)且其前視點(diǎn)已經(jīng)有高程值if((m_pDhObs[j].cpBackObj->strID==m_pUnknownPoint[i].strID) &&m_pDhObs[j].cpFrontObj->flag==1) {//后視點(diǎn)=前視點(diǎn)+高差 m_pUnknownPoint[i].H=m_pDhObs[j].cpFrontObj->H-m_pDhObs[j].HObsValue;/*m_pUnknownPoint[i].H=m_pDhObs[i].cpFrontObj->H+m_pDhObs[i].ObsValue;*/ m_pUnknownPoint[i].flag=1;break; } } } }if(i==m_iUnknownPointCount-1)//如果已經(jīng)計(jì)算到最后一個(gè)未知點(diǎn) {for(inta=0;a<m_iUnknownPointCount;a++) {if(m_pUnknownPoint[i].flag!=1)//只要有一個(gè)未知點(diǎn)的近似高程直沒有計(jì)算 {//那么要重新進(jìn)展上面的步驟直到所有的未知點(diǎn)的近似高程值都計(jì)算出 i=-1;break; } } } }}CMatrixAdjustLevel::LevleWeight(void){ CMatrixp(m_iDhObsCount,m_iDhObsCount); p.Unit();doublevalue;for(inti=0;i<m_iDhObsCount;i++) { value=(1.0/m_pDhObs[i].Dist); p(i,i)=value; }returnp;}voidAdjustLevel::FormErrorEquation(CMatrix&B,CMatrix&L){ B.SetSize(m_iDhObsCount,m_iUnknownPointCount); L.SetSize(m_iDhObsCount,1);for(inti=0;i<m_iDhObsCount;i++)//建設(shè)B系數(shù)陣 { LevelControlPoint*tmpBack=NULL,*tmpFront=NULL; tmpBack=SearchPointUsingID(m_pDhObs[i].cpBackObj->strID); tmpFront=SearchPointUsingID(m_pDhObs[i].cpFrontObj->strID);//找到與第i個(gè)觀測值有關(guān)的未知點(diǎn) tmpBack->strID;for(intj=0;j<m_iUnknownPointCount;j++) {if(m_pUnknownPoint[j].strID==tmpBack->strID)//如果是后視點(diǎn)那么前面的系數(shù)為-1 {B(i,j)=-1;continue; }if(m_pUnknownPoint[j].strID==tmpFront->strID)//如果是前視點(diǎn)那么前面的系數(shù)為 { B(i,j)=1; } } }//建設(shè)L矩陣 CStringtmp;for(inti=0;i<m_iDhObsCount;i++) {//l=高差觀測值-〔后視近似值-前視近似值〕/*L(i,0)=m_pDhObs[i].ObsValue-(m_pDhObs[i].cpBackObj->H-m_pDhObs[i].cpFrontObj->H);*/ L(i,0)=m_pDhObs[i].HObsValue-(m_pDhObs[i].cpFrontObj->H-m_pDhObs[i].cpBackObj->H); tmp.Format(_T("%.3f"),L(i,0)); L(i,0)=_tstof(tmp); L(i,0)=L(i,0)*1000;//將單位化為mm }}voidAdjustLevel::EquationCompute(CMatrix&x)//計(jì)算法方程{ CMatrixP,B,l; P=LevleWeight();//P為權(quán)矩陣 FormErrorEquation(B,l); ApproHeignt(); CMatrixBT(m_iUnknownPointCount,m_iDhObsCount); BT=~B;//B的轉(zhuǎn)置矩陣 CMatrixNBB(m_iUnknownPointCount,m_iUnknownPointCount); NBB=BT*P*B; CMatrixNBBl=NBB.Inv(); x=NBBl*BT*P*l;for(inti=0;i<m_iUnknownPointCount;i++) { m_pUnknownPoint[i].H+=x(i,0);//未知點(diǎn)高程值=近似值+改正數(shù) }}voidAdjustLevel::Accuracy_Assessment(double&r0,CMatrix&Qxx)//精度評定{ CMatrixB,l,P,x; P=LevleWeight();//P為權(quán)矩陣 FormErrorEquation(B,l); EquationCompute(x); CMatrixv(m_iDhObsCount,1); v=B*x-l; CMatrixvT(1,m_iDhObsCount); vT=~v; CMatrixr/*(1,l)*/; r=vT*P*v; r0=sqrt(r(0,0)/(m_iDhObsCount-m_iUnknownPointCount));//單位權(quán)中誤差 Qxx.SetSize(m_iUnknownPointCount,m_iUnknownPointCount); CMatrixBT(m_iUnknownPointCount,m_iDhObsCount); BT=~B; CMatrixNBB(m_iUnknownPointCount,m_iUnknownPointCount); NBB=BT*P*B; Qxx=NBB.Inv();}voidAdjustLevel::CompAdjust(double&r0,CMatrixQx[]){ ApproHeignt();//計(jì)算未知點(diǎn)的近似高程值并且存入數(shù)組 CMatrixP(m_iDhObsCount,m_iDhObsCount); P=LevleWeight();//p為權(quán)矩陣 CMatrixB,L; CMatrixx,Qxx; FormErrorEquation(B,L);//組成誤差方程,B為系數(shù)矩陣,l為常數(shù)項(xiàng) EquationCompute(x);//計(jì)算法方程 Accuracy_Assessment(r0,Qxx);//精度評定for(inti=0;i<m_iUnknownPointCount;i++)//未知點(diǎn)高程中誤差 { Qx[i]=sqrt(Qxx(i,i))*r0; }}#include"Matrix.h"#include"locale.h"#include"LevelControlPoint.h"#include"AdjustLevel.h"AdjustLevelLevelComput;CString*SplitString(CStringstr,charsplit,int&iSubStrs){intiPos=0;//分割符位置intiNums=0;//分割符的總數(shù)CStringstrTemp=str;CStringstrRight;//先計(jì)算子字符串的數(shù)量while(iPos!=-1){iPos=strTemp.Find(split);if(iPos==-1){break;}strRight=strTemp.Mid(iPos+1,str.GetLength());strTemp=strRight;iNums++;}if(iNums==0)//沒有找到分割符{//子字符串?dāng)?shù)就是字符串本身iSubStrs=1;returnNULL;}//子字符串?dāng)?shù)組iSubStrs=iNums+1;//子串的數(shù)量=分割符數(shù)量+1CString*pStrSplit;pStrSplit=newCString[iSubStrs];strTemp=str;CStringstrLeft;for(inti=0;i<iNums;i++){iPos=strTemp.Find(split);//左子串strLeft=strTemp.Left(iPos);//右子串strRight=strTemp.Mid(iPos+1,strTemp.GetLength());strTemp=strRight;pStrSplit[i]=strLeft;}pStrSplit[iNums]=strTemp;returnpStrSplit;}voidCIndircLelveDlg::OnBnClickedOpendatafile(){//TODO:在此添加控件通知處理程序代碼 UpdateData(TRUE); CFileDialogdlgFile(TRUE,_T("txt"),NULL,OFN_ALLOWMULTISELECT|OFN_EXPLORER, _T("(文本文件)|*.txt"));//創(chuàng)立文件對話框if(dlgFile.DoModal()==IDCANCEL)return;//如果選擇取消按鈕那么返回 CStringstrFileName=dlgFile.GetPathName();//翻開獲取文件文件名 setlocale(LC_ALL,"");//設(shè)置語言環(huán)境 CStdioFilesf;if(!sf.Open(strFileName,CFile::modeRead))return; InputContent.Empty();//清空字符串str_openContent中的內(nèi)容 CStringstrLine; BOOLbEOF=sf.ReadString(strLine);//讀取第一行數(shù)據(jù)while(bEOF)//開場讀取頂點(diǎn)數(shù)據(jù) { bEOF=sf.ReadString(strLine);if(bEOF) InputContent+=strLine+_T("\r\n"); } sf.Close(); UpdateData(FALSE);}voidCIndircLelveDlg::OnBnClickedSavedata(){//TODO:在此添加控件通知處理程序代碼 UpdateData(TRUE); CFileDialogdlgFile(FALSE,_T("txt"),NULL,OFN_EXPLORER, _T("(Level格式)|*.txt"));if(dlgFile.DoModal()==IDCANCEL)return; CStringstrFileName=dlgFile.GetPathName(); setlocale(LC_ALL,""); CStdioFilesf;if(!sf.Open(strFileName,CFile::modeCreate|CFile::modeWrite))return; sf.WriteString(LevleContent); sf.Close(); UpdateData(FALSE);}voidCIndircLelveDlg::OnBnClickedComputelevel(){//TODO:在此添加控件通知處理程序代碼 UpdateData(TRUE);setlocale(LC_ALL,"");double*Qx=newdouble[LevelComput.m_iUnknownPointCount];doubler0; LevelComput.CompAdjust(r0,Qx); LevleContent.Format(_T("平差后高程值:\r\n")); CStringTemp;for(inti=0;i<LevelComput.m_iUnknownPointCount;i++) { Temp.Empty(); Temp.Format(_T("%s,%.4f\r\n

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論