如何缓冲 IPoint 或 IGeometry? (如何对 IPoint 进行缓冲相交检查?)

发布于 2024-08-31 13:15:33 字数 781 浏览 4 评论 0原文

如何缓冲 IPoint 以使用 IRelationalOperator 进行相交检查?

为了论证起见,我有:

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));
}

How would I buffer an IPoint to do an intersection check using IRelationalOperator?

I have, for arguments sake:

IPoint p1 = xxx;
IPoint p2 = yyy;
IRelationalOperator rel1 = (IRelationalOperator)p1;
   if (rel.Intersects (p2))
    // Do something

But now I want to add a tolerance to my check, so I assume the right way to do that is by either buffering p1 or p2. Right?
How do I add such a buffer?

Note: the Intersects method I am using is an extension method I wrote to simplify my code. Here it is:

/// <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));
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

月寒剑心 2024-09-07 13:15:33

好的,我找到了答案。或者一个答案。
使用 ITopologicalOperator 接口。

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

OK, I found the answer. Or an answer.
Use the ITopologicalOperator interface.

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文