summaryrefslogtreecommitdiff
path: root/gps/misc.py
diff options
context:
space:
mode:
authorJon Schlueter <jschlueter@redhat.com>2016-02-06 23:42:56 -0500
committerJon Schlueter <jschlueter@redhat.com>2016-02-09 21:12:53 -0500
commitf9a3fb0b26a407b9be87c87f39fcf94301b72d11 (patch)
tree095d74ad28ef1f53b6539989381297efd58709d4 /gps/misc.py
parent093473653817f7fd4da19453d02f84e1979170a5 (diff)
downloadgpsd-f9a3fb0b26a407b9be87c87f39fcf94301b72d11.tar.gz
[pep8] autopep8 whitespace cleanup
large scale autopep8 cleanup of several pep8 whitespace warnings
Diffstat (limited to 'gps/misc.py')
-rw-r--r--gps/misc.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/gps/misc.py b/gps/misc.py
index 240a9465..2fa2b5b5 100644
--- a/gps/misc.py
+++ b/gps/misc.py
@@ -18,14 +18,17 @@ MPS_TO_KNOTS = 1.9438445 # Meters per second to knots
# EarthDistance code swiped from Kismet and corrected
+
def Deg2Rad(x):
"Degrees to radians."
return x * (math.pi/180)
+
def Rad2Deg(x):
"Radians to degress."
return x * (180/math.pi)
+
def CalcRad(lat):
"Radius of curvature in meters at specified latitude."
a = 6378.137
@@ -51,6 +54,7 @@ def CalcRad(lat):
r = r * 1000.0 # Convert to meters
return r
+
def EarthDistance((lat1, lon1), (lat2, lon2)):
"Distance in meters between two points specified in degrees."
x1 = CalcRad(lat1) * math.cos(Deg2Rad(lon1)) * math.sin(Deg2Rad(90-lat1))
@@ -68,6 +72,7 @@ def EarthDistance((lat1, lon1), (lat2, lon2)):
elif a < -1: a = -1
return CalcRad((lat1+lat2) / 2) * math.acos(a)
+
def MeterOffset((lat1, lon1), (lat2, lon2)):
"Return offset in meters of second arg from first."
dx = EarthDistance((lat1, lon1), (lat1, lon2))
@@ -76,6 +81,7 @@ def MeterOffset((lat1, lon1), (lat2, lon2)):
if lon1 < lon2: dx *= -1
return (dx, dy)
+
def isotime(s):
"Convert timestamps in ISO8661 format to and from Unix time."
if type(s) == type(1):