import math


def make_csv_line(pic):
    """
    Create a line with the required parameters for the OpenPathView toolchain
    datetime, lat, lon, alt, rad, goprofailed
    datetime : Sat Jul  8 17:40:50 2017
    lat, lon, alt : float
    rad : degree in degree minutes
    goprofailed : 0000 if the 4 cameras successfuly took the image
    separator : ;
    pic:Picture_infos namedtuple
    """

    date_time = str(pic.DateTimeOriginal.strftime("%a %b %d %H:%M:%S %Y"))
    lat = str(pic.Latitude)
    lon = str(pic.Longitude)
    ele = str(pic.Ele)
    #converting degree decimal to degree minutes
    degree = math.floor(pic.ImgDirection)
    minute = math.floor((pic.ImgDirection - degree)*60)
    rad = (str(degree) + "°" + " " + str(minute) + "'")
    
    line = (date_time, lat, lon, ele, rad, "0000")

    return line