地圖和圖層的管理設(shè)計(jì)_第1頁(yè)
地圖和圖層的管理設(shè)計(jì)_第2頁(yè)
地圖和圖層的管理設(shè)計(jì)_第3頁(yè)
地圖和圖層的管理設(shè)計(jì)_第4頁(yè)
地圖和圖層的管理設(shè)計(jì)_第5頁(yè)
已閱讀5頁(yè),還剩56頁(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、地圖文檔管理pagelayout地圖管理圖層管理render一、 地圖文檔管理lxmxddocument class接口imapdocment imapcontrol3 ipagelayoutcontrol2功能:新建、打開(kāi)、保存、另存、設(shè)置保存路徑(相對(duì)還是絕對(duì)路徑)、新建public bool createmapdocument(string mxdpath)方法功能:新建地圖文檔輸入?yún)?shù):string mxdpath 地圖文檔的保存路徑返回參數(shù):bool 值為true時(shí),表示新建成功;值為false表示建立失敗打開(kāi)public bool openmap(string strpath,bo

2、ol bpagelayout)方法功能:在mapcontrol或pagelayout中打開(kāi)給定的圖文件輸入?yún)?shù):string strmxdpath 打開(kāi)的地圖文檔路徑及文件名 bool bpagelayout 是否用pagelayout打開(kāi)地圖返回參數(shù): bool 值為true時(shí),表示打開(kāi)成功;值為false表示打開(kāi)失敗保存public bool savemapdocument(string psmxdfile,string ptmxdfile)方法功能 保存mxd文件輸入?yún)?shù) string psmxdfile 源mxd文件名string ptmxdfile 目標(biāo)mxd文件名注意psmxdfi

3、le與ptmxdfile相等返回參數(shù):bool 值為true時(shí),表示保存成功;值為false表示保存失敗另存public bool saveasmapdocument(string psmxdfile,string ptmxdfile)方法功能 保存mxd文件輸入?yún)?shù) string psmxdfile 源mxd文件名string ptmxdfile 目標(biāo)mxd文件名注意psmxdfile與ptmxdfile不相等返回參數(shù):bool 值為true時(shí),表示保存成功;值為false表示保存失敗設(shè)置保存路徑public bool setdsavepath(string dsavepath)方法功能:設(shè)

4、置文檔保存路徑 注意是相對(duì)還是絕對(duì) (還是有點(diǎn)疑問(wèn),是否要放在系統(tǒng)配置中)輸入?yún)?shù):string dsavepath 文檔保存路徑返回參數(shù):bool 值為true表示設(shè)置成功;值為false表示設(shè)置失敗 '地圖文檔打印private function mapprint()on error goto errorhandler if pagelayoutctrl.printer is nothing then msgbox "沒(méi)有打印機(jī)", , "提示" exit function end if dim pprinter as iprinter se

5、t pprinter = pagelayoutctrl.printer if pprinter.paper.orientation <> pagelayoutctrl.page.orientation then pprinter.paper.orientation = pagelayoutctrl.page.orientation end if dim dwidth as double, dheight as double pprinter.querypapersize dwidth, dheight pagelayoutctrl.printpagelayout '打印 p

6、agelayoutctrl.mousepointer = esripointerdefault exit functionerrorhandler: erroroperate err.description, erl, c_smodulefilename, "mapprintsetting"end function'地圖文檔打印設(shè)置private function mapprintsetting()on error goto errorhandler if not showprinterset then exit function '如果取消就退出 if p

7、agelayoutctrl.printer is nothing then msgbox "沒(méi)有打印機(jī)", , "提示" exit function end if dim dwidth as double, dheight as double, iunits as integer dim pprinter as iprinter set pprinter = pagelayoutctrl.printer pprinter.paper.formid = printer.papersize pprinter.paper.orientation = print

8、er.orientation dwidth = pprinter.paper.printablebounds.envelope.width dheight = pprinter.paper.printablebounds.envelope.height with pagelayoutctrl.page .formid = esripageformcustom '自定義紙張大?。吹降模?iunits = .units .units = pprinter.units .orientation = pprinter.paper.orientation .putcustomsize dwid

9、th, dheight .stretchgraphicswithpage = false .querysize dwidth, dheight end with dim pframeelement as iframeelement dim pelement as ielement dim pmapframe as imapframe set pframeelement = pagelayoutctrl.activeview.graphicscontainer.findframe(pagelayoutctrl.activeview.focusmap) if not (pframeelement

10、is nothing) then set pmapframe = pframeelement set pelement = pmapframe dim penvelope as ienvelope set penvelope = pelement.geometry.envelope with penvelope .height = dheight - .ymin * 2 '根據(jù)紙張變化重新設(shè)定地圖框大小 .width = dwidth - .xmin * 2 end with pelement.geometry = penvelope dim pgraphicscontainer as

11、 igraphicscontainer set pgraphicscontainer = pagelayoutctrl.pagelayout pgraphicscontainer.updateelement pelement end if pagelayoutctrl.page.units = iunits pagelayoutctrl.activeview.refresh exit functionerrorhandler: if err.number = 32755 then exit function 'user pressed cancel erroroperate err.d

12、escription, erl, c_smodulefilename, "mapprintsetting"end function二、 pagelayout模版切合(maps類(lèi))、視圖切換public function f_pagelayout_createenvelope(pagelayoutcontrol1 as ipagelayoutcontrol2, lxmin as long, lymin as long, lxmax as long, lymax as long) as ienvelope'函數(shù)功能:創(chuàng)建一個(gè)范圍'編寫(xiě)人 helen'編寫(xiě)

13、日期 2004/5/25 set f_pagelayout_createenvelope = nothing 'get the ipoint interface by creating points is the current page units dim ppointmin as ipoint dim ppointmax as ipoint set ppointmin = pagelayoutcontrol1.topagepoint(lxmin, lymin) set ppointmax = pagelayoutcontrol1.topagepoint(lxmax, lymax)

14、'get the ienvelope interface dim penvelope as ienvelope set penvelope = new envelope 'set the envelope coordinates penvelope.putcoords ppointmin.x, ppointmin.y, ppointmax.x, ppointmax.y set f_pagelayout_createenvelope = penvelopeend functionpublic function changelayout(optional firstpath as

15、string) as integer'函數(shù)功能: 切換地圖模版'編寫(xiě)人 wufayun'編寫(xiě)日期 2006/04/02'參數(shù): optional firstpath as string 初始化打開(kāi)對(duì)話框的路徑'返回值: = -1 '地圖模版路徑為空;= -3 '您加載的地圖模版文件有錯(cuò)誤;'= -2 '用戶單擊的是取消;= -4 '未知錯(cuò)誤;= 1 '成功on error goto errorhandler'firstpath初始路徑 commondialog1.dialogtitle = &quo

16、t;打開(kāi)地圖模版" commondialog1.filter = "地圖模版 (*.mxt)|*.mxt" commondialog1.initdir = firstpath commondialog1.cancelerror = true commondialog1.showopen 'exit if no map document is selected dim mxtfilepath as string mxtfilepath = commondialog1.filename if mxtfilepath = "" then ch

17、angelayout = -1 '地圖模版路徑為空 exit function end if if not pagelayoutctrl.checkmxfile(mxtfilepath) then changelayout = -3 '您加載的地圖模版文件有錯(cuò)誤 exit function end if pagelayoutctrl.loadmxfile mxtfilepath dim pmaps as imaps set pmaps = new maps dim pmap as imap set pmap = m_pmapdocument.map(0) pmaps.add p

18、map pagelayoutctrl.pagelayout.replacemaps pmaps pagelayoutctrl.activeview.activate pagelayoutctrl.hwnd m_pmapdocument.replacecontents pagelayoutctrl.pagelayout toccontrol1.setbuddycontrol pagelayoutctrl changelayout = 1 '成功 exit functionerrorhandler: if err.number = cdlcancel then '判斷用戶單擊的是取

19、消 changelayout = -2 '用戶單擊的是取消 else changelayout = -4 '未知錯(cuò)誤 end ifend function三、 地圖管理lxmap class接口 imap iactiveview功能:地圖輸出為圖片、比例尺設(shè)置、顯示單位設(shè)置、地圖空間參考設(shè)置新建并添加圖層組、添加圖層、移去圖層、圖層順序調(diào)整(功能性的)地圖輸出為圖片public bool exportmaptofile(string pfilename)方法功能:把地圖導(dǎo)出到指定格式的圖象文件中(*.jpg;*.pdf;*.bmp;*.tif) 注:使用iexporter的接口

20、,比如用jpegexporter實(shí)例化,把地圖轉(zhuǎn)換成jpg輸入?yún)?shù):pfilename type string,圖象文件全名返回參數(shù):bool'參數(shù)示例: pfilename="d:aa.bmp"(此處應(yīng)該是反斜線的單線吧)比例尺設(shè)置public bool setmapscale(double pscale)方法功能:地圖比例尺設(shè)置輸入?yún)?shù):double pscale 比例尺大小返回參數(shù):bool要加獲取比例尺么public ispatialreference getmapprj(integer pzone, integer pzonetype,integer ip

21、rj )方法功能:設(shè)置地圖空間參考輸入?yún)?shù):integer pzone 表示帶號(hào)integer pzonetype 值為1 表示 3度帶 值為2 表示 6度帶integer iprj iprj=1表示北京54 iprj=2 表示西安80返回參數(shù):ispatialreferencepublic ispatialreference getmapprj(imap pmap)方法功能:獲取地圖空間參考輸入?yún)?shù):imap pmap返回參數(shù):ispatialreferencepublic function f_coordinate_getunitdescription(punits as esriunit

22、s) as string'函數(shù)功能:顯示單位設(shè)置on error goto eh f_coordinate_getunitdescription = "未知" select case punits case esriinches: f_coordinate_getunitdescription = "英寸" case esripoints: f_coordinate_getunitdescription = "點(diǎn)" case esrifeet: f_coordinate_getunitdescription = "英

23、尺" case esriyards: f_coordinate_getunitdescription = "碼" case esrimiles: f_coordinate_getunitdescription = "英里" case esrinauticalmiles: f_coordinate_getunitdescription = "海里" case esrimillimeters: f_coordinate_getunitdescription = "毫米" case esricentimeter

24、s: f_coordinate_getunitdescription = "厘米" case esrimeters: f_coordinate_getunitdescription = "米" case esrikilometers: f_coordinate_getunitdescription = "公里" case esridecimaldegrees: f_coordinate_getunitdescription = "度" case esridecimeters: f_coordinate_getuni

25、tdescription = "度" case esriunknownunits: f_coordinate_getunitdescription = "未知" case else: f_coordinate_getunitdescription = "未知" end selecteh:end function'地圖刷新public function maprefresh() as boolean dim pactiveview as iactiveview maprefresh = false if m_map is not

26、hing then exit function set pactiveview = m_map pactiveview.refresh maprefresh = trueend function'放大地圖public function mapzoomin() dim point1 as ipoint' dim lzoominkey as long dim penvelope as ienvelope' lzoominkey = getkeystate(vbkeyadd)' if lzoominkey and &h8000 then set point1

27、= new point point1.x = mapctrl.extent.xmin + mapctrl.extent.width / 2 point1.y = mapctrl.extent.ymin + mapctrl.extent.height / 2 set penvelope = mapctrl.activeview.extent penvelope.height = penvelope.height / 1.5 penvelope.width = penvelope.width / 1.5 penvelope.centerat point1 mapctrl.activeview.ex

28、tent = penvelope mapctrl.activeview.partialrefresh esriviewgeography, nothing, nothing mapctrl.activeview.refresh' end if' set point1 = nothing set penvelope = nothingend function'放大地圖public function mapzoomout() dim point1 as ipoint' dim lzoomoutkey as long dim penvelope as ienvelop

29、e' lzoomoutkey = getkeystate(vbkeysubtract)' if lzoomoutkey and &h8000 then set point1 = new point point1.x = mapctrl.extent.xmin + mapctrl.extent.width / 2 point1.y = mapctrl.extent.ymin + mapctrl.extent.height / 2 set penvelope = mapctrl.activeview.extent penvelope.height = penvelope.h

30、eight * 1.5 penvelope.width = penvelope.width * 1.5 penvelope.centerat point1 mapctrl.activeview.extent = penvelope mapctrl.activeview.partialrefresh esriviewgraphics, nothing, nothing mapctrl.activeview.refresh' end if' set point1 = nothing set penvelope = nothingend function'下移地圖public

31、 function mapmovedown() dim point1 as ipoint' dim ldownkey as long dim penvelope as ienvelope' ldownkey = getkeystate(vbkeydown)' if ldownkey and &h8000 then set point1 = new point point1.x = mapctrl.extent.xmin + mapctrl.extent.width / 2 point1.y = mapctrl.extent.ymin + mapctrl.exte

32、nt.height / 2 - mapctrl.extent.height / 5 mapctrl.centerat point1 mapctrl.activeview.partialrefresh esriviewgraphics, nothing, nothing' end if set point1 = nothing set penvelope = nothingend function'左移地圖public function mapmoveleft() dim point1 as ipoint' dim lleftkey as long dim penvelo

33、pe as ienvelope ' lleftkey = getkeystate(vbkeyleft)' if lleftkey and &h8000 then set point1 = new point point1.x = mapctrl.extent.xmin + mapctrl.extent.width / 2 - mapctrl.extent.width / 5 point1.y = mapctrl.extent.ymin + mapctrl.extent.height / 2 mapctrl.centerat point1 mapctrl.activevi

34、ew.partialrefresh esriviewgraphics, nothing, nothing' end if set point1 = nothing set penvelope = nothingend function'右移地圖public function mapmoveright() dim point1 as ipoint' dim lrightkey as long dim penvelope as ienvelope ' lrightkey = getkeystate(vbkeyright)' if lrightkey and

35、&h8000 then set point1 = new point point1.x = mapctrl.extent.xmin + mapctrl.extent.width / 2 + mapctrl.extent.width / 5 point1.y = mapctrl.extent.ymin + mapctrl.extent.height / 2 mapctrl.centerat point1 mapctrl.activeview.partialrefresh esriviewgraphics, nothing, nothing' end if set point1 =

36、 nothing set penvelope = nothingend function'上移地圖public function mapmoveup() dim point1 as ipoint' dim lupkey as long dim penvelope as ienvelope ' lupkey = getkeystate(vbkeyup)' if lupkey and &h8000 then set point1 = new point point1.x = mapctrl.extent.xmin + mapctrl.extent.width

37、 / 2 point1.y = mapctrl.extent.ymin + mapctrl.extent.height / 2 + mapctrl.extent.height / 5 mapctrl.centerat point1 mapctrl.activeview.partialrefresh esriviewgraphics, nothing, nothing' end if set point1 = nothing set penvelope = nothingend functiongetallfeaturelgetallrasterlgetfeaturel四、 圖層管理lx

38、layer class接口 ilayer ifeaturelayer irasterlayer功能:獲得圖層、可見(jiàn)比例尺范圍設(shè)置、數(shù)據(jù)源設(shè)置、可見(jiàn)性設(shè)置、可選性設(shè)置、透明度設(shè)置、圖層可見(jiàn)要素設(shè)置、public function f_layer_getlayername(player as ilayer, playernametype as integer) as string f_layer_getlayername = "" if player is nothing then exit function dim i_labelname as string '圖層的

39、layer別名 dim i_datasetname as string '圖層的dataset名 dim i_datasetfullname as string '圖層的dataset全名 dim i_layerfullname as string '圖層的(layer別名+dataset全名) dim i_wsname as string '圖層所在數(shù)據(jù)庫(kù)帶路徑的全名 i_labelname = player.name if typeof player is ifeaturelayer then dim i_featurelayer as ifeaturela

