https://github.com/georust/polyline
Fast Google Encoded Polyline encoding & decoding in Rust
https://github.com/georust/polyline
polyline polyline-decoder polyline-encoder
Last synced: 6 months ago
JSON representation
Fast Google Encoded Polyline encoding & decoding in Rust
- Host: GitHub
- URL: https://github.com/georust/polyline
- Owner: georust
- License: apache-2.0
- Created: 2016-06-15T16:54:46.000Z (over 9 years ago)
- Default Branch: main
- Last Pushed: 2024-05-14T17:28:41.000Z (almost 2 years ago)
- Last Synced: 2024-10-29T18:59:29.251Z (over 1 year ago)
- Topics: polyline, polyline-decoder, polyline-encoder
- Language: Rust
- Homepage: https://crates.io/crates/polyline
- Size: 121 KB
- Stars: 25
- Watchers: 7
- Forks: 12
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE-APACHE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# polyline
[](https://github.com/georust)
[](https://crates.io/crates/polyline)
[](https://docs.rs/polyline)
[](https://discord.gg/Fp2aape)
Fast Google Encoded Polyline encoding & decoding in Rust.
# Example
```rust
use polyline;
use geo_types::line_string;
let coord = line_string![(x: -120.2, y: 38.5), (x: -120.95, y: 40.7), (x: -126.453, y: 43.252)];
let output = "_p~iF~ps|U_ulLnnqC_mqNvxq`@";
let result = polyline::encode_coordinates(coord, 5).unwrap();
assert_eq!(result, output)
```
# A Note on Coordinate Order
This crate uses `Coord` and `LineString` types from the `geo-types` crate, which encodes coordinates in `(x, y)` / `(lon, lat)` order. The Polyline algorithm and its first-party documentation assumes the _opposite_ coordinate order. It is thus advisable to pay careful attention to the order of the coordinates you use for encoding and decoding.
[Documentation](https://docs.rs/polyline/)
# FFI
C-compatible FFI bindings for this crate are provided by the [polyline-ffi](https://crates.io/crates/polyline-ffi) crate.