Skip to content

Instantly share code, notes, and snippets.

@tigluiz
Created March 2, 2015 17:34
Show Gist options
  • Save tigluiz/e0cee5716024d128505e to your computer and use it in GitHub Desktop.
Save tigluiz/e0cee5716024d128505e to your computer and use it in GitHub Desktop.
geo
[-23.569945378311086, -46.705076102601495, -23.540999021688915, -46.6734984973985]
def distance(lat1, lon1, lat2, lon2)
radio = 6378137
dlat = (lat2-lat1) * Math::PI / 180
dlon = (lon2-lon1) * Math::PI / 180
a = Math::sin(dlat/2) * Math::sin(dlat/2) + Math::cos(lat1 * Math::PI / 180 ) * Math::cos(lat2 * Math::PI / 180 ) * Math::sin(dlon/2) * Math::sin(dlon/2)
c = 2 * Math::atan2(Math.sqrt(a), Math::sqrt(1-a))
d = radio * c;
# [dlat, dlon, a, c, d]
return "#{d.round(3)} km" if d > 1
"#{(d*1000).round(3)} m"
end
http://en.wikipedia.org/wiki/Geo-fence
https://github.com/alexreisner/geocoder
https://developers.google.com/maps/documentation/geocoding/#ComponentFiltering
http://developer.android.com/training/location/retrieve-current.html
http://maps.googleapis.com/maps/api/distancematrix/json?origins=-23.5699,-46.7050&destinations=-23.54099,-46.6734&language=pt-BR&sensor=false
conn = Faraday.new(url: 'http://maps.googleapis.com')
conn = Faraday.new(url: 'http://maps.googleapis.com')
body = _.body
JSON.parse(body)
conn.get('/maps/api/distancematrix/json?origins=-23.5699,-46.7050&destinations=-23.54099,-46.6734&language=pt-BR&sensor=false')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment