#NEWLINE# def get_postalcodes_around_radius( self , pc , radius ) : #NEWLINE# #INDENT# postalcodes = self . get ( pc ) #NEWLINE# if ( postalcodes is None ) : #NEWLINE# #INDENT# raise PostalCodeNotFoundException ( "Could not find postal code you're searching for." ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# pc = postalcodes [ 0 ] #NEWLINE# #UNINDENT# radius = float ( radius ) #NEWLINE# '\n        Bounding box calculations updated from pyzipcode\n        ' #NEWLINE# earth_radius = 6371 #NEWLINE# dlat = ( radius / earth_radius ) #NEWLINE# dlon = asin ( ( sin ( dlat ) / cos ( radians ( pc . latitude ) ) ) ) #NEWLINE# lat_delta = degrees ( dlat ) #NEWLINE# lon_delta = degrees ( dlon ) #NEWLINE# if ( lat_delta < 0 ) : #NEWLINE# #INDENT# lat_range = ( ( pc . latitude + lat_delta ) , ( pc . latitude - lat_delta ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# lat_range = ( ( pc . latitude - lat_delta ) , ( pc . latitude + lat_delta ) ) #NEWLINE# #UNINDENT# long_range = ( ( pc . longitude - lat_delta ) , ( pc . longitude + lon_delta ) ) #NEWLINE# return format_result ( self . conn_manager . query ( ( PC_RANGE_QUERY % ( long_range [ 0 ] , long_range [ 1 ] , lat_range [ 0 ] , lat_range [ 1 ] ) ) ) )