overlaps method

bool overlaps(
  1. Geometry g
)

Tests whether this geometry overlaps the specified geometry.

The overlaps predicate has the following equivalent definitions:

  • The geometries have at least one point each not shared by the other (or equivalently neither covers the other), they have the same dimension, and the intersection of the interiors of the two geometries has the same dimension as the geometries themselves.
  • The DE-9IM Intersection Matrix for the two geometries matches [T*T***T**] (for two points or two surfaces) or [1*T***T**] (for two curves)
If the geometries are of different dimension this predicate returns false. This predicate is symmetric.

@param g the Geometry with which to compare this Geometry @return true if the two Geometrys overlap.

Implementation

bool overlaps(Geometry g) {
  // short-circuit test
  if (!getEnvelopeInternal().intersectsEnvelope(g.getEnvelopeInternal()))
    return false;
  return relate(g).isOverlaps(getDimension(), g.getDimension());
}