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 EuclideanDistance #1232

Merged
merged 4 commits into from
Oct 25, 2024
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
18 changes: 12 additions & 6 deletions geo/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,31 @@
* Unify various line measurements under new `line_measures::{Bearing, Distance, Destination, InterpolatePoint}` traits
Before:
```
use geo::{GeodesicBearing, HaversineBearing, GeodesicDistance, HaversineDistance};
GeodesicBearing::geodesic_bearing(p1, p2)
HaversineBearing::haversine_bearing(p1, p2)
GeodesicDistance::geodesic_distance(p1, p2)
HaversineDistance::haversine_distance(p1, p2)
use geo::{GeodesicBearing, HaversineBearing, GeodesicDistance, HaversineDistance, EuclideanDistance};
p1.geodesic_bearing(p2)
p1.haversine_bearing(p2)
p1.geodesic_distance(p2)
p1.haversine_distance(p2)
p1.euclidean_distance(p2)
```

After:
```
use geo::{Geodesic, Haversine, Bearing, Distance};
use geo::{Geodesic, Haversine, Euclidean, Bearing, Distance};
Geodesic::bearing(p1, p2)
Haversine::bearing(p1, p2)
Geodesic::distance(p1, p2)
Haversine::distance(p1, p2)
Euclidean::distance(p1, p2)
```
* <https://github.com/georust/geo/pull/1216>
* Deprecated legacy line measure traits in favor of those added in the previous changelog entry:
* `GeodesicBearing`, `GeodesicDistance`, `GeodesicDestination`, `GeodesicIntermediate`
* `RhumbBearing`, `RhumbDistance`, `RhumbDestination`, `RhumbIntermediate`
* `HaversineBearing`, `HaversineDistance`, `HaversineDestination`, `HaversineIntermediate`
* `EuclideanDistance`
* <https://github.com/georust/geo/pull/1222>
* <https://github.com/georust/geo/pull/1232>
* Deprecated `HaversineLength`, `EuclideanLength`, `RhumbLength`, `GeodesicLength` in favor of new generic `Length` trait.
```
// Before
Expand Down Expand Up @@ -77,6 +81,8 @@
* <https://github.com/georust/geo/pull/1226>
* Enable i128 geometry types
* <https://github.com/georust/geo/pull/1230>


## 0.28.0

* BREAKING: The `HasKernel` trait was removed and it's functionality was merged
Expand Down
10 changes: 3 additions & 7 deletions geo/benches/euclidean_distance.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use criterion::{criterion_group, criterion_main};
use geo::algorithm::{ConvexHull, EuclideanDistance};
use geo::algorithm::{ConvexHull, Distance, Euclidean};
use geo::{polygon, Polygon};

fn criterion_benchmark(c: &mut criterion::Criterion) {
Expand Down Expand Up @@ -37,9 +37,7 @@ fn criterion_benchmark(c: &mut criterion::Criterion) {
(x: -6.064453, y: 68.49604),
];
bencher.iter(|| {
criterion::black_box(
criterion::black_box(&poly1).euclidean_distance(criterion::black_box(&poly2)),
);
criterion::black_box(Euclidean::distance(&poly1, &poly2));
});
});

Expand Down Expand Up @@ -81,9 +79,7 @@ fn criterion_benchmark(c: &mut criterion::Criterion) {
]
.convex_hull();
bencher.iter(|| {
criterion::black_box(
criterion::black_box(&poly1).euclidean_distance(criterion::black_box(&poly2)),
);
criterion::black_box(Euclidean::distance(&poly1, &poly2));
});
},
);
Expand Down
16 changes: 8 additions & 8 deletions geo/src/algorithm/concave_hull.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::convex_hull::qhull;
use crate::utils::partial_min;
use crate::{
coord, Centroid, Coord, CoordNum, Euclidean, EuclideanDistance, GeoFloat, Length, Line,
LineString, MultiLineString, MultiPoint, MultiPolygon, Point, Polygon,
coord, Centroid, Coord, CoordNum, Distance, Euclidean, GeoFloat, Length, Line, LineString,
MultiLineString, MultiPoint, MultiPolygon, Point, Polygon,
};
use rstar::{RTree, RTreeNum};
use std::collections::VecDeque;
Expand Down Expand Up @@ -134,8 +134,8 @@ where
let closest_point =
candidates.fold(Point::new(point.x, point.y), |acc_point, candidate| {
let candidate_point = Point::new(candidate.x, candidate.y);
if line.euclidean_distance(&acc_point)
> line.euclidean_distance(&candidate_point)
if Euclidean::distance(&line, &acc_point)
> Euclidean::distance(&line, &candidate_point)
{
candidate_point
} else {
Expand All @@ -154,8 +154,8 @@ where
let closest_edge_option = match peeked_edge {
None => None,
Some(&edge) => Some(edges_nearby_point.fold(*edge, |acc, candidate| {
if closest_point.euclidean_distance(&acc)
> closest_point.euclidean_distance(candidate)
if Euclidean::distance(&closest_point, &acc)
> Euclidean::distance(&closest_point, candidate)
{
*candidate
} else {
Expand All @@ -164,8 +164,8 @@ where
})),
};
let decision_distance = partial_min(
closest_point.euclidean_distance(&line.start_point()),
closest_point.euclidean_distance(&line.end_point()),
Euclidean::distance(&closest_point, &line.start_point()),
Euclidean::distance(&closest_point, &line.end_point()),
);
if let Some(closest_edge) = closest_edge_option {
let far_enough = edge_length / decision_distance > concavity;
Expand Down
Loading
Loading