From 7d3b303aa0a33906ffb1d957adb8bb7efa8dab8d Mon Sep 17 00:00:00 2001 From: Vladimir Byko-Ianko Date: Tue, 31 Oct 2017 16:11:45 +0300 Subject: [PATCH] Review fixes. --- generator/transit_generator.cpp | 43 +++++++++++++------------------- generator/transit_generator.hpp | 4 +-- routing/index_router.cpp | 2 +- routing/routing_exceptions.hpp | 2 +- routing_common/transit_types.cpp | 2 +- 5 files changed, 23 insertions(+), 30 deletions(-) diff --git a/generator/transit_generator.cpp b/generator/transit_generator.cpp index 373e76fde7..ad23dc4c66 100644 --- a/generator/transit_generator.cpp +++ b/generator/transit_generator.cpp @@ -57,28 +57,26 @@ bool IsValid(vector const & items) struct ClearVisitor { template - void operator()(Cont & c, char const * /* name */ = nullptr) const { c.clear(); } + void operator()(Cont & c, char const * /* name */) const { c.clear(); } }; struct SortVisitor { template - void operator()(Cont & c, char const * /* name */ = nullptr) const + void operator()(Cont & c, char const * /* name */) const { sort(c.begin(), c.end()); } - void operator()(vector & c, char const * /* name */ = nullptr) const {} + + void operator()(vector & c, char const * /* name */) const {} }; struct IsValidVisitor { template - void operator()(Cont const & c, char const * /* name */ = nullptr) + void operator()(Cont const & c, char const * /* name */ ) { - if (!m_isValid) - return; - - m_isValid = ::IsValid(c); + m_isValid = m_isValid && ::IsValid(c); } bool IsValid() const { return m_isValid; } @@ -90,12 +88,9 @@ private: struct IsUniqueVisitor { template - void operator()(Cont const & c, char const * /* name */ = nullptr) + void operator()(Cont const & c, char const * /* name */) { - if (!m_isUnique) - return; - - m_isUnique = (adjacent_find(c.begin(), c.end()) == c.end()); + m_isUnique = m_isUnique && (adjacent_find(c.begin(), c.end()) == c.end()); } void operator()(vector const & c, char const * /* name */ = nullptr) {} @@ -109,12 +104,9 @@ private: struct IsSortedVisitor { template - void operator()(Cont const & c, char const * /* name */ = nullptr) + void operator()(Cont const & c, char const * /* name */) { - if (!m_isSorted) - return; - - m_isSorted = is_sorted(c.begin(), c.end()); + m_isSorted = m_isSorted && is_sorted(c.begin(), c.end()); } void operator()(vector const & c, char const * /* name */ = nullptr) {} @@ -130,7 +122,8 @@ Stop const & FindStopById(vector const & stops, StopId stopId) { ASSERT(is_sorted(stops.cbegin(), stops.cend()), ()); auto s1Id = equal_range(stops.cbegin(), stops.cend(), - Stop(stopId, kInvalidOsmId, kInvalidFeatureId, kInvalidTransferId, {}, m2::PointD(), {})); + Stop(stopId, kInvalidOsmId, kInvalidFeatureId, kInvalidTransferId, + {} /* line ids */, {} /* point */, {} /* title anchors */)); CHECK(s1Id.first != stops.cend(), ("No a stop with id:", stopId, "in stops:", stops)); CHECK_EQUAL(distance(s1Id.first, s1Id.second), 1, ("A stop with id:", stopId, "is not unique in stops:", stops)); return *s1Id.first; @@ -147,7 +140,7 @@ void FillOsmIdToFeatureIdsMap(string const & osmIdToFeatureIdsPath, OsmIdToFeatu string GetMwmPath(string const & mwmDir, string const & countryId) { - return my::JoinFoldersToPath(mwmDir, countryId + DATA_FILE_EXTENSION); + return my::JoinPath(mwmDir, countryId + DATA_FILE_EXTENSION); } template @@ -262,7 +255,7 @@ void GraphData::SerializeToMwm(string const & mwmPath) const LOG(LINFO, (TRANSIT_FILE_TAG, "section is ready. Header:", header)); } -void GraphData::Append(GraphData const & rhs) +void GraphData::AppendTo(GraphData const & rhs) { ::Append(rhs.m_stops, m_stops); ::Append(rhs.m_gates, m_gates); @@ -358,10 +351,10 @@ void GraphData::CalculateBestPedestrianSegments(string const & mwmPath, string c bestSegment.GetFeatureId(), bestSegment.GetSegmentIdx(), bestSegment.IsForward())); } } - catch (MwmIsNotAlifeException const & e) + catch (MwmIsNotAliveException const & e) { - LOG(LERROR, ("Point of a gate belongs to several mwms or doesn't belong to any mwm. Gate:", - gate, e.what())); + LOG(LERROR, ("Point of a gate belongs doesn't belong to any mwm according to " + "packed_polygons.bin. Gate:", gate, e.what())); } } } @@ -425,7 +418,7 @@ void BuildTransit(string const & mwmDir, string const & countryId, "sections.")); NOTIMPLEMENTED(); - string const graphFullPath = my::JoinFoldersToPath(transitDir, countryId + TRANSIT_FILE_EXTENSION); + string const graphFullPath = my::JoinPath(transitDir, countryId + TRANSIT_FILE_EXTENSION); string const mwmPath = GetMwmPath(mwmDir, countryId); OsmIdToFeatureIdsMap mapping; FillOsmIdToFeatureIdsMap(osmIdToFeatureIdsPath, mapping); diff --git a/generator/transit_generator.hpp b/generator/transit_generator.hpp index 7d0de361c4..e7cee82c59 100644 --- a/generator/transit_generator.hpp +++ b/generator/transit_generator.hpp @@ -110,7 +110,7 @@ class GraphData public: void DeserializeFromJson(my::Json const & root, OsmIdToFeatureIdsMap const & mapping); void SerializeToMwm(std::string const & mwmPath) const; - void Append(GraphData const & rhs); + void AppendTo(GraphData const & rhs); void Clear(); bool IsValid() const; @@ -167,7 +167,7 @@ void ProcessGraph(std::string const & mwmPath, std::string const & countryId, /// \param countryId is an mwm name without extension of the processed mwm. /// \param osmIdToFeatureIdsPath is a path to a file with osm id to feature ids mapping. /// \param transitDir a path with slash at the end to directory with json files with transit graphs. -/// It's assumed that the files have name the same with country ids and extension TRANSIT_FILE_EXTENSION. +/// It's assumed that the files have the same name with country ids and extension TRANSIT_FILE_EXTENSION. /// \note An mwm pointed by |mwmPath| should contain: /// * feature geometry /// * index graph (ROUTING_FILE_TAG) diff --git a/routing/index_router.cpp b/routing/index_router.cpp index a76ebd8419..d6506539de 100644 --- a/routing/index_router.cpp +++ b/routing/index_router.cpp @@ -693,7 +693,7 @@ bool IndexRouter::FindBestSegment(m2::PointD const & point, m2::PointD const & d auto const file = platform::CountryFile(m_countryFileFn(point)); MwmSet::MwmHandle handle = m_index.GetMwmHandleByCountryFile(file); if (!handle.IsAlive()) - MYTHROW(MwmIsNotAlifeException, ("Can't get mwm handle for", file)); + MYTHROW(MwmIsNotAliveException, ("Can't get mwm handle for", file)); auto const mwmId = MwmSet::MwmId(handle.GetInfo()); NumMwmId const numMwmId = m_numMwmIds->GetId(file); diff --git a/routing/routing_exceptions.hpp b/routing/routing_exceptions.hpp index b41c78948a..ed9e4ec675 100644 --- a/routing/routing_exceptions.hpp +++ b/routing/routing_exceptions.hpp @@ -6,5 +6,5 @@ namespace routing { DECLARE_EXCEPTION(CorruptedDataException, RootException); DECLARE_EXCEPTION(RoutingException, RootException); -DECLARE_EXCEPTION(MwmIsNotAlifeException, RootException); +DECLARE_EXCEPTION(MwmIsNotAliveException, RootException); } // namespace routing diff --git a/routing_common/transit_types.cpp b/routing_common/transit_types.cpp index d72f85825b..42daae1e30 100644 --- a/routing_common/transit_types.cpp +++ b/routing_common/transit_types.cpp @@ -168,7 +168,7 @@ bool Gate::IsValid() const bool ShapeId::operator<(ShapeId const & rhs) const { if (m_stop1Id != rhs.m_stop1Id) - return rhs.m_stop1Id < m_stop1Id; + return m_stop1Id < rhs.m_stop1Id; return m_stop2Id < rhs.m_stop2Id; }