import math


def convert_coord_to_str(lat, lon):
    """Convert coordinate to string for DEM filename."""

    # cribbed from ISCE's DemStitcher class
    if(lon > 180): lon = -(360 - lon)
    if(lon < 0): ew = 'W'
    else: ew = 'E'
    lonAbs = int(math.fabs(lon))
    if(lonAbs >= 100): ew += str(lonAbs)
    elif(lonAbs < 10): ew +=  '00' + str(lonAbs)
    else: ew +=  '0' + str(lonAbs)
    if(int(lat) >= 0): ns = 'N'
    else: ns = 'S'
    latAbs = int(math.fabs(lat))
    if(latAbs >= 10): ns += str(latAbs)
    else: ns += '0' +str(latAbs)
    return ns,ew