pub fn is_valid_polygon<G, P>(polygon: &G) -> Result<(), ValidityFailure>where
G: PolygonTrait<Point = P>,
P: PointMut + Default + Copy,
P::Scalar: CoordinateScalar + Into<f64>,
<P::Cs as CoordinateSystem>::Family: SameAs<CartesianFamily>,Expand description
Validate a polygon: its exterior ring (with exterior orientation expectations), each interior ring (with interior orientation expectations), and all exterior/interior and interior/interior ring-pair topology constraints.
Mirrors the polygon arm of boost::geometry::is_valid
(detail/is_valid/polygon.hpp).
§Errors
Returns a ValidityFailure describing the first rule the polygon
violates, including failures for outside, nested, crossing, or
disconnecting interior rings.
§Examples
use geometry_cs::Cartesian;
use geometry_model::{polygon, Point2D, Polygon};
use geometry_overlay::validity::is_valid_polygon;
type P = Point2D<f64, Cartesian>;
let pg: Polygon<P> = polygon![[(0.0, 0.0), (0.0, 4.0), (4.0, 4.0), (4.0, 0.0), (0.0, 0.0)]];
assert!(is_valid_polygon(&pg).is_ok());