pub trait Point: Geometry<Kind = PointTag, Point = Self> + Sized {
type Scalar: CoordinateScalar;
type Cs: CoordinateSystem;
const DIM: usize;
// Required method
fn get<const D: usize>(&self) -> Self::Scalar;
}Expand description
The Point concept.
Models doc/concept/point.qbk — equivalent in C++ to the five
trait specialisations spelled out in
boost/geometry/geometries/concepts/point_concept.hpp and the
per-dimension accessor declared in
boost/geometry/core/access.hpp:270-313. The five C++ pieces
collapse here to four associated items plus the super-bound:
| C++ trait | Rust counterpart |
|---|---|
traits::tag<P> (core/tag.hpp) | Geometry<Kind = PointTag> |
traits::dimension<P> (core/coordinate_dimension.hpp) | const DIM: usize |
traits::coordinate_type<P> (core/coordinate_type.hpp) | type Scalar |
traits::coordinate_system<P> (core/coordinate_system.hpp) | type Cs |
traits::access<P, D>::get (core/access.hpp:270-313) | fn get::<D> |
The read-write half — traits::access<P, D>::set — lives on the
PointMut subtrait, mirroring the way Boost’s mutating Point
concept sits above the read-only ConstPoint.
The Point = Self projection on the Geometry super-trait is
the Rust spelling of Boost’s “a Point is its own point type”
invariant — point_type<P>::type = P whenever
tag<P>::type = point_tag.
§Examples
use geometry_cs::Cartesian;
use geometry_tag::PointTag;
use geometry_trait::{Geometry, Point};
#[derive(Default)]
struct Xy { x: f64, y: f64 }
impl Geometry for Xy { type Kind = PointTag; type Point = Self; }
impl Point for Xy {
type Scalar = f64;
type Cs = Cartesian;
const DIM: usize = 2;
fn get<const D: usize>(&self) -> f64 { if D == 0 { self.x } else { self.y } }
}
let p = Xy { x: 3.0, y: 4.0 };
assert_eq!(p.get::<0>(), 3.0);Required Associated Constants§
Required Associated Types§
Sourcetype Scalar: CoordinateScalar
type Scalar: CoordinateScalar
The scalar coordinate type.
Mirrors boost::geometry::traits::coordinate_type<P>::type
(boost/geometry/core/coordinate_type.hpp).
Sourcetype Cs: CoordinateSystem
type Cs: CoordinateSystem
The coordinate system this point lives in.
Mirrors boost::geometry::traits::coordinate_system<P>::type
(boost/geometry/core/coordinate_system.hpp).
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".