python地理定位api

diblogeo的Python项目详细描述


Diblo Geo是一个面向开发人员的Python2 API。

diblo-geo使python开发人员能够轻松计算全球的坐标和方位角。

Diblo Geo是根据Cpython 2.7测试的。

Development site

版权所有The GNU General Public License v3.0下的Diblo Geo贡献者2016。

安装

使用pip和:

安装
pip install diblogeo

或者,download a wheel or source archive from PyPI

测量距离

示例1:

>>> from diblogeo import Geo
>>> distance = Geo((55.3303636516, 10.4466164796)) \
...            .distance((55.3706593849, 10.469825563))
>>> print(distance)
4.70941600331
>>> print(distance.kilometers)
4.71
>>> print(distance.feet)
15450.84

例2(海拔11.34米):

>>> from diblogeo import Geo
>>> distance = Geo((55.3303636516, 10.4466164796, 11.34)) \
...            .distance((55.3706593849, 10.469825563, 11.34))
>>> print(distance)
4.71780808395
>>> print(distance.kilometers)
4.72
>>> print(distance.feet)
15478.37

测量角度

>>> from diblogeo import Geo
>>> bearing = Geo((55.3303636516, 10.4466164796)) \
...           .bearing((55.3706593849, 10.469825563))
>>> print(bearing)
18.1225041609
>>> print(bearing.degrees)
18.12
>>> print(bearing.radians)
0.316297366315

计划目的地

示例1:

>>> from diblogeo import Geo
>>> point = Geo((55.3303636516, 10.4466164796))
>>> point.destination(37.2, 3.2)
(55.3533088458, 10.4772564424, 0)
>>> point.destination(bearing=37.2, kilometers=3.2)
(55.3533088458, 10.4772564424, 0)
>>> point.destination(37.2, meters=3200)
(55.3533088458, 10.4772564424, 0)

例2(海拔11.34米):

>>> from diblogeo import Geo
>>> point = Geo((55.3303636516, 10.4466164796, 11.34))
>>> point.destination(37.2, 3.2)
(55.3532680374, 10.4772019082, 11.34)
>>> point.destination(bearing=37.2, kilometers=3.2)
(55.3532680374, 10.4772019082, 11.34)
>>> point.destination(37.2, meters=3200)
(55.3532680374, 10.4772019082, 11.34)

计算地球半径

>>> from diblogeo import calc_earth_radius
>>> earth_radius = calc_earth_radius((55.3303636516, 10.4466164796, 11.34))
>>> print(earth_radius)
6375.05118755
>>> print(earth_radius.kilometers)
6375.05
>>> print(earth_radius.miles)
3961.27

更多的输入和输出方法

>>> from diblogeo import Geo
>>> location = Geo(("55° 19' 49.31\"", "10° 26' 47.82\"", 11.34)) \
...            .destination(37.2, miles=3.2)
>>> print(location.latitude, location.longitude, location.altitude)
(55.367221177288684, 10.495856496671713, 11.34)
>>> print(location[0], location[1], location[2])
(55.367221177288684, 10.495856496671713, 11.34)
>>> print(location.dms)
((55, 22, 1.99624, 'N'), (10, 29, 45.08339, 'E'), 11.34)
>>> print(location.dms.latitude, location.dms.longitude, location.altitude)
((55, 22, 1.99624, 'N'), (10, 29, 45.08339, 'E'), 11.34)

位置/点属性

属性可以与geodestination一起使用。

十进制度数:

  • 地址,loc,dd
  • 纬度,纬度
  • 经度,lon
  • 高度,高度,高度

locationlocdd返回点的实例

  • [点]。纬度,[点]。纬度
  • [点].经度,[点].lon
  • [\u点]。海拔,[\u点]。海拔,[\u点]。高度

度分秒:

  • DMS
  • dms.latitude,dms.lat
  • 经度,经度
  • 高度,高度,高度

测量单位

这些属性可以与距离计算地球半径一起使用。 目的地支持所有单位作为距离参数。

  • 公里,公里
  • 米,m
  • 厘米
  • 英里,英里
  • 英尺,英尺
  • 航海,海里,海里

角度单位

这些属性可以与方位一起使用。

  • 度,度
  • 弧度,rad

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
在reducer中迭代自定义可写组件时出现java问题   属性文件中属性的java命名约定   任务链关闭的java Executor服务   java从Eclipse中的字段生成多个构造函数   java通过继承读取Json   java在不知道密钥的情况下解析json   java camel cxf如何在电子邮件中发送soap请求响应   java程序似乎跳过了if语句的一部分,在移回正确位置之前先移到else语句   测试简单的Java加密/解密inputFileName不存在   java从Jenkins REST API获取所有作业的所有构建的构建细节   java基本包装器和静态“类型”类对象   在WebSphere8.5上部署java代码   java对象相等(对象引用“=”)   java MongoDB整型字段到枚举的转换   每次我重新导入gradle时,IntelliJ都会不断重置Java设置   类型使用键或索引从Java中的数据类型检索值   在Java的列表接口中需要listIterator()和iterator()是什么?