isValid method

bool isValid(
  1. Geometry linearGeom
)

Tests whether this location refers to a valid location on the given linear {@link Geometry}.

@param linearGeom a linear geometry @return true if this location is valid

Implementation

bool isValid(Geometry linearGeom) {
  if (componentIndex < 0 || componentIndex >= linearGeom.getNumGeometries())
    return false;

  LineString lineComp = linearGeom.getGeometryN(componentIndex) as LineString;
  if (segmentIndex < 0 || segmentIndex > lineComp.getNumPoints())
    return false;
  if (segmentIndex == lineComp.getNumPoints() && segmentFraction != 0.0)
    return false;

  if (segmentFraction < 0.0 || segmentFraction > 1.0) return false;
  return true;
}