* @private
*/
private static boolean isWithinRing(LinearRing linearRing, Coordinate coordinate) {
int counter = 0;
int num = linearRing.getNumPoints();
Coordinate c1 = linearRing.getCoordinateN(0);
for (int i = 1; i <= num; i++) {
Coordinate c2 = linearRing.getCoordinateN(i % num); // this way, it should work to concatenate all ring
// coordinate arrays of a polygon....(if they all have an equal number of coordinates)
if (coordinate.getY() > Math.min(c1.getY(), c2.getY())) { // some checks to try and avoid the expensive
// intersect calculation.
if (coordinate.getY() <= Math.max(c1.getY(), c2.getY())) {
if (coordinate.getX() <= Math.max(c1.getX(), c2.getX())) {
if (c1.getY() != c2.getY()) {
double xIntercept = (coordinate.getY() - c1.getY()) * (c2.getX() - c1.getX())
/ (c2.getY() - c1.getY()) + c1.getX();
if (c1.getX() == c2.getX() || coordinate.getX() <= xIntercept) {
counter++;
}
}
}
}