indexOfAfter method

LinearLocation indexOfAfter(
  1. Coordinate inputPt,
  2. LinearLocation minIndex
)

Find the nearest {@link LinearLocation} along the linear {@link Geometry} to a given {@link Coordinate} after the specified minimum {@link LinearLocation}. If possible the location returned will be strictly greater than the minLocation. If this is not possible, the value returned will equal minLocation. (An example where this is not possible is when minLocation = end of line ).

@param inputPt the coordinate to locate @param minIndex the minimum location for the point location @return the location of the nearest point

Implementation

LinearLocation indexOfAfter(Coordinate inputPt, LinearLocation minIndex) {
  if (minIndex == null) return indexOf(inputPt);

  // sanity check for minLocation at or past end of line
  LinearLocation endLoc = LinearLocation.getEndLocation(linearGeom);
  if (endLoc.compareTo(minIndex) <= 0) return endLoc;

  LinearLocation closestAfter = indexOfFromStart(inputPt, minIndex);
  /**
   * Return the minDistanceLocation found.
   * This will not be null, since it was initialized to minLocation
   */
  Assert.isTrue(closestAfter.compareTo(minIndex) >= 0,
      "computed location is before specified minimum location");
  return closestAfter;
}