forked from organicmaps/organicmaps
[storage][lightweight] review fixes
This commit is contained in:
parent
c701d2d7be
commit
608500150e
5 changed files with 14 additions and 26 deletions
|
@ -24,7 +24,7 @@ enum RequestType
|
|||
REQUEST_TYPE_USER_AUTH_STATUS = 1u << 1,
|
||||
REQUEST_TYPE_NUMBER_OF_UNSENT_EDITS = 1u << 2,
|
||||
REQUEST_TYPE_BOOKMARKS_CLOUD_ENABLED = 1u << 3,
|
||||
// Be careful to use this flag. Loading with this flag can produces a hard pressure on the disk
|
||||
// Be careful to use this flag. Loading with this flag can produce a hard pressure on the disk
|
||||
// and takes much time. For example it takes ~50ms on LG Nexus 5, ~100ms on Samsung A5, ~200ms on
|
||||
// Fly IQ4403.
|
||||
REQUEST_TYPE_LOCATION = 1u << 4,
|
||||
|
|
|
@ -50,7 +50,7 @@ private:
|
|||
};
|
||||
} // namespace
|
||||
|
||||
// CountryInfoGetterBase ---------------------------------------------------------------------------------
|
||||
// CountryInfoGetterBase ---------------------------------------------------------------------------
|
||||
TCountryId CountryInfoGetterBase::GetRegionCountryId(m2::PointD const & pt) const
|
||||
{
|
||||
TRegionId const id = FindFirstCountry(pt);
|
||||
|
@ -94,11 +94,6 @@ CountryInfoGetterBase::TRegionId CountryInfoGetterBase::FindFirstCountry(m2::Poi
|
|||
return id;
|
||||
}
|
||||
|
||||
ms::LatLon const latLon = MercatorBounds::ToLatLon(pt);
|
||||
alohalytics::LogEvent(m_isSingleMwm
|
||||
? "Small mwm case. CountryInfoGetter could not find any mwm by point."
|
||||
: "Big mwm case. CountryInfoGetter could not find any mwm by point.",
|
||||
alohalytics::Location::FromLatLon(latLon.lat, latLon.lon));
|
||||
return kInvalidId;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
namespace storage
|
||||
{
|
||||
// This class allows users to get information about country by point or by name.
|
||||
class CountryInfoGetterBase
|
||||
{
|
||||
public:
|
||||
|
@ -27,7 +28,7 @@ public:
|
|||
using TRegionId = size_t;
|
||||
using TRegionIdSet = std::vector<TRegionId>;
|
||||
|
||||
CountryInfoGetterBase(bool isSingleMwm) : m_isSingleMwm(isSingleMwm) {}
|
||||
explicit CountryInfoGetterBase(bool isSingleMwm) : m_isSingleMwm(isSingleMwm) {}
|
||||
virtual ~CountryInfoGetterBase() = default;
|
||||
|
||||
// Returns country file name without an extension for a country |pt|
|
||||
|
@ -39,21 +40,18 @@ public:
|
|||
// |regions|.
|
||||
bool IsBelongToRegions(m2::PointD const & pt, TRegionIdSet const & regions) const;
|
||||
|
||||
// Returns true if there're at least one region with id equals to
|
||||
// |countryId|.
|
||||
// Returns true if there're at least one region with id equal to |countryId|.
|
||||
bool IsBelongToRegions(TCountryId const & countryId, TRegionIdSet const & regions) const;
|
||||
|
||||
void RegionIdsToCountryIds(TRegionIdSet const & regions, TCountriesVec & countries) const;
|
||||
|
||||
protected:
|
||||
// Returns identifier of a first country containing |pt|.
|
||||
// Returns identifier of the first country containing |pt|.
|
||||
TRegionId FindFirstCountry(m2::PointD const & pt) const;
|
||||
|
||||
// Returns true when |pt| belongs to a country identified by |id|.
|
||||
virtual bool IsBelongToRegionImpl(size_t id, m2::PointD const & pt) const = 0;
|
||||
|
||||
// @TODO(bykoianko): consider to get rid of m_countryIndex.
|
||||
// The possibility should be considered.
|
||||
// List of all known countries.
|
||||
std::vector<CountryDef> m_countries;
|
||||
// m_isSingleMwm == true if the system is currently working with single (small) mwms
|
||||
|
@ -62,14 +60,11 @@ protected:
|
|||
bool m_isSingleMwm;
|
||||
};
|
||||
|
||||
// This class allows users to get information about country by point
|
||||
// or by name.
|
||||
//
|
||||
// *NOTE* This class is thread-safe.
|
||||
class CountryInfoGetter : public CountryInfoGetterBase
|
||||
{
|
||||
public:
|
||||
CountryInfoGetter(bool isSingleMwm) : CountryInfoGetterBase(isSingleMwm) {}
|
||||
explicit CountryInfoGetter(bool isSingleMwm) : CountryInfoGetterBase(isSingleMwm) {}
|
||||
|
||||
// Returns vector of countries file names without an extension for
|
||||
// countries belong to |rect|. |rough| provides fast rough result
|
||||
|
@ -111,7 +106,7 @@ public:
|
|||
void InitAffiliationsInfo(TMappingAffiliations const * affiliations);
|
||||
|
||||
protected:
|
||||
CountryInfoGetter() : CountryInfoGetterBase(true) {};
|
||||
CountryInfoGetter() : CountryInfoGetterBase(true /* isSingleMwm */ ) {};
|
||||
// Invokes |toDo| on each country whose name starts with |prefix|.
|
||||
template <typename ToDo>
|
||||
void ForEachCountry(string const & prefix, ToDo && toDo) const;
|
||||
|
@ -124,6 +119,8 @@ protected:
|
|||
|
||||
// Returns true when the distance from |pt| to country identified by |id| less then |distance|.
|
||||
virtual bool IsCloseEnough(size_t id, m2::PointD const & pt, double distance) = 0;
|
||||
// @TODO(bykoianko): consider to get rid of m_countryIndex.
|
||||
// The possibility should be considered.
|
||||
// Maps all leaf country id (file names) to their indices in m_countries.
|
||||
std::unordered_map<TCountryId, TRegionId> m_countryIndex;
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "defines.hpp"
|
||||
|
||||
namespace lightweight
|
||||
{
|
||||
CountryInfoReader::CountryInfoReader()
|
||||
|
|
|
@ -13,7 +13,7 @@ using namespace lightweight;
|
|||
|
||||
namespace
|
||||
{
|
||||
double constexpr kStepInMercator = 1; // 1 mercator ~= 9602.84 meters
|
||||
double constexpr kStepInMercator = 1;
|
||||
|
||||
struct PointAndCountry
|
||||
{
|
||||
|
@ -42,13 +42,7 @@ UNIT_CLASS_TEST(CountryInfoReader, LightweightMatching)
|
|||
}
|
||||
}
|
||||
|
||||
{
|
||||
m2::PointD ptFrom = {MercatorBounds::minX, MercatorBounds::minY};
|
||||
m2::PointD ptTo = {MercatorBounds::minX + kStepInMercator, MercatorBounds::minY};
|
||||
auto const stepSizeInMeters = MercatorBounds::DistanceOnEarth(ptFrom, ptTo);
|
||||
LOG(LINFO, ("The dataset is generated. Dataset size:", dataset.size(),
|
||||
". The step is:", stepSizeInMeters, "meters"));
|
||||
}
|
||||
LOG(LINFO, ("The dataset is generated. Dataset size:", dataset.size()));
|
||||
|
||||
for (auto const & sample : dataset)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue