forked from organicmaps/organicmaps
review fixes
This commit is contained in:
parent
c878b6a37d
commit
fc7d0d162e
9 changed files with 36 additions and 36 deletions
|
@ -19,11 +19,10 @@ namespace
|
|||
return 3;
|
||||
}
|
||||
|
||||
bool g_NegativeFunctionCalled;
|
||||
bool NegativeFunction()
|
||||
bool BoolFunction(bool result, bool & called)
|
||||
{
|
||||
g_NegativeFunctionCalled = true;
|
||||
return false;
|
||||
called = true;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,11 +52,11 @@ UNIT_TEST(NullMessage)
|
|||
|
||||
UNIT_TEST(Logging_ConditionalLog)
|
||||
{
|
||||
g_SomeFunctionCalled = false;
|
||||
CLOG(LINFO, SomeFunction(), ("This should not pass"));
|
||||
TEST(g_SomeFunctionCalled, ());
|
||||
bool isCalled = false;
|
||||
CLOG(LINFO, BoolFunction(true, isCalled), ("This should not be displayed"));
|
||||
TEST(isCalled, ());
|
||||
|
||||
g_NegativeFunctionCalled = false;
|
||||
CLOG(LWARNING, NegativeFunction(), ("This should pass"));
|
||||
TEST(g_NegativeFunctionCalled, ());
|
||||
isCalled = false;
|
||||
CLOG(LWARNING, BoolFunction(false, isCalled), ("This should be displayed"));
|
||||
TEST(isCalled, ());
|
||||
}
|
||||
|
|
|
@ -92,6 +92,6 @@ using ::my::LCRITICAL;
|
|||
#define CLOG(level, X, msg) \
|
||||
do \
|
||||
{ \
|
||||
if (!X) \
|
||||
if (!(X)) \
|
||||
LOG(level, (SRC(), "CLOG(" #X ")", ::my::impl::Message msg)); \
|
||||
} while (false)
|
||||
|
|
|
@ -161,7 +161,7 @@ std::string SimpleDebugPrint(NewType<Type, Tag> const & nt)
|
|||
{ \
|
||||
return my::newtype_default_output::SimpleDebugPrint(nt); \
|
||||
} \
|
||||
inline ostream & operator<<(ostream & ost, NAME const & nt) \
|
||||
inline std::ostream & operator<<(std::ostream & ost, NAME const & nt) \
|
||||
{ \
|
||||
return ost << my::newtype_default_output::SimpleDebugPrint(nt); \
|
||||
}
|
||||
|
|
|
@ -23,27 +23,27 @@ BookingHotel::BookingHotel(std::string const & src)
|
|||
CHECK_EQUAL(rec.size(), FieldsCount(), ("Error parsing hotels.tsv line:",
|
||||
boost::replace_all_copy(src, "\t", "\\t")));
|
||||
|
||||
CLOG(LERROR, strings::to_uint(rec[FieldIndex(Fields::Id)], m_id.Get()), ());
|
||||
CLOG(LDEBUG, strings::to_uint(rec[FieldIndex(Fields::Id)], m_id.Get()), ());
|
||||
// TODO(mgsergio): Use ms::LatLon.
|
||||
CLOG(LERROR, strings::to_double(rec[FieldIndex(Fields::Latitude)], m_latLon.lat), ());
|
||||
CLOG(LERROR, strings::to_double(rec[FieldIndex(Fields::Longtitude)], m_latLon.lon), ());
|
||||
CLOG(LDEBUG, strings::to_double(rec[FieldIndex(Fields::Latitude)], m_latLon.lat), ());
|
||||
CLOG(LDEBUG, strings::to_double(rec[FieldIndex(Fields::Longtitude)], m_latLon.lon), ());
|
||||
|
||||
m_name = rec[FieldIndex(Fields::Name)];
|
||||
m_address = rec[FieldIndex(Fields::Address)];
|
||||
|
||||
CLOG(LERROR, strings::to_uint(rec[FieldIndex(Fields::Stars)], m_stars), ());
|
||||
CLOG(LERROR, strings::to_uint(rec[FieldIndex(Fields::PriceCategory)], m_priceCategory), ());
|
||||
CLOG(LERROR, strings::to_double(rec[FieldIndex(Fields::RatingBooking)], m_ratingBooking), ());
|
||||
CLOG(LERROR, strings::to_double(rec[FieldIndex(Fields::RatingUsers)], m_ratingUser), ());
|
||||
CLOG(LDEBUG, strings::to_uint(rec[FieldIndex(Fields::Stars)], m_stars), ());
|
||||
CLOG(LDEBUG, strings::to_uint(rec[FieldIndex(Fields::PriceCategory)], m_priceCategory), ());
|
||||
CLOG(LDEBUG, strings::to_double(rec[FieldIndex(Fields::RatingBooking)], m_ratingBooking), ());
|
||||
CLOG(LDEBUG, strings::to_double(rec[FieldIndex(Fields::RatingUsers)], m_ratingUser), ());
|
||||
|
||||
m_descUrl = rec[FieldIndex(Fields::DescUrl)];
|
||||
|
||||
CLOG(LERROR, strings::to_uint(rec[FieldIndex(Fields::Type)], m_type), ());
|
||||
CLOG(LDEBUG, strings::to_uint(rec[FieldIndex(Fields::Type)], m_type), ());
|
||||
|
||||
m_translations = rec[FieldIndex(Fields::Translations)];
|
||||
}
|
||||
|
||||
ostream & operator<<(ostream & s, BookingHotel const & h)
|
||||
std::ostream & operator<<(std::ostream & s, BookingHotel const & h)
|
||||
{
|
||||
s << std::fixed << std::setprecision(7);
|
||||
s << "Id: " << h.m_id << "\t Name: " << h.m_name << "\t Address: " << h.m_address
|
||||
|
|
|
@ -239,7 +239,7 @@ void GenerateFactors(Dataset const & dataset,
|
|||
{
|
||||
for (auto const & item : sampleItems)
|
||||
{
|
||||
auto const & object = dataset.GetObjectById(item.m_sponsoredId);
|
||||
auto const & object = dataset.GetStorage().GetObjectById(item.m_sponsoredId);
|
||||
auto const & feature = features.at(item.m_osmId);
|
||||
|
||||
auto const score = generator::sponsored_scoring::Match(object, feature);
|
||||
|
@ -290,14 +290,12 @@ void GenerateSample(Dataset const & dataset,
|
|||
for (auto osmId : elementIndexes)
|
||||
{
|
||||
auto const & fb = features.at(osmId);
|
||||
auto const sponsoredIndexes = dataset.GetNearestObjects(
|
||||
MercatorBounds::ToLatLon(fb.GetKeyPoint()),
|
||||
Dataset::kMaxSelectedElements,
|
||||
Dataset::kDistanceLimitInMeters);
|
||||
auto const sponsoredIndexes = dataset.GetStorage().GetNearestObjects(
|
||||
MercatorBounds::ToLatLon(fb.GetKeyPoint()));
|
||||
|
||||
for (auto const sponsoredId : sponsoredIndexes)
|
||||
{
|
||||
auto const & object = dataset.GetObjectById(sponsoredId);
|
||||
auto const & object = dataset.GetStorage().GetObjectById(sponsoredId);
|
||||
auto const score = sponsored_scoring::Match(object, fb);
|
||||
|
||||
auto const center = MercatorBounds::ToLatLon(fb.GetKeyPoint());
|
||||
|
@ -356,7 +354,7 @@ void RunImpl(feature::GenerateInfo & info)
|
|||
{
|
||||
auto const & dataSetFilePath = GetDatasetFilePath<Dataset>(info);
|
||||
Dataset dataset(dataSetFilePath);
|
||||
LOG_SHORT(LINFO, (dataset.Size(), "objects are loaded from a file:", dataSetFilePath));
|
||||
LOG_SHORT(LINFO, (dataset.GetStorage().Size(), "objects are loaded from a file:", dataSetFilePath));
|
||||
|
||||
map<osm::Id, FeatureBuilder1> features;
|
||||
GenerateFeatures(info, [&dataset, &features](feature::GenerateInfo const & /* info */)
|
||||
|
|
|
@ -23,9 +23,9 @@ OpentableRestaurant::OpentableRestaurant(std::string const & src)
|
|||
CHECK_EQUAL(rec.size(), FieldsCount(), ("Error parsing restaurants.tsv line:",
|
||||
boost::replace_all_copy(src, "\t", "\\t")));
|
||||
|
||||
CLOG(LERROR, strings::to_uint(rec[FieldIndex(Fields::Id)], m_id.Get()), ());
|
||||
CLOG(LERROR, strings::to_double(rec[FieldIndex(Fields::Latitude)], m_latLon.lat), ());
|
||||
CLOG(LERROR, strings::to_double(rec[FieldIndex(Fields::Longtitude)], m_latLon.lon), ());
|
||||
CLOG(LDEBUG, strings::to_uint(rec[FieldIndex(Fields::Id)], m_id.Get()), ());
|
||||
CLOG(LDEBUG, strings::to_double(rec[FieldIndex(Fields::Latitude)], m_latLon.lat), ());
|
||||
CLOG(LDEBUG, strings::to_double(rec[FieldIndex(Fields::Longtitude)], m_latLon.lon), ());
|
||||
|
||||
m_name = rec[FieldIndex(Fields::Name)];
|
||||
m_address = rec[FieldIndex(Fields::Address)];
|
||||
|
|
|
@ -36,6 +36,8 @@ public:
|
|||
// Creates objects and adds them to the map (MWM) via |fn|.
|
||||
void BuildOsmObjects(std::function<void(FeatureBuilder1 &)> const & fn) const;
|
||||
|
||||
SponsoredObjectStorage<Object> const & GetStorage() const { return m_storage; }
|
||||
|
||||
private:
|
||||
void InitStorage();
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ public:
|
|||
return;
|
||||
|
||||
std::ifstream dataSource(dataPath);
|
||||
if (!dataSource.is_open())
|
||||
if (!dataSource)
|
||||
{
|
||||
LOG(LERROR, ("Error while opening", dataPath, ":", strerror(errno)));
|
||||
return;
|
||||
|
@ -82,7 +82,8 @@ public:
|
|||
for (std::string line; std::getline(src, line);)
|
||||
{
|
||||
Object object(line);
|
||||
m_objects.emplace(object.m_id, object);
|
||||
if (object.m_id != Object::InvalidObjectId())
|
||||
m_objects.emplace(object.m_id, object);
|
||||
}
|
||||
|
||||
// Try to get object address from existing MWMs.
|
||||
|
|
|
@ -38,9 +38,9 @@ ViatorCity::ViatorCity(std::string const & src)
|
|||
CHECK_EQUAL(rec.size(), FieldsCount(),
|
||||
("Error parsing viator cities, line:", boost::replace_all_copy(src, "\t", "\\t")));
|
||||
|
||||
CLOG(LERROR, strings::to_uint(rec[FieldIndex(TsvFields::Id)], m_id.Get()), ());
|
||||
CLOG(LERROR, strings::to_double(rec[FieldIndex(TsvFields::Latitude)], m_latLon.lat), ());
|
||||
CLOG(LERROR, strings::to_double(rec[FieldIndex(TsvFields::Longtitude)], m_latLon.lon), ());
|
||||
CLOG(LDEBUG, strings::to_uint(rec[FieldIndex(TsvFields::Id)], m_id.Get()), ());
|
||||
CLOG(LDEBUG, strings::to_double(rec[FieldIndex(TsvFields::Latitude)], m_latLon.lat), ());
|
||||
CLOG(LDEBUG, strings::to_double(rec[FieldIndex(TsvFields::Longtitude)], m_latLon.lon), ());
|
||||
|
||||
m_name = rec[FieldIndex(TsvFields::Name)];
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue