Skip to content

Instantly share code, notes, and snippets.

@webapprentice
Last active December 28, 2015 16:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save webapprentice/7532569 to your computer and use it in GitHub Desktop.
Save webapprentice/7532569 to your computer and use it in GitHub Desktop.
Server action code for this tutorial
# Extract EXIF metadata from a photo on the server
get '/tutorial_22_demo_1' do
# load the library file that contains methods used this tutorial
require 'lib/tutorial_22.rb'
# Extract the metadata from an image file on the server
@photo = MiniExiftool.new(File.join(root_dir, "/public/assets/photo_metadata_1_400.jpg"))
# Get the Latitude and Longitude values and convert to decimal format
@latitude_0 = dms_to_decimal(@photo['GPSLatitude'])
@longitude_0 = dms_to_decimal(@photo['GPSLongitude'])
# Compute a second Lat/Lon pair along the direction the image was taken - used to draw a line on the map
bearing = @photo['GPSImgDirection'].to_f
@latitude_1, @longitude_1 = latlong_offset(@latitude_0, @longitude_0, bearing, 0.5)
erb :tutorial_22_demo_1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment