I was doing a project on the Raspberry Pi Website, and was tracking the ISS. Then, I started playing with it, making the movement live, and putting the location in the bottom left corner (Latitude and Longitude).
I created a function to convert decimal degrees to degrees (°) minutes (') and seconds (") - a more readable format:
def to_hr(d):
d = float(d)
mod = d%1
min_ = int(mod*60)
sec = int(mod*36000%60)/10
d = int(d)
deg = d
return "{}° {}' {}\"".format(deg, min_,sec)
Then I used it to display the latitude and longitude using turtle.write() to put it on the screen:
text1 = "Lat: {} Lon: {}".format(to_hr(lat), to_hr(lon))
text.color((110, 250, 85))
style = ("Arial", 7, "bold")
text.clear()
text.goto(-175, -85)
text.write(text1, font=style)
text was earlier defined as turtle.Turtle().
I don't think it was the
turtle.Write()function. I think it was the result that was iffy.
Expected outputs:
-7° 3' 45.1"
153° 9' 36.5"
0° 0' 0"
-34 5' 6"
Actual outputs:
-7° 3' 45.1"
153° 9' 36.5"
0° 0' 0"
-34° 5' 6"
Does anyone know why it is doing that? In return I have no mention of this 'Â' character (Unicode is U+00C2) in my return, and it shouldn't be popping up in the result. I made d an integer, deg too.