Created
October 20, 2013 00:12
-
-
Save anonymous/7063176 to your computer and use it in GitHub Desktop.
Lua script to split up DMS coordinates into variables
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
dmsDB = metadata.GPS -- metadata.GPS is derived from Lightroom database as 48°12'30" N 16°22'28" (refers to Vienna) | |
dms1 = string.gsub(dmsDB, "%s+", "") | |
posdeg1 = string.find(dms1, "°") | |
posmin1 = string.find(dms1, "'") | |
possec1 = string.find(dms1, '"') | |
deglat = string.sub(dms1,1,posdeg1-1) | |
minlat = string.sub(dms1,posdeg1+2,posmin1-1) | |
seclat = string.sub(dms1,posmin1+1,possec1-1) | |
dirlat = string.sub(dms1,possec1+1,possec1+1) | |
-- got the first part alright | |
-- in the second part of dms1, the problem with single and double digits eg. 8 vs. 08 needs to be solved. | |
-- so do the same again starting after the first '"'. | |
dms2 = string.sub(dms1,possec1+2) | |
posdeg2 = string.find(dms2, "°") | |
posmin2 = string.find(dms2, "'") | |
possec2 = string.find(dms2, '"') | |
deglng = string.sub(dms2,1,posdeg2-1) | |
minlng = string.sub(dms2,posdeg2+2,posmin2-1) | |
seclng = string.sub(dms2,posmin2+1,possec2-1) | |
dirlng = string.sub(dms2,possec2+1,possec2+1) | |
-- now we've got 8 variables for the 8 values in the original string. | |
-- start dms2dec conversion |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment