Fast Google Polyline encoding and decoding using Rust FFI
Project description
Installation
pip install pypolyline
Please use a recent (>= 8.1.2) version of pip.
Supported Python Versions
Python 2.7 (*nix and Windows)
Python 3.4 (Windows)
Python 3.5 (*nix)
Supported Platforms
Linux (manylinux1-compatible)
OS X
Windows 32-bit / 64-bit
Usage
from pypolyline.util import encode_coordinates, decode_polyline
coords = [
[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)
Attempts to decode an invalid Polyline will throw util.DecodingError
Attempts to encode invalid coordinates will throw util.EncodingError
Cython Module
If you’re comfortable with a lack of built-in exceptions, you may use the compiled Cython version of the functions, instead, giving a 2x speedup over the ctypes functions:
from pypolyline.cutil import encode_coordinates, decode_polyline
Longitude errors will return strings beginning with Longitude error:
Latitude errors will return strings beginning with Latitude error:
Polyline errors will return [[nan, nan]]
How it Works
FFI and a Rust binary
Is It Fast
…Yes. You can verify this by installing polyline, cgpolyencode, then running benchmarks.py. The Rust version using ctypes and the C++ version run at the same speed, around 20x faster than Polyline. The Cythonised version runs around 40x faster than the plain Python version.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for pypolyline-0.1.8-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c70625c39ccc3404ab7861eb39defab32cceba4dbb589bd9fc59957a85b7b09b |
|
MD5 | c711b6c2c08c3fcc98ec5a5cfebd5d39 |
|
BLAKE2b-256 | f38c385176888a66ed04afcdfbf6f53e70d3407703aa5874b1c82e38d0ca75bf |
Hashes for pypolyline-0.1.8-cp35-cp35m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.macosx_10_11_intel.macosx_10_11_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d4e20ca1d8a5840ceaabc0954210885c8eafdbabb6654b0c23efe8400431bdb |
|
MD5 | 230dccfc97a97b28e23395e12705fa18 |
|
BLAKE2b-256 | 00c62889a2933d04908ef5feeee80cdcf9ea328bb4b618671e1ee2855a5a1c4e |
Hashes for pypolyline-0.1.8-cp34-cp34m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1fb3567f899d44706f211e98f9d67d0881a1b069220e03b9e3c2a537d06c2421 |
|
MD5 | ce621aad9fffbb0afa6c42a7114a3c07 |
|
BLAKE2b-256 | d73a68c679a1b4df06240b4c81bae35ab6f57db26a817ed0eff01d653097ca5d |
Hashes for pypolyline-0.1.8-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 997c55b7a3760e5f6bc436a3da1e4167f4087d92460c56b0dab6848731fb1070 |
|
MD5 | 1f45bdef4c92afa0c0f5ead2d155ac27 |
|
BLAKE2b-256 | eb975c320ccf8a8cb9b4d293fbf5e0e28f8b4ee0ee1f780c384bbc54730662b5 |
Hashes for pypolyline-0.1.8-cp27-cp27m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89db23007d21162216963ecbce23165f3fbae98b2bc44b1fc5933f9a55b3c7d1 |
|
MD5 | 2b0716bf4afa098346ff704d037eeca8 |
|
BLAKE2b-256 | 22cf5724c2468a3eee59b4f1a805ca40bbf224a8f5f7e2134f105bc95917d6f7 |
Hashes for pypolyline-0.1.8-cp27-cp27m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a6c8de7f9011b135fcde02246701cfcb2b9609c957ae9063b614c5c92b0934d |
|
MD5 | bbb967a8fd1715eac4e39f3366ae384e |
|
BLAKE2b-256 | 346d4dfd72f4806ad931b6773b806bcbb096b0bdfc15d99418a8cd5c7065f4eb |
Hashes for pypolyline-0.1.8-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.macosx_10_11_intel.macosx_10_11_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cbc10b8a8012eaa123afb256df38d1cc960852c47c7af101780849a2c7718e29 |
|
MD5 | d7914f12606246864f8865d8d5f83d3e |
|
BLAKE2b-256 | fba48ee2575d6a8aade63bae2356a1a405033080ae9d5d68f9e9cda4a0ca5893 |