mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-27 22:37:15 +00:00
reduced QuadTree contract as far as possible
Change-Id: I06c64d0a0f4ef13db50d3cb3098605871f8ae457
This commit is contained in:
1 parent
80a14625b3
commit
2350f62344
2 files changed
+4
-10
No files matched your search
@@ -1237,19 +1237,13 @@ public class QuadTreeTest {
|
||||
assertSame(getNearestByApproximateDistance(p3), p3Nearest);
|
||||
}
|
||||
|
||||
private double approximateDistance(Position p1, Position p2) {
|
||||
double dLat = p2.getLatDeg() - p1.getLatDeg();
|
||||
double dLon = p2.getLngDeg() - p1.getLngDeg();
|
||||
return Math.sqrt(dLat*dLat + dLon*dLon);
|
||||
}
|
||||
|
||||
private Position getNearestByApproximateDistance(Position pos) {
|
||||
double minDistance = Double.MAX_VALUE;
|
||||
Position nearestByDistance = null;
|
||||
for (final Position p : quadtree.get(new BoundsImpl(new DegreePosition(-90, -180), new DegreePosition(90, 180)))) { // get all
|
||||
if (approximateDistance(p, pos) < minDistance) {
|
||||
if (QuadTree.getLatLngDistance(p, pos) < minDistance) {
|
||||
nearestByDistance = p;
|
||||
minDistance = approximateDistance(p, pos);
|
||||
minDistance = QuadTree.getLatLngDistance(p, pos);
|
||||
}
|
||||
}
|
||||
return nearestByDistance;
|
||||
|
||||
Reference in new issue
Block a user