基于ArcGIS10.0和Oracle10g的空间数据管理平台十七(C#开发)-空间数据编辑(下)
来源:互联网 发布:人工智能各个方面英文 编辑:程序博客网 时间:2024/05/20 14:41
上一篇介绍了空间数据编辑一部分实现,今天继续完成剩余的部分实现。
1.根据选择编辑任务的不同显示不同形状的鼠标,以便指示相应任务方便编辑操作
- 1 /// <summary>
- 2 /// 根据选择编辑任务的不同显示不同形状的鼠标,以便指示相应任务方便编辑操作
- 3 /// </summary>
- 4 /// <param name="sender"></param>
- 5 /// <param name="e"></param>
- 6 private void cboTasks_SelectedIndexChanged(object sender, EventArgs e)
- 7 {
- 8 // Restate
- 9 m_MapControl.MousePointer = esriControlsMousePointer.esriPointerDefault;
- 10 m_bEditingFtr = false;
- 11 m_bSketching = false;
- 12 m_bSelecting = false;
- 13 m_bMove = false;
- 14
- 15 // Select an operation and mouse pointer depending on the user choice
- 16 switch (cboTasks.SelectedIndex)
- 17 {
- 18 case 0:
- 19 // Do Nothing - the tool has already been reset
- 20 break;
- 21 case 1:
- 22 m_MapControl.MousePointer = esriControlsMousePointer.esriPointerCrosshair;
- 23 m_bEditingFtr = true;
- 24 break;
- 25 case 2:
- 26 m_MapControl.MousePointer = esriControlsMousePointer.esriPointerPencil;
- 27 m_bSketching = true;
- 28 break;
- 29 case 3:
- 30 m_MapControl.MousePointer = esriControlsMousePointer.esriPointerCrosshair;
- 31 m_bSelecting = true;
- 32 break;
- 33 case 4:
- 34 m_MapControl.MousePointer = esriControlsMousePointer.esriPointerHand;
- 35 m_bMove = true;
- 36 break;
- 37 }
- 38
- 39 }
2.选择需要的图层并且在地图编辑控件中显示出来
- 1 /// <summary>
- 2 /// 选择需要的图层并且在地图编辑控件中显示出来
- 3 /// </summary>
- 4 /// <param name="sender"></param>
- 5 /// <param name="e"></param>
- 6 private void cboLayers_SelectedIndexChanged(object sender, EventArgs e)
- 7 {
- 8 if (m_pMap == null)
- 9 {
- 10 return;
- 11 }
- 12
- 13 // Clear any existing selection
- 14 m_pMap.ClearSelection();
- 15 IActiveView ipActiveView;
- 16 ipActiveView = (IActiveView)m_pMap;
- 17 ipActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
- 18
- 19 String strLayerName = cboLayers.SelectedItem.ToString();
- 20 axMapControl1.Map.ClearLayers();
- 21 AddLayerToMapCtl(strLayerName, true);
- 22 m_pCurrentLayer = m_pMap.get_Layer(0);
- 23
- 24 SetControlStates();
- 25 }
3.测试是否击中地图对象或地图对象上的节点
4.向图层中更新新的地图对象,并使之处于选中状态
5.屏幕坐标转换为地图坐标
- 1 /// <summary>
- 2 /// 屏幕坐标转换为地图坐标
- 3 /// </summary>
- 4 /// <param name="pActiveView">地图</param>
- 5 /// <param name="pixelUnits">屏幕坐标</param>
- 6 /// <returns>地图坐标</returns>
- 7 private double ConvertPixelsToMapUnits(IActiveView pActiveView, double pixelUnits)
- 8 {
- 9 // Uses the ratio of the size of the map in pixels to map units to do the conversion
- 10 IPoint p1 = pActiveView.ScreenDisplay.DisplayTransformation.VisibleBounds.UpperLeft;
- 11 IPoint p2 = pActiveView.ScreenDisplay.DisplayTransformation.VisibleBounds.UpperRight;
- 12 int x1, x2, y1, y2;
- 13 pActiveView.ScreenDisplay.DisplayTransformation.FromMapPoint(p1, out x1, out y1);
- 14 pActiveView.ScreenDisplay.DisplayTransformation.FromMapPoint(p2, out x2, out y2);
- 15 double pixelExtent = x2 - x1;
- 16 double realWorldDisplayExtent = pActiveView.ScreenDisplay.DisplayTransformation.VisibleBounds.Width;
- 17 double sizeOfOnePixel = realWorldDisplayExtent / pixelExtent;
- 18 return pixelUnits * sizeOfOnePixel;
- 19 }
6.处理地图控件上的目标按下事件
7.处理地图控件上的鼠标移动事件
- 1 private void axMapControl1_OnMouseMove(object sender, IMapControlEvents2_OnMouseMoveEvent e)
- 2 {
- 3 if (m_bSketching)
- 4 {
- 5 //新建要素任务处理
- 6 SketchMouseMove(e.x, e.y);
- 7 }
- 8 else if (m_bEditingFtr)
- 9 {
- 10 //编辑要素任务处理
- 11 FtrEditMouseMove(e.x, e.y);
- 12 }
- 13 else if (m_bMove)
- 14 {
- 15 //移动要素任务处理
- 16 MoveFeatureMouseMove(e.x, e.y);
- 17 }
- 18
- 19 }
8.处理地图控件上的鼠标按下事件
- 1 private void axMapControl1_OnMouseUp(object sender, IMapControlEvents2_OnMouseUpEvent e)
- 2 {
- 3 if (m_bEditingFtr)
- 4 {
- 5 //结束编辑任务
- 6 EndFtrEdit(e.x, e.y);
- 7 }
- 8 else if (m_bMove)
- 9 {
- 10 //结束移动要素任务
- 11 MoveFeatureEnd();
- 12 }
- 13
- 14 }
9.新建对象方法:当前图层为点图层时,每调用一次就新点一个点对象,当前图层为线图层或面图层时,第一次调用开始新建对象,并添加当前点,以后每调用一次,即向新对象中添加一个点,调用NewFeatureEnd方法完成对象创建 。
10.新建对象过程中鼠标移动方法,产生Track效果,在Map.MouseMove事件中调用本方法
- 1 /// <summary>
- 2 /// 新建对象过程中鼠标移动方法,产生Track效果
- 3 /// 在Map.MouseMove事件中调用本方法
- 4 /// </summary>
- 5 /// <param name="x">鼠标X坐标,屏幕坐标</param>
- 6 /// <param name="y">鼠标Y坐标,屏幕坐标</param>
- 7 private void SketchMouseMove(int x, int y)
- 8 {
- 9 if (!m_bInUse || m_pFeedback == null)
- 10 {
- 11 return;
- 12 }
- 13
- 14 // Move the feedback envelope and store the current mouse position
- 15 IActiveView pActiveView = (IActiveView)m_pMap;
- 16 m_pFeedback.MoveTo(pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y));
- 17 m_pPoint = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
- 18 }
11.完成新建对象,取得绘制的对象,并添加到图层中 :建议在Map.DblClick或Map.MouseDown(Button = 2)事件中调用本方法
- 1 /// <summary>
- 2 /// 完成新建对象,取得绘制的对象,并添加到图层中
- 3 /// 建议在Map.DblClick或Map.MouseDown(Button = 2)事件中调用本方法
- 4 /// </summary>
- 5 private void EndSketch()
- 6 {
- 7 IGeometry pGeom = null;
- 8 IPointCollection pPointCollection = null;
- 9
- 10 // Create a new feature if possible
- 11 if (m_pFeedback is INewMultiPointFeedback)
- 12 {
- 13 INewMultiPointFeedback pMPFeed = (INewMultiPointFeedback)m_pFeedback;
- 14 pMPFeed.Stop();
- 15 pGeom = (IGeometry)m_pPointCollection;
- 16 }
- 17 else if (m_pFeedback is INewLineFeedback)
- 18 {
- 19 INewLineFeedback pLineFeed = (INewLineFeedback)m_pFeedback;
- 20 pLineFeed.AddPoint(m_pPoint);
- 21 IPolyline pPolyLine = pLineFeed.Stop();
- 22 pPointCollection = (IPointCollection)pPolyLine;
- 23 if (pPointCollection.PointCount < 2)
- 24 MessageBox.Show("至少输入两个节点.", "错误的线几何对象", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
- 25 else
- 26 pGeom = (IGeometry)pPointCollection;
- 27 }
- 28 else if (m_pFeedback is INewPolygonFeedback)
- 29 {
- 30 INewPolygonFeedback pPolyFeed = (INewPolygonFeedback)m_pFeedback;
- 31 pPolyFeed.AddPoint(m_pPoint);
- 32 IPolygon pPolygon = pPolyFeed.Stop();
- 33 if (pPolygon != null)
- 34 pPointCollection = (IPointCollection)pPolygon;
- 35 if (pPointCollection.PointCount < 3)
- 36 MessageBox.Show("至少输入三个节点.", "错误的线几何对象", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
- 37 else
- 38 pGeom = (IGeometry)pPointCollection;
- 39 }
- 40 CreateFeature(pGeom);
- 41 m_pFeedback = null;
- 42 m_bInUse = false;
- 43 }
12.查询当前图层中鼠标位置处的地图对象,建议在Map.MouseDown事件中调用本方法
- 1 /// <summary>
- 2 /// 查询当前图层中鼠标位置处的地图对象
- 3 /// 建议在Map.MouseDown事件中调用本方法
- 4 /// </summary>
- 5 /// <param name="x">鼠标X坐标,屏幕坐标</param>
- 6 /// <param name="y">鼠标Y坐标,屏幕坐标</param>
- 7 private void SelectMouseDown(int x, int y)
- 8 {
- 9 // Searches the map for features at the given point in the current layer
- 10 // and selects them
- 11
- 12 m_pMap.ClearSelection();//清除地图中已选的要素
- 13 if (m_pCurrentLayer == null)
- 14 {
- 15 return;
- 16 }
- 17
- 18 if ((IGeoFeatureLayer)m_pCurrentLayer == null)
- 19 {
- 20 return;
- 21 }
- 22
- 23 // Get the feature layer and class of the current layer
- 24 IFeatureLayer pFeatureLayer = (IFeatureLayer)m_pCurrentLayer;
- 25 IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;
- 26 if (pFeatureClass == null)
- 27 {
- 28 return;
- 29 }
- 30
- 31 // Get the mouse down position in map coordinates
- 32 IActiveView pActiveView = (IActiveView)m_pMap;
- 33 IPoint pPoint = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
- 34 IGeometry pGeometry = pPoint;
- 35
- 36 // Use a four pixel buffer around the cursor for feature search
- 37 // 设置查询缓冲区
- 38 double length = ConvertPixelsToMapUnits(pActiveView, 4);
- 39 ITopologicalOperator pTopo = (ITopologicalOperator)pGeometry;
- 40 IGeometry pBuffer = pTopo.Buffer(length);
- 41 pGeometry = (IGeometry)pBuffer.Envelope;
- 42
- 43 // up a Filter specific to this layer
- 44 //设置过滤器对象
- 45 ISpatialFilter pSpatialFilter = new SpatialFilter();
- 46 pSpatialFilter.Geometry = pGeometry;
- 47 switch (pFeatureClass.ShapeType)
- 48 {
- 49 case esriGeometryType.esriGeometryPoint:
- 50 pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelContains;
- 51 break;
- 52 case esriGeometryType.esriGeometryPolyline:
- 53 pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelCrosses;
- 54 break;
- 55 case esriGeometryType.esriGeometryPolygon:
- 56 pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
- 57 break;
- 58 }
- 59 pSpatialFilter.GeometryField = pFeatureClass.ShapeFieldName;
- 60 IQueryFilter pFilter = pSpatialFilter;
- 61
- 62 // Do the search
- 63 // 查询
- 64 IFeatureCursor pCursor = pFeatureLayer.Search(pFilter, false);
- 65
- 66 // and select the features on the map
- 67 // 在地图上高亮显示查询结果
- 68 IFeature pFeature = pCursor.NextFeature();
- 69 while (pFeature != null)
- 70 {
- 71 m_pMap.SelectFeature(m_pCurrentLayer, pFeature);
- 72 pFeature = pCursor.NextFeature();
- 73 }
- 74 pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
- 75 }
13.编辑当前图层中鼠标击中的地图对象(开始编辑), 如果为点对象,可进行位置移动,如果为线对象或面对象,可进行节点编辑 : 建议在Map.MouseDown事件中调用本方法
- 1 /// <summary>
- 2 /// 编辑当前图层中鼠标击中的地图对象(开始编辑),
- 3 /// 如果为点对象,可进行位置移动,如果为线对象或面对象,可进行节点编辑
- 4 /// 建议在Map.MouseDown事件中调用本方法
- 5 /// </summary>
- 6 /// <param name="x">鼠标X坐标,屏幕坐标</param>
- 7 /// <param name="y">鼠标Y坐标,屏幕坐标</param>
- 8 /// <returns></returns>
- 9 private void EditFeature(int x, int y)
- 10 {
- 11 // Searches for features under the coordinate provided and starts an edit
- 12 // operation on the first one found.
- 13 IPoint pHitPoint = null;
- 14 double hitDist = 0;
- 15 int partIndex = 0;
- 16 int vertexIndex = 0;
- 17 int vertexOffset = 0;
- 18 bool vertex = false;
- 19
- 20 // Use the first feature in the selection
- 21 // 取得鼠标击中的第一个对象
- 22 SelectMouseDown(x, y);
- 23 IEnumFeature pSelected = (IEnumFeature)m_pMap.FeatureSelection;
- 24 IFeature pFeature = pSelected.Next();
- 25 if (pFeature == null)
- 26 {
- 27 return;
- 28 }
- 29
- 30 IActiveView pActiveView = (IActiveView)m_pMap;
- 31 IPoint pPoint = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
- 32
- 33 // Tolerance in pixels for line hits
- 34 // 节点空间查询容差
- 35 double tol = ConvertPixelsToMapUnits(pActiveView, 4);
- 36
- 37 // The feedback action / edit action depends on the geometry type
- 38 // and the location of point within the geometry
- 39 IGeometry pGeom = pFeature.Shape;
- 40 IObjectClass pObjectClass = pFeature.Class;
- 41 m_pEditFeature = pFeature;
- 42
- 43 switch (pGeom.GeometryType)
- 44 {
- 45 case esriGeometryType.esriGeometryPoint:
- 46 m_pFeedback = new MovePointFeedback();
- 47 m_pFeedback.Display = pActiveView.ScreenDisplay;
- 48 IMovePointFeedback pPointMove = (IMovePointFeedback)m_pFeedback;
- 49 pPointMove.Start((IPoint)pGeom, pPoint);
- 50 break;
- 51
- 52 case esriGeometryType.esriGeometryPolyline:
- 53 if (TestGeometryHit(tol, pPoint, pFeature, ref pHitPoint, ref hitDist,
- 54 ref partIndex, ref vertexIndex, ref vertexOffset, ref vertex))
- 55 {
- 56 if (!vertex)
- 57 {
- 58 // Get the path, add a point to it and vertex edit that newly added point
- 59 IGeometryCollection pGeomColn = (IGeometryCollection)pGeom;
- 60 IPath pPath = (IPath)pGeomColn.get_Geometry(partIndex);
- 61 IPointCollection pPointColn = (IPointCollection)pPath;
- 62 long numVertices = pPointColn.PointCount;
- 63
- 64 object Missing = Type.Missing;
- 65 object val;
- 66 if (vertexIndex == 0)
- 67 {
- 68 val = 1;
- 69 pPointColn.AddPoint(pPoint, ref val, ref Missing);
- 70 }
- 71 else
- 72 {
- 73 val = vertexIndex;
- 74 pPointColn.AddPoint(pPoint, ref Missing, ref val);
- 75 }
- 76
- 77 // Reset the index pointer to the new index
- 78 TestGeometryHit(tol, pPoint, pFeature, ref pHitPoint, ref hitDist, ref partIndex, ref vertexIndex, ref vertexOffset, ref vertex);
- 79 }
- 80 m_pFeedback = new LineMovePointFeedback();
- 81 m_pFeedback.Display = pActiveView.ScreenDisplay;
- 82 ILineMovePointFeedback pLineMove = (ILineMovePointFeedback)m_pFeedback;
- 83 pLineMove.Start((IPolyline)pGeom, vertexIndex, pPoint);
- 84 }
- 85 else
- 86 {
- 87 return;
- 88 }
- 89 //
- 90 break;
- 91
- 92 case esriGeometryType.esriGeometryPolygon:
- 93 if (TestGeometryHit(tol, pPoint, pFeature, ref pHitPoint, ref hitDist,
- 94 ref partIndex, ref vertexIndex, ref vertexOffset, ref vertex))
- 95 {
- 96 if (!vertex)
- 97 {
- 98 // Get the path, add a point to it and vertex edit that newly added point
- 99 IGeometryCollection pGeomColn = (IGeometryCollection)pGeom;
- 100 IPath pPath = (IPath)pGeomColn.get_Geometry(partIndex);
- 101 IPointCollection pPointColn = (IPointCollection)pPath;
- 102 long numVertices = pPointColn.PointCount;
- 103
- 104 // Rethe index pointer to the new index
- 105 object Missing = Type.Missing;
- 106 object val;
- 107 if (vertexIndex == 0)
- 108 {
- 109 val = 1;
- 110 pPointColn.AddPoint(pPoint, ref val, ref Missing);
- 111 }
- 112 else
- 113 {
- 114 val = vertexIndex;
- 115 pPointColn.AddPoint(pPoint, ref Missing, ref val);
- 116 }
- 117
- 118 // Reset the index pointer to the new index
- 119 TestGeometryHit(tol, pPoint, pFeature, ref pHitPoint, ref hitDist, ref partIndex, ref vertexIndex, ref vertexOffset, ref vertex);
- 120 }
- 121 m_pFeedback = new PolygonMovePointFeedback();
- 122 m_pFeedback.Display = pActiveView.ScreenDisplay;
- 123 IPolygonMovePointFeedback pPolyMove = (IPolygonMovePointFeedback)m_pFeedback;
- 124 pPolyMove.Start((IPolygon)pGeom, vertexIndex + vertexOffset, pPoint);
- 125 }
- 126 else
- 127 return;
- 128 break;
- 129 }
- 130
- 131 return;
- 132 }
14.编辑地图对象过程中的鼠标移动事件, 如果为点对象,进行位置移动;如果为线对象或面对象,进行节点移动:建议在Map.MouseMove事件中调用本方法
- 1 /// <summary>
- 2 /// 编辑地图对象过程中的鼠标移动事件,
- 3 /// 如果为点对象,进行位置移动
- 4 /// 如果为线对象或面对象,进行节点移动
- 5 /// 建议在Map.MouseMove事件中调用本方法
- 6 /// </summary>
- 7 /// <param name="x">鼠标X坐标,屏幕坐标</param>
- 8 /// <param name="y">鼠标Y坐标,屏幕坐标</param>
- 9 private void FtrEditMouseMove(int x, int y)
- 10 {
- 11 // Moves the edit feedback object along with the mouse.
- 12 if (m_pFeedback == null)
- 13 {
- 14 return;
- 15 }
- 16
- 17 IActiveView pActiveView = (IActiveView)m_pMap;
- 18 IPoint pPoint = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
- 19 m_pFeedback.MoveTo(pPoint);
- 20 }
15.结束feature的编辑
- 1 /// <summary>
- 2 /// 结束feature的编辑
- 3 /// </summary>
- 4 /// <param name="x"></param>
- 5 /// <param name="y"></param>
- 6 private void EndFtrEdit(int x, int y)
- 7 {
- 8 // Uses the feedback object//s geometry to rethe geometry on the feature
- 9 // being edited.
- 10
- 11 // if (no feedback no edit
- 12 if (m_pFeedback == null)
- 13 {
- 14 return;
- 15 }
- 16
- 17 IActiveView pActiveView = (IActiveView)m_pMap;
- 18 IPoint pPoint = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
- 19
- 20 if (m_pFeedback is IMovePointFeedback)
- 21 {
- 22 IMovePointFeedback pPointMove = (IMovePointFeedback)m_pFeedback;
- 23 IGeometry pGeometry = pPointMove.Stop();
- 24 UpdateFeature(m_pEditFeature, pGeometry);
- 25 }
- 26 else if (m_pFeedback is ILineMovePointFeedback)
- 27 {
- 28 ILineMovePointFeedback pLineMove = (ILineMovePointFeedback)m_pFeedback;
- 29 IGeometry pGeometry = pLineMove.Stop();
- 30 UpdateFeature(m_pEditFeature, pGeometry);
- 31 }
- 32 else if (m_pFeedback is IPolygonMovePointFeedback)
- 33 {
- 34 IPolygonMovePointFeedback pPolyMove = (IPolygonMovePointFeedback)m_pFeedback;
- 35 IGeometry pGeometry = pPolyMove.Stop();
- 36 UpdateFeature(m_pEditFeature, pGeometry);
- 37 }
- 38
- 39 m_pFeedback = null;
- 40 pActiveView.Refresh();
- 41 }
16.移动当前图层中鼠标击中地图对象的位置(开始移动):建议在Map.MouseDown事件中调用本方法
- 1 /// <summary>
- 2 /// 移动当前图层中鼠标击中地图对象的位置(开始移动)
- 3 /// 建议在Map.MouseDown事件中调用本方法
- 4 /// </summary>
- 5 /// <param name="x">鼠标X坐标,屏幕坐标</param>
- 6 /// <param name="y">鼠标Y坐标,屏幕坐标</param>
- 7 /// <returns></returns>
- 8 public bool MoveFeatureMouseDown(int x, int y)
- 9 {
- 10 try
- 11 {
- 12 m_pMap.ClearSelection();
- 13
- 14 SelectMouseDown(x, y);
- 15 IEnumFeature pSelected = (IEnumFeature)m_pMap.FeatureSelection;
- 16 IFeature pFeature = pSelected.Next();
- 17 if (pFeature == null) return false;
- 18
- 19 IActiveView pActiveView = (IActiveView)m_pMap;
- 20 IPoint pPoint = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
- 21
- 22 IGeometry pGeom = pFeature.Shape;
- 23 m_pEditFeature = pFeature;
- 24
- 25 switch (pGeom.GeometryType)
- 26 {
- 27 case esriGeometryType.esriGeometryPoint:
- 28 m_pFeedback = new MovePointFeedbackClass();
- 29 m_pFeedback.Display = pActiveView.ScreenDisplay;
- 30 IMovePointFeedback pPointMove = (IMovePointFeedback)m_pFeedback;
- 31 pPointMove.Start((IPoint)pGeom, pPoint);
- 32 break;
- 33 case esriGeometryType.esriGeometryPolyline:
- 34
- 35 m_pFeedback = new MoveLineFeedbackClass();
- 36 m_pFeedback.Display = pActiveView.ScreenDisplay;
- 37 IMoveLineFeedback pLineMove = (IMoveLineFeedback)m_pFeedback;
- 38 pLineMove.Start((IPolyline)pGeom, pPoint);
- 39 break;
- 40 case esriGeometryType.esriGeometryPolygon:
- 41 m_pFeedback = new MovePolygonFeedbackClass();
- 42 m_pFeedback.Display = pActiveView.ScreenDisplay;
- 43 IMovePolygonFeedback pPolyMove = (IMovePolygonFeedback)m_pFeedback;
- 44 pPolyMove.Start((IPolygon)pGeom, pPoint);
- 45 break;
- 46 }
- 47 return true;
- 48 }
- 49 catch (Exception e)
- 50 {
- 51 Console.WriteLine(e.Message.ToString());
- 52 return false;
- 53 }
- 54 }
17.移动地图对象过程中的鼠标移动事件:建议在Map.MouseMove事件中调用本方法
- 1 /// <summary>
- 2 /// 移动地图对象过程中的鼠标移动事件
- 3 /// 建议在Map.MouseMove事件中调用本方法
- 4 /// </summary>
- 5 /// <param name="x">鼠标X坐标,屏幕坐标</param>
- 6 /// <param name="y">鼠标Y坐标,屏幕坐标</param>
- 7 public void MoveFeatureMouseMove(int x, int y)
- 8 {
- 9 try
- 10 {
- 11 if (m_pFeedback == null) return;
- 12
- 13 IActiveView pActiveView = (IActiveView)m_pMap;
- 14 IPoint pPoint = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
- 15 m_pFeedback.MoveTo(pPoint);
- 16 }
- 17 catch (Exception e)
- 18 {
- 19 Console.WriteLine(e.Message.ToString());
- 20 }
- 21 }
18.完成地图对象移动,取得移动后的对象,并将其更新到图层中:建议在Map.MouseUp事件中调用本方法
- 1 /// <summary>
- 2 /// 完成地图对象移动,取得移动后的对象,并将其更新到图层中
- 3 /// 建议在Map.MouseUp事件中调用本方法
- 4 /// </summary>
- 5 public void MoveFeatureEnd()
- 6 {
- 7 IGeometry pGeometry;
- 8
- 9 try
- 10 {
- 11 if (m_pFeedback == null) return;
- 12
- 13 if (m_pFeedback is IMovePointFeedback)
- 14 {
- 15 IMovePointFeedback pPointMove = (IMovePointFeedback)m_pFeedback;
- 16 pGeometry = pPointMove.Stop();
- 17 UpdateFeature(m_pEditFeature, pGeometry);
- 18 }
- 19 else if (m_pFeedback is IMoveLineFeedback)
- 20 {
- 21 IMoveLineFeedback pLineMove = (IMoveLineFeedback)m_pFeedback;
- 22 pGeometry = pLineMove.Stop();
- 23 UpdateFeature(m_pEditFeature, pGeometry);
- 24 }
- 25 else if (m_pFeedback is IMovePolygonFeedback)
- 26 {
- 27 IMovePolygonFeedback pPolyMove = (IMovePolygonFeedback)m_pFeedback;
- 28 pGeometry = pPolyMove.Stop();
- 29 UpdateFeature(m_pEditFeature, pGeometry);
- 30 }
- 31
- 32 m_pFeedback = null;
- 33 IActiveView pActiveView = (IActiveView)m_pMap;
- 34 pActiveView.Refresh();
- 35 }
- 36 catch (Exception e)
- 37 {
- 38 Console.WriteLine(e.Message.ToString());
- 39 }
- 40 }
总结:终于结束了,感觉通过可视化来编辑空间数据需要做太多的工作,上面把要做的工作几乎都秒到了,至于具体流程这个只需要简单组织一下逻辑就可以了。更强大的空间数据编辑功能有待于我们更加活跃的思维去创造!OK!今天就到这里了吧!情人节已过,各位coder们赶快回来编程吧!
- 基于ArcGIS10.0和Oracle10g的空间数据管理平台十七(C#开发)-空间数据编辑(下)
- 基于ArcGIS10.0和Oracle10g的空间数据管理平台十七(C#开发)-空间数据编辑(下)
- 基于ArcGIS10.0和Oracle10g的空间数据管理平台十八(C#开发)-数据字典编辑
- 基于ArcGIS10.0和Oracle10g的空间数据管理平台十八(C#开发)-数据字典编辑
- 基于ArcGIS10.0和Oracle10g的空间数据管理平台十六(C#开发)-空间数据编辑(上)
- 基于ArcGIS10.0和Oracle10g的空间数据管理平台十六(C#开发)-空间数据编辑(上)
- 基于ArcGIS10.0和Oracle10g的空间数据管理平台十三(C#开发)-空间数据导出
- 基于ArcGIS10.0和Oracle10g的空间数据管理平台十五(C#开发)-空间数据导出
- 基于ArcGIS10.0和Oracle10g的空间数据管理平台十三(C#开发)-空间数据导出
- 基于ArcGIS10.0和Oracle10g的空间数据管理平台十五(C#开发)-空间数据导出
- 基于ArcGIS10.0和Oracle10g的空间数据管理平台(C#开发)-ArcGIS_Engine中的数据访问
- 基于ArcGIS10.0和Oracle10g的空间数据管理平台(C#开发)-ArcGIS_Engine中的数据访问
- 基于ArcGIS10.0和Oracle10g的空间数据管理平台(C#开发)-ArcGIS_Engine中的数据访问
- 基于ArcGIS10.0和Oracle10g的空间数据管理平台四(C#开发)-通用数据管理模块
- 基于ArcGIS10.0和Oracle10g的空间数据管理平台四(C#开发)-通用数据管理模块
- 基于ArcGIS10.0和Oracle10g的空间数据管理平台六(C#开发)-空间数据操作类
- 基于ArcGIS10.0和Oracle10g的空间数据管理平台九(C#开发)-空间数据导入RDBMS上-Shape格式
- 基于ArcGIS10.0和Oracle10g的空间数据管理平台十(C#开发)-空间数据导入RDBMS上-MDB格式
- 基于ArcGIS10.0和Oracle10g的空间数据管理平台十六(C#开发)-空间数据编辑(上)
- java内存区域与内存溢出异常(1)
- copy、mutableCopy详解
- Citrix Xenserver 6 安装注册激活步骤
- 三运输层(一)运输层概述
- 基于ArcGIS10.0和Oracle10g的空间数据管理平台十七(C#开发)-空间数据编辑(下)
- 基于ArcGIS10.0和Oracle10g的空间数据管理平台十八(C#开发)-数据字典编辑
- webService使用工具wsgen和wsimport
- 三运输层(二)UDP用户数据报协议
- Hibernate Lazy设置解析
- 让你自己写的Android的Launcher成为系统中第一个启动的,也是唯一的Launcher
- 三运输层(三)TCP传输控制协议(一)
- hibernate 延迟加载
- 虚拟化系列-Citrix XenServer 6.1 虚拟机的管理