<s> import math <EOL> import logging <EOL> from geo import geotypes <EOL> class Constants ( object ) : <EOL> PI_OVER_180 = math . pi / <NUM_LIT> <EOL> EARTH_RADIUS_IN_METERS = <NUM_LIT> <EOL> ONE_LATITUDINAL_DEGREE_IN_METERS_AT_SEA_LEVEL = <NUM_LIT> <EOL> METERS_PER_MILE = <NUM_LIT> <EOL> def width_of_latitudinal_degree_in_meters ( ) : <EOL> return Constants . ONE_LATITUDINAL_DEGREE_IN_METERS_AT_SEA_LEVEL <EOL> def width_of_longitudinal_degree_in_meters_for_latitude ( latitude ) : <EOL> latitude_in_radians = math . radians ( latitude ) <EOL> return math . cos ( latitude_in_radians ) * Constants . PI_OVER_180 * Constants . EARTH_RADIUS_IN_METERS <EOL> def latitudinal_degrees_from_meters ( meters ) : <EOL> return meters / Constants . ONE_LATITUDINAL_DEGREE_IN_METERS_AT_SEA_LEVEL <EOL> def longitudinal_degrees_from_meters_at_latitude ( meters , latitude ) : <EOL> one_longitudinal_degree_in_meters = width_of_longitudinal_degree_in_meters_for_latitude ( latitude ) <EOL> return meters / one_longitudinal_degree_in_meters <EOL> def miles_to_meters ( miles ) : <EOL> return miles * Constants . METERS_PER_MILE <EOL> def meters_to_miles ( meters ) : <EOL> return meters / Constants . METERS_PER_MILE <EOL> def square_bounding_box_centered_at ( latitude , longitude , side_in_miles ) : <EOL> side_in_meters = miles_to_meters ( side_in_miles ) <EOL> latitude_halfside_in_degrees = latitudinal_degrees_from_meters ( side_in_meters ) / <NUM_LIT> <EOL> longitude_halfside_in_degrees = longitudinal_degrees_from_meters_at_latitude ( side_in_meters , latitude ) / <NUM_LIT> <EOL> return geotypes . Box ( <EOL> north = latitude + latitude_halfside_in_degrees , <EOL> east = longitude + longitude_halfside_in_degrees , <EOL> south = latitude - latitude_halfside_in_degrees , <EOL> west = longitude - longitude_halfside_in_degrees ) <EOL> def are_latitude_and_longitude_valid ( latitude , longitude ) : <EOL> return ( abs ( latitude ) <= <NUM_LIT> ) and ( abs ( longitude ) <= <NUM_LIT> ) </s>
