Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/urschrei/pypolyline
Fast Google Polyline encoding and decoding using a Rust binary
https://github.com/urschrei/pypolyline
computational-geometry cython gis google-maps google-polyline polyline rust
Last synced: 5 days ago
JSON representation
Fast Google Polyline encoding and decoding using a Rust binary
- Host: GitHub
- URL: https://github.com/urschrei/pypolyline
- Owner: urschrei
- License: other
- Created: 2016-07-14T17:20:29.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-12-09T16:51:45.000Z (25 days ago)
- Last Synced: 2024-12-22T13:07:49.264Z (12 days ago)
- Topics: computational-geometry, cython, gis, google-maps, google-polyline, polyline, rust
- Language: Python
- Homepage: https://pypi.python.org/pypi/pypolyline
- Size: 1.12 MB
- Stars: 40
- Watchers: 4
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
- Citation: CITATION.cff
Awesome Lists containing this project
README
![example workflow](https://github.com/urschrei/pypolyline/actions/workflows/wheels.yml/badge.svg) [![Coverage Status](https://coveralls.io/repos/github/urschrei/pypolyline/badge.svg?branch=master)](https://coveralls.io/github/urschrei/pypolyline?branch=master) [![Downloads](https://pepy.tech/badge/pypolyline)](https://pepy.tech/project/pypolyline)[![DOI](https://zenodo.org/badge/63355673.svg)](https://zenodo.org/badge/latestdoi/63355673)
# Fast Google [Polyline](https://developers.google.com/maps/documentation/utilities/polylinealgorithm) Encoding and Decoding
## Installation
`pip install pypolyline`### Supported Python Versions
- Python 3.9
- Python 3.10
- Python 3.11
- Python 3.12
- Python 3.13### Supported Platforms
- Linux (`manylinux*`-compatible, x86_64 and aarch64)
- macOS (x86_64 and arm64)
- Windows 64-bit## Usage
Coordinates must be in (`Longitude, Latitude`) order```python
from pypolyline.cutil import encode_coordinates, decode_polylinecoords = [
[52.64125, 23.70162],
[52.64938, 23.70154],
[52.64957, 23.68546],
[52.64122, 23.68549],
[52.64125, 23.70162]
]# precision is 5 for Google Polyline, 6 for OSRM / Valhalla
polyline = encode_coordinates(coords, 5)
# polyline is 'ynh`IcftoCyq@Ne@ncBds@EEycB'
decoded_coords = decode_polyline(polyline, 5)
```## Error Handling
Failure to encode coordinates, or to decode a supplied Polyline, will raise a `RuntimeError` containing information about the invalid input.## How it Works
FFI and a [Rust binary](https://github.com/urschrei/polyline-ffi)## Is It Fast
…Yes.
You can verify this by installing the `polyline` package, then running [`benchmarks.py`](benchmarks.py), a calibrated benchmark using `cProfile`.
On an M2 MBP, The [pure-Python](https://pypi.org/project/polyline/) test runs in ~2500 ms, the [Flexpolyline](https://pypi.org/project/flexpolyline/) benchmark runs in ~1500 ms and The Rust + Cython benchmark runs in around 80 ms (30 x and 17.5 x faster, respectively).## License
[The Blue Oak Model Licence 1.0.0](LICENCE.md)## Citing `Pypolyline`
If Pypolyline has been significant in your research, and you would like to acknowledge the project in your academic publication, we suggest citing it as follows (example in APA style, 7th edition):> Hügel, S. (2021). Pypolyline (Version X.Y.Z) [Computer software]. https://doi.org/10.5281/zenodo.5774925
In Bibtex format:
@software{Hugel_Pypolyline_2021,
author = {Hügel, Stephan},
doi = {10.5281/zenodo.5774925},
license = {MIT},
month = {12},
title = {{Pypolyline}},
url = {https://github.com/urschrei/simplification},
version = {X.Y.Z},
year = {2021}
}