#NEWLINE# def get_nearest_locations( self , location , threshold_distance = 0.01 ) : #NEWLINE# #INDENT# '\n        Returns a list of locations of elements like\n        consisting of points where the location may be on the track\n\n        threshold_distance is the the minimum distance from the track\n        so that the point *may* be counted as to be "on the track".\n        For example 0.01 means 1% of the track distance.\n        ' #NEWLINE# assert location #NEWLINE# assert threshold_distance #NEWLINE# result = [ ] #NEWLINE# points = self . get_points_data ( ) #NEWLINE# if ( not points ) : #NEWLINE# #INDENT# return ( ) #NEWLINE# #UNINDENT# distance = points [ ( - 1 ) ] [ 1 ] #NEWLINE# threshold = ( distance * threshold_distance ) #NEWLINE# min_distance_candidate = None #NEWLINE# distance_from_start_candidate = None #NEWLINE# track_no_candidate = None #NEWLINE# segment_no_candidate = None #NEWLINE# point_no_candidate = None #NEWLINE# for ( point , distance_from_start , track_no , segment_no , point_no ) in points : #NEWLINE# #INDENT# distance = location . distance_3d ( point ) #NEWLINE# if ( distance < threshold ) : #NEWLINE# #INDENT# if ( ( min_distance_candidate is None ) or ( distance < min_distance_candidate ) ) : #NEWLINE# #INDENT# min_distance_candidate = distance #NEWLINE# distance_from_start_candidate = distance_from_start #NEWLINE# track_no_candidate = track_no #NEWLINE# segment_no_candidate = segment_no #NEWLINE# point_no_candidate = point_no #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( distance_from_start_candidate is not None ) : #NEWLINE# #INDENT# result . append ( ( distance_from_start_candidate , track_no_candidate , segment_no_candidate , point_no_candidate ) ) #NEWLINE# #UNINDENT# min_distance_candidate = None #NEWLINE# distance_from_start_candidate = None #NEWLINE# track_no_candidate = None #NEWLINE# segment_no_candidate = None #NEWLINE# point_no_candidate = None #NEWLINE# #UNINDENT# #UNINDENT# if ( distance_from_start_candidate is not None ) : #NEWLINE# #INDENT# result . append ( NearestLocationData ( distance_from_start_candidate , track_no_candidate , segment_no_candidate , point_no_candidate ) ) #NEWLINE# #UNINDENT# return result