| Crates.io | geo-normalized |
| lib.rs | geo-normalized |
| version | 0.1.1 |
| created_at | 2020-04-15 10:12:55.698819+00 |
| updated_at | 2020-04-15 11:42:16.860486+00 |
| description | A trait for producing a normalized Polygon/Multipolygon according to OCG winding rules |
| homepage | https://gitlab.com/bronsonbdevost/rust-geo-normalized |
| repository | https://gitlab.com/bronsonbdevost/rust-geo-normalized |
| max_upload_size | |
| id | 230443 |
| size | 13,033 |
Creates a new instance of the rust geo/geo-types Polygon/Multipolygon that follows the OGC winding rules.
The rust geo and geo-types crates are not as strict as the OGC guidelines, and allow for polygons with inner and outer rings in any winding order. This trait returns a Polygon/Multipolygon where all outer rings are clockwise, and all inner rings are anti-clockwise.
// Anti-clockwise winding order for outer ring
let bad = polygon![
(x: 1.0, y: 1.0),
(x: 4.0, y: 1.0),
(x: 4.0, y: 4.0),
(x: 1.0, y: 4.0),
(x: 1.0, y: 1.0),
];
// Clockwise winding order for outer ring
let good = polygon![
(x: 1.0, y: 1.0),
(x: 1.0, y: 4.0),
(x: 4.0, y: 4.0),
(x: 4.0, y: 1.0),
(x: 1.0, y: 1.0),
];
let norm = bad.normalized();
// norm should have the same points and shape as `bad` but in the valid winding order
assert_eq!(norm, good);