40、yer set i_featurelayer = player if i_featurelayer is nothing then exit function dim i_featureclass as ifeatureclass set i_featureclass = i_featurelayer.featureclass if i_featureclass is nothing then exit function dim i_dataset as idataset set i_dataset = i_featureclass if i_dataset is nothing then e

41、xit function dim i_workspace as iworkspace set i_workspace = i_dataset.workspace if i_workspace is nothing then exit function i_datasetname = i_dataset.name i_datasetfullname = i_workspace.pathname & "->" & i_dataset.name i_wsname = i_workspace.pathname elseif typeof player is i

42、rasterlayer then dim i_rasterlayer as irasterlayer set i_rasterlayer = player if i_rasterlayer is nothing then exit function dim i_raster as iraster set i_raster = i_rasterlayer.raster if i_raster is nothing then exit function i_datasetname = i_rasterlayer.filepath end if i_layerfullname = i_labelna

43、me & "," & i_datasetfullname if playernametype = 1 then f_layer_getlayername = i_labelname if playernametype = 2 then f_layer_getlayername = i_datasetfullname if playernametype = 3 then f_layer_getlayername = i_labelname & "," & i_datasetfullname if playernametype

44、 = 4 then f_layer_getlayername = i_datasetname if playernametype = 5 then f_layer_getlayername = i_wsname '顯示該圖層所在的組名' dim i_grouplayer as igrouplayer' set i_grouplayer = f_layer_getlayergroup(papp, player)' if not (i_grouplayer is nothing) then' f_layer_getlayername = i_grouplay

45、er.name & ":" & f_layer_getlayername' end if end function'函數(shù)功能: 對(duì)map中所有圖層進(jìn)行可選或不可選中的操作public sub f_map_selectablesetalllayers(pmap as imap, pselect as boolean) if pmap is nothing then exit sub if pmap.layercount = 0 then exit sub dim i_layerindex as integer for i_layerindex

46、= 0 to pmap.layercount - 1 dim i_layer as ilayer set i_layer = pmap.layer(i_layerindex) f_layer_selectablesetlayer i_layer, pselect nextend subgetallfeaturelgetallrasterlgetfeaturelpublic function f_layer_getallotherlayersfrommap(byval pmap as imap, byval leibie as integer, optional playername as st

47、ring) as icompositelayer'函數(shù)名稱(chēng) f_layer_getallfeaturelayersfrommap(byval pmap as imap, byval forestlayer as string) as igrouplayer'函數(shù)功能 從當(dāng)前圖層中獲得所有圖層,或所有矢量圖層,或所有林業(yè)專(zhuān)業(yè)圖層'編寫(xiě)人 wufayun'編寫(xiě)日期 2006/3/18'輸入?yún)?shù) byval leibie =1表示:從當(dāng)前圖層中獲得所有圖層,=2表示:所有矢量圖層,=3表示:所有林業(yè)專(zhuān)業(yè)圖層 =4表示獲得指定圖層名的圖層'返回值on e

48、rror goto eh dim pgrouplayer as igrouplayer dim i as integer dim j as integer dim pcompositelayer as icompositelayer dim player as ilayer dim m_layergeneralproperties as ilayergeneralproperties dim forest as string dim playerdescription as string dim a as integer5 set pcompositelayer = nothing set p

49、grouplayer = new grouplayer for i = 0 to pmap.layercount - 1 if typeof pmap.layer(i) is icompositelayer then set pcompositelayer = pmap.layer(i) for j = 0 to pcompositelayer.count - 1 set player = pcompositelayer.layer(j) if leibie = 1 then pgrouplayer.add player elseif leibie = 2 then if typeof player is ifeaturelayer then pgrouplayer.add player end if elseif leibie = 3 then if typeof player is ifeaturelayer then set m_layergeneralproperties = player playerdescription = m_layergeneralproperties.layerdescription forest = "林業(yè)專(zhuān)業(yè)" a = instr(1, playerdescription, forest, vbtextcompare)

溫馨提示

  • 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)論