




已阅读5页,还剩21页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
此次作业主要采用C+语言编写程序,同时利用了matlab进行格网点以及DEM三维显示。主要程序如下:#include StdAfx.h#include IDW.h#include IDWDlg.h#include math.h#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE = _FILE_;#endif/*/* CAboutDlg dialog used for App About */*/class CAboutDlg : public CDialogpublic:CAboutDlg();/ Dialog Data/AFX_DATA(CAboutDlg)enum IDD = IDD_ABOUTBOX ;/AFX_DATA/ ClassWizard generated virtual function overrides/AFX_VIRTUAL(CAboutDlg)protected:virtual void DoDataExchange(CDataExchange* pDX); / DDX/DDV support/AFX_VIRTUAL/ Implementationprotected:/AFX_MSG(CAboutDlg)/AFX_MSGDECLARE_MESSAGE_MAP();CAboutDlg:CAboutDlg() : CDialog(CAboutDlg:IDD)/AFX_DATA_INIT(CAboutDlg)/AFX_DATA_INITvoid CAboutDlg:DoDataExchange(CDataExchange* pDX)CDialog:DoDataExchange(pDX);/AFX_DATA_MAP(CAboutDlg)/AFX_DATA_MAPBEGIN_MESSAGE_MAP(CAboutDlg, CDialog)/AFX_MSG_MAP(CAboutDlg)/ No message handlers/AFX_MSG_MAPEND_MESSAGE_MAP()/*/* CIDWDlg dialog */*/CIDWDlg:CIDWDlg(CWnd* pParent /*=NULL*/): CDialog(CIDWDlg:IDD, pParent)/AFX_DATA_INIT(CIDWDlg)m_strOpenFileName = _T();m_strSaveFileName = _T();m_maxX = 0;m_maxY = 0;m_minX = 0;m_minY = 0;m_rad = 100.0f;m_stepDis = 100.0f;/AFX_DATA_INIT/ Note that LoadIcon does not require a subsequent DestroyIcon in Win32m_hIcon = AfxGetApp()-LoadIcon(IDR_MAINFRAME);void CIDWDlg:DoDataExchange(CDataExchange* pDX)CDialog:DoDataExchange(pDX);/AFX_DATA_MAP(CIDWDlg)DDX_Control(pDX, IDC_PROGRESS1, m_ctrProgress);DDX_Text(pDX, IDC_OPEN_FILE, m_strOpenFileName);DDX_Text(pDX, IDC_SAVE_FILE, m_strSaveFileName);DDX_Text(pDX, IDC_EDIT_MAX_X, m_maxX);DDX_Text(pDX, IDC_EDIT_MAX_Y, m_maxY);DDX_Text(pDX, IDC_EDIT_MIN_X, m_minX);DDX_Text(pDX, IDC_EDIT_MIN_Y, m_minY);DDX_Text(pDX, IDC_EDIT_RAD, m_rad);DDX_Text(pDX, IDC_EDIT_STEP_DIS, m_stepDis);/AFX_DATA_MAPBEGIN_MESSAGE_MAP(CIDWDlg, CDialog)/AFX_MSG_MAP(CIDWDlg)ON_WM_SYSCOMMAND()ON_WM_PAINT()ON_WM_QUERYDRAGICON()ON_BN_CLICKED(IDB_SOURCE_FILE, OnSourceFile)ON_BN_CLICKED(IDB_OUTPUT, OnOutput)ON_BN_CLICKED(IDB_AIM_FILE, OnAimFile)ON_EN_CHANGE(IDC_EDIT_RAD, OnChangeEditRad)ON_EN_CHANGE(IDC_EDIT_STEP_DIS, OnChangeEditStepDis)ON_EN_CHANGE(IDC_EDIT_MIN_X, OnChangeEditMinX)ON_EN_CHANGE(IDC_EDIT_MAX_X, OnChangeEditMaxX)ON_EN_CHANGE(IDC_EDIT_MIN_Y, OnChangeEditMinY)ON_EN_CHANGE(IDC_EDIT_MAX_Y, OnChangeEditMaxY)ON_BN_CLICKED(IDC_BUTTON1, Onmean_weigth)ON_BN_CLICKED(IDC_BUTTON2, Onmean)ON_EN_CHANGE(IDC_OPEN_FILE, OnChangeOpenFile)ON_EN_CHANGE(IDC_SAVE_FILE, OnChangeSaveFile)/AFX_MSG_MAPEND_MESSAGE_MAP()/*/* CIDWDlg message handlers */*/BOOL CIDWDlg:OnInitDialog()CDialog:OnInitDialog();/ Add About. menu item to system menu./ IDM_ABOUTBOX must be in the system command range.ASSERT(IDM_ABOUTBOX & 0xFFF0) = IDM_ABOUTBOX);ASSERT(IDM_ABOUTBOX AppendMenu(MF_SEPARATOR);pSysMenu-AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);/ Set the icon for this dialog. The framework does this automatically/ when the applications main window is not a dialogSetIcon(m_hIcon, TRUE);/ Set big iconSetIcon(m_hIcon, FALSE);/ Set small icon/ TODO: Add extra initialization herem_maxX = 0;m_minX = 0;m_maxY = 0;m_minY = 0;m_rad = 100;m_stepDis = 100;UpdateData(FALSE);m_ctrProgress.SetPos(0);return TRUE; / return TRUE unless you set the focus to a controlvoid CIDWDlg:OnSysCommand(UINT nID, LPARAM lParam)if (nID & 0xFFF0) = IDM_ABOUTBOX)CAboutDlg dlgAbout;dlgAbout.DoModal();elseCDialog:OnSysCommand(nID, lParam);/ If you add a minimize button to your dialog, you will need the code below/ to draw the icon. For MFC applications using the document/view model,/ this is automatically done for you by the framework.void CIDWDlg:OnPaint() if (IsIconic()CPaintDC dc(this); / device context for paintingSendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);/ Center icon in client rectangleint cxIcon = GetSystemMetrics(SM_CXICON);int cyIcon = GetSystemMetrics(SM_CYICON);CRect rect;GetClientRect(&rect);int x = (rect.Width() - cxIcon + 1) / 2;int y = (rect.Height() - cyIcon + 1) / 2;/ Draw the icondc.DrawIcon(x, y, m_hIcon);elseCDialog:OnPaint();/ the system calls this to obtain the cursor to display while the user drags/ the minimized window.HCURSOR CIDWDlg:OnQueryDragIcon()return (HCURSOR) m_hIcon;void CIDWDlg:OnSourceFile() CFileDialog FileDlg(TRUE,*.txt,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, 源数据文件(*.txt)|*.txt|All files (*.*)|*.*|); if(FileDlg.DoModal()=IDOK)m_strOpenFileName = FileDlg.GetPathName();UpdateData(false);elsereturn; /*/* open file and read data */*/FILE *pInputFile;if(pInputFile = fopen(m_strOpenFileName,r) = NULL)AfxMessageBox(打开文件失败!);pt ptTemp;while(!feof(pInputFile)fscanf(pInputFile,%d %f %f %f,&ptTemp.ID,&ptTemp.z,&ptTemp.x,&ptTemp.y);pt_source.push_back(ptTemp);fclose(pInputFile);/*/* 找出最大、最小坐标(x,y) */*/findMaxMin();void CIDWDlg:OnOutput() UpdateData(TRUE);if(m_strOpenFileName=)AfxMessageBox(请输入源数据文件!);return;if(m_strSaveFileName=)AfxMessageBox(请输入目标文件!);return;/*/* 进行插值计算 */*/ FILE *pOutputFile;if(pOutputFile = fopen(m_strSaveFileName,w) = NULL)AfxMessageBox(打开文件失败!);pt ptInsert;ptInsert.x = m_minX;ptInsert.y = m_minY;long i=0;while(ptInsert.x m_maxX)int i_temp = int(ptInsert.x - m_minX)/(m_maxX - m_minX)*100);m_ctrProgress.SetPos(i_temp);while(ptInsert.y m_maxY)ptInsert.z = calculate(ptInsert.x,ptInsert.y);if(ptInsert.z != 0) ptInsert.ID = i;i+;pt_output.push_back(ptInsert);ptInsert.y += m_stepDis;ptInsert.y = m_minY;ptInsert.x += m_stepDis; /*/* 写入插值数据 */*/pt_output_pos = pt_output.begin();while(pt_output_pos != pt_output.end()fprintf(pOutputFile,%d %f %f %fn,(*pt_output_pos).ID,(*pt_output_pos).x,(*pt_output_pos).y,(*pt_output_pos).z);/fprintf(pOutputFile,#n);pt_output_pos+;pt_output_pos = pt_output.begin();fclose(pOutputFile);AfxMessageBox(插值完成);UpdateData(TRUE);void CIDWDlg:OnAimFile() CFileDialog FileDlg(false,*.txt,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,源数据文件(*.txt)|*.txt|All files (*.*)|*.*|); if(FileDlg.DoModal() = IDOK)m_strSaveFileName = FileDlg.GetPathName();UpdateData(false);/*/* 计算所插值点的高程值 */*/float CIDWDlg:calculate(float x, float y)float dis,weigth; / 定义变量距离 dis,权 weigthfloat denominator = 0; / 定义变量分母 denominatorfloat numerator = 0; / 定义变量分子 numeratorfloat z0 = 0; / 待插值点高程 z0int extend_radius = m_rad; / 扩大搜索半径extend_radiuswhile( denominator = 0)pt_source_pos = pt_source.begin();while(pt_source_pos != pt_source.end()dis = sqrt(*pt_source_pos).x-x)*(*pt_source_pos).x-x)+(*pt_source_pos).y-y)*(*pt_source_pos).y-y);if(dis extend_radius)weigth = dis*dis; denominator += 1/weigth;numerator += (*pt_source_pos).z*(1/weigth);pt_source_pos+;extend_radius = 2 * extend_radius;pt_source_pos = pt_source.begin();z0 = numerator/ denominator;return z0;void CIDWDlg:OnChangeEditRad() UpdateData(TRUE);void CIDWDlg:OnChangeEditStepDis() UpdateData(TRUE);void CIDWDlg:OnChangeEditMinX() UpdateData(TRUE);void CIDWDlg:OnChangeEditMaxX() UpdateData(TRUE);void CIDWDlg:OnChangeEditMinY() UpdateData(TRUE);void CIDWDlg:OnChangeEditMaxY() UpdateData(TRUE);/*/* 找出最大、最小坐标(x,y) */*/void CIDWDlg:findMaxMin()double maxX,minX,maxY,minY;for (list:iterator iter = pt_source.begin();iter != pt_source.end();+iter)if (iter = pt_source.begin()maxX = (*iter).x;minX = (*iter).x;maxY = (*iter).y;minY = (*iter).y;if (maxX (*iter).x)minX = (*iter).x;if (maxY (*iter).y)minY = (*iter).y;m_maxX = (int)maxX + 1;m_minX = (int)minX - 1;m_maxY = (int)maxY + 1;m_minY = (int)minY - 1;UpdateData(FALSE);2 程序运行界面:3成果:插值结果存放于result.txt。(设置参数情况为:影响半径=100米;间隔间距=100米的平面格网图如下。下面的图形均在MATLAB下显示); (1)平面格网图(x,y):(2) 显示三维格网(x,y,z):当影响(搜索)半径为50米,格网间距为100米时;当影响(搜索)半径设为200米时,三维格网图为:影响半径为300米时:影响半径为500米时:影响半径为1000时因此可以看出,影响半径的选择,影响三维格网图的显示效果。选取半径太小,DEM表面不连续(如影响半径为50时);而半径太大,表面虽然连续,但是不以表达特征地物、特征线等(如影响半径为1000时)。本次程序在计算插值点高程时,采用的方法是加权平均法,其中权weight = 1/dis*dis。LiDAR_Suite.exe软件下显示的二维平面图(左)、三维DEM(右)4 结果数据截图:IDXYZIDXYZ0 222359.000000 120030.000000 56.8946721 222359.000000 120130.000000 63.5487632 222359.000000 120230.000000 66.8222733 222359.000000 120330.000000 68.9182134 222359.000000 120430.000000 72.0360035 222359.000000 120530.000000 72.0360036 222359.000000 120630.000000 73.3626867 222359.000000 120730.000000 71.7050638 222359.000000 120830.000000 73.4823469 222359.000000 120930.000000 77.93103810 222359.000000 121030.000000 82.35630811 222359.000000 121130.000000 85.03476712 222359.000000 121230.000000 86.27735113 222359.000000 121330.000000 88.00556214 222359.000000 121430.000000 88.16001115 222359.000000 121530.000000 88.16000416 222359.000000 121630.000000 87.58000217 222359.000000 121730.000000 86.38835918 222459.000000 120030.000000 66.54547919 222459.000000 120130.000000 65.35403420 222459.000000 120230.000000 67.98102621 222459.000000 120330.000000 73.28327222 222459.000000 120430.000000 72.75889623 222459.000000 120530.000000 75.32065624 222459.000000 120630.000000 74.68244225 222459.000000 120730.000000 75.48496226 222459.000000 120830.000000 77.22891227 222459.000000 120930.000000 79.79261028 222459.000000 121030.000000 81.77906829 222459.000000 121130.000000 84.98799930 222459.000000 121230.000000 86.73400131 222459.000000 121330.000000 88.34636732 222459.000000 121430.000000 88.55020133 222459.000000 121530.000000 88.16000434 222459.000000 121630.000000 85.64279935 222459.000000 121730.000000 84.61591336 222559.000000 120030.000000 69.71230337 222559.000000 120130.000000 71.21983338 222559.000000 120230.000000 73.37088039 222559.000000 120330.000000 75.57486040 222559.000000 120430.000000 77.35074641 222559.000000 120530.000000 76.91207942 222559.000000 120630.000000 77.32417343 222559.000000 120730.000000 79.02600144 222559.000000 120830.000000 79.04277845 222559.000000 120930.000000 79.07000746 222559.000000 121030.000000 83.67399647 222559.000000 121130.000000 86.16790048 222559.000000 121230.000000 88.74021949 222559.000000 121330.000000 89.50605050 222559.000000 121430.000000 88.95241551 222559.000000 121530.000000 89.28728552 222559.000000 121630.000000 88.55290253 222559.000000 121730.000000 86.06051654 222659.000000 120030.000000 74.01983655 222659.000000 120130.000000 73.14118256 222659.000000 120230.000000 75.12170457 222659.000000 120330.000000 76.45298058 222659.000000 120430.000000 77.80014859 222659.000000 120530.000000 78.70509360 222659.000000 120630.000000 82.06000561 222659.000000 120730.000000 82.08527462 222659.000000 120830.000000 85.15139063 222659.000000 120930.000000 85.07785864 222659.000000 121030.000000 88.23118665 222659.000000 121130.000000 89.53510366 222659.000000 121230.000000 89.67107467 222659.000000 121330.000000 91.75585968 222659.000000 121430.000000 94.31259269 222659.000000 121530.000000 90.80799970 222659.000000 121630.000000 91.48762571 222659.000000 121730.000000 90.96522572 222759.000000 120030.000000 75.31543073 222759.000000 120130.000000 77.19864774 222759.000000 120230.000000 78.75997975 222759.000000 120330.000000 80.35845976 222759.000000 120430.000000 78.52027977 222759.000000 120530.000000 80.52720678 222759.000000 120630.000000 84.89228879 222759.000000 120730.000000 85.60224280 222759.000000 120830.000000 86.74149381 222759.000000 120930.000000 88.20811582 222759.000000 121030.000000 89.83458783 222759.000000 121130.000000 91.70600184 222759.000000 121230.000000 93.84709985 222759.000000 121330.000000 96.36588386 222759.000000 121430.000000 97.44234587 222759.000000 121530.000000 100.84999888 222759.000000 121630.000000 99.81341689 222759.000000 121730.000000 100.72377090 222859.000000 120030.000000 81.06153191 222859.000000 120130.000000 81.46543192 222859.000000 120230.000000 79.86985093 222859.000000 120330.000000 82.89903394 222859.000000 120430.000000 84.58963095 222859.000000 120530.000000 86.97399196 222859.000000 120630.000000 87.29199297 222859.000000 120730.000000 88.62865498 222859.000000 120830.000000 91.63699399 222859.000000 120930.000000 93.078850100 222859.000000 121030.000000 89.273994101 222859.000000 121130.000000 94.975632102 222859.000000 121230.000000 96.137993103 222859.000000 121330.000000 100.562439104 222859.000000 121430.000000 98.951248105 222859.000000 121530.000000 107.321632106 222859.000000 121630.000000 107.196747107 222859.000000 121730.000000 104.386627108 222959.000000 120030.000000 84.767166109 222959.000000 120130.000000 84.521965110 222959.000000 120230.000000 86.337006111 222959.000000 120330.000000 83.040001112 222959.000000 120430.000000 86.080116113 222959.000000 120530.000000 86.973999114 222959.000000 120630.000000 89.797958115 222959.000000 120730.000000 93.000000116 222959.000000 120830.000000 94.997421117 222959.000000 120930.000000 95.954628118 222959.000000 121030.000000 100.122002119 222959.000000 121130.000000 104.533997120 222959.000000 121230.000000 104.533997121 222959.000000 121330.000000 108.871201122 222959.000000 121430.000000 116.010147123 222959.000000 121530.000000 116.985420124 222959.000000 121630.000000 123.041290125 222959.000000 121730.000000 120.833534126 223059.000000 120030.000000 86.208046127 223059.000000 120130.000000 87.536545128 223059.000000 120230.000000 86.336998129 223059.000000 120330.000000 92.641228130 223059.000000 120430.000000 92.356125131 223059.000000 120530.000000 90.766235132 223059.000000 120630.000000 95.461990133 223059.000000 120730.000000 96.001297134 223059.000000 120830.000000 97.371498135 223059.000000 120930.000000 100.051361136 223059.000000 121030.000000 100.232140137 223059.000000 121130.000000 106.873436138 223059.000000 121230.000000 104.533989139 223059.000000 121330.000000 114.269997140 223059.000000 121430.000000 119.584259141 223059.000000 121530.000000 130.641586142 223059.000000 121630.000000 127.860664143 223059.000000 121730.000000 125.158440144 223159.000000 120030.000000 89.967010145 223159.000000 120130.000000 92.600945146 223159.000000 120230.000000 95.180092147 223159.000000 120330.000000 96.670418148 223159.000000 120430.000000 93.891090149 223159.000000 120530.000000 94.051140150 223159.000000 120630.000000 95.462006151 223159.000000 120730.000000 96.705826152 223159.000000 120830.000000 98.882324153 223159.000000 120930.000000 101.998276154 223159.000000 121030.000000 103.133675155 223159.000000 121130.000000 110.173363156 223159.000000 121230.000000 115.937393157 223159.000000 121330.000000 120.169456158 223159.000000 121430.000000 127.906540159 223159.000000 121530.000000 135.131424160 223159.000000 121630.000000 143.097214161 223159.000000 121730.000000 148.853210162 223259.000000 120030.000000 91.738838163 223259.000000 120130.000000
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年物资储备仓库消防安全知识测试题目
- 2025年美容美发技术实操模拟题及参考答案
- 七颗钻教学课件
- 中国功夫音乐教学课件
- 2025年物资储备仓库管理信息化应用技能测试题库及解析
- 2025年中级操作工考试必-备知识点炼油工艺原理及设备结构
- 2025年特岗教师招聘考试初中地理重点知识点解析与练习
- 2025年初级电工电路基础知识和实操模拟题及答案
- 2025年焊接工艺面试通关秘籍模拟题及答案解析
- 企业级SOA实施方法论的研究与探讨
- 2025至2030医学混合成像系统行业产业运行态势及投资规划深度研究报告
- 2025年云南省高校大学《辅导员》招聘考试题库及答案
- 2025年内蒙古交通集团考试笔试试题(含答案)
- 消费品市场2025年消费者对绿色包装认知及需求调研可行性研究报告
- 常见遗传性代谢疾病的早期诊断和治疗课件
- 工程项目成本核算制度
- um-joyo c2001跨平台监控防误一体化系统使用说明书
- 输液泵/微量注射泵使用技术操作考核评分标准
- 国家科学技术奖学科专业评审组评审范围简表
- PWM控制技术的最新科技成果-介绍ISL6752
- GB 25192-2022 食品安全国家标准 再制干酪和干酪制品
评论
0/150
提交评论