Skip to content

chanced/rs-polyline-codec

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

crates.io docs.rs Crates.io

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

    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

About

Polyline encoding and decoding.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages