Fix OLC search

This commit is contained in:
crimean 2019-04-04 13:45:48 +03:00
parent 1997408377
commit 32b80eeb3b
2 changed files with 5 additions and 1 deletions

View file

@ -11,6 +11,7 @@ import net.osmand.data.LatLon;
import net.osmand.data.QuadRect;
import net.osmand.osm.AbstractPoiType;
import net.osmand.util.Algorithms;
import net.osmand.util.LocationParser;
import net.osmand.util.MapUtils;
import java.util.ArrayList;
@ -782,7 +783,7 @@ public class SearchPhrase {
searchWords.add(0, getUnknownSearchWord());
Collections.sort(searchWords, commonWordsComparator);
for (String s : searchWords) {
if (s.length() > 0 && !Character.isDigit(s.charAt(0))) {
if (s.length() > 0 && !Character.isDigit(s.charAt(0)) && !LocationParser.isValidOLC(s)) {
return s;
}
}

View file

@ -82,6 +82,9 @@ public class LocationParser {
}
}
public static boolean isValidOLC(String code) {
return OpenLocationCode.isValidCode(code);
}
public static ParsedOpenLocationCode parseOpenLocationCode(String locPhrase) {
ParsedOpenLocationCode parsedCode = new ParsedOpenLocationCode(locPhrase.trim());
return !parsedCode.isValidCode() ? null : parsedCode;