Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--base/base_tests/logging_test.cpp19
-rw-r--r--base/logging.hpp2
-rw-r--r--base/newtype.hpp2
-rw-r--r--generator/booking_dataset.cpp18
-rw-r--r--generator/booking_quality_check/booking_quality_check.cpp12
-rw-r--r--generator/opentable_dataset.cpp6
-rw-r--r--generator/sponsored_dataset.hpp2
-rw-r--r--generator/sponsored_object_storage.hpp5
-rw-r--r--generator/viator_dataset.cpp6
9 files changed, 36 insertions, 36 deletions
diff --git a/base/base_tests/logging_test.cpp b/base/base_tests/logging_test.cpp
index 365db44668..b7b39c994b 100644
--- a/base/base_tests/logging_test.cpp
+++ b/base/base_tests/logging_test.cpp
@@ -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, ());
}
diff --git a/base/logging.hpp b/base/logging.hpp
index 147958938a..2bbcbd75e8 100644
--- a/base/logging.hpp
+++ b/base/logging.hpp
@@ -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)
diff --git a/base/newtype.hpp b/base/newtype.hpp
index a51e35b65f..50f0cab9fc 100644
--- a/base/newtype.hpp
+++ b/base/newtype.hpp
@@ -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); \
}
diff --git a/generator/booking_dataset.cpp b/generator/booking_dataset.cpp
index 5cacf1869e..d77de5ac34 100644
--- a/generator/booking_dataset.cpp
+++ b/generator/booking_dataset.cpp
@@ -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
diff --git a/generator/booking_quality_check/booking_quality_check.cpp b/generator/booking_quality_check/booking_quality_check.cpp
index 2699ffeb38..c12cefcb5b 100644
--- a/generator/booking_quality_check/booking_quality_check.cpp
+++ b/generator/booking_quality_check/booking_quality_check.cpp
@@ -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 */)
diff --git a/generator/opentable_dataset.cpp b/generator/opentable_dataset.cpp
index 01c55399e1..926dd2007a 100644
--- a/generator/opentable_dataset.cpp
+++ b/generator/opentable_dataset.cpp
@@ -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)];
diff --git a/generator/sponsored_dataset.hpp b/generator/sponsored_dataset.hpp
index 6ae9b8cfe3..3b8bad6eb7 100644
--- a/generator/sponsored_dataset.hpp
+++ b/generator/sponsored_dataset.hpp
@@ -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();
diff --git a/generator/sponsored_object_storage.hpp b/generator/sponsored_object_storage.hpp
index 50d0eb3568..0f9a46d096 100644
--- a/generator/sponsored_object_storage.hpp
+++ b/generator/sponsored_object_storage.hpp
@@ -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.
diff --git a/generator/viator_dataset.cpp b/generator/viator_dataset.cpp
index dc88fd093c..7a83bbb58c 100644
--- a/generator/viator_dataset.cpp
+++ b/generator/viator_dataset.cpp
@@ -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)];
}