两条线相交,有多个交点,如何用这些交点一次性分割其中的一条线,获取其所有分割后的要素

两条线相交,有多个交点,如何用这些交点一次性分割其中的一条线,获取其所有分割后的要素
已邀请:

朱新颖

赞同来自:

【解决办法】:
想要一次性得到所有的打断线可以使用IPolycurve2.SplitAtPoints进行多点的切割。执行完后该IPolyline变为了多个Part,可以转为IGeometryCollection,遍历获取每个部分,新建Feature。参考该部分代码可以实现(前提是两条线有交点)。

ITopologicalOperator qTopologicalOperator = qFeature.Shape as ITopologicalOperator;//qFeature为要打断的线要素
IPointCollection qPointCollection = qTopologicalOperator.Intersect(mGeometry, esriGeometryDimension.esriGeometry0Dimension) as IPointCollection; // mGeometry为与其相交的线
IPolyline qPolyline = qFeature.Shape as IPolyline;

IEnumVertex enumVertex = qPointCollection.EnumVertices;
IPolycurve2 polycurve = qPolyline as IPolycurve2;
polycurve.SplitAtPoints(enumVertex,false,true,1);
IGeometryCollection geoCol = polycurve as IGeometryCollection;
object Missing = Type.Missing;
for(int i = 0;i<geoCol.GeometryCount;i++)
{
IFeature newFea = qFeatureClass.CreateFeature();
IGeometryCollection newPol = new PolylineClass();
IPath geo = new PathClass();
geo = geoCol.get_Geometry(i) as IPath;
newPol.AddGeometry(geo as IGeometry,ref Missing, ref Missing);
newFea.Shape = newPol as IGeometry;
newFea.Store();
}

xiaosi9524 - GISER

赞同来自:

polycurve.SplitAtPoints(enumVertex,false,true,1);
程序在执行到这句的时候崩溃了 没有任何提示,请问在何种情况下会出现这种情况?(使用直线切割椭圆)

要回复问题请先登录注册