private IArray method_1(IGeometry igeometry_0, IGeometry igeometry_1) { IArray array; IPolyline polyline = null; ITopologicalOperator4 igeometry0 = null; if (!(igeometry_0 == null ? false : igeometry_1 != null)) { array = null; } else if (igeometry_0.GeometryType == esriGeometryType.esriGeometryPolygon) { polyline = (igeometry_1.GeometryType == esriGeometryType.esriGeometryPolyline ? (IPolyline)igeometry_1 : (IPolyline)((ITopologicalOperator4)igeometry_1).Boundary); igeometry0 = (ITopologicalOperator4)igeometry_0; IArray arrayClass = new Array(); IGeometryCollection geometryCollection = igeometry0.Cut2(polyline); for (int i = 0; i < geometryCollection.GeometryCount; i++) { arrayClass.Add(geometryCollection.Geometry[i]); } array = arrayClass; } else { array = null; } return(array); }
public static List <IFeature> Split(IFeature ifeature_0, IPolyline ipolyline_0) { IGeometry geometry; IGeometry geometry1; IFeature feature; IFeature feature1; List <IFeature> features = new List <IFeature>(); ITopologicalOperator4 shapeCopy = ifeature_0.ShapeCopy as ITopologicalOperator4; IGeometry geometry2 = shapeCopy.Intersect(ipolyline_0, esriGeometryDimension.esriGeometry0Dimension); List <IFeature> features1 = new List <IFeature>(); ZDEditTools.StartEditDateTime = DateTime.Now; if (geometry2.IsEmpty) { shapeCopy.Cut(ipolyline_0, out geometry, out geometry1); if ((geometry == null ? false : geometry1 != null)) { feature = ZDEditTools.WriteHistory(ifeature_0); feature1 = ZDEditTools.ZDFeatureClass.CreateFeature(); features.Add(feature1); feature1.Shape = geometry; RowOperator.CopyFeatureAttributeToFeature(ifeature_0, feature1); feature1.Store(); ZDEditTools.Oids.Add(feature1.OID); ZDEditTools.WriteHistoryLine(ifeature_0, feature1, feature, 2, ZDEditTools.StartEditDateTime); feature1 = ZDEditTools.ZDFeatureClass.CreateFeature(); features.Add(feature1); feature1.Shape = geometry1; RowOperator.CopyFeatureAttributeToFeature(ifeature_0, feature1); feature1.Store(); ZDEditTools.Oids.Add(feature1.OID); ZDEditTools.WriteHistoryLine(ifeature_0, feature1, feature, 2, ZDEditTools.StartEditDateTime); ifeature_0.Delete(); } } else if ((!(geometry2 is IMultipoint) ? false : (geometry2 as IPointCollection).PointCount > 1)) { ISpatialFilter spatialFilterClass = new SpatialFilter() { Geometry = ipolyline_0, SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects }; IFeatureCursor featureCursor = (ifeature_0.Class as IFeatureClass).Search(spatialFilterClass, false); for (IFeature i = featureCursor.NextFeature(); i != null; i = featureCursor.NextFeature()) { if (i.OID != ifeature_0.OID) { features1.Add(i); } } ComReleaser.ReleaseCOMObject(featureCursor); int pointCount = (geometry2 as IPointCollection).PointCount; IPoint point = (geometry2 as IPointCollection).Point[0]; IPoint point1 = (geometry2 as IPointCollection).Point[pointCount - 1]; foreach (IFeature feature2 in features1) { ZDEditTools.HitTest(feature2, point); ZDEditTools.HitTest(feature2, point1); } IGeometryCollection geometryCollection = shapeCopy.Cut2(ipolyline_0); DateTime startEditDateTime = ZDEditTools.StartEditDateTime; feature = ZDEditTools.WriteHistory(ifeature_0); for (int j = 0; j < geometryCollection.GeometryCount; j++) { IGeometry geometry3 = geometryCollection.Geometry[j]; feature1 = ZDEditTools.ZDFeatureClass.CreateFeature(); features.Add(feature1); feature1.Shape = geometry3; RowOperator.CopyFeatureAttributeToFeature(ifeature_0, feature1); feature1.Store(); ZDEditTools.Oids.Add(feature1.OID); ZDEditTools.WriteHistoryLine(ifeature_0, feature1, feature, 2, startEditDateTime); } ifeature_0.Delete(); } return(features); }
public static System.Collections.Generic.List <IFeature> Split(IFeature ifeature_0, IPolyline ipolyline_0) { System.Collections.Generic.List <IFeature> list = new System.Collections.Generic.List <IFeature>(); ITopologicalOperator4 topologicalOperator = ifeature_0.ShapeCopy as ITopologicalOperator4; IGeometry geometry = topologicalOperator.Intersect(ipolyline_0, esriGeometryDimension.esriGeometry0Dimension); System.Collections.Generic.List <IFeature> list2 = new System.Collections.Generic.List <IFeature>(); ZDEditTools.StartEditDateTime = System.DateTime.Now; if (geometry.IsEmpty) { IGeometry geometry2; IGeometry geometry3; topologicalOperator.Cut(ipolyline_0, out geometry2, out geometry3); if (geometry2 != null && geometry3 != null) { IFeature ifeature_ = ZDEditTools.WriteHistory(ifeature_0); IFeature feature = ZDEditTools.ZDFeatureClass.CreateFeature(); list.Add(feature); feature.Shape = geometry2; RowOperator.CopyFeatureAttributeToFeature(ifeature_0, feature); feature.Store(); ZDEditTools.Oids.Add(feature.OID); ZDEditTools.WriteHistoryLine(ifeature_0, feature, ifeature_, 2, ZDEditTools.StartEditDateTime); feature = ZDEditTools.ZDFeatureClass.CreateFeature(); list.Add(feature); feature.Shape = geometry3; RowOperator.CopyFeatureAttributeToFeature(ifeature_0, feature); feature.Store(); ZDEditTools.Oids.Add(feature.OID); ZDEditTools.WriteHistoryLine(ifeature_0, feature, ifeature_, 2, ZDEditTools.StartEditDateTime); ifeature_0.Delete(); } } else if (geometry is IMultipoint && (geometry as IPointCollection).PointCount > 1) { ISpatialFilter spatialFilter = new SpatialFilter(); spatialFilter.Geometry = ipolyline_0; spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; IFeatureCursor featureCursor = (ifeature_0.Class as IFeatureClass).Search(spatialFilter, false); for (IFeature feature2 = featureCursor.NextFeature(); feature2 != null; feature2 = featureCursor.NextFeature()) { if (feature2.OID != ifeature_0.OID) { list2.Add(feature2); } } ComReleaser.ReleaseCOMObject(featureCursor); int pointCount = (geometry as IPointCollection).PointCount; IPoint ipoint_ = (geometry as IPointCollection).get_Point(0); IPoint ipoint_2 = (geometry as IPointCollection).get_Point(pointCount - 1); foreach (IFeature current in list2) { ZDEditTools.HitTest(current, ipoint_); ZDEditTools.HitTest(current, ipoint_2); } IGeometryCollection geometryCollection = topologicalOperator.Cut2(ipolyline_0); System.DateTime startEditDateTime = ZDEditTools.StartEditDateTime; IFeature ifeature_ = ZDEditTools.WriteHistory(ifeature_0); for (int i = 0; i < geometryCollection.GeometryCount; i++) { IGeometry shape = geometryCollection.get_Geometry(i); IFeature feature = ZDEditTools.ZDFeatureClass.CreateFeature(); list.Add(feature); feature.Shape = shape; RowOperator.CopyFeatureAttributeToFeature(ifeature_0, feature); feature.Store(); ZDEditTools.Oids.Add(feature.OID); ZDEditTools.WriteHistoryLine(ifeature_0, feature, ifeature_, 2, startEditDateTime); } ifeature_0.Delete(); } return(list); }