const Coordinate WayLocation::getCoordinate() const { ConstNodePtr p0 = _map->getNode(_way->getNodeId(_segmentIndex)); if (_segmentFraction <= 0.0) { return p0->toCoordinate(); } else { ConstNodePtr p1 = _map->getNode(_way->getNodeId(_segmentIndex + 1)); return pointAlongSegmentByFraction(p0->toCoordinate(), p1->toCoordinate(), _segmentFraction); } }
/* public */ Coordinate LinearLocation::getCoordinate(const Geometry* linearGeom) const { const LineString* lineComp = dynamic_cast<const LineString *> (linearGeom->getGeometryN(componentIndex)); if ( ! lineComp ) { throw util::IllegalArgumentException("LinearLocation::getCoordinate only works with LineString geometries"); } Coordinate p0 = lineComp->getCoordinateN(segmentIndex); if (segmentIndex >= lineComp->getNumPoints() - 1) return p0; Coordinate p1 = lineComp->getCoordinateN(segmentIndex + 1); return pointAlongSegmentByFraction(p0, p1, segmentFraction); }