contains method

bool contains(
  1. Point point
)

Returns whether or not the Polygon contains the Point. Uses the Ray Casting algorithm.

Example:

Polygon polygon = Polygon([
  LinearRing([
    Coordinate(0, 0),
    Coordinate(0, 1),
    Coordinate(1, 1),
    Coordinate(1, 0),
    Coordinate(0, 0),
  ]),
]);
print(polygon.contains(Point(0.5, 0.5))); // true

Implementation

bool contains(Point point) {
  return coordinates.first.contains(point) &&
      !coordinates.sublist(1).any((ring) => ring.contains(point));
}