isOnSameSegment method

bool isOnSameSegment(
  1. LinearLocation loc
)

Tests whether two locations are on the same segment in the parent {@link Geometry}.

@param loc a location on the same geometry @return true if the locations are on the same segment of the parent geometry

Implementation

bool isOnSameSegment(LinearLocation loc) {
  if (componentIndex != loc.componentIndex) return false;
  if (segmentIndex == loc.segmentIndex) return true;
  if (loc.segmentIndex - segmentIndex == 1 && loc.segmentFraction == 0.0)
    return true;
  if (segmentIndex - loc.segmentIndex == 1 && segmentFraction == 0.0)
    return true;
  return false;
}