diff --git a/OsmAnd-java/src/net/osmand/binary/BinaryMapIndexReader.java b/OsmAnd-java/src/net/osmand/binary/BinaryMapIndexReader.java index beb84615d0..5ace190cd5 100644 --- a/OsmAnd-java/src/net/osmand/binary/BinaryMapIndexReader.java +++ b/OsmAnd-java/src/net/osmand/binary/BinaryMapIndexReader.java @@ -1952,8 +1952,8 @@ public class BinaryMapIndexReader { private static boolean testMapSearch = false; private static boolean testAddressSearch = false; - private static boolean testPoiSearch = false; - private static boolean testPoiSearchOnPath = true; + private static boolean testPoiSearch = true; + private static boolean testPoiSearchOnPath = false; private static boolean testTransportSearch = false; private static int sleft = MapUtils.get31TileNumberX(6.3); private static int sright = MapUtils.get31TileNumberX(6.5); @@ -1966,7 +1966,7 @@ public class BinaryMapIndexReader { } public static void main(String[] args) throws IOException { - RandomAccessFile raf = new RandomAccessFile("/Users/victorshcherb/osmand/maps/Netherlands_europe_2.obf", "r"); + RandomAccessFile raf = new RandomAccessFile("/Users/victorshcherb/osmand/maps/Canada_alberta_northamerica_wiki.obf", "r"); BinaryMapIndexReader reader = new BinaryMapIndexReader(raf); println("VERSION " + reader.getVersion()); //$NON-NLS-1$ @@ -2109,11 +2109,12 @@ public class BinaryMapIndexReader { private static void testPoiSearchByName(BinaryMapIndexReader reader) throws IOException { println("Searching by name..."); - SearchRequest req = buildSearchPoiRequest(0, 0, "roch", + SearchRequest req = buildSearchPoiRequest(0, 0, "КАлг", 0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE, null); reader.searchPoiByName(req); for (Amenity a : req.getSearchResults()) { - println(a.getType() + " " + a.getSubType() + " " + a.getName() + " " + a.getLocation()); + println(a.getType().getTranslation() + + " " + a.getSubType() + " " + a.getName() + " " + a.getLocation()); } } diff --git a/OsmAnd-java/src/net/osmand/binary/BinaryMapPoiReaderAdapter.java b/OsmAnd-java/src/net/osmand/binary/BinaryMapPoiReaderAdapter.java index a27a060af9..ff19583c89 100644 --- a/OsmAnd-java/src/net/osmand/binary/BinaryMapPoiReaderAdapter.java +++ b/OsmAnd-java/src/net/osmand/binary/BinaryMapPoiReaderAdapter.java @@ -12,8 +12,10 @@ import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; +import java.util.Iterator; import java.util.LinkedList; import java.util.List; +import java.util.Map.Entry; import java.util.zip.GZIPInputStream; import net.osmand.Collator; @@ -276,7 +278,8 @@ public class BinaryMapPoiReaderAdapter { protected void searchPoiByName( PoiRegion region, SearchRequest req) throws IOException { TIntLongHashMap offsets = new TIntLongHashMap(); - CollatorStringMatcher matcher = new CollatorStringMatcher(req.nameQuery, + String query = req.nameQuery.toLowerCase(); + CollatorStringMatcher matcher = new CollatorStringMatcher(query, StringMatcherMode.CHECK_STARTS_FROM_SPACE); long time = System.currentTimeMillis(); int indexOffset = codedIS.getTotalBytesRead(); @@ -293,7 +296,7 @@ public class BinaryMapPoiReaderAdapter { int length = readInt(); int oldLimit = codedIS.pushLimit(length); // here offsets are sorted by distance - offsets = readPoiNameIndex(matcher.getCollator(), req.nameQuery, req); + offsets = readPoiNameIndex(matcher.getCollator(), query, req); codedIS.popLimit(oldLimit); break; case OsmandOdb.OsmAndPoiIndex.POIDATA_FIELD_NUMBER : @@ -545,7 +548,17 @@ public class BinaryMapPoiReaderAdapter { Amenity am = readPoiPoint(0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE, x, y, zoom, req, region, false); codedIS.popLimit(oldLim); if (am != null) { - if(matcher.matches(am.getName(false)) || matcher.matches(am.getName(true))) { + boolean matches = matcher.matches(am.getName(false).toLowerCase()) || matcher.matches(am.getName(true).toLowerCase()); + if (!matches) { + Iterator> it = am.getAdditionalInfo().entrySet().iterator(); + while (!matches && it.hasNext()) { + Entry n = it.next(); + if (n.getKey().startsWith("name:")) { + matches = matcher.matches(n.getValue().toLowerCase()); + } + } + } + if(matches) { req.publish(am); } }