ArcGIS engineeC#慢速演示点从一个坐标移动向另一个坐标的轨迹过程

时间: 2023-09-16 14:12:53 浏览: 39
首先,我们需要创建一个ArcGIS Engine的C#项目,并添加一个MapControl控件。 接下来,我们需要定义两个点,即起点和终点。可以使用IPoint接口来表示这两个点。例如: ```csharp IPoint startPoint = new PointClass(); startPoint.X = 100; startPoint.Y = 100; IPoint endPoint = new PointClass(); endPoint.X = 200; endPoint.Y = 200; ``` 然后,我们可以使用IMarkerSymbol接口来定义一个标记符号,表示移动的点。例如: ```csharp IMarkerSymbol markerSymbol = new SimpleMarkerSymbolClass(); markerSymbol.Size = 10; markerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; ``` 接下来,我们可以使用IElement接口来创建一个元素,并将标记符号与起点关联。例如: ```csharp IElement element = new MarkerElementClass(); element.Geometry = startPoint; element.Symbol = markerSymbol; ``` 然后,我们可以将元素添加到地图中。例如: ```csharp IMap map = axMapControl1.Map; IElementContainer elementContainer = map as IElementContainer; elementContainer.AddElement(element, 0); axMapControl1.Refresh(); ``` 接下来,我们可以使用IPointCollection接口来获取起点和终点之间的所有点,并依次移动元素。例如: ```csharp IPointCollection pointCollection = new PathClass(); pointCollection.AddPoint(startPoint); pointCollection.AddPoint(endPoint); double distance = startPoint.Distance(endPoint); double step = distance / 100; double currentDistance = 0; while (currentDistance < distance) { for (int i = 1; i < pointCollection.PointCount; i++) { IPoint fromPoint = pointCollection.get_Point(i - 1); IPoint toPoint = pointCollection.get_Point(i); double segmentDistance = fromPoint.Distance(toPoint); double segmentStep = step; while (segmentStep < segmentDistance) { IPoint currentPoint = new PointClass(); currentPoint.X = fromPoint.X + (toPoint.X - fromPoint.X) * segmentStep / segmentDistance; currentPoint.Y = fromPoint.Y + (toPoint.Y - fromPoint.Y) * segmentStep / segmentDistance; element.Geometry = currentPoint; axMapControl1.Refresh(); segmentStep += step; currentDistance += step; System.Threading.Thread.Sleep(50); } } } ``` 上面的代码中,我们首先计算起点和终点之间的距离,然后将其分为100个步骤。然后,我们依次遍历起点和终点之间的每个线段,并在每个线段上移动元素。我们通过计算每个线段的长度和步骤来确定当前点的位置。在每次移动后,我们使用System.Threading.Thread.Sleep方法来暂停50毫秒,以便使移动看起来更平滑。 最后,我们可以在移动结束后将元素从地图中删除。例如: ```csharp elementContainer.DeleteElement(element); axMapControl1.Refresh(); ```

相关推荐

最新推荐

recommend-type

ArcGIS如何把多个tif影像合成一个tif影像

ArcGIS如何把多个tif影像合成一个tif影像 在ArcGIS软件中进行日常影像(栅格)数据的拼接与提取(裁剪)的工具与方法。影像的拼接常用到的工具是Mosaic和Mosaic To New Raster
recommend-type

arcgis和supermap中多个图层合并为一个图层

arcgis和supermap中多个图层合并为一个图层,也是地理信息系统数据处理常常要遇到的问题。
recommend-type

基于ArcGIS的80西安坐标系转换到2000国家坐标系的研究

就西安80 坐标系到2000 国家坐标系之间的转换的基础理论和方法进 行了研究,给出了基于ArcGIS 环境下将1980 西安坐标系转换到2000 中国大地坐标系的有效解决办法。
recommend-type

[1]arcgis属性表中选择同一属性的多个值.docx

arcgis中编辑的数据怎样在属性表中选择同一个属性的多个值,本文给出了详细的解答,并有真实案例配图
recommend-type

arcgis经纬度坐标的shape面层计算面积的详细步骤

经纬度坐标的shape面层计算面积的详细步骤 (1)运行ArcGis ArcToolsBox 选择Projections Define Projection Wizard shapeFiles geodatabase 定义地理坐标
recommend-type

zigbee-cluster-library-specification

最新的zigbee-cluster-library-specification说明文档。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

实现实时数据湖架构:Kafka与Hive集成

![实现实时数据湖架构:Kafka与Hive集成](https://img-blog.csdnimg.cn/img_convert/10eb2e6972b3b6086286fc64c0b3ee41.jpeg) # 1. 实时数据湖架构概述** 实时数据湖是一种现代数据管理架构,它允许企业以低延迟的方式收集、存储和处理大量数据。与传统数据仓库不同,实时数据湖不依赖于预先定义的模式,而是采用灵活的架构,可以处理各种数据类型和格式。这种架构为企业提供了以下优势: - **实时洞察:**实时数据湖允许企业访问最新的数据,从而做出更明智的决策。 - **数据民主化:**实时数据湖使各种利益相关者都可
recommend-type

用 Python 画一个可以动的爱心

好的,我可以帮助您使用Python来绘制一个动态的爱心。您可以使用turtle库来实现。以下是实现代码: ```python import turtle import math # 设置画布和画笔 canvas = turtle.Screen() canvas.bgcolor("black") pencil = turtle.Turtle() pencil.speed(0) pencil.color("red", "pink") pencil.pensize(3) # 定义爱心函数 def draw_love(heart_size, x_offset=0, y_offset=0):
recommend-type

JSBSim Reference Manual

JSBSim参考手册,其中包含JSBSim简介,JSBSim配置文件xml的编写语法,编程手册以及一些应用实例等。其中有部分内容还没有写完,估计有生之年很难看到完整版了,但是内容还是很有参考价值的。