当前位置: 首页>>代码示例>>C#>>正文


C# PolylineClass.RemovePoints方法代码示例

本文整理汇总了C#中PolylineClass.RemovePoints方法的典型用法代码示例。如果您正苦于以下问题:C# PolylineClass.RemovePoints方法的具体用法?C# PolylineClass.RemovePoints怎么用?C# PolylineClass.RemovePoints使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PolylineClass的用法示例。


在下文中一共展示了PolylineClass.RemovePoints方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: deleteFeature

        //IFeatureLayer m_FeatureLayer
        /// <summary>
        /// 删除节点
        /// </summary>
        /// <param name="m_Feature"></param>
        public bool deleteFeature(int x, int y)
        {
            //IGeometryCollection pGeomColn ;
            //IPointCollection pPointColn;
            IObjectClass pObjectClass;
            IFeature pFeature;
            IGeometry pGeom;

            //IPath pPath ;
            IPoint pHitPoint = null;
            IPoint pPoint = null;
            Double hitDist = 0.0;
            double tol;
            int vertexIndex = 0;
            //int numVertices;
            int partIndex = 0;
            bool vertex = false;
            try
            {
                m_pMap.ClearSelection();
                // 取得鼠标击中的第一个对象
                SelectMouseDown(x, y);
                IEnumFeature pSelected = (IEnumFeature)m_pMap.FeatureSelection;
                pFeature = pSelected.Next();
                if (pFeature == null) return false;
                IActiveView pActiveView = (IActiveView)m_pMap;
                pPoint = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
                // 节点空间查询容差
                tol = ConvertPixelsToMapUnits(pActiveView, 4.0);
                pGeom = pFeature.Shape;
                pObjectClass = pFeature.Class;
                m_pEditFeature = pFeature;
                object objNull = Missing.Value;
                //object objBefore, objAfter;

                IPointCollection pointCollection;
                if (m_pEditFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline & TestGeometryHit(tol, pPoint, pFeature, pHitPoint, hitDist, out partIndex, out vertexIndex, out vertex))
                {
                    pointCollection = new PolylineClass();
                    IPolyline polyline = m_pEditFeature.Shape as IPolyline;
                    pointCollection = polyline as IPointCollection;
                    //如果点个数少于两个就无法构成线
                    if (pointCollection.PointCount > 2)
                    {
                        //移除指定的节点
                        pointCollection.RemovePoints(vertexIndex, 1);
                    }
                    else
                    {
                        MessageBox.Show("此先已经少于两个点,不能在删除");
                    }
                }
                else if (m_pEditFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolygon & TestGeometryHit(tol, pPoint, pFeature, pHitPoint, hitDist, out partIndex, out vertexIndex, out vertex))
                {
                    pointCollection = new PolygonClass();
                    IPolygon polygon = m_pEditFeature.Shape as IPolygon;
                    pointCollection = polygon as IPointCollection;
                    //点数少于三个就不能能构成面
                    if (pointCollection.PointCount > 3)
                    {
                        //移除指点的节点
                        pointCollection.RemovePoints(vertexIndex, 1);
                    }
                    else
                    {
                        MessageBox.Show("此先已经少于三个点,不能在删除");
                    }
                }
                IWorkspaceEdit workspaceEdit;
                IWorkspace workspace;
                IFeatureLayer pFeatureLayer = (IFeatureLayer)m_pCurrentLayer;
                IDataset dataset = pFeatureLayer.FeatureClass as IDataset;
                workspace = dataset.Workspace;
                workspaceEdit = workspace as IWorkspaceEdit;
                //开始编辑
                workspaceEdit.StartEditing(true);
                workspaceEdit.StartEditOperation();
                //保存数据
                m_pEditFeature.Store();
                //结束编辑
                workspaceEdit.StopEditOperation();
                workspaceEdit.StopEditing(true);
                pActiveView = (IActiveView)m_pMap;
                pActiveView.Refresh();
                return true;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message.ToString());
                return false;
            }
        }
开发者ID:609878415,项目名称:fff12138,代码行数:97,代码来源:AoEditor.cs


注:本文中的PolylineClass.RemovePoints方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。