#polyline #geo

polyline

Encoder and decoder for the Google Encoded Polyline format

11 releases (breaking)

0.9.0 Feb 5, 2021
0.8.0 Jun 23, 2020
0.7.2 Apr 13, 2020
0.7.1 Mar 11, 2020
0.4.0 Jul 17, 2016

#284 in Science

Download history 525/week @ 2022-08-15 298/week @ 2022-08-22 332/week @ 2022-08-29 238/week @ 2022-09-05 288/week @ 2022-09-12 411/week @ 2022-09-19 457/week @ 2022-09-26 506/week @ 2022-10-03 413/week @ 2022-10-10 415/week @ 2022-10-17 397/week @ 2022-10-24 355/week @ 2022-10-31 489/week @ 2022-11-07 538/week @ 2022-11-14 472/week @ 2022-11-21 487/week @ 2022-11-28

1,990 downloads per month
Used in 3 crates

MIT/Apache

12KB
174 lines

polyline

Crates.io Build Status

Google Encoded Polyline encoding & decoding in Rust.

A Note on Coordinate Order

This crate uses Coordinate and LineString types from the geo-types crate, which encodes coordinates in (x, y) order. The Polyline algorithm and 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


lib.rs:

Google Encoded Polyline encoding & decoding in Rust

Polyline is a lossy compression algorithm that allows you to store a series of coordinates as a single string.

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 Coordinate and LineString types from the geo-types crate, which encodes coordinates in (x, y) order. The Polyline algorithm and 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.

Dependencies

~320KB