def print_lon(lon): # def stampalon(lon):
# returns a string in the format xxDegrees,xxMinutes, N/S
lon_decimal = math.copysign(math.degrees(lon), 1) # londecimali
lon_degree = int(lon_decimal) # longradi
lon_minutes = (lon_decimal - lon_degree) * 60 # lonprimi
if lon_minutes > 59.51:
lon_degree = lon_degree + 1
lon_minutes = 0
else:
if lon_minutes - int(lon_minutes) > 0.51:
lon_minutes = int(lon_minutes) + 1
else:
lon_minutes = int(lon_minutes)
if lon > 0:
hemisphere = "W"
else:
hemisphere = "E"
degrees = "%3d" % lon_degree # gradi
minutes = "%2d" % lon_minutes
lon = (degrees.replace(" ", "0") + u"°" + minutes.replace(" ", "0")
+ "'" + hemisphere)
return lon
评论列表
文章目录