Skip to main content

Fast Google Polyline encoding and decoding using Rust FFI

Project description

Build Status Build status Coverage Status

Fast Google Polyline Encoding and Decoding

Installation

pip install pypolyline
Please use a recent (>= 8.1.2) version of pip.

Supported Python Versions

  • Python 2.7
  • Python 3.6
  • Python 3.7

Supported Platforms

  • Linux (manylinux1-compatible)
  • OS X
  • Windows 32-bit / 64-bit

Usage

Coordinates must be in (Longitude, Latitude) order

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.EncodingError
Attempts to encode invalid coordinates will throw util.DecodingError

Cython Module 🔥

If you're comfortable with a lack of built-in exceptions, you may use the compiled Cython version of the functions, giving a 3x 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 the polyline and cgpolyencode packages, then running benchmarks.py, a calibrated benchmark using cProfile.
On a 1.8 GHz Intel Core i7, The pure-Python test runs in ~21 s, the C++ (cgpolyencode.GPolyEncoder) test runs in around 600 ms, and The Rust + Cython benchmark runs in around 400 ms (33% faster).

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pypolyline-0.2.4-cp38-cp38-manylinux2010_x86_64.whl (581.8 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.12+ x86-64

pypolyline-0.2.4-cp38-cp38-manylinux1_x86_64.whl (581.8 kB view details)

Uploaded CPython 3.8

pypolyline-0.2.4-cp38-cp38-macosx_10_13_x86_64.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 (272.2 kB view details)

Uploaded CPython 3.8macOS 10.10+ Intel (x86-64, i386)macOS 10.10+ x86-64macOS 10.11+ Intel (x86-64, i386)macOS 10.11+ x86-64macOS 10.13+ x86-64macOS 10.9+ Intel (x86-64, i386)macOS 10.9+ x86-64

pypolyline-0.2.4-cp37-cp37m-manylinux2010_x86_64.whl (543.4 kB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.12+ x86-64

pypolyline-0.2.4-cp37-cp37m-manylinux1_x86_64.whl (543.4 kB view details)

Uploaded CPython 3.7m

pypolyline-0.2.4-cp37-cp37m-macosx_10_13_x86_64.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 (272.9 kB view details)

Uploaded CPython 3.7mmacOS 10.10+ Intel (x86-64, i386)macOS 10.10+ x86-64macOS 10.11+ Intel (x86-64, i386)macOS 10.11+ x86-64macOS 10.13+ x86-64macOS 10.9+ Intel (x86-64, i386)macOS 10.9+ x86-64

pypolyline-0.2.4-cp36-cp36m-win_amd64.whl (312.1 kB view details)

Uploaded CPython 3.6mWindows x86-64

pypolyline-0.2.4-cp36-cp36m-win32.whl (289.0 kB view details)

Uploaded CPython 3.6mWindows x86

pypolyline-0.2.4-cp36-cp36m-manylinux2010_x86_64.whl (542.8 kB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.12+ x86-64

pypolyline-0.2.4-cp36-cp36m-manylinux1_x86_64.whl (542.8 kB view details)

Uploaded CPython 3.6m

pypolyline-0.2.4-cp36-cp36m-macosx_10_13_x86_64.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 (274.5 kB view details)

Uploaded CPython 3.6mmacOS 10.10+ Intel (x86-64, i386)macOS 10.10+ x86-64macOS 10.11+ Intel (x86-64, i386)macOS 10.11+ x86-64macOS 10.13+ x86-64macOS 10.9+ Intel (x86-64, i386)macOS 10.9+ x86-64

pypolyline-0.2.4-cp27-cp27mu-manylinux2010_x86_64.whl (507.8 kB view details)

Uploaded CPython 2.7mumanylinux: glibc 2.12+ x86-64

pypolyline-0.2.4-cp27-cp27mu-manylinux1_x86_64.whl (507.8 kB view details)

Uploaded CPython 2.7mu

pypolyline-0.2.4-cp27-cp27m-win_amd64.whl (310.6 kB view details)

Uploaded CPython 2.7mWindows x86-64

pypolyline-0.2.4-cp27-cp27m-win32.whl (290.4 kB view details)

Uploaded CPython 2.7mWindows x86

pypolyline-0.2.4-cp27-cp27m-macosx_10_13_x86_64.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 (274.6 kB view details)

Uploaded CPython 2.7mmacOS 10.10+ Intel (x86-64, i386)macOS 10.10+ x86-64macOS 10.11+ Intel (x86-64, i386)macOS 10.11+ x86-64macOS 10.13+ x86-64macOS 10.9+ Intel (x86-64, i386)macOS 10.9+ x86-64

File details

Details for the file pypolyline-0.2.4-cp38-cp38-manylinux2010_x86_64.whl.

File metadata

  • Download URL: pypolyline-0.2.4-cp38-cp38-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 581.8 kB
  • Tags: CPython 3.8, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3

File hashes

Hashes for pypolyline-0.2.4-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 96e15bcc1d241785470329fed2a038be46d259689c132ffd4f1b4887400757cc
MD5 1b58ab6ec3330355b470395a9dd99ede
BLAKE2b-256 e5752279d97c53c2bd7d87aef2f4d170611ad6b3359bb6e558bc0de0b9e522b3

See more details on using hashes here.

File details

Details for the file pypolyline-0.2.4-cp38-cp38-manylinux1_x86_64.whl.

File metadata

  • Download URL: pypolyline-0.2.4-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 581.8 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3

File hashes

Hashes for pypolyline-0.2.4-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 0d6a8e27332eb831e3c6d4ef130a465563a5e7f9fd7f2fcd761efafbe2692f42
MD5 3df6bd2a2c4b286121e126047eb89664
BLAKE2b-256 ade4e5329aff8920ae29835024ef2fae8828bb8a03d891d438ff7149ef653c6f

See more details on using hashes here.

File details

Details for the file pypolyline-0.2.4-cp38-cp38-macosx_10_13_x86_64.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.

File metadata

File hashes

Hashes for pypolyline-0.2.4-cp38-cp38-macosx_10_13_x86_64.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 02f3320aa98070f73940a4d0ee258b21d4596acc373a2e905891d9f3d3874c1f
MD5 1c00bca7337af11039fc966510fd3a77
BLAKE2b-256 09b35e257ca08dc11ad97be61cc6861308cc6af88b6e760636d6f484a0c40b93

See more details on using hashes here.

File details

Details for the file pypolyline-0.2.4-cp37-cp37m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: pypolyline-0.2.4-cp37-cp37m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 543.4 kB
  • Tags: CPython 3.7m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3

File hashes

Hashes for pypolyline-0.2.4-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 16a74c6d7fcde2674bfc0c68b6ff966581ae1c09af3ac1833f927b21736fcc43
MD5 ce23ff88be94bb78b375c28c5e9b7171
BLAKE2b-256 6989d39650b43befec2b3c5fe2a1e6c77525cfb89e6265be0e15e54607a47a18

See more details on using hashes here.

File details

Details for the file pypolyline-0.2.4-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: pypolyline-0.2.4-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 543.4 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3

File hashes

Hashes for pypolyline-0.2.4-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 0b39485679002440cc177702436b46f86e0bdf7c8afe170c776649e2d3461fb5
MD5 3728e937a70241e5f352218da48b5526
BLAKE2b-256 dd8b2ec574c297cadeb8685d1bc32ebd2aa1c150f4a9877225f68b2db6ed7b45

See more details on using hashes here.

File details

Details for the file pypolyline-0.2.4-cp37-cp37m-macosx_10_13_x86_64.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.

File metadata

File hashes

Hashes for pypolyline-0.2.4-cp37-cp37m-macosx_10_13_x86_64.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 4a4b9b2bd7ed55f98cd8394ac20cfda32c4e250d617cde93fa74e408902dd110
MD5 71a6666d9217a9f4c7f26e85443365cb
BLAKE2b-256 81f2e848a25987abde6b1887708e8298bb44d4ef3fab5e18fb5a073b468ea9c7

See more details on using hashes here.

File details

Details for the file pypolyline-0.2.4-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: pypolyline-0.2.4-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 312.1 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3

File hashes

Hashes for pypolyline-0.2.4-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 012f995fb71a4d207fb9f0ad4fb44234f74367efa3be2e2fb6c30dbaf3ccf35a
MD5 952090617a6752ce9d9a7ceac694368c
BLAKE2b-256 96572ae19143306353cf0c5d527a28fbda3bdba7ff8f6c82a946c2e76d0375b8

See more details on using hashes here.

File details

Details for the file pypolyline-0.2.4-cp36-cp36m-win32.whl.

File metadata

  • Download URL: pypolyline-0.2.4-cp36-cp36m-win32.whl
  • Upload date:
  • Size: 289.0 kB
  • Tags: CPython 3.6m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3

File hashes

Hashes for pypolyline-0.2.4-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 95801f714cb9a64e1c84092b5e57b36b5ccfcce1e3df8b6e1148cf876d055212
MD5 2ab48d75390198cf632d4352714afb68
BLAKE2b-256 dc61c9b3d1b1283dbdb0a72b11985bf054f795d2fb1f068a72820375e564a61e

See more details on using hashes here.

File details

Details for the file pypolyline-0.2.4-cp36-cp36m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: pypolyline-0.2.4-cp36-cp36m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 542.8 kB
  • Tags: CPython 3.6m, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3

File hashes

Hashes for pypolyline-0.2.4-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 da4815ea9087af09044c507d033f3de45f34e30299bcc7f54f73b5bac20554f0
MD5 be6045722158e03b3cbfe4af317349cf
BLAKE2b-256 0bd8a27b449e7ca1f57c87537143dfa624a13acd6749fea450aaa8c6e5992d5f

See more details on using hashes here.

File details

Details for the file pypolyline-0.2.4-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: pypolyline-0.2.4-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 542.8 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3

File hashes

Hashes for pypolyline-0.2.4-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 b04d138833c36b042a39ec73ded51d03a949f65a8c80aa325e4406f509053a7e
MD5 c4b6d8a6c816ee99ded2b496879f4fd9
BLAKE2b-256 8e6b56c6375676d24133c46322882001e2b220b156f5857212d284e90003770d

See more details on using hashes here.

File details

Details for the file pypolyline-0.2.4-cp36-cp36m-macosx_10_13_x86_64.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.

File metadata

File hashes

Hashes for pypolyline-0.2.4-cp36-cp36m-macosx_10_13_x86_64.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 6d4baeabbfab742df0a68971883046720ee3471ab96cb5460a300a089a0f85b7
MD5 25d28b76c5b99be5dc4879e0b4944cf2
BLAKE2b-256 f5bc1afe123f978ea4b3a437d3b2d60518660e77e8560d67435a7fd8cbef5a64

See more details on using hashes here.

File details

Details for the file pypolyline-0.2.4-cp27-cp27mu-manylinux2010_x86_64.whl.

File metadata

  • Download URL: pypolyline-0.2.4-cp27-cp27mu-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 507.8 kB
  • Tags: CPython 2.7mu, manylinux: glibc 2.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3

File hashes

Hashes for pypolyline-0.2.4-cp27-cp27mu-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 9af3cd19e68a8b87d867ca54fbb61a7363566a1a9d167f4a3dac1ccfa4296735
MD5 2d1f82cd8178f4f3cd85b70d4f855933
BLAKE2b-256 a0dcfbc94e7ba78910255e4c53392ab4b519df83a6d085544c08fa8db077d021

See more details on using hashes here.

File details

Details for the file pypolyline-0.2.4-cp27-cp27mu-manylinux1_x86_64.whl.

File metadata

  • Download URL: pypolyline-0.2.4-cp27-cp27mu-manylinux1_x86_64.whl
  • Upload date:
  • Size: 507.8 kB
  • Tags: CPython 2.7mu
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3

File hashes

Hashes for pypolyline-0.2.4-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 803b1614928e86e05368f657add8aa2f42e107bc6486400b688c39a8b13be4db
MD5 d94bf3474673ac1d0f6d844bd54d7281
BLAKE2b-256 3c65c969815a20bef690d5a6ffa6d6205f65a2ac862ae2a3e3d2f2dc81e60798

See more details on using hashes here.

File details

Details for the file pypolyline-0.2.4-cp27-cp27m-win_amd64.whl.

File metadata

  • Download URL: pypolyline-0.2.4-cp27-cp27m-win_amd64.whl
  • Upload date:
  • Size: 310.6 kB
  • Tags: CPython 2.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3

File hashes

Hashes for pypolyline-0.2.4-cp27-cp27m-win_amd64.whl
Algorithm Hash digest
SHA256 ce072b238680220091d4ade8287eb41816df5385bc7de306c90d9c7693c48d1b
MD5 42c40eeb894d5803cd76e5263ec813ff
BLAKE2b-256 01b5eb2d47b6f90580ce9989f020c76614dc4e538b9d896c3a28b8a2694287d3

See more details on using hashes here.

File details

Details for the file pypolyline-0.2.4-cp27-cp27m-win32.whl.

File metadata

  • Download URL: pypolyline-0.2.4-cp27-cp27m-win32.whl
  • Upload date:
  • Size: 290.4 kB
  • Tags: CPython 2.7m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3

File hashes

Hashes for pypolyline-0.2.4-cp27-cp27m-win32.whl
Algorithm Hash digest
SHA256 1300565a58166fef52c8e1b0504e975d9977caf66dadc65cff8aa1f57719f0f6
MD5 a0b3df944066a707b2dc47e1680db905
BLAKE2b-256 46723eca43d5e42624c510ff1226fe415ecf1fa5dde371f657060bfe80309056

See more details on using hashes here.

File details

Details for the file pypolyline-0.2.4-cp27-cp27m-macosx_10_13_x86_64.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.

File metadata

File hashes

Hashes for pypolyline-0.2.4-cp27-cp27m-macosx_10_13_x86_64.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 12d6441d5e9d3c1e0c38604e7fc040efd7334c06afd3dfcdc6a43027cd88505e
MD5 47516a90bd51801b607f08886c924037
BLAKE2b-256 f8188b954ba0ac6476783c2805a257420de7d70b94b18f351a78e472a51eea9f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page