pub trait Polygon: Geometry<Kind = PolygonTag> {
type Ring: Ring<Point = Self::Point>;
// Required methods
fn exterior(&self) -> &Self::Ring;
fn interiors(&self) -> impl ExactSizeIterator<Item = &Self::Ring>;
}Expand description
A polygon — an exterior ring plus zero or more interior rings.
Mirrors the Polygon concept (doc/concept/polygon.qbk); the
canonical model is boost::geometry::model::polygon in
boost/geometry/geometries/polygon.hpp. All rings share the
polygon’s point type, matching the constraint that
traits::ring_const_type<P>::type and the polygon’s
traits::point_type<P>::type are mutually consistent
(boost/geometry/core/{ring_type,point_type}.hpp).
Ring is an associated type — locked in proposal §10.3 — so the
inner ring kind is fixed at the impl site and dispatch stays
monomorphic (Boost’s traits::ring_const_type<P>::type).
As with crate::Linestring and crate::Ring, the interior
rings are exposed via RPITIT so each impl can hand back whatever
iterator its underlying container provides.
§Examples
use geometry_trait::Polygon;
fn hole_count<P: Polygon>(p: &P) -> usize { p.interiors().len() }Required Associated Types§
Required Methods§
Sourcefn exterior(&self) -> &Self::Ring
fn exterior(&self) -> &Self::Ring
The exterior ring (outer boundary) of this polygon.
Mirrors boost::geometry::traits::exterior_ring<P>::get(p)
(boost/geometry/core/exterior_ring.hpp).
Sourcefn interiors(&self) -> impl ExactSizeIterator<Item = &Self::Ring>
fn interiors(&self) -> impl ExactSizeIterator<Item = &Self::Ring>
The interior rings (holes) of this polygon, in declared order.
Mirrors boost::geometry::traits::interior_rings<P>::get(p)
(boost/geometry/core/interior_rings.hpp). The returned
iterator is ExactSizeIterator so callers can ask for the
hole count without consuming it — the analogue of
boost::size(traits::interior_rings<P>::get(p)).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".