地图学实验报告课程:地图学班级:******学号: ******姓名:******实验目的及要求:1.利用计算机编程实现地图图幅编号的计算。
2.深化对地图图幅编号计算的原理,地图图幅编号的计算的理解,并掌握其计算步骤。
3.提高自己的计算机语言编程能力。
4.实验完成后提交报告,实验总结,编写代码,要独立编程,程序稳定可行。
工具:Visual C++ 6.0实验感悟:此次实验,首先认真学习了书中对地图分幅编号的计算。
首先在数据输入的编辑框中添加了判断语句,以确保编辑框中输入数据的可用性。
在旧的比例尺分幅计算中,有时W计算完成后需要转换成英文大写或小写字母,此处运用了ASCII码进行了转换。
最后根据课件内容对程序进行了调试、验证。
通过这次试验,熟悉了新旧两种地图分幅编号的计算。
程序运行结果:程序代码://地图分幅的计算void CMyDlg::OnCal(){// TODO: Add your control notification handler code hereUpdateData();//字符转换int LDeg = atoi(m_LDeg.Right(m_LDeg.GetLength()-1));double LMin = strtod(m_LSec,NULL);int BDeg = atoi(m_BDeg);double BMin = strtod(m_BSec,NULL);int index;index = ((CComboBox*)GetDlgItem(IDC_COMBO1))->GetCurSel()+1;int i,j,c,d,W,V,n;//W所求比例尺图幅代号n代表划分为该比例尺后的列数c列号d行号CString C,D;double l,b;//l,b分别表示经差和纬差i = (int)(BDeg/4.0)+1;CString s = m_LDeg.Left(1);CString s1;//判断东经西经if(s == "E" || s == "e"){j = (int) (floor(LDeg/6.0))+31;}else if(s == "W" || s == "w"){j = 31-(int)(floor(LDeg/6.0));}else{MessageBox("输入经度错误", "Error", MB_ICONERROR );}//1:100万基本比例尺图幅计算s = "";s.Format(_T("-%d"),j);Old = (int)(i+64);Old+=s;New = (int)(i+64);s.Format(_T(" %d"),j);New+=s;//1:10万基本比例尺计算V=133;l=30.0*60;b=20.0*60;n=12;W = V-(int)((((int)(BDeg*3600+BMin*60))%(4*3600))/((int)b))*n +(int)((((int)(LDeg*3600+LMin*60))%(6*3600))/((int)l));s1.Format(_T("-%d"),W);Old1=Old+s1;switch(index){case 1://1:100万m_Old=Old;m_New=New;break;case 2://1:50万V=3;l=3*3600.0;b=2*3600.0;n=2;//旧的分幅编号W = V-(int)((((int)(BDeg*3600+BMin*60))%(4*3600))/((int)b))*n +(int)((((int)(LDeg*3600+LMin*60))%(6*3600))/((int)l));s = (int)(W+64);Old += "-";m_Old=Old+s;//新的分幅编号c=(int)(4*3600/b)-(int)(((int)(BDeg*3600+BMin*60)%(4*3600))/b);d=(int)(((int)(LDeg*3600+LMin*60)/(6*3600))/l)+1;C.Format(_T("%.3d"),c);D.Format(_T("%.3d"),d);m_New = New + " B"+C+D;break;case 3://1:25万V=13;l=1.5*3600;b=1.0*3600;n=4;//旧的分幅编号W = V-(int)((((int)(BDeg*3600+BMin*60))%(4*3600))/((int)b))*n +(int)((((int)(LDeg*3600+LMin*60))%(6*3600))/((int)l));s.Format(_T("-[%d]"),W);m_Old=Old+s;//新的分幅编号c=(int)(4*3600/b)-(int)(((int)(BDeg*3600+BMin*60)%(4*3600))/b);d=(int)(((int)(LDeg*3600+LMin*60)%(6*3600))/l)+1;C.Format(_T("%.3d"),c);D.Format(_T("%.3d"),d);m_New=New+" C"+C+D;break;case 4://1:10万m_Old=Old1;//新的分幅编号c=(int)(4*3600/b)-(int)(((int)(BDeg*3600+BMin*60)%(4*3600))/b);d=(int)(((int)(LDeg*3600+LMin*60)%(6*3600))/l)+1;C.Format(_T("%.3d"),c);D.Format(_T("%.3d"),d);m_New=New+" C"+C+D;break;case 5://1:5万V=3;l=15.0*60;b=10.0*60;n=2;//旧的分幅编号W = V-(int)((((int)(BDeg*3600+BMin*60))%(20*60))/((int)b))*n +(int)((((int)(LDeg*3600+LMin*60))%(30*60))/((int)l));s=(int)(W+64);m_Old=Old1+"-"+s;//新的分幅编号c=(int)(4*3600/b)-(int)(((int)(BDeg*3600+BMin*60)%(4*3600))/b);d=(int)(((int)(LDeg*3600+LMin*60)%(6*3600))/l)+1;C.Format(_T("%.3d"),c);D.Format(_T("%.3d"),d);m_New=New+" D"+C+D;break;case 6://1:2.5万//1:5万编号计算V=3;l=15.0*60;b=10.0*60;n=2;W = V-(int)((((int)(BDeg*3600+BMin*60))%(20*60))/((int)b))*n +(int)((((int)(LDeg*3600+LMin*60))%(30*60))/((int)l));s=(int)(W+64);m_Old=Old1+"-"+s;V=3;l=7.5*60;b=5*60;n=2;//旧的分幅编号W = V-(int)((((int)(BDeg*3600+BMin*60))%(10*60))/((int)b))*n +(int)((((int)(LDeg*3600+LMin*60))%(15*60))/((int)l));s.Format(_T("-%d"),W);m_Old+=s;//新的分幅编号c=(int)(4*3600/b)-(int)(((int)(BDeg*3600+BMin*60)%(4*3600))/b);d=(int)(((int)(LDeg*3600+LMin*60)%(6*3600))/l)+1;C.Format(_T("%.3d"),c);D.Format(_T("%.3d"),d);m_New=New+" F"+C+D;break;case 7://1:1万V=57;l=3.75*60;b=2.5*60;n=8;//旧的分幅编号W = V-(int)((((int)(BDeg*3600+BMin*60))%(20*60))/((int)b))*n +(int)((((int)(LDeg*3600+LMin*60))%(30*60))/((int)l));s.Format(_T("-(%d)"),W);m_Old = Old1+s;//新的分幅编号c=(int)(4*3600/b)-(int)(((int)(BDeg*3600+BMin*60)%(4*3600))/b);d=(int)(((int)(LDeg*3600+LMin*60)%(6*3600))/l)+1;C.Format(_T("%.3d"),c);D.Format(_T("%.3d"),d);m_New=New+" G"+C+D;break;case 8://1:5000//1:1万基本比例尺计算V=57;l=3.75*60;b=2.5*60;n=8;W = V-(int)((((int)(BDeg*3600+BMin*60))%(20*60))/((int)b))*n +(int)((((int)(LDeg*3600+LMin*60))%(30*60))/((int)l));s.Format(_T("-(%d)"),W);m_Old = Old1+s;V=3;l=1.875*60;b=1.25*60;n=2;//旧的分幅编号W = V-(int)((((int)(BDeg*3600+BMin*60))%150)/((int)b))*n+(int)((((int)(LDeg*3600*60+LMin*60*60))%(225*60))/((int)(l*60)));s=(int)(W+96);m_Old+="-"+s;//新的分幅编号c=(int)(4*3600/b)-(int)(((int)(BDeg*3600+BMin*60)%(4*3600))/b);d=(int)(((int)(LDeg*3600+LMin*60)%(6*3600))/l)+1;C.Format(_T("%.3d"),c);D.Format(_T("%.3d"),d);m_New=New+" H"+C+D;break;}if(m_BDeg == "" || m_BSec == "" || m_LSec == "" || m_LDeg == ""){if (m_BDeg == "" && m_BSec == "" && m_LSec == "" &&(m_LDeg == "E" || m_LDeg == "W")){MessageBox("请输入经度、纬度","错误",MB_ICONERROR);m_Old = "";m_New = "";}else{MessageBox("系统将空白处自动赋值为0","提示",MB_ICONEXCLAMATION);}}UpdateData(false);}//对话框的初始设置BOOL CMyDlg::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 < 0xF000);CMenu* pSysMenu = GetSystemMenu(FALSE);if (pSysMenu != NULL){CString strAboutMenu;strAboutMenu.LoadString(IDS_ABOUTBOX);if (!strAboutMenu.IsEmpty()){pSysMenu->AppendMenu(MF_SEPARATOR);pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);}}// Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialogSetIcon(m_hIcon, TRUE); // Set big iconSetIcon(m_hIcon, FALSE); // Set small icon// TODO: Add extra initialization hereGetDlgItem(IDC_EDIT5)->EnableWindow(false);GetDlgItem(IDC_EDIT6)->EnableWindow(false);//设置图标m_hIcons[0] =LoadIcon(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDI_ICON1));m_hIcons[1] =LoadIcon(AfxGetApp()->m_hInstance,MAKEINTRESOURCE(IDI_ICON2));m_hIcons[2] =LoadIcon(AfxGetApp()->m_hInstance,MAKEINTRESOURCE(IDI_ICON3));m_hIcons[3] =LoadIcon(AfxGetApp()->m_hInstance,MAKEINTRESOURCE(IDI_ICON4));m_hIcons[4] =LoadIcon(AfxGetApp()->m_hInstance,MAKEINTRESOURCE(IDI_ICON5));m_hIcons[5] =LoadIcon(AfxGetApp()->m_hInstance,MAKEINTRESOURCE(IDI_ICON6));m_hIcons[6] =LoadIcon(AfxGetApp()->m_hInstance,MAKEINTRESOURCE(IDI_ICON7));SetClassLong(m_hWnd,GCL_HICON,(long)m_hIcons[0]);SetTimer(1,1000,NULL);//列表框((CComboBox*)GetDlgItem(IDC_COMBO1))->AddString("1:100万");((CComboBox*)GetDlgItem(IDC_COMBO1))->AddString("1:50万");((CComboBox*)GetDlgItem(IDC_COMBO1))->AddString("1:25万");((CComboBox*)GetDlgItem(IDC_COMBO1))->AddString("1:10万");((CComboBox*)GetDlgItem(IDC_COMBO1))->AddString("1:5万");((CComboBox*)GetDlgItem(IDC_COMBO1))->AddString("1:2.5万");((CComboBox*)GetDlgItem(IDC_COMBO1))->AddString("1:1万");((CComboBox*)GetDlgItem(IDC_COMBO1))->AddString("1:5000");((CComboBox*)GetDlgItem(IDC_COMBO1))->SetCurSel(0);//设置字体CFont * f;f = new CFont;f->CreateFont(18, // nHeight0, // nWidth0, // nEscapement0, // nOrientationFW_BOLD, // nWeightFALSE, // bItalicFALSE, // bUnderline0, // cStrikeOutANSI_CHARSET, // nCharSetOUT_DEFAULT_PRECIS, // nOutPrecisionCLIP_DEFAULT_PRECIS, // nClipPrecisionDEFAULT_QUALITY, // nQualityDEFAULT_PITCH | FF_SWISS, // nPitchAndFamily_T("宋体")); // lpszFacGetDlgItem(IDC_STATIC1)->SetFont(f);return TRUE; // return TRUE unless you set the focus to a control }void CMyDlg::OnQuit(){// TODO: Add your control notification handler code herethis->DestroyWindow();}void CMyDlg::OnTimer(UINT nIDEvent){// TODO: Add your message handler code here and/or call defaultstatic int index=1;SetClassLong(m_hWnd,GCL_HICON,(long)m_hIcons[index]);index = ++index%7;CDialog::OnTimer(nIDEvent);}void CMyDlg::OnHelp(){// TODO: Add your control notification handler code hereCAboutDlg dlgAbout;dlgAbout.DoModal();// GotoDlgCtrl((CEdit*)GetDlgItem(IDC_LDeg));}void CMyDlg::OnClear(){// TODO: Add your control notification handler code herem_BDeg = "";m_BSec = "";m_LSec = "";m_LDeg = "E";m_Old = "";m_New = "";((CComboBox*)GetDlgItem(IDC_COMBO1))->SetCurSel(0);GotoDlgCtrl((CEdit*)GetDlgItem(IDC_LDeg));}void CMyDlg::OnTimer(UINT nIDEvent){// TODO: Add your message handler code here and/or call default static int index=1;SetClassLong(m_hWnd,GCL_HICON,(long)m_hIcons[index]);index = ++index%7;CDialog::OnTimer(nIDEvent);}void CMyDlg::OnHelp(){// TODO: Add your control notification handler code hereCAboutDlg dlgAbout;dlgAbout.DoModal();// GotoDlgCtrl((CEdit*)GetDlgItem(IDC_LDeg));}void CMyDlg::OnClear(){// TODO: Add your control notification handler code herem_BDeg = "";m_BSec = "";m_LSec = "";m_LDeg = "E";m_Old = "";m_New = "";((CComboBox*)GetDlgItem(IDC_COMBO1))->SetCurSel(0);GotoDlgCtrl((CEdit*)GetDlgItem(IDC_LDeg));}。