Crates.io | polyline-codec |
lib.rs | polyline-codec |
version | 0.1.3 |
source | src |
created_at | 2022-04-10 22:55:17.054452 |
updated_at | 2022-04-11 01:13:14.868208 |
description | Encode and decode polylines. |
homepage | |
repository | https://github.com/chanced/rs-polyline-codec |
max_upload_size | |
id | 565266 |
size | 22,435 |
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.
I have no affiliation with Google or Google Maps. This package was ported from https://github.com/googlemaps/js-polyline-codec.
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`@",
);
MIT OR Apache v2.0