Flexible Polyline encoding
The flexible polyline encoding is a lossy compressed representation of a list of coordinate pairs or coordinate triples. It achieves that by:
- Reducing the decimal digits of each value.
- Encoding only the offset from the previous point.
- Using variable length for each coordinate delta.
- Using 64 URL-safe characters to display the result.
The encoding is a variant of Encoded Polyline Algorithm Format. The advantage of this encoding over the original are the following:
- Output string is composed by only URL-safe characters, i.e. may be used without URL encoding as query parameters.
- Floating point precision is configurable: This allows to represent coordinates with precision up to microns (5 decimal places allow meter precision only).
- It allows to encode a 3rd dimension with a given precision, which may be a level, altitude, elevation or some other custom value.
Specification
See Specification.
Example
use ;
// encode
let coordinates = vec!;
let polyline = Data2d ;
let encoded = polyline.encode.unwrap;
assert_eq!;
// decode
let decoded = decode.unwrap;
assert_eq!;