exif-py icon indicating copy to clipboard operation
exif-py copied to clipboard

sugestion,create an tag that returns the gps geocode itself,not string

Open mzramna opened this issue 6 years ago • 2 comments

i've made an function thar convert the parameters ("GPS GPSLatitude" and "GPS GPSLatitudeRef") or ("GPS GPSLongitude" and "GPS GPSLongitudeRef") to an float value usable into google mpas api or other gps functions

def convertMetaInCood(gps, quadrante): cood = {} regexHour = re.compile(r"\[(\d+)\,") regexMinute = re.compile(r"\, (\d+)\,") regexSecond = re.compile(r"\,\ (\d+)\/") regexSecondDivisor = re.compile(r"\/(\d+)\]") cood["hour"] = re.findall(regexHour, str(gps))[0] cood["minute"] = re.findall(regexMinute, str(gps))[0] cood["second"] = re.findall(regexSecond, str(gps))[0] cood["secondDivisor"] = re.findall(regexSecondDivisor, str(gps))[0] cood["total"] = float(int(cood["hour"]) + ( (int(cood["minute"]) * 60) + (int(cood["second"])) / int(cood["secondDivisor"])) / 3600) if str(quadrante) == "S" or str(quadrante) == "W": cood["total"] = cood["total"] * -1 return cood["total"]

mzramna avatar Dec 19 '19 20:12 mzramna

I would consider this outside the scope of this library.

However I will not close this ticket so others may find it more easily.

ianare avatar Jul 31 '20 03:07 ianare

no return in case of non West or South data so empty results for E and N coordinates. Corrected below:

def convertMetaInCood(gps, quadrante):
    cood = {} 
    regexHour = re.compile(r"\[(\d+)\,") 
    regexMinute = re.compile(r"\, (\d+)\,") 
    regexSecond = re.compile(r"\,\ (\d+)\/") 
    regexSecondDivisor = re.compile(r"\/(\d+)\]") 
    cood["hour"] = re.findall(regexHour, str(gps))[0] 
    cood["minute"] = re.findall(regexMinute, str(gps))[0] 
    cood["second"] = re.findall(regexSecond, str(gps))[0] 
    cood["secondDivisor"] = re.findall(regexSecondDivisor, str(gps))[0] 
    cood["total"] = float(int(cood["hour"]) + ( (int(cood["minute"]) * 60) + (int(cood["second"])) / int(cood["secondDivisor"])) / 3600) 
    if str(quadrante) == "S" or str(quadrante) == "W": 
        cood["total"] = cood["total"] * -1 
        return cood["total"]
    else:
        return cood["total"]

Btw thank you @mzramna

kikislater avatar Jun 23 '23 15:06 kikislater