From 188e21935b8338e81b09326442da2055c0f21433 Mon Sep 17 00:00:00 2001 From: sonora Date: Sat, 2 Jan 2016 14:26:49 +0100 Subject: [PATCH] fine tune "Near" criterion for reverese geocoding --- .../src/net/osmand/binary/GeocodingUtilities.java | 12 ++++++++++-- .../plus/mapcontextmenu/MenuTitleController.java | 9 ++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/OsmAnd-java/src/net/osmand/binary/GeocodingUtilities.java b/OsmAnd-java/src/net/osmand/binary/GeocodingUtilities.java index 4c23500c1f..900967acf3 100644 --- a/OsmAnd-java/src/net/osmand/binary/GeocodingUtilities.java +++ b/OsmAnd-java/src/net/osmand/binary/GeocodingUtilities.java @@ -1,4 +1,4 @@ -package net.osmand.binary; +package net.osmand.binary; import net.osmand.PlatformUtil; import net.osmand.ResultMatcher; @@ -124,7 +124,15 @@ public class GeocodingUtilities { } return dist; } - + + public double getDistanceP() { + if(point != null && searchPoint != null) { + return MapUtils.getDistance(point, searchPoint); + } else { + return -1; + } + } + @Override public String toString() { StringBuilder bld = new StringBuilder(); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuTitleController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuTitleController.java index 73ab9c1e42..af0a5dc553 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuTitleController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuTitleController.java @@ -164,6 +164,8 @@ public abstract class MenuTitleController { OsmandSettings settings = getMapActivity().getMyApplication().getSettings(); String lang = settings.MAP_PREFERRED_LOCALE.get(); String geocodingResult = ""; + double relevantDistance = -1; + if (object.building != null) { String bldName = object.building.getName(lang); if (!Algorithms.isEmpty(object.buildingInterpolation)) { @@ -173,6 +175,7 @@ public abstract class MenuTitleController { + object.city.getName(lang); } else if (object.street != null) { geocodingResult = object.street.getName(lang) + ", " + object.city.getName(lang); + relevantDistance = object.getDistanceP(); } else if (object.city != null) { geocodingResult = object.city.getName(lang); } else if (object.point != null) { @@ -189,11 +192,15 @@ public abstract class MenuTitleController { sname += ref; } geocodingResult = sname; + relevantDistance = object.getDistanceP(); } streetStr = geocodingResult; + if (relevantDistance == -1) { + relevantDistance = object.getDistance(); + } - if (!Algorithms.isEmpty(streetStr) && object.getDistance() > 100) { + if (!Algorithms.isEmpty(streetStr) && relevantDistance > 100) { streetStr = getMapActivity().getString(R.string.shared_string_near) + " " + streetStr; } else if (Algorithms.isEmpty(streetStr)) { streetStr = getMapActivity().getString(R.string.no_address_found);