编程实现Google Earth和ArcGIS的联动_第1页
编程实现Google Earth和ArcGIS的联动_第2页
编程实现Google Earth和ArcGIS的联动_第3页
编程实现Google Earth和ArcGIS的联动_第4页
编程实现Google Earth和ArcGIS的联动_第5页
已阅读5页,还剩3页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、编程实现Google Earth和ArcGIS的联动demo       这个DEMO实现的功能就是在google earth中用鼠标获取地理坐标,然后自动定位到ARCGIS对应的区域影像中。前段时间因项目引导,在师兄的启发下,做了一个这样的Demo,后来因为各种原因一直没有进行下去。现在感觉还是有些用处的,现在抽空整理一下。    Google Earth是一款优秀的Map Explorer,它的优秀在于使用普及和方便,虽然DigitalGlobe影像数据更新速度慢,但分辨率是还是很高的,最高可达到0.5m。如果

2、忽略其误差,可以利用Google Earth的影像资源进行定位参考、解译参考、数字化等。    Google Earth继Google Map API之后推出的Google Earth COM API ,提供的功能相对比较弱,一些功能据说似乎还存在着Bug。网址:。google earth的二次开发有两种方法:(1)使用windows API控制两个进程的调用,利用google earth api实现核心功能。(2)使用做好的务功能重点放在GE API开发上。    这个demo使用的是GEVContorl(GEVC),它是

3、一个完全COM的控件,对截止目前所有版本的GoogleEarth都支持,具有很高的兼容性和可用性,能够将GE视图(地球视图)集成到开发人员的应用系统中,并且支持滚轮功能。 一、安装完GE后,系统会自动拷贝一个EARTHLib.dll,添加Google Earth 1.0 Type Library到库应用.二、.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的主应用API 18    Public hookhelper As IHookHelper 'hookhelper 19    Public longitude As Double '经度 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        '初始化应用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;    '屏幕坐标到GE屏幕坐标的转换 46            pt.x = e.evtArgs.X * 2 / Me.Width - 1 47            pt.y = -

15、e.evtArgs.Y * 2 / Me.Height + 1 48            'GE屏幕坐标到地理坐标的转换 49            GePt = g_GeHelper.GetPointOnTerrainFromScreenCoord

16、s(CDbl(pt.X), CDbl(pt.Y) 50 51            MsgBox("点击屏幕坐标:" & pt.x & "  ,  " & pt.y & "获得ge坐标:" & GePt.Lon

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

18、.Latitude 54            pMap = hookhelper.ActiveView 55 56            'arcmap中绘制点 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中点的定位 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中实现组件注册:  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. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论