From ed7fe94f1da3b333a1ffff4f9238bab7484a81ca Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 15 Apr 2016 10:15:56 +1200 Subject: Fix check style code issues --- src/org/traccar/helper/LocationTree.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/org/traccar/helper') diff --git a/src/org/traccar/helper/LocationTree.java b/src/org/traccar/helper/LocationTree.java index 1d7d8ab25..90e5fe8c2 100644 --- a/src/org/traccar/helper/LocationTree.java +++ b/src/org/traccar/helper/LocationTree.java @@ -95,16 +95,27 @@ public class LocationTree { private Item findNearest(Item current, Item search, int depth) { int direction = comparators.get(depth % 2).compare(search, current); - Item next = (direction < 0) ? current.left : current.right; - Item other = (direction < 0) ? current.right : current.left; - Item best = (next == null) ? current : findNearest(next, search, depth + 1); + Item next, other; + if (direction < 0) { + next = current.left; + other = current.right; + } else { + next = current.right; + other = current.left; + } + + Item best = current; + if (next != null) { + findNearest(next, search, depth + 1); + } + if (current.squaredDistance(search) < best.squaredDistance(search)) { best = current; } if (other != null) { if (current.axisSquaredDistance(search, depth % 2) < best.squaredDistance(search)) { Item possibleBest = findNearest(other, search, depth + 1); - if (possibleBest.squaredDistance(search) < best.squaredDistance(search) ) { + if (possibleBest.squaredDistance(search) < best.squaredDistance(search)) { best = possibleBest; } } -- cgit v1.2.3