isLineStringContainedInBoundary method

bool isLineStringContainedInBoundary(
  1. LineString line
)

Tests if a linestring is completely contained in the boundary of the target rectangle. @param line the linestring to test @return true if the linestring is contained in the boundary

Implementation

bool isLineStringContainedInBoundary(LineString line) {
  CoordinateSequence seq = line.getCoordinateSequence();
  Coordinate p0 = new Coordinate.empty2D();
  Coordinate p1 = new Coordinate.empty2D();
  for (int i = 0; i < seq.size() - 1; i++) {
    seq.getCoordinateInto(i, p0);
    seq.getCoordinateInto(i + 1, p1);

    if (!isLineSegmentContainedInBoundary(p0, p1)) return false;
  }
  return true;
}