Skip to content

Instantly share code, notes, and snippets.

@cupakromer
Created May 23, 2012 04:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cupakromer/2773353 to your computer and use it in GitHub Desktop.
Save cupakromer/2773353 to your computer and use it in GitHub Desktop.
which way is the way?
# 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