#[cfg(feature = "geo-types")]
pub mod geo_types;
use crate::errors::Result;
use crate::proj::Proj;
use crate::transform::{transform, Transform, TransformClosure};
impl Transform for (f64, f64, f64) {
fn transform_coordinates<F: TransformClosure>(&mut self, f: &mut F) -> Result<()> {
(self.0, self.1, self.2) = f(self.0, self.1, self.2)?;
Ok(())
}
}
impl Transform for (f64, f64) {
fn transform_coordinates<F: TransformClosure>(&mut self, f: &mut F) -> Result<()> {
(self.0, self.1) = f(self.0, self.1, 0.).map(|(x, y, _)| (x, y))?;
Ok(())
}
}
pub fn transform_vertex_3d(src: &Proj, dst: &Proj, pt: (f64, f64, f64)) -> Result<(f64, f64, f64)> {
let mut pt_out = pt;
transform(src, dst, &mut pt_out)?;
Ok(pt_out)
}
#[inline(always)]
pub fn transform_vertex_2d(src: &Proj, dst: &Proj, pt: (f64, f64)) -> Result<(f64, f64)> {
transform_vertex_3d(src, dst, (pt.0, pt.1, 0.)).map(|(x, y, _)| (x, y))
}
#[inline(always)]
pub fn transform_xyz(src: &Proj, dst: &Proj, x: f64, y: f64, z: f64) -> Result<(f64, f64, f64)> {
transform_vertex_3d(src, dst, (x, y, z))
}
#[inline(always)]
pub fn transform_xy(src: &Proj, dst: &Proj, x: f64, y: f64) -> Result<(f64, f64)> {
transform_xyz(src, dst, x, y, 0.).map(|(x, y, _)| (x, y))
}
impl Transform for [(f64, f64, f64)] {
fn transform_coordinates<F: TransformClosure>(&mut self, f: &mut F) -> Result<()> {
self.iter_mut()
.try_for_each(|xyz| xyz.transform_coordinates(f))
}
}
impl Transform for [(f64, f64)] {
fn transform_coordinates<F: TransformClosure>(&mut self, f: &mut F) -> Result<()> {
self.iter_mut()
.try_for_each(|xy| xy.transform_coordinates(f))
}
}