Created
March 26, 2009 22:33
-
-
Save mmb/86400 to your computer and use it in GitHub Desktop.
get latitude and longitude from a photo
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
#!/usr/bin/ruby | |
# get latitude and longitude from a photo | |
# known to work with iphone photots | |
require 'rubygems' | |
require 'exifr' | |
x = EXIFR::JPEG.new(ARGV[0]) | |
lat = x.gps_latitude | |
lon = x.gps_longitude | |
unless lat.nil? or lon.nil? | |
lat = lat[0] + lat[1] / 60.0 + lat[2] / 3600.0 | |
lon = lon[0] + lon[1] / 60.0 + lon[2] / 3600.0 | |
lat *= -1 if x.gps_longitude_ref == 'S' | |
lon *= -1 if x.gps_longitude_ref == 'W' | |
puts "http://maps.google.com/maps?q=#{lat},#{lon}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment