Browse Source

Conversion functions.

Douglas William Thrift 14 years ago
parent
commit
a75aae71f6
1 changed files with 42 additions and 0 deletions
  1. 42 0
      locationbot.py

+ 42 - 0
locationbot.py

@@ -845,6 +845,48 @@ class LocationBot(ircbot.SingleServerIRCBot):
 	def success(self):
 		self.connection.privmsg(self.__nick, 'successfully reloaded')
 
+def _meters_per_second_to_miles_per_hour(meters_per_second):
+	return meters_per_second * 2.23693629
+
+def _meters_to_feet(meters):
+	return meters * 3.2808399
+
+def _heading_to_direction(heading):
+	heading %= 360
+
+	if 348.75 < heading or heading <= 11.25:
+		return 'N'
+	elif 11.25 < heading <= 33.75:
+		return 'NNE'
+	elif 33.75 < heading <= 56.25:
+		return 'NE'
+	elif 56.25 < heading <= 78.75:
+		return 'ENE'
+	elif 78.75 < heading <= 101.25:
+		return 'E'
+	elif 101.25 < heading <= 123.75:
+		return 'ESE'
+	elif 123.75 < heading <= 146.25:
+		return 'SE'
+	elif 146.25 < heading <= 168.75:
+		return 'SSE'
+	elif 168.75 < heading <= 191.25:
+		return 'S'
+	elif 191.25 < heading <= 213.75:
+		return 'SSW'
+	elif 213.75 < heading <= 236.25:
+		return 'SW'
+	elif 236.25 < heading <= 258.75:
+		return 'WSW'
+	elif 258.75 < heading <= 281.25:
+		return 'W'
+	elif 281.25 < heading <= 303.75:
+		return 'WNW'
+	elif 303.75 < heading <= 326.25:
+		return 'NW'
+	else:
+		return 'NNW'
+
 def _or(function, values):
 	for value in values:
 		if function(value):