locatePointInRingList static method

int locatePointInRingList(
  1. Coordinate p,
  2. List<Coordinate> ring
)

Determines the {@link Location} of a point in a ring. This method is an exemplar of how to use this class.

@param p the point to test @param ring an array of Coordinates forming a ring @return the location of the point in the ring

Implementation

static int locatePointInRingList(Coordinate p, List<Coordinate> ring) {
  RayCrossingCounter counter = new RayCrossingCounter(p);

  for (int i = 1; i < ring.length; i++) {
    Coordinate p1 = ring[i];
    Coordinate p2 = ring[i - 1];
    counter.countSegment(p1, p2);
    if (counter.isOnSegment()) return counter.getLocation();
  }
  return counter.getLocation();
}