Crates.io | simplify-polyline |
lib.rs | simplify-polyline |
version | 0.5.0 |
source | src |
created_at | 2022-10-06 14:43:46.83272 |
updated_at | 2023-10-15 15:04:35.834547 |
description | Simplify polylines using Douglas-Peucker and radial distance algorithms. Port of the simplify-js library. |
homepage | https://github.com/kade-robertson/simplify-polyline |
repository | https://github.com/kade-robertson/simplify-polyline |
max_upload_size | |
id | 681384 |
size | 2,421,309 |
A Rust port of the Javascript simplify-js library.
use simplify_polyline::*;
fn main() {
let points = [
Point { vec: [0.0, 0.0] }, Point { vec: [1.0, 1.0] },
Point { vec: [2.0, 2.0] }, Point { vec: [3.0, 3.0] },
Point { vec: [4.0, 4.0] }
];
// alternatively, use the point! macro
let points = [
point!(0.0, 0.0), point!(1.0, 1.0), point!(2.0, 2.0),
point!(3.0, 3.0), point!(4.0, 4.0)
];
// alternatively, use the points! macro
let points = points![(0.0, 0.0), (1.0, 1.0), (2.0, 2.0), (3.0, 3.0), (4.0, 4.0)];
// low-quality simplification (fast)
let new_points = simplify(&points, 1.0, false);
// low-quality simplification (slower)
let new_points = simplify(&points, 1.0, true);
}
serde
, optional, defaults to off. Allows serializing/deserializing points.
Measurements taken with an AMD Ryzen 7 5800x, in Pop!_OS 22.04.
Test Case | simplify-polyline | simplify-js |
---|---|---|
1118 Points, Low Quality, Tolerance 1 | 16.584 μs | 52.907 μs |
1118 Points, High Quality, Tolerance 1 | 26.989 μs | 85.653 μs |
1118 Points, Low Quality, Tolerance 5 | 3.987 μs | 12.840 μs |
1118 Points, High Quality, Tolerance 5 | 19.497 μs | 57.901 μs |
73752 Points, Low Quality, Tolerance 1 | 82.251 μs | 273.075 μs |
73752 Points, High Quality, Tolerance 1 | 1933.700 μs | 5376.344 μs |
73752 Points, Low Quality, Tolerance 5 | 54.150 μs | 181.554 μs |
73752 Points, High Quality, Tolerance 5 | 1458.900 μs | 3921.569 μs |
$ cargo test --all-features
or
$ cargo make test
$ cargo bench --all-features
or
$ cargo make bench