Skip to content

Instantly share code, notes, and snippets.

@daz
Created January 19, 2018 06:31
Show Gist options
  • Save daz/9b0f66c1f28c7c7048210e66bfa2088d to your computer and use it in GitHub Desktop.
Save daz/9b0f66c1f28c7c7048210e66bfa2088d to your computer and use it in GitHub Desktop.
require 'geo/coord'
EXIFTOOL_DMS_REGEX = %r{
^(?<latd>\d+)\sdeg\s
(?<latm>\d+)'\s
(?<lats>(\d+\.\d+))"\s
(?<lath>N|S),\s
(?<lngd>\d+)\sdeg\s
(?<lngm>\d+)'\s
(?<lngs>(\d+\.\d+))"\s
(?<lngh>E|W)
}x
lat_lng = "13 deg 48' 38.43\" S, 121 deg 7' 45.65\" E"
matches = lat_lng.match EXIFTOOL_DMS_REGEX
geo = Geo::Coord.new(latd: matches[:latd],
latm: matches[:latm],
lats: matches[:lats],
lath: matches[:lath],
lngd: matches[:lngd],
lngm: matches[:lngm],
lngs: matches[:lngs],
lngh: matches[:lngh])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment