測(cè)繪程序設(shè)計(jì)—實(shí)驗(yàn)八 水準(zhǔn)網(wǎng)平差程序設(shè)計(jì)報(bào)告_第1頁(yè)
測(cè)繪程序設(shè)計(jì)—實(shí)驗(yàn)八 水準(zhǔn)網(wǎng)平差程序設(shè)計(jì)報(bào)告_第2頁(yè)
測(cè)繪程序設(shè)計(jì)—實(shí)驗(yàn)八 水準(zhǔn)網(wǎng)平差程序設(shè)計(jì)報(bào)告_第3頁(yè)
測(cè)繪程序設(shè)計(jì)—實(shí)驗(yàn)八 水準(zhǔn)網(wǎng)平差程序設(shè)計(jì)報(bào)告_第4頁(yè)
測(cè)繪程序設(shè)計(jì)—實(shí)驗(yàn)八 水準(zhǔn)網(wǎng)平差程序設(shè)計(jì)報(bào)告_第5頁(yè)
已閱讀5頁(yè),還剩14頁(yè)未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡(jiǎn)介

1、;測(cè)繪程序設(shè)計(jì)(VC.net)上機(jī)實(shí)驗(yàn)報(bào)告(Visual C+.Net)班 級(jí): 測(cè)繪0901班 學(xué) 號(hào): 0405090204 姓 名: 代婭琴 2012年4月29日實(shí)驗(yàn)八 平差程序設(shè)計(jì)基礎(chǔ)一、 實(shí)驗(yàn)?zāi)康?鞏固過(guò)程的定義與調(diào)用 鞏固類的創(chuàng)建與使用 鞏固間接平差模型及平差計(jì)算 掌握平差程序設(shè)計(jì)的基本技巧與步驟二、 實(shí)驗(yàn)內(nèi)容水準(zhǔn)網(wǎng)平差程序設(shè)計(jì)。設(shè)計(jì)一個(gè)水準(zhǔn)網(wǎng)平差的程序,要求數(shù)據(jù)從文件中讀取,計(jì)算部分與界面無(wú)關(guān)。1. 水準(zhǔn)網(wǎng)間接平差模型:2. 計(jì)算示例:近似高程計(jì)算:3. 水準(zhǔn)網(wǎng)平差計(jì)算一般步驟(1)讀取觀測(cè)數(shù)據(jù)和已知數(shù)據(jù);(2)計(jì)算未知點(diǎn)高程近似值;(3)列高差觀測(cè)值誤差方程;(4)根據(jù)水準(zhǔn)路線

2、長(zhǎng)度計(jì)算高差觀測(cè)值的權(quán);(5)組成法方程;(6)解法方程,求得未知點(diǎn)高程改正數(shù)及平差后高程值;(7)求高差觀測(cè)值殘差及平差后高差觀測(cè)值;(8)精度評(píng)定;(9)輸出平差結(jié)果。4. 水準(zhǔn)網(wǎng)高程近似值計(jì)算算法 5. 輸入數(shù)據(jù)格式示例實(shí)驗(yàn)代碼:#pragma onceclass LevelControlPointpublic:LevelControlPoint(void);LevelControlPoint(void);public:CString strName;/點(diǎn)名CString strID;/點(diǎn)號(hào)float H;bool flag;/標(biāo)記是否已經(jīng)計(jì)算出近似高程值,若計(jì)算出則為,否則為;clas

3、s CDhObspublic:CDhObs(void);CDhObs(void);public:LevelControlPoint* cpBackObj;/后視點(diǎn)LevelControlPoint* cpFrontObj;/前視點(diǎn)double ObsValue;/高差值double Dist;/測(cè)站的距離;#include StdAfx.h#include LevelControlPoint.hLevelControlPoint:LevelControlPoint(void)strName=_T();strID=_T();H=0;flag=0;LevelControlPoint:LevelCo

4、ntrolPoint(void)CDhObs:CDhObs(void)CDhObs:CDhObs(void)#pragma once#includeLevelControlPoint.h#include Matrix.hclass AdjustLevelpublic:AdjustLevel(void);AdjustLevel(void);public:LevelControlPoint* m_pKnownPoint;/已知點(diǎn)數(shù)組int m_iKnownPointCount;/已知點(diǎn)個(gè)數(shù)LevelControlPoint* m_pUnknownPoint;/未知點(diǎn)數(shù)組int m_iUnknown

5、PointCount;/未知點(diǎn)個(gè)數(shù)CDhObs* m_pDhObs;/高差觀測(cè)值數(shù)組int m_iDhObsCount;/高差觀測(cè)值個(gè)數(shù)public:void SetKnownPointSize(int size);/創(chuàng)建大小為size的已知點(diǎn)數(shù)組void SetUnkonwnPointSize(int size);/創(chuàng)建大小為size的未知點(diǎn)數(shù)組void SetDhObsSize(int size);/創(chuàng)建大小為size的觀測(cè)值數(shù)組bool LoadObsData(const CString& strFile);/讀入觀測(cè)文件CString* SplitString(CString str,

6、 char split, int& iSubStrs); void ApproHeignt(void);/計(jì)算近似值private:LevelControlPoint* SearchKnownPointUsingID(CString ID);LevelControlPoint* SearchUnknownPointUsingID(CString ID);LevelControlPoint* SearchPointUsingID(CString ID); CMatrix LevleWeight(void);/計(jì)算權(quán)矩陣public:void FormErrorEquation(CMatrix &

7、B, CMatrix &L);/組成誤差方程 void EquationCompute(CMatrix &x);/計(jì)算法方程void Accuracy_Assessment(double &r0,CMatrix &Qxx);/精度評(píng)定void CompAdjust(double &r0,CMatrix Qx);#include StdAfx.h#include AdjustLevel.h#include #include LevelControlPoint.h#include math.hAdjustLevel:AdjustLevel(void)m_pKnownPoint=NULL;/已知點(diǎn)數(shù)

8、組m_iKnownPointCount=0;/已知點(diǎn)個(gè)數(shù)m_pUnknownPoint=NULL;/未知點(diǎn)數(shù)組m_iUnknownPointCount=0;/未知點(diǎn)個(gè)數(shù)m_pDhObs=NULL;/高差觀測(cè)值數(shù)組m_iDhObsCount=0;/高差觀測(cè)值個(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_pDhO

9、bs!=NULL)delete m_pDhObs;m_pDhObs=NULL;void AdjustLevel:SetKnownPointSize(int size)m_pKnownPoint=new LevelControlPointsize;/創(chuàng)建動(dòng)態(tài)指針m_iKnownPointCount=size;void AdjustLevel:SetUnkonwnPointSize(int size)m_pUnknownPoint=new LevelControlPointsize;m_iUnknownPointCount=size;void AdjustLevel:SetDhObsSize(in

10、t size)m_pDhObs=new CDhObssize;m_iDhObsCount=size;/高差觀測(cè)值個(gè)數(shù)bool AdjustLevel:LoadObsData(const CString& strFile)CStdioFile sf;if(!sf.Open(strFile,CFile:modeRead) return false;/創(chuàng)建并打開(kāi)文件對(duì)象CString strLine;bool bEOF=sf.ReadString(strLine);/讀取第一行,即已知點(diǎn)的數(shù)目SetKnownPointSize(_ttoi(strLine);/根據(jù)已知點(diǎn)的數(shù)目,創(chuàng)建已知點(diǎn)數(shù)組;int

11、 n=0;for(int i=0;im_iKnownPointCount;i+)/讀取已知點(diǎn)的點(diǎn)名和高程值sf.ReadString(strLine);CString *pstrData=SplitString(strLine,n);m_pKnownPointi.strName=pstrData0;m_pKnownPointi.strID=pstrData0;m_pKnownPointi.H=_tstof(pstrData1);m_pKnownPointi.flag=1;/已知點(diǎn)不用平差,故將其的flag設(shè)置為delete pstrData;pstrData=NULL;sf.ReadStrin

12、g(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(int i=0;im_iUnknownPointCount;i+)/將未知點(diǎn)的點(diǎn)名放入未知點(diǎn)數(shù)組m_pUnknownPointi.strName=pstrDatai;m_pUnknownPointi.strID=pstrDatai;m_pUnknownPointi.H=0;/未知點(diǎn)的高程值設(shè)置為m_pU

13、nknownPointi.flag=0;/還沒(méi)有求得近似高程,故其flag設(shè)置為if(pstrData!=NULL)delete pstrData;pstrData=NULL;sf.ReadString(strLine);/讀取觀測(cè)值的個(gè)數(shù)SetDhObsSize(_ttoi(strLine);/按照觀測(cè)值的大小,創(chuàng)建觀測(cè)值數(shù)組for(int i=0;im_iDhObsCount;i+)/分行讀取觀測(cè)值的數(shù)據(jù),將其存入觀測(cè)值數(shù)組sf.ReadString(strLine);CString *pstrData=SplitString(strLine,n);m_pDhObsi.cpBackObj=

14、SearchPointUsingID(pstrData0);/后視點(diǎn)m_pDhObsi.cpFrontObj=SearchPointUsingID(pstrData1);/前視點(diǎn)m_pDhObsi.HObsValue=_tstof(pstrData2);/高差觀測(cè)值m_pDhObsi.Dist=_tstof(pstrData3);/距離觀測(cè)值delete pstrData;pstrData=NULL;sf.Close();return 1;CString* AdjustLevel:SplitString(CString str, char split, int& iSubStrs)int iP

15、os = 0; /分割符位置 int iNums = 0; /分割符的總數(shù) CString strTemp = str; CString strRight; /先計(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) /沒(méi)有找到分割符 /子字符串?dāng)?shù)就是字符串本身 iSubStrs = 1; return NUL

16、L; /子字符串?dāng)?shù)組 iSubStrs = iNums + 1; /子串的數(shù)量= 分割符數(shù)量+ 1 CString* pStrSplit; pStrSplit = new CStringiSubStrs; strTemp = str; CString strLeft; for (int i = 0; i iNums; i+) iPos = strTemp.Find(split); /左子串 strLeft = strTemp.Left(iPos); /右子串 strRight = strTemp.Mid(iPos + 1, strTemp.GetLength(); strTemp = strR

17、ight; pStrSpliti = strLeft; pStrSplitiNums = strTemp; return pStrSplit;/LevelControlPoint* AdjustLevel:SearchKnownPointUsingID(CString ID)for(int i=0;im_iKnownPointCount;i+)if(m_pKnownPointi.strID=ID)return &m_pKnownPointi;return NULL;/LevelControlPoint* AdjustLevel:SearchUnknownPointUsingID(CString

18、 ID)for(int i=0;im_iUnknownPointCount;i+)if(m_pUnknownPointi.strID=ID)return &m_pUnknownPointi;return NULL;LevelControlPoint* AdjustLevel:SearchPointUsingID(CString ID)LevelControlPoint* cp;cp=SearchKnownPointUsingID(ID);if(cp=NULL)cp=SearchUnknownPointUsingID(ID);return cp;void AdjustLevel:ApproHei

19、gnt(void)/用于計(jì)算高程近似值的函數(shù)for(int i=0;im_iUnknownPointCount;i+)/計(jì)算未知點(diǎn)高程值if(m_pUnknownPointi.flag!=1)/先在未知點(diǎn)作為觀測(cè)值的前視點(diǎn)的情況for(int j=0;jstrID=m_pUnknownPointi.strID)& m_pDhObsj.cpBackObj-flag=1 ) /前視點(diǎn)=后視點(diǎn)-高差/*m_pUnknownPointi.H=m_pDhObsi.cpBackObj-H - m_pDhObsi.ObsValue;*/m_pUnknownPointi.H=m_pDhObsj.cpBackO

20、bj-H + m_pDhObsj.HObsValue;m_pUnknownPointi.flag=1; break;if(m_pUnknownPointi.flag!=1)/如果經(jīng)過(guò)上一步驟未知點(diǎn)仍沒(méi)有計(jì)算出近似值for(int j=0;jstrID=m_pUnknownPointi.strID)& m_pDhObsj.cpFrontObj-flag=1 ) /后視點(diǎn)=前視點(diǎn)+高差 m_pUnknownPointi.H=m_pDhObsj.cpFrontObj-H-m_pDhObsj.HObsValue; /* m_pUnknownPointi.H=m_pDhObsi.cpFrontObj-H

21、+m_pDhObsi.ObsValue;*/ m_pUnknownPointi.flag=1; break; if(i=m_iUnknownPointCount-1)/如果已經(jīng)計(jì)算到最后一個(gè)未知點(diǎn)for(int a=0;am_iUnknownPointCount;a+)if(m_pUnknownPointi.flag!=1)/只要有一個(gè)未知點(diǎn)的近似高程直沒(méi)有計(jì)算 /則要重新進(jìn)行上面的步驟直到所有的未知點(diǎn)的近似高程值都計(jì)算出i=-1;break;CMatrix AdjustLevel:LevleWeight(void)CMatrix p(m_iDhObsCount,m_iDhObsCount);

22、p.Unit();double value;for(int i=0;im_iDhObsCount;i+)value=(1.0/m_pDhObsi.Dist);p(i,i)=value;return p;void AdjustLevel:FormErrorEquation(CMatrix &B, CMatrix &L)B.SetSize(m_iDhObsCount,m_iUnknownPointCount);L.SetSize(m_iDhObsCount,1);for(int i=0;istrID);tmpFront=SearchPointUsingID(m_pDhObsi.cpFrontObj

23、-strID);/找到與第i個(gè)觀測(cè)值有關(guān)的未知點(diǎn)tmpBack-strID;for(int j=0;jstrID)/如果是后視點(diǎn)則前面的系數(shù)為-1 B(i,j)=-1;continue;if(m_pUnknownPointj.strID=tmpFront-strID)/如果是前視點(diǎn)則前面的系數(shù)為 B(i,j)=1;/建立L矩陣 CString tmp;for(int i=0;iH-m_pDhObsi.cpFrontObj-H);*/L(i,0)=m_pDhObsi.HObsValue-(m_pDhObsi.cpFrontObj-H - m_pDhObsi.cpBackObj-H);tmp.Fo

24、rmat(_T(%.3f),L(i,0);L(i,0)=_tstof(tmp);L(i,0)=L(i,0)*1000;/將單位化為mmvoid AdjustLevel:EquationCompute(CMatrix &x)/計(jì)算法方程CMatrix P,B,l;P=LevleWeight(); /P為權(quán)矩陣FormErrorEquation(B,l);ApproHeignt();CMatrix BT(m_iUnknownPointCount,m_iDhObsCount);BT=B; /B的轉(zhuǎn)置矩陣CMatrix NBB(m_iUnknownPointCount,m_iUnknownPointC

25、ount);NBB=BT*P*B;CMatrix NBBl=NBB.Inv();x=NBBl*BT*P*l;for(int i=0;im_iUnknownPointCount;i+)m_pUnknownPointi.H+=x(i,0);/未知點(diǎn)高程值=近似值+改正數(shù)void AdjustLevel:Accuracy_Assessment(double &r0,CMatrix &Qxx)/精度評(píng)定CMatrix B,l,P,x;P=LevleWeight(); /P為權(quán)矩陣FormErrorEquation(B,l);EquationCompute(x);CMatrix v(m_iDhObsCo

26、unt,1);v=B*x-l;CMatrix vT(1,m_iDhObsCount);vT=v;CMatrix r/*(1,l)*/;r=vT*P*v;r0=sqrt(r(0,0)/(m_iDhObsCount-m_iUnknownPointCount);/單位權(quán)中誤差Qxx.SetSize(m_iUnknownPointCount,m_iUnknownPointCount);CMatrix BT(m_iUnknownPointCount,m_iDhObsCount);BT=B;CMatrix NBB(m_iUnknownPointCount,m_iUnknownPointCount);NBB

27、=BT*P*B;Qxx=NBB.Inv();void AdjustLevel:CompAdjust(double &r0,CMatrix Qx)ApproHeignt();/計(jì)算未知點(diǎn)的近似高程值并且存入數(shù)組CMatrix P(m_iDhObsCount,m_iDhObsCount);P=LevleWeight();/p為權(quán)矩陣CMatrix B,L;CMatrix x,Qxx;FormErrorEquation(B,L);/組成誤差方程,B為系數(shù)矩陣,l為常數(shù)項(xiàng)EquationCompute(x);/計(jì)算法方程Accuracy_Assessment(r0,Qxx);/精度評(píng)定for(int

28、i=0;im_iUnknownPointCount;i+)/未知點(diǎn)高程中誤差Qxi=sqrt(Qxx(i,i)*r0;#include Matrix.h#include locale.h#include LevelControlPoint.h#include AdjustLevel.hAdjustLevel LevelComput;CString* SplitString(CString str, char split, int& iSubStrs)int iPos = 0; /分割符位置 int iNums = 0; /分割符的總數(shù) CString strTemp = str; CStrin

29、g strRight; /先計(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) /沒(méi)有找到分割符 /子字符串?dāng)?shù)就是字符串本身 iSubStrs = 1; return NULL; /子字符串?dāng)?shù)組 iSubStrs = iNums + 1; /子串的數(shù)量= 分割符數(shù)量+ 1 CString* pStrSpli

