Merge pull request #9646 from androiddevkotlin/street_complete_parsing

Fix #9532
This commit is contained in:
vshcherb 2020-08-21 10:29:35 +02:00 committed by GitHub
commit 133e8a25ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 54 additions and 54 deletions

View file

@ -133,19 +133,19 @@ public class SearchCoreFactory {
public int getMinimalSearchRadius(SearchPhrase phrase) { public int getMinimalSearchRadius(SearchPhrase phrase) {
return 0; return 0;
} }
@Override @Override
public int getNextSearchRadius(SearchPhrase phrase) { public int getNextSearchRadius(SearchPhrase phrase) {
return 0; return 0;
} }
protected void subSearchApiOrPublish(SearchPhrase phrase, SearchResultMatcher resultMatcher, SearchResult res, SearchBaseAPI api) protected void subSearchApiOrPublish(SearchPhrase phrase, SearchResultMatcher resultMatcher, SearchResult res, SearchBaseAPI api)
throws IOException { throws IOException {
subSearchApiOrPublish(phrase, resultMatcher, res, api, true); subSearchApiOrPublish(phrase, resultMatcher, res, api, true);
} }
protected void subSearchApiOrPublish(SearchPhrase phrase, SearchResultMatcher resultMatcher, SearchResult res, SearchBaseAPI api, protected void subSearchApiOrPublish(SearchPhrase phrase, SearchResultMatcher resultMatcher, SearchResult res, SearchBaseAPI api,
boolean publish) boolean publish)
throws IOException { throws IOException {
phrase.countUnknownWordsMatchMainResult(res); phrase.countUnknownWordsMatchMainResult(res);
boolean firstUnknownWordMatches = res.firstUnknownWordMatches; boolean firstUnknownWordMatches = res.firstUnknownWordMatches;
@ -154,7 +154,7 @@ public class SearchCoreFactory {
leftUnknownSearchWords.removeAll(res.otherWordsMatch); leftUnknownSearchWords.removeAll(res.otherWordsMatch);
} }
SearchResult newParentSearchResult = null; SearchResult newParentSearchResult = null;
if (res.parentSearchResult == null && resultMatcher.getParentSearchResult() == null && if (res.parentSearchResult == null && resultMatcher.getParentSearchResult() == null &&
res.objectType == ObjectType.STREET && res.object instanceof Street && ((Street) res.object).getCity() != null) { res.objectType == ObjectType.STREET && res.object instanceof Street && ((Street) res.object).getCity() != null) {
City ct = ((Street) res.object).getCity(); City ct = ((Street) res.object).getCity();
SearchResult cityResult = new SearchResult(phrase); SearchResult cityResult = new SearchResult(phrase);
@ -204,15 +204,15 @@ public class SearchCoreFactory {
} }
} }
if (!leftUnknownSearchWords.isEmpty() && api != null && api.isSearchAvailable(phrase)) { if (!leftUnknownSearchWords.isEmpty() && api != null && api.isSearchAvailable(phrase)) {
SearchPhrase nphrase = phrase.selectWord(res, leftUnknownSearchWords, SearchPhrase nphrase = phrase.selectWord(res, leftUnknownSearchWords,
phrase.isLastUnknownSearchWordComplete() || phrase.isLastUnknownSearchWordComplete() ||
!leftUnknownSearchWords.contains(phrase.getLastUnknownSearchWord())); !leftUnknownSearchWords.contains(phrase.getLastUnknownSearchWord()));
SearchResult prev = resultMatcher.setParentSearchResult(publish ? res : SearchResult prev = resultMatcher.setParentSearchResult(publish ? res :
resultMatcher.getParentSearchResult()); resultMatcher.getParentSearchResult());
api.search(nphrase, resultMatcher); api.search(nphrase, resultMatcher);
resultMatcher.setParentSearchResult(prev); resultMatcher.setParentSearchResult(prev);
} }
} }
@Override @Override
@ -307,7 +307,7 @@ public class SearchCoreFactory {
public int getMinimalSearchRadius(SearchPhrase phrase) { public int getMinimalSearchRadius(SearchPhrase phrase) {
return phrase.getRadiusSearch(DEFAULT_ADDRESS_BBOX_RADIUS); return phrase.getRadiusSearch(DEFAULT_ADDRESS_BBOX_RADIUS);
} }
@Override @Override
public int getNextSearchRadius(SearchPhrase phrase) { public int getNextSearchRadius(SearchPhrase phrase) {
return phrase.getNextRadiusSearch(DEFAULT_ADDRESS_BBOX_RADIUS); return phrase.getNextRadiusSearch(DEFAULT_ADDRESS_BBOX_RADIUS);
@ -383,7 +383,7 @@ public class SearchCoreFactory {
private void searchByName(final SearchPhrase phrase, final SearchResultMatcher resultMatcher) private void searchByName(final SearchPhrase phrase, final SearchResultMatcher resultMatcher)
throws IOException { throws IOException {
if (phrase.getRadiusLevel() > 1 || phrase.getUnknownWordToSearch().length() > 3 || if (phrase.getRadiusLevel() > 1 || phrase.getUnknownWordToSearch().length() > 3 ||
phrase.hasMoreThanOneUnknownSearchWord()|| phrase.isSearchTypeAllowed(ObjectType.POSTCODE, true)) { phrase.hasMoreThanOneUnknownSearchWord()|| phrase.isSearchTypeAllowed(ObjectType.POSTCODE, true)) {
final boolean locSpecified = phrase.getLastTokenLocation() != null; final boolean locSpecified = phrase.getLastTokenLocation() != null;
LatLon loc = phrase.getLastTokenLocation(); LatLon loc = phrase.getLastTokenLocation();
@ -424,7 +424,7 @@ public class SearchCoreFactory {
if (object.getName().startsWith("<")) { if (object.getName().startsWith("<")) {
return false; return false;
} }
if (!phrase.getUnknownWordToSearchBuildingNameMatcher().matches(stripBraces(sr.localeName))) { if (!phrase.getUnknownWordToSearchBuildingNameMatcher().matches(stripBraces(sr.localeName))) {
sr.priorityDistance = 5; sr.priorityDistance = 5;
} }
@ -558,7 +558,7 @@ public class SearchCoreFactory {
} }
// Take into account POI [bar] - 'Hospital 512' // Take into account POI [bar] - 'Hospital 512'
// BEFORE: it was searching exact match of whole phrase.getUnknownSearchPhrase() [ Check feedback ] // BEFORE: it was searching exact match of whole phrase.getUnknownSearchPhrase() [ Check feedback ]
final BinaryMapIndexReader[] currentFile = new BinaryMapIndexReader[1]; final BinaryMapIndexReader[] currentFile = new BinaryMapIndexReader[1];
Iterator<BinaryMapIndexReader> offlineIterator = phrase.getRadiusOfflineIndexes(BBOX_RADIUS, Iterator<BinaryMapIndexReader> offlineIterator = phrase.getRadiusOfflineIndexes(BBOX_RADIUS,
SearchPhraseDataType.POI); SearchPhraseDataType.POI);
@ -670,7 +670,7 @@ public class SearchCoreFactory {
return phrase.getNextRadiusSearch(BBOX_RADIUS); return phrase.getNextRadiusSearch(BBOX_RADIUS);
} }
} }
protected static class PoiTypeResult { protected static class PoiTypeResult {
public AbstractPoiType pt; public AbstractPoiType pt;
public Set<String> foundWords = new LinkedHashSet<String>(); public Set<String> foundWords = new LinkedHashSet<String>();
@ -709,7 +709,7 @@ public class SearchCoreFactory {
this.activePoiFilters.put(filterOrder.get(i), i); this.activePoiFilters.put(filterOrder.get(i), i);
} }
} }
public Map<String, PoiTypeResult> getPoiTypeResults(NameStringMatcher nm, NameStringMatcher nmAdditional) { public Map<String, PoiTypeResult> getPoiTypeResults(NameStringMatcher nm, NameStringMatcher nmAdditional) {
Map<String, PoiTypeResult> results = new LinkedHashMap<>(); Map<String, PoiTypeResult> results = new LinkedHashMap<>();
for (AbstractPoiType pf : topVisibleFilters) { for (AbstractPoiType pf : topVisibleFilters) {
@ -764,7 +764,7 @@ public class SearchCoreFactory {
} else { } else {
String enTranslation = a.getEnTranslation().toLowerCase(); String enTranslation = a.getEnTranslation().toLowerCase();
if (!"no".equals(enTranslation) // && !"yes".equals(enTranslation) if (!"no".equals(enTranslation) // && !"yes".equals(enTranslation)
) { ) {
PoiTypeResult ptr = checkPoiType(nm, a); PoiTypeResult ptr = checkPoiType(nm, a);
if (ptr != null) { if (ptr != null) {
results.put(a.getKeyName(), ptr); results.put(a.getKeyName(), ptr);
@ -816,12 +816,12 @@ public class SearchCoreFactory {
categories = types.getCategories(false); categories = types.getCategories(false);
} }
} }
@Override @Override
public boolean search(SearchPhrase phrase, SearchResultMatcher resultMatcher) throws IOException { public boolean search(SearchPhrase phrase, SearchResultMatcher resultMatcher) throws IOException {
boolean showTopFiltersOnly = !phrase.isUnknownSearchWordPresent(); boolean showTopFiltersOnly = !phrase.isUnknownSearchWordPresent();
NameStringMatcher nm = phrase.getFirstUnknownNameStringMatcher(); NameStringMatcher nm = phrase.getFirstUnknownNameStringMatcher();
initPoiTypes(); initPoiTypes();
if (showTopFiltersOnly) { if (showTopFiltersOnly) {
for (AbstractPoiType pt : topVisibleFilters) { for (AbstractPoiType pt : topVisibleFilters) {
@ -830,10 +830,10 @@ public class SearchCoreFactory {
res.object = pt; res.object = pt;
addPoiTypeResult(phrase, resultMatcher, showTopFiltersOnly, getStandardFilterId(pt), res); addPoiTypeResult(phrase, resultMatcher, showTopFiltersOnly, getStandardFilterId(pt), res);
} }
} else { } else {
boolean includeAdditional = !phrase.hasMoreThanOneUnknownSearchWord(); boolean includeAdditional = !phrase.hasMoreThanOneUnknownSearchWord();
NameStringMatcher nmAdditional = includeAdditional ? NameStringMatcher nmAdditional = includeAdditional ?
new NameStringMatcher(phrase.getFirstUnknownSearchWord(), StringMatcherMode.CHECK_EQUALS_FROM_SPACE) : null; new NameStringMatcher(phrase.getFirstUnknownSearchWord(), StringMatcherMode.CHECK_EQUALS_FROM_SPACE) : null;
Map<String, PoiTypeResult> poiTypes = getPoiTypeResults(nm, nmAdditional); Map<String, PoiTypeResult> poiTypes = getPoiTypeResults(nm, nmAdditional);
for (PoiTypeResult ptr : poiTypes.values()) { for (PoiTypeResult ptr : poiTypes.values()) {
@ -869,7 +869,7 @@ public class SearchCoreFactory {
} }
private void addPoiTypeResult(SearchPhrase phrase, SearchResultMatcher resultMatcher, boolean showTopFiltersOnly, private void addPoiTypeResult(SearchPhrase phrase, SearchResultMatcher resultMatcher, boolean showTopFiltersOnly,
String stdFilterId, SearchResult res) { String stdFilterId, SearchResult res) {
res.priorityDistance = 0; res.priorityDistance = 0;
res.objectType = ObjectType.POI_TYPE; res.objectType = ObjectType.POI_TYPE;
res.firstUnknownWordMatches = true; res.firstUnknownWordMatches = true;
@ -893,7 +893,7 @@ public class SearchCoreFactory {
return SEARCH_AMENITY_TYPE_PRIORITY + i.intValue(); return SEARCH_AMENITY_TYPE_PRIORITY + i.intValue();
} }
public String getStandardFilterId(AbstractPoiType poi) { public String getStandardFilterId(AbstractPoiType poi) {
return STD_POI_FILTER_PREFIX + poi.getKeyName(); return STD_POI_FILTER_PREFIX + poi.getKeyName();
@ -926,7 +926,7 @@ public class SearchCoreFactory {
private MapPoiTypes types; private MapPoiTypes types;
private AbstractPoiType unselectedPoiType; private AbstractPoiType unselectedPoiType;
private String nameFilter; private String nameFilter;
public SearchAmenityByTypeAPI(MapPoiTypes types, SearchAmenityTypesAPI searchAmenityTypesAPI) { public SearchAmenityByTypeAPI(MapPoiTypes types, SearchAmenityTypesAPI searchAmenityTypesAPI) {
super(ObjectType.POI); super(ObjectType.POI);
this.types = types; this.types = types;
@ -975,7 +975,7 @@ public class SearchCoreFactory {
nameFilter = phrase.getUnknownSearchPhrase(); nameFilter = phrase.getUnknownSearchPhrase();
} else if (searchAmenityTypesAPI != null && phrase.isFirstUnknownSearchWordComplete()) { } else if (searchAmenityTypesAPI != null && phrase.isFirstUnknownSearchWordComplete()) {
NameStringMatcher nm = phrase.getFirstUnknownNameStringMatcher(); NameStringMatcher nm = phrase.getFirstUnknownNameStringMatcher();
NameStringMatcher nmAdditional = new NameStringMatcher(phrase.getFirstUnknownSearchWord(), NameStringMatcher nmAdditional = new NameStringMatcher(phrase.getFirstUnknownSearchWord(),
StringMatcherMode.CHECK_EQUALS_FROM_SPACE) ; StringMatcherMode.CHECK_EQUALS_FROM_SPACE) ;
searchAmenityTypesAPI.initPoiTypes(); searchAmenityTypesAPI.initPoiTypes();
Map<String, PoiTypeResult> poiTypeResults = searchAmenityTypesAPI.getPoiTypeResults(nm, nmAdditional); Map<String, PoiTypeResult> poiTypeResults = searchAmenityTypesAPI.getPoiTypeResults(nm, nmAdditional);
@ -1010,7 +1010,7 @@ public class SearchCoreFactory {
List<BinaryMapIndexReader> offlineIndexes = phrase.getOfflineIndexes(); List<BinaryMapIndexReader> offlineIndexes = phrase.getOfflineIndexes();
Set<String> searchedPois = new TreeSet<>(); Set<String> searchedPois = new TreeSet<>();
for (BinaryMapIndexReader r : offlineIndexes) { for (BinaryMapIndexReader r : offlineIndexes) {
ResultMatcher<Amenity> rm = getResultMatcher(phrase, poiTypeFilter, resultMatcher, nameFilter, r, ResultMatcher<Amenity> rm = getResultMatcher(phrase, poiTypeFilter, resultMatcher, nameFilter, r,
searchedPois, poiAdditionals, countExtraWords); searchedPois, poiAdditionals, countExtraWords);
if (poiTypeFilter instanceof CustomSearchPoiFilter) { if (poiTypeFilter instanceof CustomSearchPoiFilter) {
rm = ((CustomSearchPoiFilter) poiTypeFilter).wrapResultMatcher(rm); rm = ((CustomSearchPoiFilter) poiTypeFilter).wrapResultMatcher(rm);
@ -1025,12 +1025,12 @@ public class SearchCoreFactory {
} }
private ResultMatcher<Amenity> getResultMatcher(final SearchPhrase phrase, final SearchPoiTypeFilter poiTypeFilter, private ResultMatcher<Amenity> getResultMatcher(final SearchPhrase phrase, final SearchPoiTypeFilter poiTypeFilter,
final SearchResultMatcher resultMatcher, final String nameFilter, final SearchResultMatcher resultMatcher, final String nameFilter,
final BinaryMapIndexReader selected, final Set<String> searchedPois, final BinaryMapIndexReader selected, final Set<String> searchedPois,
final Collection<String> poiAdditionals, final int countExtraWords) { final Collection<String> poiAdditionals, final int countExtraWords) {
final NameStringMatcher ns = nameFilter == null ? null : new NameStringMatcher(nameFilter, StringMatcherMode.CHECK_STARTS_FROM_SPACE); final NameStringMatcher ns = nameFilter == null ? null : new NameStringMatcher(nameFilter, StringMatcherMode.CHECK_STARTS_FROM_SPACE);
return new ResultMatcher<Amenity>() { return new ResultMatcher<Amenity>() {
@ -1186,7 +1186,7 @@ public class SearchCoreFactory {
NameStringMatcher nm = phrase.getMainUnknownNameStringMatcher(); NameStringMatcher nm = phrase.getMainUnknownNameStringMatcher();
for (Street object : c.getStreets()) { for (Street object : c.getStreets()) {
SearchResult res = new SearchResult(phrase); SearchResult res = new SearchResult(phrase);
res.localeName = object.getName(phrase.getSettings().getLang(), phrase.getSettings().isTransliterate()); res.localeName = object.getName(phrase.getSettings().getLang(), phrase.getSettings().isTransliterate());
res.otherNames = object.getAllNames(true); res.otherNames = object.getAllNames(true);
boolean pub = true; boolean pub = true;
@ -1266,7 +1266,7 @@ public class SearchCoreFactory {
if (s != null) { if (s != null) {
BinaryMapIndexReader file = phrase.getLastSelectedWord().getResult().file; BinaryMapIndexReader file = phrase.getLastSelectedWord().getResult().file;
if (cacheBuilding != s) { if (cacheBuilding != s) {
cacheBuilding = s; cacheBuilding = s;
SearchRequest<Building> sr = BinaryMapIndexReader SearchRequest<Building> sr = BinaryMapIndexReader
@ -1325,13 +1325,13 @@ public class SearchCoreFactory {
res.location = b.getLocation(); res.location = b.getLocation();
} }
res.preferredZoom = 17; res.preferredZoom = 17;
resultMatcher.publish(res); resultMatcher.publish(res);
} }
String streetIntersection = phrase.getUnknownWordToSearch(); String streetIntersection = phrase.getUnknownWordToSearch();
NameStringMatcher streetMatch = phrase.getMainUnknownNameStringMatcher(); NameStringMatcher streetMatch = phrase.getMainUnknownNameStringMatcher();
if (Algorithms.isEmpty(streetIntersection) || if (Algorithms.isEmpty(streetIntersection) ||
(!Character.isDigit(streetIntersection.charAt(0)) && (!Character.isDigit(streetIntersection.charAt(0)) &&
CommonWords.getCommonSearch(streetIntersection) == -1) ) { CommonWords.getCommonSearch(streetIntersection) == -1) ) {
for (Street street : s.getIntersectedStreets()) { for (Street street : s.getIntersectedStreets()) {
SearchResult res = new SearchResult(phrase); SearchResult res = new SearchResult(phrase);
@ -1369,7 +1369,7 @@ public class SearchCoreFactory {
return SEARCH_BUILDING_BY_STREET_PRIORITY; return SEARCH_BUILDING_BY_STREET_PRIORITY;
} }
} }
protected static class PoiAdditionalCustomFilter extends AbstractPoiType { protected static class PoiAdditionalCustomFilter extends AbstractPoiType {
protected List<PoiType> additionalPoiTypes = new ArrayList<PoiType>(); protected List<PoiType> additionalPoiTypes = new ArrayList<PoiType>();
@ -1378,7 +1378,7 @@ public class SearchCoreFactory {
super(pt.getKeyName(), registry); super(pt.getKeyName(), registry);
additionalPoiTypes.add(pt); additionalPoiTypes.add(pt);
} }
@Override @Override
public boolean isAdditional() { public boolean isAdditional() {
return true; return true;
@ -1397,7 +1397,7 @@ public class SearchCoreFactory {
} }
return acceptedTypes; return acceptedTypes;
} }
} }
public static class SearchLocationAndUrlAPI extends SearchBaseAPI { public static class SearchLocationAndUrlAPI extends SearchBaseAPI {
@ -1569,7 +1569,7 @@ public class SearchCoreFactory {
} }
return retName; return retName;
} }
public static boolean isLastWordCityGroup(SearchPhrase p ) { public static boolean isLastWordCityGroup(SearchPhrase p ) {
return p.isLastWord(ObjectType.CITY) || p.isLastWord(ObjectType.POSTCODE) || return p.isLastWord(ObjectType.CITY) || p.isLastWord(ObjectType.POSTCODE) ||
p.isLastWord(ObjectType.VILLAGE); p.isLastWord(ObjectType.VILLAGE);

View file

@ -13,7 +13,7 @@ import java.util.regex.Pattern;
public class GeoPointParserUtil { public class GeoPointParserUtil {
private static String getQueryParameter(final String param, URI uri) { private static String getQueryParameter(final String param, URI uri) {
final String query = uri.getQuery(); final String query = uri.getQuery();
String value = null; String value = null;
@ -103,7 +103,7 @@ public class GeoPointParserUtil {
if(uri.getSchemeSpecificPart() == null) { if(uri.getSchemeSpecificPart() == null) {
return null; return null;
} else if(!uri.getSchemeSpecificPart().contains("=")) { } else if(!uri.getSchemeSpecificPart().contains("=")) {
params = getQueryParameters("q="+uri.getSchemeSpecificPart()); params = getQueryParameters("q="+uri.getSchemeSpecificPart());
} else { } else {
params = getQueryParameters(uri.getSchemeSpecificPart()); params = getQueryParameters(uri.getSchemeSpecificPart());
} }
@ -181,7 +181,7 @@ public class GeoPointParserUtil {
} }
} else if (host.startsWith("map.baidu.")) { // .com and .cn both work } else if (host.startsWith("map.baidu.")) { // .com and .cn both work
/* Baidu Map uses a custom format for lat/lon., it is basically standard lat/lon /* Baidu Map uses a custom format for lat/lon., it is basically standard lat/lon
* multiplied by 100,000, then rounded to an integer */ * multiplied by 100,000, then rounded to an integer */
String zm = params.get("l"); String zm = params.get("l");
String[] vls = silentSplit(params.get("c"), ","); String[] vls = silentSplit(params.get("c"), ",");
if (vls != null && vls.length >= 2) { if (vls != null && vls.length >= 2) {
@ -219,7 +219,7 @@ public class GeoPointParserUtil {
String latString = null; String latString = null;
String lonString = null; String lonString = null;
String z = String.valueOf(GeoParsedPoint.NO_ZOOM); String z = String.valueOf(GeoParsedPoint.NO_ZOOM);
if (params.containsKey("q")) { if (params.containsKey("q")) {
System.out.println("q=" + params.get("q")); System.out.println("q=" + params.get("q"));
Matcher matcher = commaSeparatedPairPattern.matcher(params.get("q")); Matcher matcher = commaSeparatedPairPattern.matcher(params.get("q"));
@ -297,7 +297,7 @@ public class GeoPointParserUtil {
Pattern p; Pattern p;
Matcher matcher; Matcher matcher;
final String[] patterns = { final String[] patterns = {
/* though this looks like Query String, it is also used as part of the Fragment */ /* though this looks like Query String, it is also used as part of the Fragment */
".*q=([+-]?\\d+(?:\\.\\d+)?),([+-]?\\d+(?:\\.\\d+)?).*&radius=(\\d+).*", ".*q=([+-]?\\d+(?:\\.\\d+)?),([+-]?\\d+(?:\\.\\d+)?).*&radius=(\\d+).*",
".*q=([+-]?\\d+(?:\\.\\d+)?),([+-]?\\d+(?:\\.\\d+)?).*", ".*q=([+-]?\\d+(?:\\.\\d+)?),([+-]?\\d+(?:\\.\\d+)?).*",
".*p=(?:[A-Z0-9]+),([+-]?\\d+(?:\\.\\d+)?),([+-]?\\d+(?:\\.\\d+)?).*",}; ".*p=(?:[A-Z0-9]+),([+-]?\\d+(?:\\.\\d+)?),([+-]?\\d+(?:\\.\\d+)?).*",};
@ -315,7 +315,7 @@ public class GeoPointParserUtil {
} }
} }
} }
} else if (host.equals("here.com") || host.endsWith(".here.com")) { // www.here.com, share.here.com, here.com } else if (host.equals("here.com") || host.endsWith(".here.com")) { // www.here.com, share.here.com, here.com
String z = String.valueOf(GeoParsedPoint.NO_ZOOM); String z = String.valueOf(GeoParsedPoint.NO_ZOOM);
String label = null; String label = null;
if (params.containsKey("msg")) { if (params.containsKey("msg")) {
@ -492,7 +492,7 @@ public class GeoPointParserUtil {
} }
if ("z".equals(paramName) && paramValue != null) { if ("z".equals(paramName) && paramValue != null) {
zoom = Integer.parseInt(paramValue); zoom = (int) Float.parseFloat(paramValue);
} else if ("q".equals(paramName) && paramValue != null) { } else if ("q".equals(paramName) && paramValue != null) {
searchRequest = URLDecoder.decode(paramValue); searchRequest = URLDecoder.decode(paramValue);
} }
@ -587,7 +587,7 @@ public class GeoPointParserUtil {
private static int parseZoom(String zoom) { private static int parseZoom(String zoom) {
try { try {
if (zoom != null) { if (zoom != null) {
return Integer.valueOf(zoom); return (int) Float.parseFloat(zoom);
} }
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
} }
@ -597,7 +597,7 @@ public class GeoPointParserUtil {
private static double parseSilentDouble(String zoom) { private static double parseSilentDouble(String zoom) {
return parseSilentDouble(zoom, 0); return parseSilentDouble(zoom, 0);
} }
private static double parseSilentDouble(String zoom, double vl) { private static double parseSilentDouble(String zoom, double vl) {
try { try {
if (zoom != null) { if (zoom != null) {
@ -772,9 +772,9 @@ public class GeoPointParserUtil {
@Override @Override
public String toString() { public String toString() {
return isGeoPoint() ? return isGeoPoint() ?
String.format("GeoParsedPoint [lat=%.5f, lon=%.5f, zoom=%d, label=%s]", lat, lon, zoom, label) : String.format("GeoParsedPoint [lat=%.5f, lon=%.5f, zoom=%d, label=%s]", lat, lon, zoom, label) :
String.format("GeoParsedPoint [query=%s]",query); String.format("GeoParsedPoint [query=%s]",query);
} }
} }
} }

View file

@ -716,7 +716,7 @@ public class GeoPointParserUtilTest {
actual = GeoPointParserUtil.parse(url); actual = GeoPointParserUtil.parse(url);
assertGeoPoint(actual, new GeoParsedPoint(dlat, dlon, z)); assertGeoPoint(actual, new GeoParsedPoint(dlat, dlon, z));
/* URLs straight from various services, instead of generated here */ /* URLs straight from various services, instead of generated here */
String urls[] = { String urls[] = {
"https://openstreetmap.org/go/0LQ127-?m", "https://openstreetmap.org/go/0LQ127-?m",

View file

@ -307,7 +307,7 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
int position = getListView().getPositionForView(selected); int position = getListView().getPositionForView(selected);
if ((position != AdapterView.INVALID_POSITION) && (position >= getListView().getHeaderViewsCount())) { if ((position != AdapterView.INVALID_POSITION) && (position >= getListView().getHeaderViewsCount())) {
dialogFragment.getNavigationInfo().updateTargetDirection( dialogFragment.getNavigationInfo().updateTargetDirection(
listAdapter.getItem(position - getListView().getHeaderViewsCount()).getSearchResult().location, listAdapter.getItem(position - getListView().getHeaderViewsCount()).getSearchResult().location,
heading.floatValue()); heading.floatValue());
} }
} catch (Exception e) { } catch (Exception e) {