年度变更建库软件5.0版本
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
3.0 KiB

using ESRI.ArcGIS.ADF;
using ESRI.ArcGIS.Geometry;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace KGIS.PlatformPlugin.Commands.Tools.TraceTool
{
public static class SegmentEx
{
public static IPolyline ConvertSegmentToPolyline(this ISegment pSegment)
{
if (pSegment == null)
{
return null;
}
ISegmentCollection segmentCollection = new PolylineClass();
if (segmentCollection != null)
{
ISegmentCollection arg_20_0 = segmentCollection;
object value = System.Reflection.Missing.Value;
object value2 = System.Reflection.Missing.Value;
arg_20_0.AddSegment(pSegment, ref value, ref value2);
return segmentCollection as IPolyline;
}
return null;
}
public static System.Collections.Generic.List<IPoint> GetInterserctPoint(this ISegment pSegment0, ISegment pSegment1)
{
IPolyline polyline = new PolylineClass();
IPolyline polyline2 = new PolylineClass();
ISegmentCollection arg_25_0 = polyline as ISegmentCollection;
object value = System.Reflection.Missing.Value;
object value2 = System.Reflection.Missing.Value;
arg_25_0.AddSegment(pSegment0, ref value, ref value2);
ISegmentCollection arg_43_0 = polyline2 as ISegmentCollection;
object value3 = System.Reflection.Missing.Value;
object value4 = System.Reflection.Missing.Value;
arg_43_0.AddSegment(pSegment1, ref value3, ref value4);
System.Collections.Generic.List<IPoint> list = new System.Collections.Generic.List<IPoint>();
ITopologicalOperator topologicalOperator = polyline as ITopologicalOperator;
IRelationalOperator relationalOperator = polyline as IRelationalOperator;
if (relationalOperator.Crosses(polyline2))
{
IGeometry geometry = topologicalOperator.Intersect(polyline2, esriGeometryDimension.esriGeometry0Dimension);
if (geometry != null && !geometry.IsEmpty)
{
if (geometry is IPoint)
{
list.Add(geometry as IPoint);
}
if (geometry is IMultipoint)
{
IPointCollection pointCollection = geometry as IPointCollection;
int pointCount = pointCollection.PointCount;
for (int i = 0; i < pointCount; i++)
{
IPoint item = pointCollection.get_Point(i);
list.Add(item);
}
}
}
}
ComReleaser.ReleaseCOMObject(polyline);
ComReleaser.ReleaseCOMObject(polyline2);
return list;
}
}
}