pub trait DefaultDistance<Other> {
type Strategy: Default;
}Expand description
“Which distance strategy do we pick by default for a pair of
coordinate-system families Self (for the first geometry’s
CS family) and Other (for the second)?”
Mirrors boost::geometry::strategy::distance::services:: default_strategy<Tag1, Tag2, Point1, Point2, CsTag1, CsTag2>
from boost/geometry/strategies/distance/services.hpp, together
with the per-CS specialisations in
strategies/{cartesian,spherical,geographic}/distance.hpp and
the umbrella strategies/default_strategy.hpp.
In Boost the dispatch keys on the coordinate-system tag
(cs_tag<Point>::type). The Rust analogue is the
CoordinateSystem::Family associated type defined in
geometry-cs — every concrete CS (Cartesian,
Spherical<Degree>, Spherical<Radian>, Geographic<Degree>,
…) reports one of the family marker types
(CartesianFamily, SphericalFamily, GeographicFamily,
PolarFamily).
Implementations land in geometry-strategy alongside each
concrete strategy:
impl DefaultDistance<CartesianFamily> for CartesianFamily { type Strategy = Pythagoras; }
impl DefaultDistance<SphericalFamily> for SphericalFamily { type Strategy = Haversine; }
impl DefaultDistance<GeographicFamily> for GeographicFamily { type Strategy = Andoyer; }The Strategy: Default bound matches Boost’s expectation that
services::default_strategy<...>::type is default-constructible
(every strategies/.../distance_*.hpp concrete strategy has a
no-arg constructor).
Required Associated Types§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl DefaultDistance<CartesianFamily> for CartesianFamily
Cartesian × Cartesian defaults to Pythagoras.
impl DefaultDistance<CartesianFamily> for CartesianFamily
Cartesian × Cartesian defaults to Pythagoras.
Mirrors the services::default_strategy<point_tag, point_tag, P1, P2, cartesian_tag, cartesian_tag> specialisation at
strategies/cartesian/distance_pythagoras.hpp:276-283.
type Strategy = Pythagoras
Source§impl DefaultDistance<GeographicFamily> for GeographicFamily
Geographic × Geographic defaults to Andoyer.
impl DefaultDistance<GeographicFamily> for GeographicFamily
Geographic × Geographic defaults to Andoyer.
Mirrors the services::default_strategy<point_tag, point_tag, P1, P2, geographic_tag, geographic_tag> specialisation in
strategies/geographic/distance.hpp — Boost picks
strategy::distance::geographic<strategy::andoyer, Spheroid> as
the geographic default, which is exactly
strategy::distance::andoyer<Spheroid>.
Source§impl DefaultDistance<SphericalFamily> for SphericalFamily
Spherical × Spherical defaults to Haversine.
impl DefaultDistance<SphericalFamily> for SphericalFamily
Spherical × Spherical defaults to Haversine.
Mirrors the services::default_strategy<point_tag, point_tag, P1, P2, spherical_equatorial_tag, spherical_equatorial_tag>
specialisation in strategies/spherical/distance_haversine.hpp
(around the services::* block at lines 222-260).