trajectory
is a library for lossy compression of trajectory data based on Google's Encoded Polyline Algorithm Format (http://goo.gl/PvXf8Y). It is heavily based on (in fact forked from) https://github.com/hicsail/polyline.
trajectory
can be installed using pip
or easy_install
$ pip install trajectory
or
$ easy_install trajectory
To serialize a trajectory (set of (lat, lon, unix time in seconds) tuples)
import trajectory
trajectory.encode([
(38.500, -120.200, 1582482601),
(40.700, -120.950, 1582482611),
(43.252, -126.453, 1582482627)
], 5)
This should return _p~iF~ps|U_ynpijgz~G_ulLnnqC_c`|@_mqNvxq`@__t`B
.
You can set the required precision with the optional precision
parameter. The default value is 5.
To deserialize a trajectory (set of (lat, lon, unix time in seconds) tuples) represented by an encoded string
import trajectory
trajectory.decode('_p~iF~ps|U_ynpijgz~G_ulLnnqC_c`|@_mqNvxq`@__t`B', 5)
This should return the following:
[
(38.500, -120.200, 1582482601),
(40.700, -120.950, 1582482611),
(43.252, -126.453, 1582482627)
]
You can set the required precision with the optional precision
parameter. The default value is 5.
$ poetry install
$ poetry run pytest
Issues and pull requests are welcome.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。