Skip to content

Commit

Permalink
Utilize Coord instead of now-deprecated Coordinate
Browse files Browse the repository at this point in the history
  • Loading branch information
frewsxcv committed Nov 5, 2022
1 parent 2049036 commit 495c57d
Show file tree
Hide file tree
Showing 82 changed files with 531 additions and 531 deletions.
4 changes: 2 additions & 2 deletions geo-bool-ops-benches/benches/utils/bops.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![allow(dead_code)]

use geo_types::{Coordinate, LineString, MultiPolygon, Polygon};
use geo_types::{Coord, LineString, MultiPolygon, Polygon};

pub fn convert_poly(poly: &Polygon<f64>) -> gt_prev::Polygon<f64> {
let ext: Vec<_> = poly
Expand All @@ -21,7 +21,7 @@ pub fn convert_back_poly(poly: &gt_prev::Polygon<f64>) -> Polygon<f64> {
.exterior()
.0
.iter()
.map(|c| Coordinate { x: c.x, y: c.y })
.map(|c| Coord { x: c.x, y: c.y })
.collect();
Polygon::new(LineString(ext), vec![])
}
Expand Down
4 changes: 2 additions & 2 deletions geo-postgis/src/to_postgis.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use geo_types::{
Coordinate, Geometry, GeometryCollection, Line, LineString, MultiLineString, MultiPoint,
Coord, Geometry, GeometryCollection, Line, LineString, MultiLineString, MultiPoint,
MultiPolygon, Point, Polygon,
};
use postgis::ewkb;
Expand All @@ -19,7 +19,7 @@ pub trait ToPostgis<T> {
}
}

impl ToPostgis<ewkb::Point> for Coordinate {
impl ToPostgis<ewkb::Point> for Coord {
fn to_postgis_with_srid(&self, srid: Option<i32>) -> ewkb::Point {
ewkb::Point::new(self.x, self.y, srid)
}
Expand Down
40 changes: 20 additions & 20 deletions geo-types/src/geometry/coordinate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub struct Coord<T: CoordNum = f64> {
#[deprecated(note = "Renamed to `geo_types::Coord` (or `geo::Coord`)")]
pub type Coordinate<T: CoordNum = f64> = Coord<T>;

impl<T: CoordNum> From<(T, T)> for Coordinate<T> {
impl<T: CoordNum> From<(T, T)> for Coord<T> {
#[inline]
fn from(coords: (T, T)) -> Self {
coord! {
Expand All @@ -43,7 +43,7 @@ impl<T: CoordNum> From<(T, T)> for Coordinate<T> {
}
}

impl<T: CoordNum> From<[T; 2]> for Coordinate<T> {
impl<T: CoordNum> From<[T; 2]> for Coord<T> {
#[inline]
fn from(coords: [T; 2]) -> Self {
coord! {
Expand All @@ -53,7 +53,7 @@ impl<T: CoordNum> From<[T; 2]> for Coordinate<T> {
}
}

impl<T: CoordNum> From<Point<T>> for Coordinate<T> {
impl<T: CoordNum> From<Point<T>> for Coord<T> {
#[inline]
fn from(point: Point<T>) -> Self {
coord! {
Expand All @@ -63,21 +63,21 @@ impl<T: CoordNum> From<Point<T>> for Coordinate<T> {
}
}

impl<T: CoordNum> From<Coordinate<T>> for (T, T) {
impl<T: CoordNum> From<Coord<T>> for (T, T) {
#[inline]
fn from(coord: Coordinate<T>) -> Self {
fn from(coord: Coord<T>) -> Self {
(coord.x, coord.y)
}
}

impl<T: CoordNum> From<Coordinate<T>> for [T; 2] {
impl<T: CoordNum> From<Coord<T>> for [T; 2] {
#[inline]
fn from(coord: Coordinate<T>) -> Self {
fn from(coord: Coord<T>) -> Self {
[coord.x, coord.y]
}
}

impl<T: CoordNum> Coordinate<T> {
impl<T: CoordNum> Coord<T> {
/// Returns a tuple that contains the x/horizontal & y/vertical component of the coordinate.
///
/// # Examples
Expand Down Expand Up @@ -115,7 +115,7 @@ use std::ops::{Add, Div, Mul, Neg, Sub};
/// assert_eq!(q.x, -p.x);
/// assert_eq!(q.y, -p.y);
/// ```
impl<T> Neg for Coordinate<T>
impl<T> Neg for Coord<T>
where
T: CoordNum + Neg<Output = T>,
{
Expand Down Expand Up @@ -144,7 +144,7 @@ where
/// assert_eq!(sum.x, 2.75);
/// assert_eq!(sum.y, 5.0);
/// ```
impl<T: CoordNum> Add for Coordinate<T> {
impl<T: CoordNum> Add for Coord<T> {
type Output = Self;

#[inline]
Expand All @@ -170,7 +170,7 @@ impl<T: CoordNum> Add for Coordinate<T> {
/// assert_eq!(diff.x, 0.25);
/// assert_eq!(diff.y, 0.);
/// ```
impl<T: CoordNum> Sub for Coordinate<T> {
impl<T: CoordNum> Sub for Coord<T> {
type Output = Self;

#[inline]
Expand All @@ -195,7 +195,7 @@ impl<T: CoordNum> Sub for Coordinate<T> {
/// assert_eq!(q.x, 5.0);
/// assert_eq!(q.y, 10.0);
/// ```
impl<T: CoordNum> Mul<T> for Coordinate<T> {
impl<T: CoordNum> Mul<T> for Coord<T> {
type Output = Self;

#[inline]
Expand All @@ -220,7 +220,7 @@ impl<T: CoordNum> Mul<T> for Coordinate<T> {
/// assert_eq!(q.x, 1.25);
/// assert_eq!(q.y, 2.5);
/// ```
impl<T: CoordNum> Div<T> for Coordinate<T> {
impl<T: CoordNum> Div<T> for Coord<T> {
type Output = Self;

#[inline]
Expand All @@ -246,7 +246,7 @@ use num_traits::Zero;
/// assert_eq!(p.x, 0.);
/// assert_eq!(p.y, 0.);
/// ```
impl<T: CoordNum> Coordinate<T> {
impl<T: CoordNum> Coord<T> {
#[inline]
pub fn zero() -> Self {
coord! {
Expand All @@ -256,7 +256,7 @@ impl<T: CoordNum> Coordinate<T> {
}
}

impl<T: CoordNum> Zero for Coordinate<T> {
impl<T: CoordNum> Zero for Coord<T> {
#[inline]
fn zero() -> Self {
Self::zero()
Expand All @@ -268,7 +268,7 @@ impl<T: CoordNum> Zero for Coordinate<T> {
}

#[cfg(any(feature = "approx", test))]
impl<T: CoordNum + AbsDiffEq> AbsDiffEq for Coordinate<T>
impl<T: CoordNum + AbsDiffEq> AbsDiffEq for Coord<T>
where
T::Epsilon: Copy,
{
Expand All @@ -286,7 +286,7 @@ where
}

#[cfg(any(feature = "approx", test))]
impl<T: CoordNum + RelativeEq> RelativeEq for Coordinate<T>
impl<T: CoordNum + RelativeEq> RelativeEq for Coord<T>
where
T::Epsilon: Copy,
{
Expand All @@ -303,7 +303,7 @@ where
}

#[cfg(any(feature = "approx", test))]
impl<T: CoordNum + UlpsEq> UlpsEq for Coordinate<T>
impl<T: CoordNum + UlpsEq> UlpsEq for Coord<T>
where
T::Epsilon: Copy,
{
Expand All @@ -320,7 +320,7 @@ where
}

#[cfg(feature = "rstar_0_8")]
impl<T> ::rstar_0_8::Point for Coordinate<T>
impl<T> ::rstar_0_8::Point for Coord<T>
where
T: ::num_traits::Float + ::rstar_0_8::RTreeNum,
{
Expand Down Expand Up @@ -356,7 +356,7 @@ where
}

#[cfg(feature = "rstar_0_9")]
impl<T> ::rstar_0_9::Point for Coordinate<T>
impl<T> ::rstar_0_9::Point for Coord<T>
where
T: ::num_traits::Float + ::rstar_0_9::RTreeNum,
{
Expand Down
10 changes: 5 additions & 5 deletions geo-types/src/geometry/line.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{CoordNum, Coordinate, Point};
use crate::{CoordNum, Coord, Point};
#[cfg(any(feature = "approx", test))]
use approx::{AbsDiffEq, RelativeEq};

Expand All @@ -12,8 +12,8 @@ use approx::{AbsDiffEq, RelativeEq};
#[derive(Eq, PartialEq, Clone, Copy, Debug, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Line<T: CoordNum = f64> {
pub start: Coordinate<T>,
pub end: Coordinate<T>,
pub start: Coord<T>,
pub end: Coord<T>,
}

impl<T: CoordNum> Line<T> {
Expand All @@ -31,7 +31,7 @@ impl<T: CoordNum> Line<T> {
/// ```
pub fn new<C>(start: C, end: C) -> Self
where
C: Into<Coordinate<T>>,
C: Into<Coord<T>>,
{
Self {
start: start.into(),
Expand All @@ -40,7 +40,7 @@ impl<T: CoordNum> Line<T> {
}

/// Calculate the difference in coordinates (Δx, Δy).
pub fn delta(&self) -> Coordinate<T> {
pub fn delta(&self) -> Coord<T> {
self.end - self.start
}

Expand Down
40 changes: 20 additions & 20 deletions geo-types/src/geometry/line_string.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#[cfg(any(feature = "approx", test))]
use approx::{AbsDiffEq, RelativeEq};

use crate::{CoordNum, Coordinate, Line, Point, Triangle};
use crate::{CoordNum, Coord, Line, Point, Triangle};
use std::iter::FromIterator;
use std::ops::{Index, IndexMut};

Expand Down Expand Up @@ -132,11 +132,11 @@ use std::ops::{Index, IndexMut};
#[derive(Eq, PartialEq, Clone, Debug, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct LineString<T: CoordNum = f64>(pub Vec<Coordinate<T>>);
pub struct LineString<T: CoordNum = f64>(pub Vec<Coord<T>>);

/// A [`Point`] iterator returned by the `points` method
#[derive(Debug)]
pub struct PointsIter<'a, T: CoordNum + 'a>(::std::slice::Iter<'a, Coordinate<T>>);
pub struct PointsIter<'a, T: CoordNum + 'a>(::std::slice::Iter<'a, Coord<T>>);

impl<'a, T: CoordNum> Iterator for PointsIter<'a, T> {
type Item = Point<T>;
Expand Down Expand Up @@ -164,10 +164,10 @@ impl<'a, T: CoordNum> DoubleEndedIterator for PointsIter<'a, T> {

/// A [`Coordinate`] iterator used by the `into_iter` method on a [`LineString`]
#[derive(Debug)]
pub struct CoordinatesIter<'a, T: CoordNum + 'a>(::std::slice::Iter<'a, Coordinate<T>>);
pub struct CoordinatesIter<'a, T: CoordNum + 'a>(::std::slice::Iter<'a, Coord<T>>);

impl<'a, T: CoordNum> Iterator for CoordinatesIter<'a, T> {
type Item = &'a Coordinate<T>;
type Item = &'a Coord<T>;

fn next(&mut self) -> Option<Self::Item> {
self.0.next()
Expand All @@ -192,7 +192,7 @@ impl<'a, T: CoordNum> DoubleEndedIterator for CoordinatesIter<'a, T> {

impl<T: CoordNum> LineString<T> {
/// Instantiate Self from the raw content value
pub fn new(value: Vec<Coordinate<T>>) -> Self {
pub fn new(value: Vec<Coord<T>>) -> Self {
Self(value)
}

Expand All @@ -208,12 +208,12 @@ impl<T: CoordNum> LineString<T> {
}

/// Return an iterator yielding the members of a [`LineString`] as [`Coordinate`]s
pub fn coords(&self) -> impl Iterator<Item = &Coordinate<T>> {
pub fn coords(&self) -> impl Iterator<Item = &Coord<T>> {
self.0.iter()
}

/// Return an iterator yielding the coordinates of a [`LineString`] as mutable [`Coordinate`]s
pub fn coords_mut(&mut self) -> impl Iterator<Item = &mut Coordinate<T>> {
pub fn coords_mut(&mut self) -> impl Iterator<Item = &mut Coord<T>> {
self.0.iter_mut()
}

Expand All @@ -223,7 +223,7 @@ impl<T: CoordNum> LineString<T> {
}

/// Return the coordinates of a [`LineString`] as a [`Vec`] of [`Coordinate`]s
pub fn into_inner(self) -> Vec<Coordinate<T>> {
pub fn into_inner(self) -> Vec<Coord<T>> {
self.0
}

Expand Down Expand Up @@ -336,7 +336,7 @@ impl<T: CoordNum> LineString<T> {
}

/// Turn a [`Vec`] of [`Point`]-like objects into a [`LineString`].
impl<T: CoordNum, IC: Into<Coordinate<T>>> From<Vec<IC>> for LineString<T> {
impl<T: CoordNum, IC: Into<Coord<T>>> From<Vec<IC>> for LineString<T> {
fn from(v: Vec<IC>) -> Self {
Self(v.into_iter().map(|c| c.into()).collect())
}
Expand All @@ -349,24 +349,24 @@ impl<T: CoordNum> From<Line<T>> for LineString<T> {
}

/// Turn an iterator of [`Point`]-like objects into a [`LineString`].
impl<T: CoordNum, IC: Into<Coordinate<T>>> FromIterator<IC> for LineString<T> {
impl<T: CoordNum, IC: Into<Coord<T>>> FromIterator<IC> for LineString<T> {
fn from_iter<I: IntoIterator<Item = IC>>(iter: I) -> Self {
Self(iter.into_iter().map(|c| c.into()).collect())
}
}

/// Iterate over all the [`Coordinate`]s in this [`LineString`].
impl<T: CoordNum> IntoIterator for LineString<T> {
type Item = Coordinate<T>;
type IntoIter = ::std::vec::IntoIter<Coordinate<T>>;
type Item = Coord<T>;
type IntoIter = ::std::vec::IntoIter<Coord<T>>;

fn into_iter(self) -> Self::IntoIter {
self.0.into_iter()
}
}

impl<'a, T: CoordNum> IntoIterator for &'a LineString<T> {
type Item = &'a Coordinate<T>;
type Item = &'a Coord<T>;
type IntoIter = CoordinatesIter<'a, T>;

fn into_iter(self) -> Self::IntoIter {
Expand All @@ -376,24 +376,24 @@ impl<'a, T: CoordNum> IntoIterator for &'a LineString<T> {

/// Mutably iterate over all the [`Coordinate`]s in this [`LineString`]
impl<'a, T: CoordNum> IntoIterator for &'a mut LineString<T> {
type Item = &'a mut Coordinate<T>;
type IntoIter = ::std::slice::IterMut<'a, Coordinate<T>>;
type Item = &'a mut Coord<T>;
type IntoIter = ::std::slice::IterMut<'a, Coord<T>>;

fn into_iter(self) -> ::std::slice::IterMut<'a, Coordinate<T>> {
fn into_iter(self) -> ::std::slice::IterMut<'a, Coord<T>> {
self.0.iter_mut()
}
}

impl<T: CoordNum> Index<usize> for LineString<T> {
type Output = Coordinate<T>;
type Output = Coord<T>;

fn index(&self, index: usize) -> &Coordinate<T> {
fn index(&self, index: usize) -> &Coord<T> {
self.0.index(index)
}
}

impl<T: CoordNum> IndexMut<usize> for LineString<T> {
fn index_mut(&mut self, index: usize) -> &mut Coordinate<T> {
fn index_mut(&mut self, index: usize) -> &mut Coord<T> {
self.0.index_mut(index)
}
}
Expand Down
2 changes: 1 addition & 1 deletion geo-types/src/geometry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub(crate) mod rect;
pub(crate) mod triangle;

// re-export all the geometry variants:
pub use coordinate::Coordinate;
pub use coordinate::{Coord, Coordinate};
pub use geometry_collection::GeometryCollection;
pub use line::Line;
pub use line_string::LineString;
Expand Down
8 changes: 4 additions & 4 deletions geo-types/src/geometry/point.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{point, CoordFloat, CoordNum, Coordinate};
use crate::{point, CoordFloat, CoordNum, Coord};

#[cfg(any(feature = "approx", test))]
use approx::{AbsDiffEq, RelativeEq};
Expand Down Expand Up @@ -28,10 +28,10 @@ use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssi
/// ```
#[derive(Eq, PartialEq, Clone, Copy, Debug, Hash, Default)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Point<T: CoordNum = f64>(pub Coordinate<T>);
pub struct Point<T: CoordNum = f64>(pub Coord<T>);

impl<T: CoordNum> From<Coordinate<T>> for Point<T> {
fn from(x: Coordinate<T>) -> Self {
impl<T: CoordNum> From<Coord<T>> for Point<T> {
fn from(x: Coord<T>) -> Self {
Point(x)
}
}
Expand Down
Loading

0 comments on commit 495c57d

Please sign in to comment.