Metadata-Version: 2.4
Name: polyline-rs
Version: 3.0.0
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Zero-Clause BSD (0BSD)
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Rust
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
License-File: LICENSE-THIRD-PARTY.md
License-File: LICENSE.md
Summary: Google Encoded Polyline encoding and decoding
Keywords: decoding,encoding,gis,google,mapbox,openstreetmap,polyline
Author-email: Kamil Monicz <kamil@monicz.dev>
License-Expression: 0BSD
Requires-Python: >=3.11
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Issues, https://github.com/Zaczero/pkgs/issues
Project-URL: Repository, https://github.com/Zaczero/pkgs/tree/main/polyline-rs

# polyline-rs

[![PyPI - Python Version](https://shields.monicz.dev/pypi/pyversions/polyline-rs)](https://pypi.org/p/polyline-rs)

Encode and decode Google Encoded Polyline strings from Python with an explicit
choice of `(longitude, latitude)` (`order='lonlat'`, default) or
`(latitude, longitude)` (`order='latlon'`) coordinate order. Requires Python
3.11 or newer.

[Encoded Polyline Algorithm Format](https://developers.google.com/maps/documentation/utilities/polylinealgorithm)

## Installation

```sh
pip install polyline-rs
```

## Basic usage

```py
from polyline_rs import decode, encode

line = encode(
    [(38.5, -120.2), (40.7, -120.95), (43.252, -126.453)],
    precision=5,
    order='latlon',
)
assert line == "_p~iF~ps|U_ulLnnqC_mqNvxq`@"

lonlat = decode(line, precision=5)  # Default order='lonlat'.
latlon = decode(line, precision=5, order='latlon')
```

## Coordinate and precision limits

Use the same precision when encoding and decoding; `5` means five decimal
places. Coordinates are rounded half away from zero. Scaled coordinates and
their successive differences must fit signed 32-bit integers; overflow and
malformed encodings raise `ValueError`.

`order='lonlat'` (the default) uses longitude first; `order='latlon'` uses
latitude first. Rows accept at least two numbers and ignore additional values.

## API reference and support

The function signatures and error contracts are documented in the
[package typing stubs](https://github.com/Zaczero/pkgs/blob/main/polyline-rs/python/polyline_rs/_lib.pyi).

[Issues and questions](https://github.com/Zaczero/pkgs/issues) ·
[Private security reports](https://github.com/Zaczero/pkgs/security/advisories/new) ·
[Premium support](https://monicz.dev/#get-in-touch)

