use geometry_coords::CoordinateScalar;
use geometry_cs::CoordinateSystem;
use crate::{
Box, Linestring, MultiLinestring, MultiPoint, MultiPolygon, Point, Polygon, Ring, Segment,
};
pub trait RebindGeometry<T: CoordinateScalar, Cs: CoordinateSystem> {
type Output;
}
pub type Rebound<G, T, Cs> = <G as RebindGeometry<T, Cs>>::Output;
impl<A, const D: usize, OldCs, T, Cs> RebindGeometry<T, Cs> for Point<A, D, OldCs>
where
A: CoordinateScalar,
OldCs: CoordinateSystem,
T: CoordinateScalar,
Cs: CoordinateSystem,
{
type Output = Point<T, D, Cs>;
}
impl<A, const D: usize, OldCs, T, Cs> RebindGeometry<T, Cs> for Box<Point<A, D, OldCs>>
where
A: CoordinateScalar,
OldCs: CoordinateSystem,
T: CoordinateScalar,
Cs: CoordinateSystem,
{
type Output = Box<Point<T, D, Cs>>;
}
impl<A, const D: usize, OldCs, T, Cs> RebindGeometry<T, Cs> for Linestring<Point<A, D, OldCs>>
where
A: CoordinateScalar,
OldCs: CoordinateSystem,
T: CoordinateScalar,
Cs: CoordinateSystem,
{
type Output = Linestring<Point<T, D, Cs>>;
}
impl<A, const D: usize, OldCs, T, Cs, const CW: bool, const CL: bool> RebindGeometry<T, Cs>
for Ring<Point<A, D, OldCs>, CW, CL>
where
A: CoordinateScalar,
OldCs: CoordinateSystem,
T: CoordinateScalar,
Cs: CoordinateSystem,
{
type Output = Ring<Point<T, D, Cs>, CW, CL>;
}
impl<A, const D: usize, OldCs, T, Cs> RebindGeometry<T, Cs> for Segment<Point<A, D, OldCs>>
where
A: CoordinateScalar,
OldCs: CoordinateSystem,
T: CoordinateScalar,
Cs: CoordinateSystem,
{
type Output = Segment<Point<T, D, Cs>>;
}
impl<A, const D: usize, OldCs, T, Cs> RebindGeometry<T, Cs> for MultiPoint<Point<A, D, OldCs>>
where
A: CoordinateScalar,
OldCs: CoordinateSystem,
T: CoordinateScalar,
Cs: CoordinateSystem,
{
type Output = MultiPoint<Point<T, D, Cs>>;
}
impl<A, const D: usize, OldCs, T, Cs, const CW: bool, const CL: bool> RebindGeometry<T, Cs>
for Polygon<Point<A, D, OldCs>, CW, CL>
where
A: CoordinateScalar,
OldCs: CoordinateSystem,
T: CoordinateScalar,
Cs: CoordinateSystem,
{
type Output = Polygon<Point<T, D, Cs>, CW, CL>;
}
impl<A, const D: usize, OldCs, T, Cs> RebindGeometry<T, Cs>
for MultiLinestring<Linestring<Point<A, D, OldCs>>>
where
A: CoordinateScalar,
OldCs: CoordinateSystem,
T: CoordinateScalar,
Cs: CoordinateSystem,
{
type Output = MultiLinestring<Linestring<Point<T, D, Cs>>>;
}
impl<A, const D: usize, OldCs, T, Cs, const CW: bool, const CL: bool> RebindGeometry<T, Cs>
for MultiPolygon<Polygon<Point<A, D, OldCs>, CW, CL>>
where
A: CoordinateScalar,
OldCs: CoordinateSystem,
T: CoordinateScalar,
Cs: CoordinateSystem,
{
type Output = MultiPolygon<Polygon<Point<T, D, Cs>, CW, CL>>;
}