Trait geo::algorithm::map_coords::MapCoords
[−]
[src]
pub trait MapCoords<T, NT> { type Output; fn map_coords(&self, func: &Fn(&(T, T)) -> (NT, NT)) -> Self::Output
where
T: CoordinateType,
NT: CoordinateType; }
Map all the coordinates in an object, returning a new one
Associated Types
type Output
Required Methods
fn map_coords(&self, func: &Fn(&(T, T)) -> (NT, NT)) -> Self::Output where
T: CoordinateType,
NT: CoordinateType,
T: CoordinateType,
NT: CoordinateType,
Apply a function to all the coordinates in a geometric object, returning a new object.
use geo::Point; use geo::algorithm::map_coords::MapCoords; let p1 = Point::new(10., 20.); let p2 = p1.map_coords(&|&(x, y)| (x+1000., y*2.)); assert_eq!(p2, Point::new(1010., 40.));
You can convert the coordinate type this way as well
let p1: Point<f32> = Point::new(10.0f32, 20.0f32); let p2: Point<f64> = p1.map_coords(&|&(x, y)| (x as f64, y as f64)); assert_eq!(p2, Point::new(10.0f64, 20.0f64));
Implementors
impl<T: CoordinateType, NT: CoordinateType> MapCoords<T, NT> for Point<T> type Output = Point<NT>;
impl<T: CoordinateType, NT: CoordinateType> MapCoords<T, NT> for Line<T> type Output = Line<NT>;
impl<T: CoordinateType, NT: CoordinateType> MapCoords<T, NT> for LineString<T> type Output = LineString<NT>;
impl<T: CoordinateType, NT: CoordinateType> MapCoords<T, NT> for Polygon<T> type Output = Polygon<NT>;
impl<T: CoordinateType, NT: CoordinateType> MapCoords<T, NT> for MultiPoint<T> type Output = MultiPoint<NT>;
impl<T: CoordinateType, NT: CoordinateType> MapCoords<T, NT> for MultiLineString<T> type Output = MultiLineString<NT>;
impl<T: CoordinateType, NT: CoordinateType> MapCoords<T, NT> for MultiPolygon<T> type Output = MultiPolygon<NT>;
impl<T: CoordinateType, NT: CoordinateType> MapCoords<T, NT> for Geometry<T> type Output = Geometry<NT>;
impl<T: CoordinateType, NT: CoordinateType> MapCoords<T, NT> for GeometryCollection<T> type Output = GeometryCollection<NT>;