Next / Previous / Contents / TCC Help System / NM Tech homepage

27. latLonFormat(): Present the center coordinates in standard format

cbchistlib.py
# - - -   l a t L o n F o r m a t

def latLonFormat(lat, lon):
    '''Format a latitude and longitude nicely.

      [ lat is a latitude as "DDMM" and lon is a longitude as "DDDMM" ->
          return those values formatted as unicode in braces ]
    '''
    if lat.strip()=='' and lon.strip()=='':
        return " {unknown} "

    latDeg = lat[:2]
    latMin = lat[2:]
    lonDeg = lon[:3]
    lonMin = lon[3:]
    return(" {%s%s%s%sN %s%s%s%sW} " %
           (latDeg, DEGREES, latMin, MINUTES,
            lonDeg, DEGREES, lonMin, MINUTES))