getLength method
Implementation
double getLength(LinearLocation loc) {
double totalLength = 0.0;
LinearIterator it = new LinearIterator(linearGeom);
while (it.hasNext()) {
if (!it.isEndOfLine()) {
Coordinate p0 = it.getSegmentStart();
Coordinate p1 = it.getSegmentEnd()!;
double segLen = p1.distance(p0);
// length falls in this segment
if (loc.getComponentIndex() == it.getComponentIndex() &&
loc.getSegmentIndex() == it.getVertexIndex()) {
return totalLength + segLen * loc.getSegmentFraction();
}
totalLength += segLen;
}
it.next();
}
return totalLength;
}