intersects method

bool intersects(
  1. RectangleGeographicArea area
)

Tests whether this rectangle intersects with another rectangle.

Determines if the two rectangles have any overlapping area, including cases where they share an edge or corner. The test uses standard rectangle intersection logic comparing the bounds of both rectangles.

Parameters

Returns

  • true if the rectangles intersect or touch, false if they are completely separate.

Implementation

bool intersects(final RectangleGeographicArea area) {
  return bottomRight.longitude >= area.topLeft.longitude &&
      area.bottomRight.longitude >= topLeft.longitude &&
      topLeft.latitude >= area.bottomRight.latitude &&
      area.topLeft.latitude >= bottomRight.latitude;
}