#NEWLINE# def _encode( self , points , dists , abs_max_dist ) : #NEWLINE# #INDENT# encoded_levels = StringIO ( ) #NEWLINE# encoded_points = StringIO ( ) #NEWLINE# plat = 0 #NEWLINE# plng = 0 #NEWLINE# if self . _force_endpoints : #NEWLINE# #INDENT# encoded_levels . write ( self . _encode_number ( ( self . _num_levels - 1 ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# encoded_levels . write ( self . _encode_number ( ( ( self . _num_levels - self . _compute_level ( abs_max_dist ) ) - 1 ) ) ) #NEWLINE# #UNINDENT# n_points = len ( points ) #NEWLINE# for ( i , p ) in enumerate ( points ) : #NEWLINE# #INDENT# if ( ( i > 0 ) and ( i < ( n_points - 1 ) ) and ( i in dists ) ) : #NEWLINE# #INDENT# encoded_levels . write ( self . _encode_number ( ( ( self . _num_levels - self . _compute_level ( dists [ i ] ) ) - 1 ) ) ) #NEWLINE# #UNINDENT# if ( ( i in dists ) or ( i == 0 ) or ( i == ( n_points - 1 ) ) ) : #NEWLINE# #INDENT# late5 = int ( math . floor ( ( p [ 1 ] * 100000.0 ) ) ) #NEWLINE# lnge5 = int ( math . floor ( ( p [ 0 ] * 100000.0 ) ) ) #NEWLINE# dlat = ( late5 - plat ) #NEWLINE# dlng = ( lnge5 - plng ) #NEWLINE# plat = late5 #NEWLINE# plng = lnge5 #NEWLINE# encoded_points . write ( self . _encode_signed_number ( dlat ) ) #NEWLINE# encoded_points . write ( self . _encode_signed_number ( dlng ) ) #NEWLINE# #UNINDENT# #UNINDENT# if self . _force_endpoints : #NEWLINE# #INDENT# encoded_levels . write ( self . _encode_number ( ( self . _num_levels - 1 ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# encoded_levels . write ( self . _encode_number ( ( ( self . _num_levels - self . _compute_level ( abs_max_dist ) ) - 1 ) ) ) #NEWLINE# #UNINDENT# return ( encoded_points . getvalue ( ) , encoded_levels . getvalue ( ) )