在指南针点和度数之间转换
portolan的Python项目详细描述
在compass points和之间转换 度。这是一个超级小的库,没有依赖关系。
pip install portolan
方法
只有几个:point,traditional,degrees,middle, range。
示例
从缩写或十进制度数转换到指南针点:
importportolanportolan.point(abbr='nnw')# 'north-northwest'portolan.point(degree=275.1)# 'west'
转换为地中海盆地的传统名称:
portolan.traditional(degree=12.6)# 'Quarto di Tramontana verso Greco'portolan.traditional(abbr='NEbE')# 'Quarto di Greco verso Levante'
在度数和缩写之间转换:
portolan.abbr(145.0)# 'SEbS'portolan.middle('SEbS')# 146.25portolan.range('SEbS')# (140.625, 151.875)# Remember that North spans the originportolan.range('n')# (354.375, 5.625)# the degrees method returns the minimum, middle, and maximum of a compass pointportolan.degrees('SEbS')# (140.625, 146.25, 151.875)