版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、.第一章MapObjects基礎(chǔ)l Gis常用開發(fā)平臺l MapObjects簡介Ø MapObjects功能Ø MapObjects優(yōu)點Ø MapObjects基礎(chǔ)l 編程規(guī)范01、Gis軟件開發(fā)常用開發(fā)平臺常用開發(fā)平臺的比較:VB:較易入門VBA:對于擴充原有功能較好。如AutoCAD、ArcMap中的VBA。開發(fā)效率最高的一種開發(fā)方式(常常是一個語名即可實現(xiàn)其它開發(fā)工具要幾十甚至上百行的代碼才能實現(xiàn)的功能)。缺點是所開發(fā)出的應(yīng)用程序不能脫離相應(yīng)的運行環(huán)境。(如在ArcMap中開發(fā)的應(yīng)用程序,必須先要安裝ArcMap)VC+:較為靈活,開發(fā)資料眾多。可實現(xiàn)對系
2、統(tǒng)的全面操作。缺點是學(xué)習(xí)起來較難,所開發(fā)出的應(yīng)用程序常常會產(chǎn)生難以預(yù)計的錯誤。(如內(nèi)存泄露等)Delphi:可擴充性最好,現(xiàn)已有上萬個帶源碼的控件可供使用,幾乎涉及到各各方面。如數(shù)據(jù)庫控件InfoPower3000、OpenGL控件GLScene,工業(yè)控制控件等。GIS組件簡介:MapObjects:ESRI1、 可實現(xiàn)功能:2、 可使用的數(shù)據(jù)ArcView Gis Shapefiles:創(chuàng)建新層、讀寫數(shù)據(jù),添加刪除記錄與幾何要素ArcSDE:不能創(chuàng)建新層Arcinfo Coverages:只讀CAD格式及VPF數(shù)據(jù)庫:只讀(Vector Product Format是一種標(biāo)準(zhǔn)的基于空間關(guān)系數(shù)
3、據(jù)模型的大型空間數(shù)據(jù)庫的格式、結(jié)構(gòu)與組織。是美國國防部的標(biāo)準(zhǔn))外部數(shù)據(jù)庫:只讀ArcObjects:ESRIMapX:MapinfoSupermap:中科院地理所一般用戶(大多數(shù)用戶)關(guān)心的問題:應(yīng)用程序的運行速度與穩(wěn)定性。不關(guān)心所采用的開發(fā)工具及內(nèi)部實現(xiàn)方式。只有特殊用戶(少量用戶)考慮與原有系統(tǒng)的兼容性才關(guān)心開發(fā)平臺。軟件開發(fā)中應(yīng)注意的問題:代碼的規(guī)范性:1、命名約定 2、代碼縮進(jìn) 3、邏輯關(guān)系的排列次序?qū)τ谳^為普通的問題盡量使用較常見的解決方式。盡量不使用較為古怪的技巧(如:兩數(shù)的交換),這樣會降低代碼的可讀性。Delphi開發(fā)環(huán)境簡介:1、數(shù)據(jù)庫應(yīng)用 2、OpenGL應(yīng)用 3、報表制作
4、 02、通用GIS功能的界面框架設(shè)計1、 菜單的設(shè)計2、 工具條的設(shè)計3、 狀態(tài)欄提示信息的顯示(標(biāo)準(zhǔn)控件及1stClass控件的使用)4、 fcLookoutBar控件的使用5、 TActionList控件的使用6、 圖標(biāo)及標(biāo)題的設(shè)置03、MapObjects的模塊間關(guān)系簡介屬性、事件、方法:屬性:對象的性質(zhì),方法:對象的動作,事件:對象的響應(yīng)。(只有Map Control有事件)可創(chuàng)建對象與不可創(chuàng)建對象為有效地使用MapObjects中的OLE Automation對象,必須注意一些對象可以創(chuàng)建,一些對象不可創(chuàng)建。如果某個對象可以創(chuàng)建,在對象圖中對象名稱下有一個Creatable標(biāo)注。如一
5、個對象可以創(chuàng)建可用如下代碼創(chuàng)建:(假設(shè)創(chuàng)建點對象). v.Dim NewObject as New MapObjects2.Point或Dim NewObject as MapObjects2.PointSet NewObject = New MapObjects2.Point在將對象的引用賦給變量、數(shù)據(jù)類型的元素或可寫對象的屬性時,須使用關(guān)鍵字Set;在創(chuàng)建對象的實例時,須使用關(guān)鍵字NewVar NewObject: ImoPoint;Begin NewObject := coPoint.Create;End;在Delphi中如一個對象可創(chuàng)建,可用coXXX.Create方法進(jìn)行創(chuàng)建。XXX
6、為可創(chuàng)建對象名. v.值傳遞與引用傳遞:值傳遞:新的變量得到原始數(shù)據(jù)或?qū)ο蟮囊粋€拷貝,其值的改變不影響原值。Name屬性;引用傳遞:新的變量得到原始數(shù)據(jù)或?qū)ο蟮膬?nèi)存地址,其值的改變影響原值。Symbol屬性. v.值傳遞. v.Dim LayerName As StringLayerName= Map1.Layers.Item(0).NameLayerName = "MyLayerName"MsgBox LayerNameMsgBox Map1.Layers.Item(0).Namevar LayerName: string;begin LayerName := ImoMa
7、pLayer(Map1.layers.Item(0).Name; LayerName := 'MyLayerName' ShowMessage(LayerName); ShowMessage(ImoMapLayer(Map1.layers.Item(0).Name);End;. v.引用傳遞. v.Dim MySymbol As New MapObjects2.SymbolSet MySymbol = Map1.Layers.Item(0).SymbolMySymbol.Color = moRedMap1.Refreshvar MySymbol: imoSymbol;begin
8、 MySymbol := coSymbol.Create ; MySymbol := ImoMapLayer(Map1.Layers.Item(0).Symbol; MySymbol.Color := moRed; Map1.Refresh ;end;. v.MapObjects中的常量:常量均以mo開頭。在編寫代碼時,可使用常量名也可使用常量左邊的整數(shù)。但最好使用常量名稱以增強代碼的可讀性。MainMap.MousePointer = moArrow;或MainMap.MousePointer = 1;第二章 地圖與圖層l Map Controll Layers Collection
9、6; MapLayersØ ImageLayersl Rectangle、pointl DataConnectionl GeoDatasets Collectionl GeoDatasetl TrackingLayer查看地圖 地圖的放大、縮小、平移等操作交互式方法:Pan、 TrackRegtangle、 TrackPolygon、 TrackCircle。當(dāng)使用上述方法時,運行時線程將暫停,等待用戶使用鼠標(biāo)與Map控件交互。實現(xiàn)對地圖的基本操作。(地圖的放大、縮小、平移). v.Private Sub MainMap_MouseDown(Button As Integer, Sh
10、ift As Integer, x As Single, y As Single) Dim r As new MapObjects2.Rectangle If barDisplay.Buttons("Zoom in").Value = 1 Then MainMap.Extent = MainMap.TrackRectangle ElseIf barDisplay.Buttons("Zoom out").Value = 1 Thenr = MainMap.Extentr.ScaleRectangle(1.25)MainMap.Extent = r Else
11、If barDisplay.Buttons("Pan").Value = 1 Then MainMap.Pan ElseIf barDisplay.Buttons("Identify").Value = 1 Then Call frmIdentify.Identify(x, y)Endif MainMap.RefreshEnd sub procedure TMainFRM.MainMapMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);v
12、ar r: imoRectangle;begin if tbZoomIn.Down then MainMap.Extent := MainMap.TrackRectangle else if tbZoomOut.Down then begin r := coRectangle.Create; r := MainMap.Extent; /(Extent:為地圖的空間區(qū)域可理解為當(dāng)前的顯示范圍) r.ScaleRectangle(1.25); / MainMap.Extent := r; end else if tbPan.Down then MainMap.Pan else if (tbIden
13、tify.Down) and (Button = mbLeft) then/ GetIdentify(X, Y) ;MainMap.Refresh;End;. v.獲取鼠標(biāo)坐標(biāo)在創(chuàng)建面向圖形的應(yīng)用程序時,必須解決兩種坐標(biāo)系統(tǒng)的轉(zhuǎn)換問題:定義窗體中控件的尺寸與位置的控制坐標(biāo),以及定義在打印機或顯示器上圖形的大小與位置的設(shè)備坐標(biāo)。MapObjects開發(fā)人員還須使用第三種坐標(biāo)系統(tǒng):地圖坐標(biāo)系統(tǒng)。此坐標(biāo)定義了地圖上幾何要素或影像的笛卡爾位置。為保證有效,此坐標(biāo)系統(tǒng)必須與某種投影或非投影坐標(biāo)相匹配,以定義物體在地表的位置。在MapObjects中,ToMapPoint方法以參數(shù)形式接收MouseDow
14、n、MouseUp、MouseMove事件傳遞的鼠標(biāo)位置的x,y參數(shù)。這些x,y值是以控制坐標(biāo)來表達(dá)的。ToMapPoint方法將窗體上點的位置轉(zhuǎn)換成相應(yīng)的地圖上的點位置。FromMapPoint方法實現(xiàn)相反的轉(zhuǎn)換。類式的方法有:ToMapDistance與FromMapDistance. v.Private Sub Map1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Dim MyPoint As New PointSet MyPoint = Map1.ToMapPoint(X, Y) Te
15、xt1.Text = Str(MyPoint.X) + " " + Str(MyPoint.Y)End Subprocedure TForm1.Map1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);var MyPoint: ImoPoint;begin MyPoint := coPoint.Create ; MyPoint := Map1.ToMapPoint(x,y); Edit1.Text := FloatToStr(MyPoint.X) + ' + FloatToStr(MyPoin
16、t.Y );end;. v.圖層集合(Layers)Ø 每個地圖控件有且只有一個Layers集合Ø Layers集合可包含MapLayer與ImageLayer兩類地圖文件Ø 每個圖層可有自已的顯示方式. v.Dim i As Integer For i = 0 To Map1.Layers.Count - 1 MsgBox Map1.Layers.Item(i).Name Next ivar i: integer; MyLayers: imoLayers;begin MyLayers := Map1.Layers ; for i := 0 to MyLayers
17、.Count - 1 do ShowMessage(ImoMapLayer(MyLayers.Item(i).Name);end;或:var i: integer;begin for i := 0 to Map1.Layers.Count - 1 do ShowMessage(ImoMapLayer(Map1.Layers.Item(i).Name);end;. v.04、MapObjects圖層操作1、 ArcView格式地圖2、 AutoCAD圖形3、 位圖注意觀察如下圖形中的紅線部份:加入ArcView格式地圖步驟:1、生成數(shù)據(jù)連接對象(ImoDataConnection)2、設(shè)定數(shù)據(jù)連
18、接對象的DataBase屬性4、 取得空間數(shù)據(jù)集5、 生成新的圖層6、 將新生成的圖層加入地圖控件. v.Private Sub Command1_Click()Dim dc As New MapObjects2.DataConnectionDim lyr As New MapObjects2.MapLayerdc.Database = "C:USA"If dc.Connect Then Set lyr.GeoDataset = dc.FindGeoDataset("Counties")If lyr.Valid Then Map1.Layers.Add
19、lyrElse MsgBox "無法加入圖層"End IfElse MsgBox "出錯,請確定數(shù)據(jù)是否存在. "End IfEnd Subvar dc: imoDataConnection; lyr: imoMapLayer;begin dc := coDataConnection.Create; lyr := coMapLayer.Create; dc.Database := 'C:USA' if dc.Connect then begin lyr.GeoDataset := dc.FindGeoDataset('Counti
20、es'); if lyr.Valid then Map1.Layers.Add(lyr) else ShowMessage('無法加入圖層') end else ShowMessage('出錯,請確定數(shù)據(jù)是否存在.');end;. v.注意要點:DataBase:對于shapefile,數(shù)據(jù)庫屬性僅為一包含有shapefile的文件夾或目錄字符串。FindGeoDataset:對于shapefile,參數(shù)字符串只須設(shè)為沒有擴展名的ShapeFile文件名。較為完整的加入ShapeFile的Delphi代碼:function TMapManage.AddS
21、hapeFile(sFileName: string; LayerColor: integer = 16711680): string;var gs: IMoGeoDataset; dc: IMoDataConnection; name, fname: string; Newlayer: IMoMapLayer;begin dc := IMoDataConnection(CreateOleObject('MapObjects2.DataConnection');/ 或dc := coDataConnection.Create ; name := SFileName; fname
22、 := ExtractFileDir(name); /獲取某一文件所在的路徑 dc.database := fname; /DataBase屬性:指明所采用的數(shù)據(jù),如為SDE則為數(shù)據(jù)庫名,如為Shp文件則為Shp文件所在的目錄 if not dc.connect then exit; Name := GetFileName(Name); if not LayerExist(Name) then begin gs := dc.FindGeoDataset(name); gs.AllowSharing := true; if VarIsEmpty(gs) then exit; /判斷對象是否為空,
23、(在Delphi6中此函數(shù)存在錯誤) NewLayer := IMoMapLayer(CreateOleObject('MapObjects2.MapLayer'); NewLayer.GeoDataset := gs; NewLayer.Symbol.Color := LayerColor;MainMap.Layers.Add(NewLayer); end else begin MessageBox(Handle, '已存在圖層', '圖層管理', MB_OK + MB_ICONINFORMATION); Result := ''
24、; Exit; end; Result := Name;end;/假設(shè)sFileNmae 為C:ProjectsLean.shp函數(shù)返回值為Leanfunction GetFileName(sFileName: string): string;begin while pos('', sFileName) > 0 do begin delete(sFileName, 1, 1); end; while pos('.', sFileName) > 0 do delete(sFileName, Pos('.', sFileName), 4)
25、; Result := sFileName;end;更正Delphi6中的VarIsEmpty函數(shù):將: Result := FindVarData(V).VType = varEmpty;改為: with TVarData(V) do Result := (VType = varEmpty) or (VType = varDispatch) or (VType = varUnknown) and (VDispatch = nil);/判斷指定的圖層是否存在function LayerExist(sLayerName: string): boolean;var i: integer; Curr
26、entMap: ImoMapLayer;begin CurrentMap := CoMapLayer.Create; for i := 0 to Map.Layers.Count - 1 do begin CurrentMap := ImoMapLayer(Map.Layers.Item(i); if CurrentMap.Name = sLayerName then begin Result := true; exit; end; end; Result := false;end;加入Coverage圖層:加入SDE圖層加入Image圖層:. v.Private Sub Command1_C
27、lick() Dim lyr As New MapObjects2.ImageLayer lyr.File = "D: WashingtonWash.bmp" Map1.Layers.Add lyrEnd Subprocedure TForm1.Button1Click(Sender: TObject);var Lyr: imoImageLayer;begin lyr := coImageLayer.Create ; Lyr.File_ := 'D:WashingtonWash.bmp' Map1.Layers.Add(Lyr);end;. v.注意要點:與
28、失量數(shù)據(jù)不同,在創(chuàng)建ImageLayer時不需要創(chuàng)建DataConnection和GeoDataset對象,中需設(shè)置ImageLayer對象實例的File屬性,再將ImageLayer加入Map控件即可。加入CAD文件:. v.Private Sub Command2_Click() Dim dc As New MapObjects2.DataConnection Dim lyr As New MapObjects2.MapLayer dc.Database = "CADPointD:ARCVIEWCAD" Set lyr.GeoDataset = dc.FindGeoDa
29、taset("Parcels.dwg") Map1.Layers.Add lyrEnd Subprocedure TForm1.Button3Click(Sender: TObject);var dc: imoDataConnection; Lyr: imoMapLayer;begin dc := coDataConnection.Create ; Lyr := coMapLayer.Create ; dc.Database := 'CADPointD:ARCVIEWCAD' lyr.GeoDataset := dc.FindGeoDataset('
30、Parcels.dwg'); Map1.Layers.Add(Lyr);end;. v.注意要點:DataConnection的Database屬性字符串不僅要提供文件所在的路徑,而且要包括實體類型的前綴。如CADPoint、CADArea及CADText等,前綴CAD默認(rèn)為線實體。在使用FindGeoDataset方法時,其參數(shù)必須包括擴展名在內(nèi)的完整文件名。小結(jié):測試數(shù)據(jù)庫聯(lián)接:Connect與DisConnect:Connect與DisConnect是作用在DataConnection對象上的方法。Connected與ConnectErr是DataConnection對象的屬性,
31、可以在任何時間讀取檢驗連接狀態(tài)。Connect首先讀取數(shù)據(jù)庫屬性,確定數(shù)據(jù)的存儲位置;讀取存儲的文件并創(chuàng)建數(shù)據(jù)的GeoDataset集合;Connect返回一布爾值,并在Connected屬性中寫入這一布爾值;若Connect返回的布爾值為False,它將設(shè)置ConnectError的值。DisConnect方法釋放DataConnection對象和數(shù)據(jù)存儲位置間的連接,清空GeoDataSets集合,并重新設(shè)置Connected值為False。加入圖層時應(yīng)注意到不同類型的數(shù)據(jù)其DataConnection的DataBase屬性字符串的值格式不同。文件類型DataConnection的Data
32、base屬性DataConnection的FindGetDataset方法ShapeFile:Shp文件所在的路徑不帶擴展名的Shp文件名AutoCAD:類型+CAD文件所在的路徑包括擴展名在內(nèi)的完整文件名Image:不需要設(shè)置不需要設(shè)置Coverage:05、圖層的顯示次序圖層在地圖控件的次序決定或影響整個地圖的顯示效果,點狀信息或線狀信息常常會被面狀信息所掩蓋??赏ㄟ^Layers集合中的MoveTo、MovtToBottom、MoveToTop方法控制圖層的次序。及MapLayer對象中的Visible屬性控制某個圖層顯示與否。/獲取當(dāng)前所打開的所有圖層名及狀態(tài)procedure TLay
33、erManagerFRM.FormActivate(Sender: TObject);var i: Integer;CurrentLayer: ImoMapLayer;begin CheckListBoxLayers.Clear; for i := 0 to MainFRM.MainMap.Layers.Count - 1 do beginCurrentLayer := ImoMapLayer(CurrentMap.Layers.Item(i); if CurrentLayer.LayerType = moMapLayer then checkListBoxLayers.Items.Add(C
34、urrentLayer.Name); CheckListBoxLayers.Checkedi := CurrentLayer.Visible; end;end;/確定各個按鈕的狀態(tài)procedure TLayerManagerFRM.CheckListBoxLayersClick(Sender: TObject);var CurrentLayer: Integer; LayerCount: Integer; Layer: ImoMapLayer;begin CurrentLayer := CheckListBoxLayers.ItemIndex; Layer := ImoMapLayer(Cu
35、rrentMap.Layers.Item(CurrentLayer); LayerCount := CurrentMap.Layers.Count; if (LayerCount = 1) or (LayerCount = 0) then else begin sbTop.Enabled := CurrentLayer <> 0; sbButtom.Enabled := CurrentLayer < LayerCount - 1; sbUp.Enabled := CurrentLayer <> 0; sbDown.Enabled := CurrentLayer &
36、lt; LayerCount - 1; end; CmbRemove.Enabled := CheckListboxLayers.Items.Count > 0; bbtnAttribute.Enabled := CmbRemove.Enabled;end;/移動圖層procedure TLayerManagerFRM.MoveLayer(Sender: TObject);var CurrentLayerIndex: Integer;begin CurrentLayerIndex := CheckListBoxLayers.ItemIndex; if CurrentLayerIndex
37、< 0 then ShowMessage('請選擇所要移動的圖層。') else begin with CurrentMap.Layers do begin case (Sender as TSpeedButton).tag of 1: MoveToTop(CurrentLayerIndex); 2: MoveTo(CurrentLayerIndex, CurrentLayerIndex - 1); 3: MoveTo(CurrentLayerIndex, CurrentLayerIndex + 1); 4: MoveToBottom(CurrentLayerIndex)
38、; end; end; end; LayerManagerFRM.FormActivate(Sender); CurrentMap.Refresh;end;Map控件1) BeforeLayerDraw (index as Integer, hDC as stdole.OLEHandle)繪制圖層2) AfterLayerDraw (index as Integer, canceled as Boolean, hDC as stdole.OLEHandle)3) BeforeTrackingLayerDraw (hDC as stdole.OLEHandle)繪制Tracking圖層4) Af
39、terTrackingLayerDraw (hDC as stdole.OLEHandle)BeforeLayerDraw事件:在繪制圖層前執(zhí)行,主要用于檢查當(dāng)前圖層的顯示比例,決定在當(dāng)前顯示比例下是否顯示此圖層。這樣可使地圖更具有地圖學(xué)意義,同時提高顯示速度。第三章數(shù)據(jù)集/提取某一圖層中的每一條記錄,填充Memoprocedure TForm1.Button1Click(Sender: TObject);var MyRecord: imoRecordSet; CurrentLayer: imoMapLayer; i: integer; MyTableDesc: imoTableDesc;be
40、gin CurrentLayer := coMapLayer.Create; myTableDesc := coTableDesc.Create ; CurrentLayer := ImoMapLayer(Map1.Layers.Item(0); MyRecord := CurrentLayer.Records; myTableDesc := MyRecord.TableDesc ; for i := 0 to MyTableDesc.FieldCount - 1 do begin Memo1.Lines.Add(MyTableDesc.FieldNamei); Memo1.Lines.Add
41、(myRecord.Fields.Item(MyTableDesc.FieldNamei).ValueAsString) ; end;end;/較為完整的Identify代碼:procedure TMainFRM.GetIdentify(x, y: integer);var CurrentPoint: imoPoint; i: integer; MyTableDesc: imoTableDesc; MyRecordSet: imoRecordSet; CurrentLayer: imoMapLayer;begin CurrentPoint := coPoint.Create; CurrentL
42、ayer := coMapLayer.Create; MyTableDesc := coTableDesc.Create; CurrentPoint := MainMap.ToMapPoint(x, y); IdentifyFRM.plCurrentCoordinate.Caption := '拾取點坐標(biāo):' + FloatToStr(CurrentPoint.X) + ' ; ' + FloatToStr(CurrentPoint.Y); myRecordSet := ImoMapLayer(MainMap.Layers.Item(0).SearchShape
43、(CurrentPoint, 12, ''); MyTableDesc := myRecordSet.TableDesc; IdentifyFRM.sgValues.Cells0, 0 := '字段' IdentifyFRM.sgValues.Cells1, 0 := '值' IdentifyFRM.sgValues.RowCount := myTableDesc.FieldCount + 1;myRecordSet.MoveFirst; while not MyRecordSet.EOF do begin for i := 0 to MyTab
44、leDesc.FieldCount - 1 do begin IdentifyFRM.sgValues.Cells0, i + 1 := MyTAbleDesc.FieldNamei; IdentifyFRM.sgValues.Cells1, i + 1 := myRecordset.Fields.Item(MyTableDesc.FieldNamei).ValueAsString;end; MainMap.FlashShape(myRecordset.Fields.Item('Shape').Value, 2); MyRecordSet.MoveNext; end; Iden
45、tifyFRM.Show;end;注:本模塊需完善:在同一圖層中查找到多個對象的情況在單擊處存在多個圖層的情況/編輯記錄創(chuàng)建新圖層:第四章地圖要素的查詢與選擇l SearchExpressionl SearchByDistancel SearchShape使用MapLayer的SearchExpression方法可實現(xiàn)根據(jù)屬性值查詢屬性所對應(yīng)的地圖要素的功能。SearchExpression:其實質(zhì)是構(gòu)建Select語句中的Where子句的內(nèi)容。procedure TForm1.Button1Click(Sender: TObject);var CurrentLayer: imoMapLaye
46、r;begin CurrentLayer := coMapLayer.Create; CurrentLayer := ImoMapLayer(Map1.Layers.Item(0); myRecordSet := CurrentLayer.SearchExpression(Edit1.Text); Map1.Refresh;end;/將查詢結(jié)果以另外一種Color 顯示procedure TForm1.Map1AfterLayerDraw(Sender: TObject; index: Smallint; canceled: WordBool; hDC: Cardinal);var
47、MySymbol: imoSymbol;begin mysymbol := coSymbol.Create; mySymbol.Color := moYellow; if not VarIsEmpty(myRecordSet) then Map1.DrawShape(myRecordSet, mySymbol);end;注:在本例中SearchExpression為一固定值,在實際應(yīng)用中應(yīng)根據(jù)用戶的選擇自動組合。編程實現(xiàn)大體步驟:Ø 在窗口的FormActivate事件中提取當(dāng)前地圖中所有的圖層名Ø 當(dāng)用戶選取某一圖層時提取此圖層所包含的字段Ø 根據(jù)用戶對不同字段
48、的類型選擇組合查詢條件,如字符型字段需加另外一種方法是用戶只需輸入所要查詢的內(nèi)容,系統(tǒng)實現(xiàn)對所有圖層,所有字段的查詢,此方法編程較為復(fù)雜。 采用SearchByDistance方法可實現(xiàn)使用距離選擇要素SearchByDistance (shape as Object, distance as Double,expression as String) as RecordSetSearchByDistance方法的第一個參數(shù)可以是一個shape或者為包含具有0或多個shape的Recordset對象。第二個參數(shù)使用一個距離容限值,第三個參數(shù)為可選的SQL Where 從句與前面的條件為AND關(guān)系
49、。SearchByDistance方法作用于MapLayer對象。對于圖層中的每一個要素,根據(jù)其與方法中shape參數(shù)的距離,被選擇或不被選擇。如果要素的任何部分落在由shape及距離參數(shù)創(chuàng)建的虛擬緩沖區(qū)范圍內(nèi),那么該對象及其所有屬性值將被選中,并輸入到結(jié)果Recordset中。procedure TForm1.MainMapMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);var mySymbol: imoSymbol;begin mySymbol := cosymbol.C
50、reate; myPoint := coPoint.Create; MySymbol.Color := moYellow; MyPoint := MainMap.ToMapPoint(x, y); MyRecordSet := ImoMapLayer(MainMap.Layers.Item(0).SearchByDistance(myPoint, udDistance.Position, ''); MainMap.Refresh;end;procedure TForm1.MainMapAfterLayerDraw(Sender: TObject; index: Smallint; canceled: WordBool; hDC: Cardinal);var m
溫馨提示
- 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)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 二零二五版智慧農(nóng)業(yè)項目合作合同范本4篇
- 二零二五年度農(nóng)產(chǎn)品供應(yīng)鏈金融服務(wù)合同7篇
- 二零二五年度廚師食材采購與成本控制服務(wù)合同3篇
- 二零二五年度新能源研發(fā)中心聘請兼職勞務(wù)合同4篇
- 2025年文化創(chuàng)意產(chǎn)業(yè)貨款合同退款及知識產(chǎn)權(quán)保護(hù)協(xié)議3篇
- 二零二五年度排水管道安裝與水質(zhì)監(jiān)測服務(wù)合同3篇
- 二零二五年度農(nóng)藥研發(fā)成果轉(zhuǎn)化與應(yīng)用合同3篇
- 2025年度個人投資理財顧問委托合同3篇
- 2025版特色商業(yè)街區(qū)門面店裝修施工合同2篇
- 2025年度民品典當(dāng)借款合同標(biāo)準(zhǔn)化文本4篇
- 有砟軌道施工工藝課件
- 兩辦意見八硬措施煤礦安全生產(chǎn)條例宣貫學(xué)習(xí)課件
- 40篇短文搞定高中英語3500單詞
- 人教版高中數(shù)學(xué)必修二《第九章 統(tǒng)計》同步練習(xí)及答案解析
- 兒科護(hù)理安全警示教育課件
- 三年級下冊口算天天100題
- 國家中英文名稱及代碼縮寫(三位)
- 人員密集場所消防安全培訓(xùn)
- 液晶高壓芯片去保護(hù)方法
- 使用AVF血液透析患者的護(hù)理查房
- 拜太歲科儀文檔
評論
0/150
提交評論