Skip to content

Commit 7e3a98b

Browse files
committed
Minor rename
1 parent ff85f03 commit 7e3a98b

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

core/src/main/java/com/graphhopper/storage/index/LocationIndexTree.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,7 @@ public class LocationIndexTree implements LocationIndex {
7777
private double deltaLon;
7878
private int initSizeLeafEntries = 4;
7979
private boolean initialized = false;
80-
private static final Comparator<Snap> Snap_COMPARATOR = new Comparator<Snap>() {
81-
@Override
82-
public int compare(Snap o1, Snap o2) {
83-
return Double.compare(o1.getQueryDistance(), o2.getQueryDistance());
84-
}
85-
};
80+
private static final Comparator<Snap> SNAP_COMPARATOR = Comparator.comparingDouble(Snap::getQueryDistance);
8681
/**
8782
* If normed distance is smaller than this value the node or edge is 'identical' and the
8883
* algorithm can stop search.
@@ -734,7 +729,7 @@ protected boolean check(int node, double normedDist, int wayIndex, EdgeIteratorS
734729
}
735730

736731
// TODO: pass boolean argument for whether or not to sort? Can be expensive if not required.
737-
Collections.sort(snaps, Snap_COMPARATOR);
732+
Collections.sort(snaps, SNAP_COMPARATOR);
738733

739734
for (Snap snap : snaps) {
740735
if (snap.isValid()) {

core/src/test/java/com/graphhopper/routing/RandomizedRoutingTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ public void randomGraph_withQueryGraph() {
244244
List<String> strictViolations = new ArrayList<>();
245245
for (int i = 0; i < numQueries; i++) {
246246
List<GHPoint> points = getRandomPoints(graph.getBounds(), 2, index, rnd);
247-
List<Snap> snaps = findSnap(index, points);
247+
List<Snap> snaps = findSnaps(index, points);
248248
QueryGraph queryGraph = QueryGraph.create(graph, snaps);
249249

250250
int source = snaps.get(0).getClosestNode();
@@ -279,7 +279,7 @@ static List<GHPoint> getRandomPoints(BBox bounds, int numPoints, LocationIndex i
279279
return points;
280280
}
281281

282-
private List<Snap> findSnap(LocationIndexTree index, List<GHPoint> ghPoints) {
282+
private List<Snap> findSnaps(LocationIndexTree index, List<GHPoint> ghPoints) {
283283
List<Snap> result = new ArrayList<>(ghPoints.size());
284284
for (GHPoint ghPoint : ghPoints) {
285285
result.add(index.findClosest(ghPoint.getLat(), ghPoint.getLon(), DefaultEdgeFilter.ALL_EDGES));

0 commit comments

Comments
 (0)