mohammedX6/poly_bool_dart

[Feature suggestion] Add a `contains(Coordinate c)` method.

n3o2k7i8ch5 opened this issue · 1 comments

It would come really handy if it was possible to check if a coordinate is contained by the polygon.

bool contains(Coordinate c, {bool includeBorder = true});

E.g.:

Polygon poly = Polygon(regions: [
  [
    Coordinate(10, 10),
    Coordinate(10, 0),
    Coordinate(0, 0),
    Coordinate(0, 10),
  ]
]);

poly.contains(Coordinate(5, 5));  // true
poly.contains(Coordinate(10, 5), includeBorder = true);  // true
poly.contains(Coordinate(10, 5), includeBorder = false);  // false

Afaik it would simply mean to iterate through all regions in the Polygon object and check if the number of regions containing the Coordinate is odd.

Hi
I would suggest using this library https://pub.dev/packages/dart_jts
It has features you want
Thanks!