Created
January 19, 2018 06:31
-
-
Save daz/9b0f66c1f28c7c7048210e66bfa2088d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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