編程實現(xiàn)Google Earth和ArcGIS的聯(lián)動_第1頁
編程實現(xiàn)Google Earth和ArcGIS的聯(lián)動_第2頁
編程實現(xiàn)Google Earth和ArcGIS的聯(lián)動_第3頁
編程實現(xiàn)Google Earth和ArcGIS的聯(lián)動_第4頁
編程實現(xiàn)Google Earth和ArcGIS的聯(lián)動_第5頁
已閱讀5頁,還剩3頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡介

1、編程實現(xiàn)Google Earth和ArcGIS的聯(lián)動demo       這個DEMO實現(xiàn)的功能就是在google earth中用鼠標(biāo)獲取地理坐標(biāo),然后自動定位到ARCGIS對應(yīng)的區(qū)域影像中。前段時間因項目引導(dǎo),在師兄的啟發(fā)下,做了一個這樣的Demo,后來因為各種原因一直沒有進(jìn)行下去。現(xiàn)在感覺還是有些用處的,現(xiàn)在抽空整理一下。    Google Earth是一款優(yōu)秀的Map Explorer,它的優(yōu)秀在于使用普及和方便,雖然DigitalGlobe影像數(shù)據(jù)更新速度慢,但分辨率是還是很高的,最高可達(dá)到0.5m。如果

2、忽略其誤差,可以利用Google Earth的影像資源進(jìn)行定位參考、解譯參考、數(shù)字化等。    Google Earth繼Google Map API之后推出的Google Earth COM API ,提供的功能相對比較弱,一些功能據(jù)說似乎還存在著Bug。網(wǎng)址:。google earth的二次開發(fā)有兩種方法:(1)使用windows API控制兩個進(jìn)程的調(diào)用,利用google earth api實現(xiàn)核心功能。(2)使用做好的務(wù)功能重點(diǎn)放在GE API開發(fā)上。    這個demo使用的是GEVContorl(GEVC),它是

3、一個完全COM的控件,對截止目前所有版本的GoogleEarth都支持,具有很高的兼容性和可用性,能夠?qū)E視圖(地球視圖)集成到開發(fā)人員的應(yīng)用系統(tǒng)中,并且支持滾輪功能。 一、安裝完GE后,系統(tǒng)會自動拷貝一個EARTHLib.dll,添加Google Earth 1.0 Type Library到庫應(yīng)用.二、.NET中新建Arcgis command類。將生成一個dll,可以被ARCGIS自動添加到組件庫中。三、部分代碼,主窗口中:   1Imports EARTHLib  2Imports ESRI.ArcGIS

4、.Controls  3Imports ESRI.ArcGIS.Geometry  4Imports ESRI.ArcGIS.Carto  5Imports ESRI.ArcGIS.SystemUI  6Imports ESRI.ArcGIS.ArcMapUI  7Imports ESRI.ArcGIS.esriSystem  8Imports ESRI.ArcGIS.Framework  9Im

5、ports ESRI.ArcGIS.Geodatabase 10Imports ESRI.ArcGIS.Display 11Imports System.Windows.Forms.Cursor 12Imports System.Drawing 13Imports System.Drawing.Drawing2D 14 15 16Public Class Form2 17    Public g_

6、GeHelper As EARTHLib.ApplicationGE 'GE的主應(yīng)用API 18    Public hookhelper As IHookHelper 'hookhelper 19    Public longitude As Double '經(jīng)度 20    Public latitu

7、de As Double '維度 21    Dim pApp As IApplication 22    Dim pEnable As Boolean 23    Dim pDoc As IMxDocument 24    Dim pWorkspace

8、0;As IWorkspace 25    Dim pMap As IMap 26    Dim pLayer As ILayer 27    Dim pWorkE As IWorkspaceEdit 28    Dim pFeaLayer As IFeatureLay

9、er 29    Private Structure POINTAPI 30        Dim x As Double 31        Dim y As Double 32    End Structure 33

10、 34    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 35        '初始化應(yīng)用GE 36     

11、   g_GeHelper = New EARTHLib.ApplicationGE 37        AxGEViewer1.HookGE(g_GeHelper.GetMainHwnd, g_GeHelper.GetRenderHwnd) 38    End Sub 39 40 41    Private

12、 Sub AxGEViewer1_MouseDownEvent(ByVal sender As System.Object, ByVal e As AxGEVControl._GEViewer_MouseDownEvent) Handles AxGEViewer1.MouseDownEvent 42        If CheckBox1.Checked = True

13、 Then 43            Dim GePt As PointOnTerrainGE 44            Dim pt As POINTAPI 45       

14、0;    '屏幕坐標(biāo)到GE屏幕坐標(biāo)的轉(zhuǎn)換 46            pt.x = e.evtArgs.X * 2 / Me.Width - 1 47            pt.y = -

