isGeoPointInPolygon method
check if a given geo point is in the a polygon using even-odd rule algorithm
Implementation
bool isGeoPointInPolygon(Coordinate l, List<Coordinate> polygon) {
var isInPolygon = false;
for (var i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
if ((((polygon[i].y <= l.y) && (l.y < polygon[j].y)) ||
((polygon[j].y <= l.y) && (l.y < polygon[i].y))) &&
(l.x <
(polygon[j].x - polygon[i].x) *
(l.y - polygon[i].y) /
(polygon[j].y - polygon[i].y) +
polygon[i].x)) isInPolygon = !isInPolygon;
}
return isInPolygon;
}