diff --git a/generator/routing_helpers.cpp b/generator/routing_helpers.cpp index 62570d0823..13479e28d9 100644 --- a/generator/routing_helpers.cpp +++ b/generator/routing_helpers.cpp @@ -41,14 +41,14 @@ bool ParseOsmIdToFeatureIdMapping(string const & osmIdsToFeatureIdPath, } bool ParseFeatureIdToOsmIdMapping(string const & osmIdsToFeatureIdPath, - map & featureIdToOsmId) + map & featureIdToOsmId) { featureIdToOsmId.clear(); bool idsAreOk = true; bool const readSuccess = - ForEachRoadFromFile(osmIdsToFeatureIdPath, [&](uint32_t featureId, osm::Id osmId) { - auto const emplaced = featureIdToOsmId.emplace(featureId, connector::OsmId(osmId.OsmId())); + ForEachRoadFromFile(osmIdsToFeatureIdPath, [&](uint32_t featureId, osm::Id const & osmId) { + auto const emplaced = featureIdToOsmId.emplace(featureId, osmId); if (emplaced.second) return; diff --git a/generator/routing_helpers.hpp b/generator/routing_helpers.hpp index 8e4a2bbbce..b92da45fa5 100644 --- a/generator/routing_helpers.hpp +++ b/generator/routing_helpers.hpp @@ -34,5 +34,5 @@ void AddFeatureId(osm::Id osmId, uint32_t featureId, std::map bool ParseOsmIdToFeatureIdMapping(std::string const & osmIdsToFeatureIdPath, std::map & osmIdToFeatureId); bool ParseFeatureIdToOsmIdMapping(std::string const & osmIdsToFeatureIdPath, - std::map & featureIdToOsmId); + std::map & featureIdToOsmId); } // namespace routing diff --git a/generator/routing_index_generator.cpp b/generator/routing_index_generator.cpp index 16afbb3073..82310d1168 100644 --- a/generator/routing_index_generator.cpp +++ b/generator/routing_index_generator.cpp @@ -215,10 +215,10 @@ double CalcDistanceAlongTheBorders(vector const & borders, void CalcCrossMwmTransitions( string const & mwmFile, string const & mappingFile, vector const & borders, string const & country, CountryParentNameGetterFn const & countryParentNameGetterFn, - vector> & transitions) + vector> & transitions) { VehicleMaskBuilder const maskMaker(country, countryParentNameGetterFn); - map featureIdToOsmId; + map featureIdToOsmId; CHECK(ParseFeatureIdToOsmIdMapping(mappingFile, featureIdToOsmId), ("Can't parse feature id to osm id mapping. File:", mappingFile)); @@ -455,7 +455,7 @@ void BuildRoutingCrossMwmSection(string const & path, string const & mwmFile, string const & osmToFeatureFile, bool disableCrossMwmProgress) { LOG(LINFO, ("Building cross mwm section for", country)); - using CrossMwmId = connector::OsmId; + using CrossMwmId = osm::Id; CrossMwmConnectorPerVehicleType connectors; vector> transitions; diff --git a/routing/cross_mwm_connector.hpp b/routing/cross_mwm_connector.hpp index a678db9467..ae0b5e3c25 100644 --- a/routing/cross_mwm_connector.hpp +++ b/routing/cross_mwm_connector.hpp @@ -253,7 +253,7 @@ private: uint32_t m_enterIdx = 0; uint32_t m_exitIdx = 0; - CrossMwmIdInner m_crossMwmId = {}; + CrossMwmIdInner m_crossMwmId = CrossMwmIdInner(); // Endpoints of transition segment. // m_backPoint = points[segmentIdx] // m_frontPoint = points[segmentIdx + 1] diff --git a/routing/cross_mwm_connector_serialization.hpp b/routing/cross_mwm_connector_serialization.hpp index 574cebf390..0acc698013 100644 --- a/routing/cross_mwm_connector_serialization.hpp +++ b/routing/cross_mwm_connector_serialization.hpp @@ -17,6 +17,7 @@ #include "coding/writer.hpp" #include "base/checked_cast.hpp" +#include "base/osm_id.hpp" #include #include @@ -75,9 +76,9 @@ public: } template - void WriteCrossMwmId(connector::OsmId const & id, uint8_t bits, BitWriter & w) const + void WriteCrossMwmId(osm::Id const & id, uint8_t bits, BitWriter & w) const { - w.WriteAtMost64Bits(id.Get(), bits); + w.WriteAtMost64Bits(id.EncodedId(), bits); } template @@ -117,9 +118,9 @@ public: template void ReadCrossMwmId(uint8_t bitsPerCrossMwmId, BitReader & reader, - connector::OsmId & readed) + osm::Id & readed) { - readed.Set(reader.ReadAtMost64Bits(bitsPerCrossMwmId)); + readed = osm::Id(reader.ReadAtMost64Bits(bitsPerCrossMwmId)); } template @@ -148,7 +149,7 @@ public: VehicleMask GetOneWayMask() const { return m_oneWayMask; } private: - CrossMwmId m_crossMwmId = {}; + CrossMwmId m_crossMwmId = CrossMwmId(); uint32_t m_featureId = 0; uint32_t m_segmentIdx = 0; m2::PointD m_backPoint = m2::PointD::Zero(); @@ -432,13 +433,13 @@ private: }; static uint32_t CalcBitsPerCrossMwmId( - std::vector> const & transitions) + std::vector> const & transitions) { - connector::OsmId osmId(0ULL); - for (Transition const & transition : transitions) + osm::Id osmId(0ULL); + for (Transition const & transition : transitions) osmId = std::max(osmId, transition.GetCrossMwmId()); - return bits::NumUsedBits(osmId.Get()); + return bits::NumUsedBits(osmId.OsmId()); } static uint32_t CalcBitsPerCrossMwmId( diff --git a/routing/cross_mwm_graph.hpp b/routing/cross_mwm_graph.hpp index 89036fae1b..c2228b0606 100644 --- a/routing/cross_mwm_graph.hpp +++ b/routing/cross_mwm_graph.hpp @@ -14,6 +14,7 @@ #include "geometry/tree4d.hpp" #include "base/math.hpp" +#include "base/osm_id.hpp" #include #include @@ -157,7 +158,7 @@ private: CourntryRectFn const & m_countryRectFn; // @todo(@tatiana-kondakova) For the time being CrossMwmGraph is implemented for osm id. // To add cross mwm for transit graph it's necessary to add CrossMwmIndexGraph. - CrossMwmIndexGraph m_crossMwmIndexGraph; + CrossMwmIndexGraph m_crossMwmIndexGraph; CrossMwmOsrmGraph m_crossMwmOsrmGraph; }; diff --git a/routing/cross_mwm_ids.hpp b/routing/cross_mwm_ids.hpp index 1fae058e6c..49c0085bd0 100644 --- a/routing/cross_mwm_ids.hpp +++ b/routing/cross_mwm_ids.hpp @@ -3,6 +3,7 @@ #include "routing_common/transit_types.hpp" #include "base/newtype.hpp" +#include "base/osm_id.hpp" #include "base/visitor.hpp" #include @@ -12,11 +13,6 @@ namespace routing { namespace connector { -// Identifier to find a border edge in neighbouring mwm while cross mwm transition -// for pedestrian, bicycle and car routing. -NEWTYPE(uint64_t, OsmId); -NEWTYPE_SIMPLE_OUTPUT(OsmId); - // Identifier to find a border edge in neighbouring mwm while cross mwm transition // for transit routing. struct TransitId @@ -57,9 +53,9 @@ struct TransitId struct HashKey { - size_t operator()(OsmId const & key) const + size_t operator()(osm::Id const & key) const { - return std::hash()(key.Get()); + return osm::HashId()(key); } size_t operator()(TransitId const & key) const diff --git a/routing/routing_tests/cross_mwm_connector_test.cpp b/routing/routing_tests/cross_mwm_connector_test.cpp index dc3057ca9a..b0cc7345e1 100644 --- a/routing/routing_tests/cross_mwm_connector_test.cpp +++ b/routing/routing_tests/cross_mwm_connector_test.cpp @@ -5,6 +5,8 @@ #include "coding/writer.hpp" +#include "base/osm_id.hpp" + using namespace routing; using namespace routing::connector; using namespace std; @@ -239,7 +241,7 @@ void TestSerialization(vector> const transitions = { + vector> const transitions = { /* osmId featureId, segmentIdx, roadMask, oneWayMask, forwardIsEnter, backPoint, frontPoint */ - {OsmId(100ULL), 10, 1, kCarMask, kCarMask, true, m2::PointD(1.1, 1.2), + {osm::Id(100ULL), 10, 1, kCarMask, kCarMask, true, m2::PointD(1.1, 1.2), m2::PointD(1.3, 1.4)}, - {OsmId(200ULL), 20, 2, kCarMask, 0, true, m2::PointD(2.1, 2.2), m2::PointD(2.3, 2.4)}, - {OsmId(300ULL), 30, 3, kPedestrianMask, kCarMask, true, m2::PointD(3.1, 3.2), + {osm::Id(200ULL), 20, 2, kCarMask, 0, true, m2::PointD(2.1, 2.2), m2::PointD(2.3, 2.4)}, + {osm::Id(300ULL), 30, 3, kPedestrianMask, kCarMask, true, m2::PointD(3.1, 3.2), m2::PointD(3.3, 3.4)}}; TestSerialization(transitions); } @@ -377,7 +379,7 @@ UNIT_TEST(Serialization) UNIT_TEST(WeightsSerialization) { - TestWeightsSerialization(); + TestWeightsSerialization(); TestWeightsSerialization(); } } // namespace routing_test