From bc9b92956ffe444b9cac95bf26238e0d53765afe Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sat, 30 Jul 2016 00:55:50 +0200 Subject: [PATCH] Fix ui search route --- .../src/net/osmand/search/SearchUICore.java | 41 ++++++++----------- 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/OsmAnd-java/src/net/osmand/search/SearchUICore.java b/OsmAnd-java/src/net/osmand/search/SearchUICore.java index 1f1d6543c0..b1cb7152b9 100644 --- a/OsmAnd-java/src/net/osmand/search/SearchUICore.java +++ b/OsmAnd-java/src/net/osmand/search/SearchUICore.java @@ -251,33 +251,26 @@ public class SearchUICore { } if (r1.localeName.equals(r2.localeName)) { double similarityRadius = 30; - if(a1 != null && a2 != null) { - if(a1.getType().getKeyName().equals("natural") && - a2.getType().getKeyName().equals("natural")) { - similarityRadius = 10000; + if (a1 != null && a2 != null) { + // here 2 points are amenity + String type1 = a1.getType().getKeyName(); + String type2 = a2.getType().getKeyName(); + String subType1 = a1.getSubType(); + String subType2 = a2.getSubType(); + if (!type1.equals(type2)) { + return false; } - } - if(ObjectType.isAddress(r1.objectType) && ObjectType.isAddress(r2.objectType)) { + if (type1.equals("natural")) { + similarityRadius = 10000; + } else if (subType1.equals(subType2)) { + if (subType1.contains("cn_ref") || subType1.contains("wn_ref") + || (subType1.startsWith("route_hiking_") && subType1.endsWith("n_poi"))) { + similarityRadius = 10000; + } + } + } else if(ObjectType.isAddress(r1.objectType) && ObjectType.isAddress(r2.objectType)) { similarityRadius = 100; } - if (a1.getSubType().contains("cn_ref") && a2.getSubType().contains("cn_ref") && a1.getType().getKeyName().equals(a2.getType().getKeyName())) { - similarityRadius = 10000; - } - if (a1.getSubType().contains("wn_ref") && a2.getSubType().contains("wn_ref") && a1.getType().getKeyName().equals(a2.getType().getKeyName())) { - similarityRadius = 10000; - } - if (a1.getSubType().equals("route_hiking_iwn_poi") && a2.getSubType().equals("route_hiking_iwn_poi") && a1.getType().getKeyName().equals(a2.getType().getKeyName())) { - similarityRadius = 10000; - } - if (a1.getSubType().equals("route_hiking_nwn_poi") && a2.getSubType().equals("route_hiking_nwn_poi") && a1.getType().getKeyName().equals(a2.getType().getKeyName())) { - similarityRadius = 10000; - } - if (a1.getSubType().equals("route_hiking_rwn_poi") && a2.getSubType().equals("route_hiking_rwn_poi") && a1.getType().getKeyName().equals(a2.getType().getKeyName())) { - similarityRadius = 10000; - } - if (a1.getSubType().equals("route_hiking_lwn_poi") && a2.getSubType().equals("route_hiking_lwn_poi") && a1.getType().getKeyName().equals(a2.getType().getKeyName())) { - similarityRadius = 10000; - } return MapUtils.getDistance(r1.location, r2.location) < similarityRadius; } }