/usr/lib/python2.7/dist-packages/geopy/units.py is in python-geopy 1.3.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | """
Convert units.
"""
import math
# Angles
def degrees(radians=0, arcminutes=0, arcseconds=0): # pylint: disable=W0621
"""
TODO docs.
"""
deg = 0.
if radians:
deg = math.degrees(radians)
if arcminutes:
deg += arcminutes / arcmin(degrees=1.)
if arcseconds:
deg += arcseconds / arcsec(degrees=1.)
return deg
def radians(degrees=0, arcminutes=0, arcseconds=0): # pylint: disable=W0621
"""
TODO docs.
"""
if arcminutes:
degrees += arcminutes / arcmin(degrees=1.)
if arcseconds:
degrees += arcseconds / arcsec(degrees=1.)
return math.radians(degrees)
def arcminutes(degrees=0, radians=0, arcseconds=0): # pylint: disable=W0621
"""
TODO docs.
"""
if radians:
degrees += math.degrees(radians)
if arcseconds:
degrees += arcseconds / arcsec(degrees=1.)
return degrees * 60.
def arcseconds(degrees=0, radians=0, arcminutes=0): # pylint: disable=W0621
"""
TODO docs.
"""
if radians:
degrees += math.degrees(radians)
if arcminutes:
degrees += arcminutes / arcmin(degrees=1.)
return degrees * 3600.
# Lengths
def kilometers(meters=0, miles=0, feet=0, nautical=0): # pylint: disable=W0621
"""
TODO docs.
"""
ret = 0.
if meters:
ret += meters / 1000.
if feet:
miles += feet / ft(1.)
if nautical:
ret += nautical / nm(1.)
ret += miles * 1.609344
return ret
def meters(kilometers=0, miles=0, feet=0, nautical=0): # pylint: disable=W0621
"""
TODO docs.
"""
return (kilometers + km(nautical=nautical, miles=miles, feet=feet)) * 1000
def miles(kilometers=0, meters=0, feet=0, nautical=0): # pylint: disable=W0621
"""
TODO docs.
"""
ret = 0.
if nautical:
kilometers += nautical / nm(1.)
if feet:
ret += feet / ft(1.)
if meters:
kilometers += meters / 1000.
ret += kilometers * 0.621371192
return ret
def feet(kilometers=0, meters=0, miles=0, nautical=0): # pylint: disable=W0621
"""
TODO docs.
"""
ret = 0.
if nautical:
kilometers += nautical / nm(1.)
if meters:
kilometers += meters / 1000.
if kilometers:
miles += mi(kilometers=kilometers)
ret += miles * 5280
return ret
def nautical(kilometers=0, meters=0, miles=0, feet=0): # pylint: disable=W0621
"""
TODO docs.
"""
ret = 0.
if feet:
miles += feet / ft(1.)
if miles:
kilometers += km(miles=miles)
if meters:
kilometers += meters / 1000.
ret += kilometers / 1.852
return ret
# Compatible names
rad = radians # pylint: disable=C0103
arcmin = arcminutes # pylint: disable=C0103
arcsec = arcseconds # pylint: disable=C0103
km = kilometers # pylint: disable=C0103
m = meters # pylint: disable=C0103
mi = miles # pylint: disable=C0103
ft = feet # pylint: disable=C0103
nm = nautical # pylint: disable=C0103
|