#codec #gis #encoded #decoding #line-string #google

polyline

Encoder and decoder for the Google Encoded Polyline format

15 releases (breaking)

0.11.0 May 13, 2024
0.10.1 May 10, 2023
0.10.0 Mar 12, 2023
0.9.0 Feb 5, 2021
0.4.0 Jul 17, 2016

#7 in Geospatial

Download history 1209/week @ 2024-07-03 1042/week @ 2024-07-10 919/week @ 2024-07-17 1342/week @ 2024-07-24 1010/week @ 2024-07-31 934/week @ 2024-08-07 1130/week @ 2024-08-14 1627/week @ 2024-08-21 1743/week @ 2024-08-28 1752/week @ 2024-09-04 1768/week @ 2024-09-11 1643/week @ 2024-09-18 1725/week @ 2024-09-25 1747/week @ 2024-10-02 1986/week @ 2024-10-09 2194/week @ 2024-10-16

8,077 downloads per month
Used in 11 crates (9 directly)

MIT/Apache

32KB
325 lines

polyline

polyline

polyline on Crates.io Documentation Discord

Fast Google Encoded Polyline encoding & decoding in Rust.

Example

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

FFI

C-compatible FFI bindings for this crate are provided by the polyline-ffi crate.

Dependencies

~750KB
~15K SLoC