Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate Point::{lat,lng} and friends #711

Merged
merged 3 commits into from
Jan 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions geo-types/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

## Unreleased

* DEPRECATION: Deprecate `Point::lng`, `Point::lat`, `Point::set_lng` and `Point::set_lat`
* <https://github.com/georust/geo/pull/711>
* Support `rstar` version `0.9` in feature `use-rstar_0_9`
* <https://github.com/georust/geo/pull/682>
* `Geometry` and `GeometryCollection` now support serde.
* <https://github.com/georust/geo/pull/704>

* add `Coordinate` iterators to LineString, regularise its iterator methods, and refactor its docs
* https://github.com/georust/geo/pull/705
* Add `Coordinate` iterators to LineString, regularise its iterator methods, and refactor its docs
* <https://github.com/georust/geo/pull/705>

## 0.7.2

Expand Down
12 changes: 8 additions & 4 deletions geo-types/src/point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,9 @@ where
///
/// let p = Point::new(1.234, 2.345);
///
/// assert_eq!(p.lng(), 1.234);
/// assert_eq!(p.x(), 1.234);
/// ```
#[deprecated = "use `Point::x` instead, it's less ambigous"]
pub fn lng(self) -> T {
self.x()
}
Expand All @@ -187,8 +188,9 @@ where
/// let mut p = Point::new(1.234, 2.345);
/// p.set_lng(9.876);
///
/// assert_eq!(p.lng(), 9.876);
/// assert_eq!(p.x(), 9.876);
/// ```
#[deprecated = "use `Point::set_x` instead, it's less ambigous"]
pub fn set_lng(&mut self, lng: T) -> &mut Point<T> {
self.set_x(lng)
}
Expand All @@ -202,8 +204,9 @@ where
///
/// let p = Point::new(1.234, 2.345);
///
/// assert_eq!(p.lat(), 2.345);
/// assert_eq!(p.y(), 2.345);
/// ```
#[deprecated = "use `Point::y` instead, it's less ambigous"]
pub fn lat(self) -> T {
self.y()
}
Expand All @@ -217,8 +220,9 @@ where
/// let mut p = Point::new(1.234, 2.345);
/// p.set_lat(9.876);
///
/// assert_eq!(p.lat(), 9.876);
/// assert_eq!(p.y(), 9.876);
/// ```
#[deprecated = "use `Point::set_y` instead, it's less ambigous"]
pub fn set_lat(&mut self, lat: T) -> &mut Point<T> {
self.set_y(lat)
}
Expand Down
2 changes: 1 addition & 1 deletion geo/src/algorithm/geodesic_distance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ pub trait GeodesicDistance<T, Rhs = Self> {

impl GeodesicDistance<f64> for Point<f64> {
fn geodesic_distance(&self, rhs: &Point<f64>) -> f64 {
Geodesic::wgs84().inverse(self.lat(), self.lng(), rhs.lat(), rhs.lng())
Geodesic::wgs84().inverse(self.y(), self.x(), rhs.y(), rhs.x())
}
}
9 changes: 4 additions & 5 deletions geo/src/algorithm/geodesic_intermediate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ impl GeodesicIntermediate<f64> for Point<f64> {
fn geodesic_intermediate(&self, other: &Point<f64>, f: f64) -> Point<f64> {
let g = Geodesic::wgs84();
let (total_distance, azi1, _azi2, _a12) =
g.inverse(self.lat(), self.lng(), other.lat(), other.lng());
g.inverse(self.y(), self.x(), other.y(), other.x());
let distance = total_distance * f;
let (lat2, lon2) = g.direct(self.lat(), self.lng(), azi1, distance);
let (lat2, lon2) = g.direct(self.y(), self.x(), azi1, distance);

Point::new(lon2, lat2)
}
Expand All @@ -55,7 +55,7 @@ impl GeodesicIntermediate<f64> for Point<f64> {
) -> Vec<Point<f64>> {
let g = Geodesic::wgs84();
let (total_distance, azi1, _azi2, _a12) =
g.inverse(self.lat(), self.lng(), other.lat(), other.lng());
g.inverse(self.y(), self.x(), other.y(), other.x());

if total_distance <= max_dist {
if include_ends {
Expand All @@ -72,8 +72,7 @@ impl GeodesicIntermediate<f64> for Point<f64> {
let mut points = if include_ends { vec![*self] } else { vec![] };

while current_step < 1.0 {
let (lat2, lon2) =
g.direct(self.lat(), self.lng(), azi1, total_distance * current_step);
let (lat2, lon2) = g.direct(self.y(), self.x(), azi1, total_distance * current_step);
let point = Point::new(lon2, lat2);
points.push(point);
current_step += interval;
Expand Down
6 changes: 3 additions & 3 deletions geo/src/algorithm/vincenty_distance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ where
let b = T::from(POLAR_EARTH_RADIUS).unwrap();
let f = T::from(EARTH_FLATTENING).unwrap();
// Difference in longitude
let L = (rhs.lng() - self.lng()).to_radians();
let L = (rhs.x() - self.x()).to_radians();
// Reduced latitude (latitude on the auxiliary sphere)
let U1 = ((t_1 - f) * self.lat().to_radians().tan()).atan();
let U1 = ((t_1 - f) * self.y().to_radians().tan()).atan();
// Reduced latitude (latitude on the auxiliary sphere)
let U2 = ((t_1 - f) * rhs.lat().to_radians().tan()).atan();
let U2 = ((t_1 - f) * rhs.y().to_radians().tan()).atan();
let (sinU1, cosU1) = U1.sin_cos();
let (sinU2, cosU2) = U2.sin_cos();
let mut cosSqAlpha;
Expand Down