30、t; pStrSplit = new CStringiSubStrs; strTemp = str; CString strLeft; for (int i = 0; i iNums; i+) iPos = strTemp.Find(split); /左子串 strLeft = strTemp.Left(iPos); /右子串 strRight = strTemp.Mid(iPos + 1, strTemp.GetLength(); strTemp = strRight; pStrSpliti = strLeft; pStrSplitiNums = strTemp; return pStrSp

31、lit;void CIndircLelveDlg:OnBnClickedOpendatafile()/ TODO: 在此添加控件通知處理程序代碼UpdateData(TRUE);CFileDialog dlgFile(TRUE,_T(txt),NULL,OFN_ALLOWMULTISELECT|OFN_EXPLORER,_T(文本文件)|*.txt);/創(chuàng)建文件對(duì)話框if(dlgFile.DoModal()=IDCANCEL) return;/如果選擇取消按鈕則返回CString strFileName=dlgFile.GetPathName();/打開(kāi)獲取文件文件名setlocale(LC_

32、ALL,); /設(shè)置語(yǔ)言環(huán)境CStdioFile sf;if(!sf.Open(strFileName, CFile:modeRead) return;InputContent.Empty();/清空字符串str_openContent中的內(nèi)容CString strLine;BOOL bEOF=sf.ReadString(strLine);/讀取第一行數(shù)據(jù)while(bEOF)/開(kāi)始讀取頂點(diǎn)數(shù)據(jù)bEOF=sf.ReadString(strLine); if(bEOF) InputContent+=strLine+_T(rn); sf.Close();UpdateData(FALSE);void

33、 CIndircLelveDlg:OnBnClickedSavedata()/ TODO: 在此添加控件通知處理程序代碼 UpdateData(TRUE);CFileDialog dlgFile(FALSE,_T(txt),NULL,OFN_EXPLORER,_T(Level格式)|*.txt);if(dlgFile.DoModal()=IDCANCEL) return;CString strFileName=dlgFile.GetPathName();setlocale(LC_ALL,); CStdioFile sf;if(!sf.Open(strFileName, CFile:modeCr

34、eate|CFile:modeWrite) return;sf.WriteString(LevleContent);sf.Close();UpdateData(FALSE);void CIndircLelveDlg:OnBnClickedComputelevel()/ TODO: 在此添加控件通知處理程序代碼UpdateData(TRUE); setlocale(LC_ALL,); double *Qx=new doubleLevelComput.m_iUnknownPointCount;double r0;LevelComput.CompAdjust(r0,Qx);LevleContent.Format(_T(平差后高程值:rn);CString Temp;for(int i=0;iLevelComput.m_iUnknownPointCount;i+) Temp.Empty();Temp.Format(_T(%s,%.4frn), LevelComput.m_pUnknownPointi.strID,LevelComput.m_pUnknownPointi.H);LevleContent+=Temp;Temp.Format(_T(單位權(quán)中誤差:%.1f mmrn),r0

溫馨提示

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

最新文檔

評(píng)論

0/150

提交評(píng)論