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

#229 in Geospatial

Download history 2168/week @ 2024-12-03 1831/week @ 2024-12-10 1667/week @ 2024-12-17 313/week @ 2024-12-24 790/week @ 2024-12-31 1747/week @ 2025-01-07 1833/week @ 2025-01-14 2032/week @ 2025-01-21 2094/week @ 2025-01-28 1849/week @ 2025-02-04 1817/week @ 2025-02-11 1698/week @ 2025-02-18 1727/week @ 2025-02-25 1531/week @ 2025-03-04 1551/week @ 2025-03-11 1216/week @ 2025-03-18

6,352 downloads per month
Used in 12 crates (10 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

~770KB
~15K SLoC