diff --git a/generator/routing_index_generator.cpp b/generator/routing_index_generator.cpp index 763df9421a..ed6ba8f9e1 100644 --- a/generator/routing_index_generator.cpp +++ b/generator/routing_index_generator.cpp @@ -379,9 +379,9 @@ void CalcCrossMwmTransitions( void CalcCrossMwmTransitionsExperimental( string const & mwmFile, vector const & borders, string const & country, routing::CountryParentNameGetterFn const & /* countryParentNameGetterFn */, + ::transit::experimental::EdgeIdToFeatureId const & edgeIdToFeatureId, vector> & - transitions, - ::transit::experimental::EdgeIdToFeatureId const & edgeIdToFeatureId) + transitions) { try { @@ -445,8 +445,8 @@ void CalcCrossMwmTransitionsExperimental( void CalcCrossMwmTransitionsExperimental( string const & mwmFile, vector const & borders, string const & country, routing::CountryParentNameGetterFn const & countryParentNameGetterFn, - vector> & transitions, - ::transit::experimental::EdgeIdToFeatureId const & edgeIdToFeatureId) + ::transit::experimental::EdgeIdToFeatureId const & edgeIdToFeatureId, + vector> & transitions) { CHECK(false, ("This is dummy specialization and it shouldn't be called.")); } @@ -461,9 +461,9 @@ void CalcCrossMwmConnectors( string const & path, string const & mwmFile, string const & intermediateDir, string const & country, routing::CountryParentNameGetterFn const & countryParentNameGetterFn, string const & mappingFile, + ::transit::experimental::EdgeIdToFeatureId const & edgeIdToFeatureId, vector> & transitions, routing::CrossMwmConnectorPerVehicleType & connectors, - ::transit::experimental::EdgeIdToFeatureId const & edgeIdToFeatureId, bool experimentalTransit = false) { base::Timer timer; @@ -486,7 +486,7 @@ void CalcCrossMwmConnectors( CHECK(!edgeIdToFeatureId.empty(), ("Edge id to feature id must be filled before building cross-mwm transit section.")); CalcCrossMwmTransitionsExperimental(mwmFile, borders, country, countryParentNameGetterFn, - transitions, edgeIdToFeatureId); + edgeIdToFeatureId, transitions); } else { @@ -709,7 +709,7 @@ void BuildRoutingCrossMwmSection(string const & path, string const & mwmFile, vector> transitions; CalcCrossMwmConnectors(path, mwmFile, intermediateDir, country, countryParentNameGetterFn, - osmToFeatureFile, transitions, connectors, {} /*edgeIdToFeatureId */); + osmToFeatureFile, {} /*edgeIdToFeatureId */, transitions, connectors); // We use leaps for cars only. To use leaps for other vehicle types add weights generation // here and change WorldGraph mode selection rule in IndexRouter::CalculateSubroute. @@ -731,8 +731,8 @@ void BuildTransitCrossMwmSection( vector> transitions; CalcCrossMwmConnectors(path, mwmFile, "" /* intermediateDir */, country, - countryParentNameGetterFn, "" /* mapping file */, transitions, connectors, - edgeIdToFeatureId, experimentalTransit); + countryParentNameGetterFn, "" /* mapping file */, edgeIdToFeatureId, + transitions, connectors, experimentalTransit); CHECK(connectors[static_cast(VehicleType::Pedestrian)].IsEmpty(), ()); CHECK(connectors[static_cast(VehicleType::Bicycle)].IsEmpty(), ()); diff --git a/transit/experimental/transit_data.cpp b/transit/experimental/transit_data.cpp index 880fe37e03..8a7525a054 100644 --- a/transit/experimental/transit_data.cpp +++ b/transit/experimental/transit_data.cpp @@ -408,7 +408,7 @@ void Read(base::Json const & obj, std::vector & shapes) shapes.emplace_back(id, polyline); } -void Read(base::Json const & obj, std::vector & edges) +void Read(base::Json const & obj, std::vector & edges, EdgeIdToFeatureId & edgeFeatureIds) { TransitId stopFrom = kInvalidTransitId; TransitId stopTo = kInvalidTransitId; @@ -423,6 +423,10 @@ void Read(base::Json const & obj, std::vector & edges) bool isTransfer = false; FromJSONObjectOptionalField(obj.get(), "line_id", lineId); + + TransitId featureId = kInvalidFeatureId; + FromJSONObjectOptionalField(obj.get(), "feature_id", featureId); + if (lineId == 0) { lineId = kInvalidTransitId; @@ -434,6 +438,7 @@ void Read(base::Json const & obj, std::vector & edges) } edges.emplace_back(stopFrom, stopTo, weight, lineId, isTransfer, shapeLink); + edgeFeatureIds.emplace(EdgeId(stopFrom, stopTo, lineId), featureId); } void Read(base::Json const & obj, std::vector & transfers) @@ -501,8 +506,8 @@ void TransitData::DeserializeFromJson(std::string const & dirWithJsons, ReadData(base::JoinPath(dirWithJsons, kLinesMetadataFile), m_linesMetadata); ReadData(base::JoinPath(dirWithJsons, kStopsFile), m_stops, mapping); ReadData(base::JoinPath(dirWithJsons, kShapesFile), m_shapes); - ReadData(base::JoinPath(dirWithJsons, kEdgesFile), m_edges); - ReadData(base::JoinPath(dirWithJsons, kEdgesTransferFile), m_edges); + ReadData(base::JoinPath(dirWithJsons, kEdgesFile), m_edges, m_edgeFeatureIds); + ReadData(base::JoinPath(dirWithJsons, kEdgesTransferFile), m_edges, m_edgeFeatureIds); ReadData(base::JoinPath(dirWithJsons, kTransfersFile), m_transfers); ReadData(base::JoinPath(dirWithJsons, kGatesFile), m_gates, mapping); } diff --git a/transit/experimental/transit_data.hpp b/transit/experimental/transit_data.hpp index cbb3f544a2..d691a08b01 100644 --- a/transit/experimental/transit_data.hpp +++ b/transit/experimental/transit_data.hpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include "3party/jansson/myjansson.hpp" @@ -26,7 +27,7 @@ namespace transit namespace experimental { using OsmIdToFeatureIdsMap = std::map>; - +using EdgeIdToFeatureId = std::unordered_map; // Functions for parsing one line of line-by-line json and creating corresponding item in container. void Read(base::Json const & obj, std::vector & networks); void Read(base::Json const & obj, std::vector & routes); @@ -34,7 +35,7 @@ void Read(base::Json const & obj, std::vector & lines); void Read(base::Json const & obj, std::vector & linesMetadata); void Read(base::Json const & obj, std::vector & stops, OsmIdToFeatureIdsMap const & mapping); void Read(base::Json const & obj, std::vector & shapes); -void Read(base::Json const & obj, std::vector & edges); +void Read(base::Json const & obj, std::vector & edges, EdgeIdToFeatureId & edgeFeatureIds); void Read(base::Json const & obj, std::vector & transfers); void Read(base::Json const & obj, std::vector & gates, OsmIdToFeatureIdsMap const & mapping); @@ -69,6 +70,8 @@ public: std::vector const & GetRoutes() const { return m_routes; } std::vector const & GetNetworks() const { return m_networks; } + EdgeIdToFeatureId const & GetEdgeIdToFeatureId() const { return m_edgeFeatureIds; } + private: DECLARE_VISITOR_AND_DEBUG_PRINT(TransitData, visitor(m_stops, "stops"), visitor(m_gates, "gates"), visitor(m_edges, "edges"), visitor(m_transfers, "transfers"), @@ -106,6 +109,8 @@ private: std::vector m_lines; std::vector m_linesMetadata; std::vector m_shapes; + + EdgeIdToFeatureId m_edgeFeatureIds; }; } // namespace experimental } // namespace transit diff --git a/transit/transit_entities.hpp b/transit/transit_entities.hpp index 5bb8e9ff1b..1e53674f70 100644 --- a/transit/transit_entities.hpp +++ b/transit/transit_entities.hpp @@ -152,7 +152,7 @@ struct EdgeData } explicit EdgeData(EdgeWeight const & weight) : m_weight(weight) {} - + ShapeLink m_shapeLink; EdgeWeight m_weight = 0; diff --git a/transit/transit_experimental_tests/parse_transit_from_json_tests.cpp b/transit/transit_experimental_tests/parse_transit_from_json_tests.cpp index 029c65eefa..075ea916e1 100644 --- a/transit/transit_experimental_tests/parse_transit_from_json_tests.cpp +++ b/transit/transit_experimental_tests/parse_transit_from_json_tests.cpp @@ -252,8 +252,9 @@ UNIT_TEST(ReadJson_Edge) ShapeLink(kInvalidTransitId /* shapeId */, 0 /* startIndex */, 0 /* endIndex */))}; std::vector edgesFact; + EdgeIdToFeatureId edgeIdToFeatureId; - FillContainer(lineByLineJson, edgesFact); + FillContainer(lineByLineJson, edgesFact, edgeIdToFeatureId); TestEqual(edgesFact, edgesPlan); } diff --git a/transit/world_feed/world_feed.cpp b/transit/world_feed/world_feed.cpp index 8f3296a50f..9370a13f13 100644 --- a/transit/world_feed/world_feed.cpp +++ b/transit/world_feed/world_feed.cpp @@ -347,12 +347,6 @@ TransitId IdGenerator::MakeId(const std::string & hash) return it->second; } -void IdGenerator::SetCurId(TransitId curId) -{ - if (curId > m_curId) - m_curId = curId; -} - void IdGenerator::Save() { LOG(LINFO, ("Started saving", m_hashToId.size(), "mappings to", m_idMappingPath)); diff --git a/transit/world_feed/world_feed.hpp b/transit/world_feed/world_feed.hpp index 97dbe28ad3..1fd86b37c1 100644 --- a/transit/world_feed/world_feed.hpp +++ b/transit/world_feed/world_feed.hpp @@ -34,7 +34,6 @@ public: void Save(); TransitId MakeId(std::string const & hash); - void SetCurId(TransitId curId); private: std::unordered_map m_hashToId;