判斷要素位置關係
public static bool DKContains(this IGeometry geometry1, IGeometry geometry2)
{
//使用IRelationalOperator的方法來判斷空間位置關係
IRelationalOperator pRelOperator = geometry1 as IRelationalOperator;
if (!pRelOperator.Touches(geometry2) && !pRelOperator.Disjoint(geometry2))
{
return true;
}
else
{
return false;
}
}
public static bool Touches(this IGeometry geometry1, IGeometry geometry2)
{
//使用IRelationalOperator的方法來判斷空間位置關係
IRelationalOperator pRelOperator = geometry1 as IRelationalOperator;
if (pRelOperator.Touches(geometry2))
{
return true;
}
else
{
return false;
}
}
/// <summary>
/// 判斷前者是否在後者內部
/// </summary>
/// <param name="geo1"></param>
/// <param name="geo2"></param>
/// <returns></returns>
public static bool Within(this IGeometry geo1, IGeometry geo2)
{
//使用IRelationalOperator的方法來判斷空間位置關係
IRelationalOperator pRelOperator = geo1 as IRelationalOperator;
return pRelOperator.Within(geo2);
}