用线切割面

//不太常用,标记       

public IGeometryCollection CutPolygon(IPolygon polygon,IPolyline polyline)
        {
            if (polygon == null || polyline == null)
            {
                return null;
            }
            ITopologicalOperator4 topologicalOperator4 = polygon as ITopologicalOperator4; // Dynamic Cast
            IGeometryCollection geometryCollection = topologicalOperator4.Cut2(polyline);
            return geometryCollection;
       }

//大数据量计算时,速度不理想

        public void SplitPolygonFeaturesByLine(IFeatureClass polygonFC, IFeatureClass lineFC)
        {
            if (polygonFC.ShapeType != esriGeometryType.esriGeometryPolygon)
            {
                MessageBox.Show("The target layer is not a polygon layer.");
                return;
            }
            IFeatureCursor lineFeatureCursor = lineFC.Search(null, false);

            IGeoDataset geoDS = polygonFC as IGeoDataset;
            IEnvelope processingBounds = geoDS.Extent;

            //Define an IInValidArea object.
            IInvalidArea invalidArea = new InvalidAreaClass();

            //Define a construct feature object.
            IFeatureConstruction featureConstruction = new FeatureConstructionClass();

            //Start an edit session.
            IDataset dataset = polygonFC as IDataset;
            IWorkspace workspace = dataset.Workspace;
            IWorkspaceEdit workspaceEdit = workspace as IWorkspaceEdit;

            if (workspaceEdit.IsBeingEdited() != true)
            {
                workspaceEdit.StartEditing(true);
                workspaceEdit.StartEditOperation();
            }
            try
            {
                featureConstruction.SplitPolygonsWithLinesFromCursor(null, polygonFC, processingBounds, lineFeatureCursor, invalidArea, -1);
                workspaceEdit.StopEditOperation();
                workspaceEdit.StopEditing(true);
            }

            catch (Exception e)
            {
                //Abort the edit operation if errors are detected.
                MessageBox.Show("Construct polygons failed. " + e.Message);
                workspaceEdit.AbortEditOperation();
            }
        }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值