isBoundaryInsidePolygon static method

bool isBoundaryInsidePolygon(
  1. BoundingBox boundary,
  2. List<ILatLong> polygon
)

Checks if a bounding box is completely contained within a polygon.

boundary The rectangular boundary to test polygon List of vertices defining the polygon Returns true if the entire boundary is inside the polygon

Implementation

static bool isBoundaryInsidePolygon(BoundingBox boundary, List<ILatLong> polygon) {
  if (polygon.length < 3) return false;

  // Get boundary corner points
  List<ILatLong> boundaryCorners = [
    LatLong(boundary.maxLatitude, boundary.minLongitude), // top-left
    LatLong(boundary.maxLatitude, boundary.maxLongitude), // top-right
    LatLong(boundary.minLatitude, boundary.maxLongitude), // bottom-right
    LatLong(boundary.minLatitude, boundary.minLongitude), // bottom-left
  ];

  // Check if all boundary corners are inside the polygon
  for (ILatLong corner in boundaryCorners) {
    if (!isPointInPolygon(corner, polygon)) {
      return false;
    }
  }

  return true;
}