https://github.com/chanced/rs-polyline-codec
Polyline encoding and decoding.
https://github.com/chanced/rs-polyline-codec
Last synced: about 1 year ago
JSON representation
Polyline encoding and decoding.
- Host: GitHub
- URL: https://github.com/chanced/rs-polyline-codec
- Owner: chanced
- License: apache-2.0
- Created: 2022-04-10T22:44:36.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-04-11T01:13:09.000Z (about 4 years ago)
- Last Synced: 2024-10-06T00:42:37.652Z (over 1 year ago)
- Language: Rust
- Size: 17.6 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://crates.io/crates/polyline-codec) [](https://docs.rs/polyline-codec)

# Rust port of Google Maps Polyline Encoding
## Description
Encode and decode polyines in Rust using this package.
Polyline encoding is a lossy compression algorithm that allows you to store a series of coordinates as a single string. Point coordinates are encoded using signed values.
Read more at https://developers.google.com/maps/documentation/utilities/polylinealgorithm.
## Note
I have no affiliation with Google or Google Maps. This package was ported from https://github.com/googlemaps/js-polyline-codec.
## Example
```rust
use polyline_codec::LatLng;
let encoded = "_p~iF~ps|U_ulLnnqC_mqNvxq`@";
assert_eq!(
polyline_codec::decode(encoded, 5).unwrap(),
vec![
LatLng(38.5, -120.2,),
LatLng(40.7, -120.95,),
LatLng(43.252, -126.453,),
]
);
let path = &[(38.5, -120.2), (40.7, -120.95), (43.252, -126.453)];
assert_eq!(
polyline_codec::encode(path, 5).unwrap(),
"_p~iF~ps|U_ulLnnqC_mqNvxq`@",
);
```
## License
MIT OR Apache v2.0