Skip to main content

Ring

Trait Ring 

Source
pub trait Ring: Geometry<Kind = RingTag> {
    // Required method
    fn points(&self) -> impl ExactSizeIterator<Item = &Self::Point> + Clone;

    // Provided methods
    fn closure(&self) -> Closure { ... }
    fn point_order(&self) -> PointOrder { ... }
}
Expand description

A ring — an ordered sequence of points whose first and last either coincide (Closure::Closed) or are implicitly connected (Closure::Open).

Mirrors the Ring concept (doc/concept/ring.qbk); the canonical model is boost::geometry::model::ring in boost/geometry/geometries/ring.hpp, which is parameterised on bool ClockWise = true, bool Closed = true — the Boost defaults match the defaults on Ring::point_order and Ring::closure.

As with crate::Linestring, points are exposed as an ExactSizeIterator + Clone returned via RPITIT so each impl can reuse whatever iterator its container provides.

§Examples

use geometry_trait::{Closure, PointOrder, Ring};
fn ring_defaults<R: Ring>(r: &R) -> (Closure, PointOrder) {
    (r.closure(), r.point_order())
}

Required Methods§

Source

fn points(&self) -> impl ExactSizeIterator<Item = &Self::Point> + Clone

The points of this ring, in declared order.

Plays the role of boost::begin(r) / boost::end(r) from boost/geometry/geometries/ring.hpp when read together.

Provided Methods§

Source

fn closure(&self) -> Closure

Whether this ring’s last point repeats its first.

Mirrors boost::geometry::traits::closure<R>::value (boost/geometry/core/closure.hpp). Defaults to Closure::Closed, matching Boost’s default specialisation traits::closure<G>::value = closed.

Source

fn point_order(&self) -> PointOrder

The traversal direction of this ring’s boundary.

Mirrors boost::geometry::traits::point_order<R>::value (boost/geometry/core/point_order.hpp). Defaults to PointOrder::Clockwise, matching Boost’s default specialisation traits::point_order<G>::value = clockwise.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§