/// <summary> /// 创建要素 /// </summary> /// <param name="pGeometry"></param> private void CreateFeature(IGeometry pGeometry) { try { if (m_EngineEditLayers == null) { return; } IFeatureLayer pFeatLyr = m_EngineEditLayers.TargetLayer; if (pFeatLyr == null) { return; } IFeatureClass pFeatCls = pFeatLyr.FeatureClass; if (pFeatCls == null) { return; } if (m_EngineEditor == null) { return; } if (pGeometry == null) { return; } ITopologicalOperator pTop = pGeometry as ITopologicalOperator; pTop.Simplify(); IGeoDataset pGeoDataset = pFeatCls as IGeoDataset; if (pGeoDataset.SpatialReference != null) { pGeometry.Project(pGeoDataset.SpatialReference); } m_EngineEditor.StartOperation(); IFeature pFeature = null; pFeature = pFeatCls.CreateFeature(); pFeature.Shape = SupportZMFeatureClass.ModifyGeomtryZMValue(pFeatCls, pGeometry); pFeature.Store(); m_EngineEditor.StopOperation("添加要素"); m_Map.SelectFeature(pFeatLyr, pFeature); m_activeView.Refresh(); } catch (Exception ex) { } }
private void MoveFeature(IFeature pFeature, IPoint lastpoint, IPoint firstpoint) { double deltax; double deltay; IGeoDataset pGeoDataSet; ITransform2D transform; IGeometry pGeometry; IFeatureClass pClass = pFeature.Class as IFeatureClass; pGeoDataSet = pClass as IGeoDataset; pGeometry = pFeature.Shape; if (pGeometry.GeometryType == esriGeometryType.esriGeometryMultiPatch || pGeometry.GeometryType == esriGeometryType.esriGeometryPoint || pGeometry.GeometryType == esriGeometryType.esriGeometryPolyline || pGeometry.GeometryType == esriGeometryType.esriGeometryPolygon) { pGeometry = pFeature.Shape; transform = pGeometry as ITransform2D; if (!MapManager.CalDistance(lastpoint, firstpoint, out deltax, out deltay)) { MessageBox.Show("计算距离出现错误", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } //根据两点在X轴和Y轴上的距离差,对要素进行移动 transform.Move(deltax, deltay); pGeometry = (IGeometry)transform; if (pGeoDataSet.SpatialReference != null) { pGeometry.Project(pGeoDataSet.SpatialReference); } pFeature.Shape = SupportZMFeatureClass.ModifyGeomtryZMValue(pClass, pGeometry); //保存移动后的对象 pFeature.Store(); } }