A package containing:
geo-validator
.When running repair, it will try its best to produce a (Multi)Polygon that meets OGC standards. Some very invalid polygons may still fail, but most come through as valid with very little change.
```rust use georepairpolygon::repair::Repair; use geo_types::polygon;
let bowtie = polygon![ (x: 0_f64, y: 0.), (x: 0., y: 20.), (x: 20., y: 0.), (x: 20., y: 20.), (x: 0., y: 0.)];
let expected = polygon![ (x: 0_f64, y: 0.), (x: 9.999999999999996, y: 9.999999999999996), (x: 10.000000000000004, y: 9.999999999999996), (x: 20., y: 0.), (x: 20., y: 20.), (x: 10.000000000000004, y: 10.000000000000004), (x: 9.999999999999996, y: 10.000000000000004), (x: 0., y: 20.), (x: 0., y: 0.)];
let repairedbowtie = bowtie.repair(); assert!(repairedbowtie.issome()); asserteq!(repaired_bowtie.unwrap(), expected); ```
The join trait for MultiPolygon will merge all of its Polygons into a single valid Polygon. This may involve a union or the creation of a small bridge between the closest points of non-overlapping Polygons.
``` rust use georepairpolygon::join::Join; use geo_types::{polygon, MultiPolygon};
let separatepolygons: MultiPolygon
let expected = polygon![ (x: 10_f64, y: 10.), (x: 11., y: 11.), (x: 20., y: 11.), (x: 20., y: 20.), (x: 11., y: 20.), (x: 11., y: 11.000000000000004), (x: 9.999999999999996, y: 10.), (x: 0., y: 10.), (x: 0., y: 0.), (x: 10., y: 0.), (x: 10., y: 10.)];
let merged = separatepolygons.join(); asserteq!(merged, expected); ```