[new downloader][ios] Fixed empty country search result handling.

This commit is contained in:
Ilya Grechuhin 2016-02-20 14:47:48 +03:00 committed by Sergey Yershov
parent 9fbb229c17
commit 44dcdce3ff
2 changed files with 7 additions and 4 deletions

View file

@ -35,9 +35,12 @@ extern NSString * const kPlaceCellIdentifier;
if (!it->HasPoint())
continue;
auto const & mercator = it->GetFeatureCenter();
NSString * countryId = @(countryInfoGetter.GetRegionCountryId(mercator).c_str());
[nsSearchCoutryIds addObject:countryId];
nsSearchResults[countryId] = @(it->GetString().c_str());
TCountryId countryId = countryInfoGetter.GetRegionCountryId(mercator);
if (countryId == kInvalidCountryId)
continue;
NSString * nsCountryId = @(countryId.c_str());
[nsSearchCoutryIds addObject:nsCountryId];
nsSearchResults[nsCountryId] = @(it->GetString().c_str());
}
NSAssert(nsSearchCoutryIds.count != 0, @"Search results can not be empty.");
self.searchCoutryIds = [nsSearchCoutryIds array];

View file

@ -53,7 +53,7 @@ private:
TCountryId CountryInfoGetter::GetRegionCountryId(m2::PointD const & pt) const
{
IdType const id = FindFirstCountry(pt);
return id != kInvalidId ? m_countries[id].m_name : TCountryId();
return id != kInvalidId ? m_countries[id].m_name : kInvalidCountryId;
}
void CountryInfoGetter::GetRegionsCountryId(m2::PointD const & pt, TCountriesVec & closestCoutryIds)