15、e.evtArgs.Y * 2 / Me.Height + 1 48            'GE屏幕坐標(biāo)到地理坐標(biāo)的轉(zhuǎn)換 49            GePt = g_GeHelper.GetPointOnTerrainFromScreenCoord

16、s(CDbl(pt.X), CDbl(pt.Y) 50 51            MsgBox("點(diǎn)擊屏幕坐標(biāo):" & pt.x & "  ,  " & pt.y & "獲得ge坐標(biāo):" & GePt.Lon

17、gitude & " , " & GePt.Latitude) 52            longitude = GePt.Longitude 53            latitude = GePt

18、.Latitude 54            pMap = hookhelper.ActiveView 55 56            'arcmap中繪制點(diǎn) 57          &#

19、160; Dim point As IPoint 58            point = New ESRI.ArcGIS.Geometry.Point 59            point.PutCoords(longitude, latitude)&#

20、160;60 61            Dim pMarkerElement As IMarkerElement 62            pMarkerElement = New MarkerElement 63 64   

21、         Dim pMarkerSymbol As ESRI.ArcGIS.Display.ISimpleMarkerSymbol 65            pMarkerSymbol = New ESRI.ArcGIS.Display.SimpleMarkerSymbol 66 

22、0;          pMarkerSymbol.Size = 3 67            pMarkerSymbol.Style = ESRI.ArcGIS.Display.esriSimpleMarkerStyle.esriSMSDiamond 68 69   

23、0;        Dim pElement As IElement 70            pElement = pMarkerElement 71            pElement.Geometr

24、y = point 72            pMarkerElement.Symbol = pMarkerSymbol 73 74            Dim pGraphicsContainer As IGraphicsContainer 7

25、5            Dim pActiveView As IActiveView 76            pActiveView = pMap 77           

26、 'pActiveView.Extent.CenterAt(point) 78 79            'arcmap中點(diǎn)的定位 80            Dim pEnvelop As IEnvelope 81    

27、;        pEnvelop = pActiveView.Extent 82            pEnvelop.CenterAt(point) 83            pActiveView.Extent =

28、60;pEnvelop 84            pActiveView.Refresh() 85            pGraphicsContainer = pMap 86           

29、; pGraphicsContainer.AddElement(pMarkerElement, 0) 87            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, Nothing, Nothing) 88        End If

30、60;89 90    End Sub 91    Public WriteOnly Property hook() As IHookHelper 92        Set(ByVal value As IHookHelper) 93      &

31、#160;     hookhelper = value 94        End Set 95    End Property 96 97    Private Sub Form2_Load(ByVal sender As System.Object,&#

32、160;ByVal e As System.EventArgs) Handles MyBase.Load 98 99    End Sub100End Class   command.cs中實現(xiàn)組件注冊:  63    Private m_hookHelper As IHookHelper 64 65 66 

33、   ' A creatable COM class must have a Public Sub New()  67    ' with no parameters, otherwise, the class will not be  68   

34、60;' registered in the COM registry and cannot be created  69    ' via CreateObject. 70    Public Sub New() 71        MyBase.Ne

35、w() 72 73        ' TODO: Define values for the public properties 74        MyBase.m_category = "test"  'localizable text &

36、#160;75        MyBase.m_caption = "tool1"   'localizable text  76        MyBase.m_message = "This should work in ArcMap/MapControl/

37、PageLayoutControl"   'localizable text  77        MyBase.m_toolTip = "" 'localizable text  78        MyBase.m_name = "&quo

38、t;  'unique id, non-localizable (e.g. "MyCategory_MyCommand") 79        Try 80            'TODO: change bitmap name if

39、0;necessary 81            Dim bitmapResourceName As String = Me.GetType().Name + ".bmp" 82            MyBase.m_bitmap =&

40、#160;New Bitmap(Me.GetType(), bitmapResourceName) 83        Catch ex As Exception 84            System.Diagnostics.Trace.WriteLine(ex.Message, "Invalid

41、0;Bitmap") 85        End Try 86 87 88    End Sub 89 90 91    Public Overrides Sub OnCreate(ByVal hook As Object) 92   &#

42、160;    If m_hookHelper Is Nothing Then m_hookHelper = New HookHelperClass 93 94        If Not hook Is Nothing Then 95       

43、     Try 96                m_hookHelper.Hook = hook 97                If m_hookHelper.Acti

44、veView Is Nothing Then m_hookHelper = Nothing 98            Catch 99                m_hookHelper = Nothing100&

45、#160;           End Try101102            'Disable if hook fails103            If m_hookHelper Is Nothing Then104                MyBase.m_enabled = False105            Else106  

溫馨提示

  • 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)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論