toLowest method
Converts a linear location to the lowest equivalent location index. The lowest index has the lowest possible component and segment indices.
Specifically:
- if the location point is an endpoint, a location value is returned as (nseg-1, 1.0)
- if the location point is ambiguous (i.e. an endpoint and a startpoint), the lowest endpoint location is returned
@param linearGeom the linear geometry referenced by this location @return the lowest equivalent location
Implementation
LinearLocation toLowest(Geometry linearGeom) {
// TODO: compute lowest component index
LineString lineComp = linearGeom.getGeometryN(componentIndex) as LineString;
int nseg = numSegments(lineComp);
// if not an endpoint can be returned directly
if (segmentIndex < nseg) return this;
return new LinearLocation.fromComponentSegmentIndexFractionNorm(
componentIndex, nseg - 1, 1.0, false);
}