diff --git a/OsmAnd-java/src/net/osmand/search/SearchUICore.java b/OsmAnd-java/src/net/osmand/search/SearchUICore.java index b108e0f1bb..3507f78019 100644 --- a/OsmAnd-java/src/net/osmand/search/SearchUICore.java +++ b/OsmAnd-java/src/net/osmand/search/SearchUICore.java @@ -294,7 +294,13 @@ public class SearchUICore { if(st1 != st2) { return Algorithms.compare(st1, st2); } - return collator.compare(o1.localeName, o2.localeName); + cmp = collator.compare(o1.localeName, o2.localeName); + if(cmp != 0) { + return cmp; + } + s1 = o1.getSearchDistance(loc, 1); + s2 = o2.getSearchDistance(loc, 1); + return Double.compare(s1, s2); } }); } diff --git a/OsmAnd-java/src/net/osmand/search/core/SearchResult.java b/OsmAnd-java/src/net/osmand/search/core/SearchResult.java index 58e82b1372..07378cb324 100644 --- a/OsmAnd-java/src/net/osmand/search/core/SearchResult.java +++ b/OsmAnd-java/src/net/osmand/search/core/SearchResult.java @@ -42,6 +42,14 @@ public class SearchResult { return priority - 1 / (1 + priorityDistance * distance); } + public double getSearchDistance(LatLon location, double pd) { + double distance = 0; + if (location != null && this.location != null) { + distance = MapUtils.getDistance(location, this.location); + } + return priority - 1 / (1 + pd * distance); + } + public LatLon location; public int preferredZoom = 15; public String localeName;