Skip to content

Latest commit

 

History

History
92 lines (63 loc) · 1.83 KB

README.md

File metadata and controls

92 lines (63 loc) · 1.83 KB

Fast Polylines

Implementation of the Google polyline algorithm.

Up to 60x faster than the polyline package.

Benchmark

make bench made on a Apple M1 computer.

encode

fast_polyline:	10.606ms
polyline:	613.5ms
fast_polyline is 57.8 times faster.

decode

fast_polyline:	23.447ms
polyline:	425.96ms
fast_polyline is 18.2 times faster.

Install

pip install fast_polyline

or in your requirements.txt:

fast_polyline~=0.2.0

Usage

import fast_polyline

fast_polyline.encode([[38.5, -120.2], [40.7, -120.95], [43.252, -126.453]])
# => "_p~iF~ps|U_ulLnnqC_mqNvxq`@"

fast_polyline.decode("_p~iF~ps|U_ulLnnqC_mqNvxq`@")
# => [[38.5, -120.2], [40.7, -120.95], [43.252, -126.453]]

Advanced usage

Use a different precision

Default precision is 5 decimals, to use a precision of 6:

fast_polyline.encode([[38.5, -120.2], [40.7, -120.95], [43.252, -126.453]], 6)
# => "_izlhA~rlgdF_{geC~ywl@_kwzCn`{nI"

fast_polyline.decode("_izlhA~rlgdF_{geC~ywl@_kwzCn`{nI", 6)
# => [[38.5, -120.2], [40.7, -120.95], [43.252, -126.453]]

The precision max is 13. And I advanced against using it since it is already way too precise.

Encoder and Decoder modules are deprec

Contributing

git clone git@github.com:BuonOmo/fast-polyline.py
cd fast-polyline.py
make # show all commands you might need
# Implement a feature, resolve a bug...
make lint
make test
git commit "feat: respect conventional commits"
# Make a PR

And here's the Python C ABI doc.

License

Please see the LICENSE file.