@ Pure public RoadSegment getNearestRoadSegment ( Point2D < ? , ? > point ) { assert point != null ; double distance = Double . MAX_VALUE ; RoadSegment nearestSegment = null ; final Iterator < RoadSegment > iterator = this . roadSegments . roadSegments ( ) ; RoadSegment segment ; while ( iterator . hasNext ( ) ) { segment = iterator . next ( ) ; final double d = segment . distance ( point ) ; if ( d < distance ) { distance = d ; nearestSegment = segment ; } } return nearestSegment ; }
Replies the nearest road segment from this itinerary to the given point .