I have parcel data intersecting line data. In the parcel data there are some parcels that don't intersect the line.
How could I programmatically figure out if the non-intersecting parcel is on the Right side or the Left side of the line?
Use the IHitTest interface. Your query point will be the polygon centroid and the input geometry will be the line. One of the outputs will be a boolean (bRightSide) which will tell you what side of the line you're on.
You can use the dot product for this
/// <summary>
/// Used to indicate the orientation of an object in space
/// with respect to another object
/// </summary>
public enum OrientationType
{
Left,
Right,
Coincident,
Unknown
}
/// <summary>
/// Determines if a point is oriented left, right or coincident with
/// a directed line.
/// Line direction is determined by its From and To points.
/// </summary>
/// <param name="p">The point to test.</param>
/// <param name="segment">The line dividing the space</param>
/// <returns>An OrientationType indicating the orientation.</returns>
public static OrientationType GetPointOrientation(IPoint p, ISegment segment)
{
OrientationType result = OrientationType.Unknown;
double Ax = segment.FromPoint.X;
double Ay = segment.FromPoint.Y;
double Bx = segment.ToPoint.X;
double By = segment.ToPoint.Y;
double Px = p.X;
double Py = p.Y;
double nDotV = ((Ay - By) * (Px - Ax)) + ((Bx - Ax) * (Py - Ay));
if (nDotV < 0)
{
result = OrientationType.Right;//opposite direction to normal vector
}
else if (nDotV > 0)
{
result = OrientationType.Left;
}
else if (nDotV == 0)
{
result = OrientationType.Coincident;
}
return result;
}
Algorithm to get desired result: