Skip to main content

GeometryCollection

Trait GeometryCollection 

Source
pub trait GeometryCollection: Geometry<Kind = GeometryCollectionTag> {
    type Item: Geometry;

    // Required method
    fn items(&self) -> impl ExactSizeIterator<Item = &Self::Item>;
}
Expand description

A collection of geometries belonging to each other.

Mirrors the GeometryCollection concept; the canonical C++ model is boost::geometry::model::geometry_collection in boost/geometry/geometries/geometry_collection.hpp, tagged with geometry_collection_tag (boost/geometry/core/tags.hpp).

In v1 the Item associated type is bound only on Geometry — every concrete impl is homogeneous (a single element type for the whole collection). Heterogeneous dispatch is intentionally deferred to a later iteration (a DynGeometry variant and a heterogeneous GeometryCollection).

§Examples

use geometry_trait::GeometryCollection;
fn count<C: GeometryCollection>(c: &C) -> usize { c.items().len() }

Required Associated Types§

Source

type Item: Geometry

The element geometry type.

Mirrors the DynamicGeometry template parameter on boost::geometry::model::geometry_collection<DynamicGeometry, …> (boost/geometry/geometries/geometry_collection.hpp). In v1 the bound is just Geometry; once §1.4 lands this will tighten to a dynamic-geometry concept.

Required Methods§

Source

fn items(&self) -> impl ExactSizeIterator<Item = &Self::Item>

The items of this collection, in declared order.

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

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§