isOnLineList static method

bool isOnLineList(
  1. Coordinate p,
  2. List<Coordinate> line
)

Tests whether a point lies on the line defined by a list of coordinates.

@param p the point to test @param line the line coordinates @return true if the point is a vertex of the line or lies in the interior of a line segment in the line

Implementation

static bool isOnLineList(Coordinate p, List<Coordinate> line) {
  LineIntersector lineIntersector = new RobustLineIntersector();
  for (int i = 1; i < line.length; i++) {
    Coordinate p0 = line[i - 1];
    Coordinate p1 = line[i];
    lineIntersector.computeIntersectionPointLine(p, p0, p1);
    if (lineIntersector.hasIntersection()) {
      return true;
    }
  }
  return false;
}