diff --git a/OsmAnd-java/src/net/osmand/binary/GeocodingUtilities.java b/OsmAnd-java/src/net/osmand/binary/GeocodingUtilities.java index f2edb35451..b2663be432 100644 --- a/OsmAnd-java/src/net/osmand/binary/GeocodingUtilities.java +++ b/OsmAnd-java/src/net/osmand/binary/GeocodingUtilities.java @@ -35,6 +35,13 @@ import org.apache.commons.logging.Log; public class GeocodingUtilities { private static final Log log = PlatformUtil.getLog(GeocodingUtilities.class); + + public static final float THRESHOLD_MULTIPLIER_SKIP_BUILDINGS_AFTER = 1.5f; + public static final float THRESHOLD_MULTIPLIER_SKIP_STREETS_AFTER = 4; + public static final float DISTANCE_STREET_NAME_PROXIMITY_BY_NAME = 15000; + public static final float DISTANCE_BULDING_PROXIMITY = 100; + public static final float DISTANCE_STREET_FROM_CLOSEST = 1000; + public static final String[] SUFFIXES = new String[] {"av.", "avenue", "просп.", "пер.", "пр.","заул.", "проспект", "переул.", "бул.", "бульвар", "тракт"}; public static final String[] DEFAULT_SUFFIXES = new String[] {"str.", "street", "улица", "ул."}; private static Set SET_DEF_SUFFIXES = null; @@ -56,10 +63,6 @@ public class GeocodingUtilities { return SET_SUFFIXES; } - public static final float THRESHOLD_MULTIPLIER_SKIP_BUILDINGS_AFTER = 1.5f; - public static final float THRESHOLD_MULTIPLIER_SKIP_STREETS_AFTER = 3; - public static final float DISTANCE_STREET_NAME_PROXIMITY_BY_NAME = 15000; - public static final float DISTANCE_BULDING_PROXIMITY = 100; public static final Comparator DISTANCE_COMPARATOR = new Comparator() { @Override @@ -137,6 +140,8 @@ public class GeocodingUtilities { return bld.toString(); } } + + public List reverseGeocodingSearch(RoutingContext ctx, double lat, double lon) throws IOException { RoutePlannerFrontEnd rp = new RoutePlannerFrontEnd(false); @@ -268,7 +273,7 @@ public class GeocodingUtilities { for (GeocodingResult street : streetsList) { if(streetDistance == 0) { streetDistance = street.getDistance(); - } else if(street.getDistance() > streetDistance + 1000) { + } else if(street.getDistance() > streetDistance + DISTANCE_STREET_FROM_CLOSEST) { continue; } street.connectionPoint = road.connectionPoint; diff --git a/OsmAnd/src/net/osmand/plus/CurrentPositionHelper.java b/OsmAnd/src/net/osmand/plus/CurrentPositionHelper.java index 9c86875e38..cc21ededa8 100644 --- a/OsmAnd/src/net/osmand/plus/CurrentPositionHelper.java +++ b/OsmAnd/src/net/osmand/plus/CurrentPositionHelper.java @@ -87,11 +87,15 @@ public class CurrentPositionHelper { } protected void justifyResult(List res, final ResultMatcher result) { - double minBuildingDistance = 0; List complete = new ArrayList(); + double minBuildingDistance = 0; + double minStreetDistance = 0; for (GeocodingResult r : res) { - if (minBuildingDistance > 0 - && r.getDistance() > GeocodingUtilities.THRESHOLD_MULTIPLIER_SKIP_STREETS_AFTER * minBuildingDistance) { + double streetDistance = r.getDistance(); + if(minStreetDistance == 0) { + minStreetDistance = streetDistance; + } else if(streetDistance > GeocodingUtilities.THRESHOLD_MULTIPLIER_SKIP_STREETS_AFTER * minStreetDistance || + streetDistance > minStreetDistance + GeocodingUtilities.DISTANCE_STREET_FROM_CLOSEST) { break; } Collection rar = app.getResourceManager().getAddressRepositories();