https://github.com/adonmo/trajectory
A python library for lossy compression/serialization of trajectory data based on Google's Encoded Polyline Algorithm Format
https://github.com/adonmo/trajectory
compression geospatial gis mobility serialization spatiotemporal trajectory
Last synced: 2 months ago
JSON representation
A python library for lossy compression/serialization of trajectory data based on Google's Encoded Polyline Algorithm Format
- Host: GitHub
- URL: https://github.com/adonmo/trajectory
- Owner: adonmo
- License: mit
- Created: 2020-02-24T16:56:59.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-02-24T17:52:21.000Z (over 5 years ago)
- Last Synced: 2024-11-16T03:19:11.695Z (11 months ago)
- Topics: compression, geospatial, gis, mobility, serialization, spatiotemporal, trajectory
- Language: Python
- Homepage:
- Size: 61.5 KB
- Stars: 11
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
.. image:: https://github.com/adonmo/trajectory/workflows/Tests/badge.svg
:target: https://github.com/adonmo/trajectory/actions
:alt: Test Status.. image:: https://img.shields.io/pypi/dm/trajectory.svg
:target: https://pypistats.org/packages/trajectory
:alt: PyPI downloads.. image:: https://img.shields.io/github/license/adonmo/trajectory.svg
:target: https://github.com/adonmo/trajectory/blob/master/LICENSE
:alt: MIT Licensetrajectory
============``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.
Installation
============``trajectory`` can be installed using ``pip`` or ``easy_install``
.. code-block:: sh
$ pip install trajectory
or
$ easy_install trajectoryAPI Documentation
=================Encoding
--------To serialize a trajectory (set of (lat, lon, unix time in seconds) tuples)
.. code-block:: py
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.
Decoding
--------To deserialize a trajectory (set of (lat, lon, unix time in seconds) tuples) represented by an encoded string
.. code-block:: py
import trajectory
trajectory.decode('_p~iF~ps|U_ynpijgz~G_ulLnnqC_c`|@_mqNvxq`@__t`B', 5)This should return the following:
.. code-block:: py
[
(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.
Development
===========Setup Dependencies
------------------.. code-block:: sh
$ poetry install
Running Tests
-------------.. code-block:: sh
$ poetry run pytest
Contributing
------------Issues and pull requests are welcome.
* For proposing new features/improvements or reporting bugs, `create an issue `_.
* Check `open issues `_ for viewing existing ideas, verify if it is already proposed/being worked upon.
* When implementing new features make sure to add relavant tests and documentation before sending pull requests.