Fix poi search (casing)
This commit is contained in:
parent
81348e0071
commit
5e0bfb0a46
2 changed files with 22 additions and 8 deletions
|
@ -1952,8 +1952,8 @@ public class BinaryMapIndexReader {
|
||||||
|
|
||||||
private static boolean testMapSearch = false;
|
private static boolean testMapSearch = false;
|
||||||
private static boolean testAddressSearch = false;
|
private static boolean testAddressSearch = false;
|
||||||
private static boolean testPoiSearch = false;
|
private static boolean testPoiSearch = true;
|
||||||
private static boolean testPoiSearchOnPath = true;
|
private static boolean testPoiSearchOnPath = false;
|
||||||
private static boolean testTransportSearch = false;
|
private static boolean testTransportSearch = false;
|
||||||
private static int sleft = MapUtils.get31TileNumberX(6.3);
|
private static int sleft = MapUtils.get31TileNumberX(6.3);
|
||||||
private static int sright = MapUtils.get31TileNumberX(6.5);
|
private static int sright = MapUtils.get31TileNumberX(6.5);
|
||||||
|
@ -1966,7 +1966,7 @@ public class BinaryMapIndexReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws IOException {
|
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);
|
BinaryMapIndexReader reader = new BinaryMapIndexReader(raf);
|
||||||
println("VERSION " + reader.getVersion()); //$NON-NLS-1$
|
println("VERSION " + reader.getVersion()); //$NON-NLS-1$
|
||||||
|
@ -2109,11 +2109,12 @@ public class BinaryMapIndexReader {
|
||||||
|
|
||||||
private static void testPoiSearchByName(BinaryMapIndexReader reader) throws IOException {
|
private static void testPoiSearchByName(BinaryMapIndexReader reader) throws IOException {
|
||||||
println("Searching by name...");
|
println("Searching by name...");
|
||||||
SearchRequest<Amenity> req = buildSearchPoiRequest(0, 0, "roch",
|
SearchRequest<Amenity> req = buildSearchPoiRequest(0, 0, "КАлг",
|
||||||
0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE, null);
|
0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE, null);
|
||||||
reader.searchPoiByName(req);
|
reader.searchPoiByName(req);
|
||||||
for (Amenity a : req.getSearchResults()) {
|
for (Amenity a : req.getSearchResults()) {
|
||||||
println(a.getType() + " " + a.getSubType() + " " + a.getName() + " " + a.getLocation());
|
println(a.getType().getTranslation() +
|
||||||
|
" " + a.getSubType() + " " + a.getName() + " " + a.getLocation());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,10 @@ import java.io.InputStreamReader;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
import net.osmand.Collator;
|
import net.osmand.Collator;
|
||||||
|
@ -276,7 +278,8 @@ public class BinaryMapPoiReaderAdapter {
|
||||||
|
|
||||||
protected void searchPoiByName( PoiRegion region, SearchRequest<Amenity> req) throws IOException {
|
protected void searchPoiByName( PoiRegion region, SearchRequest<Amenity> req) throws IOException {
|
||||||
TIntLongHashMap offsets = new TIntLongHashMap();
|
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);
|
StringMatcherMode.CHECK_STARTS_FROM_SPACE);
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
int indexOffset = codedIS.getTotalBytesRead();
|
int indexOffset = codedIS.getTotalBytesRead();
|
||||||
|
@ -293,7 +296,7 @@ public class BinaryMapPoiReaderAdapter {
|
||||||
int length = readInt();
|
int length = readInt();
|
||||||
int oldLimit = codedIS.pushLimit(length);
|
int oldLimit = codedIS.pushLimit(length);
|
||||||
// here offsets are sorted by distance
|
// here offsets are sorted by distance
|
||||||
offsets = readPoiNameIndex(matcher.getCollator(), req.nameQuery, req);
|
offsets = readPoiNameIndex(matcher.getCollator(), query, req);
|
||||||
codedIS.popLimit(oldLimit);
|
codedIS.popLimit(oldLimit);
|
||||||
break;
|
break;
|
||||||
case OsmandOdb.OsmAndPoiIndex.POIDATA_FIELD_NUMBER :
|
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);
|
Amenity am = readPoiPoint(0, Integer.MAX_VALUE, 0, Integer.MAX_VALUE, x, y, zoom, req, region, false);
|
||||||
codedIS.popLimit(oldLim);
|
codedIS.popLimit(oldLim);
|
||||||
if (am != null) {
|
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<Entry<String, String>> it = am.getAdditionalInfo().entrySet().iterator();
|
||||||
|
while (!matches && it.hasNext()) {
|
||||||
|
Entry<String, String> n = it.next();
|
||||||
|
if (n.getKey().startsWith("name:")) {
|
||||||
|
matches = matcher.matches(n.getValue().toLowerCase());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(matches) {
|
||||||
req.publish(am);
|
req.publish(am);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue