tags:

views:

146

answers:

1

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

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
Jacques Bosch
In my opinion using IEnvelope.Expand(x,y,false) on a search point's envelope is better in most cases. Yes, you can get a few extra hits near the corners, but I suspect envelope searches are faster than geometries containing circulararcs - which is what Buffer returns.
Kirk Kuykendall
Thanx. I'll look into that.
Jacques Bosch
As a side note, I see your name around, but how many active ArcObjects users are there here on stackoverflow? Seems quite quiet.
Jacques Bosch

related questions