コード例 #1
0
ファイル: LengthLocationMap.cpp プロジェクト: h4ck3rm1k3/geos
double LengthLocationMap::getLength(const LinearLocation& loc) const
{
	double totalLength = 0.0;

	LinearIterator it(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;
}
コード例 #2
0
unsigned int LinearIterator::segmentEndVertexIndex(const LinearLocation& loc)
{
	if (loc.getSegmentFraction() > 0.0)
		return loc.getSegmentIndex() + 1;
	return loc.getSegmentIndex();
}