Crates.io | polyline |
lib.rs | polyline |
version | 0.11.0 |
source | src |
created_at | 2016-06-21 17:47:28.056847 |
updated_at | 2024-05-13 19:15:26.586524 |
description | Encoder and decoder for the Google Encoded Polyline format |
homepage | |
repository | https://github.com/georust/polyline |
max_upload_size | |
id | 5446 |
size | 61,957 |
Fast Google Encoded Polyline encoding & decoding in Rust.
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)
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.
C-compatible FFI bindings for this crate are provided by the polyline-ffi crate.