containsCoordinates method
- Coordinates point
override
Checks if the specified point is contained within the geographic area.
Parameters
- IN point A Coordinates object representing the point to check.
Returns
- True if the point is within the geographic area, false otherwise.
Implementation
@override
bool containsCoordinates(final Coordinates point) {
final int nVecs = coordinates.length;
if (nVecs < 3) {
return false;
}
int i = 0;
int j = nVecs - 1;
bool status = false;
while (i < nVecs) {
final Coordinates ci = coordinates[i];
final Coordinates cj = coordinates[j];
if ((ci.latitude > point.latitude) != (cj.latitude > point.latitude)) {
final double intersectLongitude = (point.latitude - ci.latitude) *
(cj.longitude - ci.longitude) /
(cj.latitude - ci.latitude) +
ci.longitude;
if (point.longitude < intersectLongitude) {
status = !status;
}
}
j = i++;
}
return status;
}