年度变更建库软件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.
 
 

94 lines
3.7 KiB

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 PointEx
{
public static bool IsSamePoint(this IPoint pPoint, IPoint pPointCompare, double dTolerance = 0.001)
{
if (pPoint != null && pPointCompare != null)
{
IProximityOperator proximityOperator = pPoint as IProximityOperator;
double num = proximityOperator.ReturnDistance(pPointCompare);
return num <= 0.001;
}
return false;
}
public static bool IsOnLine(this IPoint pPoint, System.Collections.Generic.List<IPolyline> listLines)
{
if (pPoint != null && listLines != null && listLines.Count >= 1)
{
int count = listLines.Count;
for (int i = 0; i < count; i++)
{
IRelationalOperator relationalOperator = listLines[i] as IRelationalOperator;
if (relationalOperator != null && (relationalOperator.Contains(pPoint) || relationalOperator.Touches(pPoint)))
{
return true;
}
}
return false;
}
return false;
}
public static bool IsOnLine(this IPoint pPoint, IPolyline pPolyline)
{
if (pPoint != null && pPolyline != null)
{
IRelationalOperator relationalOperator = pPolyline as IRelationalOperator;
return relationalOperator != null && (relationalOperator.Contains(pPoint) || relationalOperator.Touches(pPoint));
}
return false;
}
public static bool IsOnRing(this IPoint pPoint, IPolygon pPolygon)
{
if (pPoint != null && pPolygon != null)
{
ITopologicalOperator topologicalOperator = pPolygon as ITopologicalOperator;
IGeometry boundary = topologicalOperator.Boundary;
IRelationalOperator relationalOperator = boundary as IRelationalOperator;
return relationalOperator != null && (relationalOperator.Contains(pPoint) || relationalOperator.Touches(pPoint));
}
return false;
}
public static bool IsInGeometry(this IPoint pPoint, IGeometry pGeometry)
{
if (pPoint != null && pGeometry != null)
{
IRelationalOperator relationalOperator = pGeometry as IRelationalOperator;
return relationalOperator != null && (relationalOperator.Contains(pPoint) || relationalOperator.Touches(pPoint));
}
return false;
}
public static IPoint[] Explode(this IMultipoint iMultiPoint)
{
IPoint[] array = null;
IPointCollection pointCollection = iMultiPoint as IPointCollection;
int pointCount = pointCollection.PointCount;
if (pointCount != 1)
{
if (pointCount > 1)
{
array = new IPoint[pointCount];
for (int i = 0; i < pointCount; i++)
{
array[i] = new PointClass();
IPoint point = pointCollection.get_Point(i);
array[i].X = point.X;
array[i].Y = point.Y;
}
}
return array;
}
return new IPoint[]
{
iMultiPoint as IPoint
};
}
}
}