如何使用IRelationalOperator缓冲IPoint以进行交叉检查?
为了论证,我有:
IPoint p1 = xxx;
IPoint p2 = yyy;
IRelationalOperator rel1 = (IRelationalOperator)p1;
if (rel.Intersects (p2))
// Do something
但是现在我想为我的支票添加一个容差,所以我认为正确的方法是通过缓冲p1或p2。对? 如何添加这样的缓冲区?
注意:我使用的Intersects方法是我为简化代码而编写的扩展方法。这是:
/// <summary>
/// Returns true if the IGeometry is intersected.
/// This method negates the Disjoint method.
/// </summary>
/// <param name="relOp">The rel op.</param>
/// <param name="other">The other.</param>
/// <returns></returns>
public static bool Intersects (
this IRelationalOperator relOp,
IGeometry other)
{
return (!relOp.Disjoint (other));
}
答案 0 :(得分:2)
IPoint p1 = xxx;
IPoint p2 = yyy;
ITopologicalOperator topoOp = (ITopologicalOperator)p2 ;
IGeometry p2Bufferd = topoOp.Buffer (bufferSize);
IRelationalOperator rel1 = (IRelationalOperator)p1;
if (rel.Intersects (p2Bufferd))
// Do something