Created
May 23, 2012 04:57
-
-
Save cupakromer/2773353 to your computer and use it in GitHub Desktop.
which way is the way?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The points are stored in a nested hash | |
# { | |
# "bounds"=> { | |
# "northeast"=>{"lat"=>39.0464399, "lng"=>-76.9836289}, | |
# "southwest"=>{"lat"=>38.995162, "lng"=>-77.033157} | |
# }, | |
# } | |
# We just want the values, as an array: | |
# [north_lat, east_lng, south_lat, west_lng] | |
def extract_bounding_box_version1 | |
geometry["bounds"].values.map{|h| h.values}.flatten | |
end | |
def extract_bounding_box_version2 | |
bounds = geometry["bounds"] | |
[ | |
bounds["northeast"]["lat"], # :north_lat | |
bounds["northeast"]["lng"], # :east_lng | |
bounds["southwest"]["lat"], # :south_lat | |
bounds["southwest"]["lng"], # :west_lng | |
] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment