From bab6d988778f9d0e845df3ba172dfa2e82cf6927 Mon Sep 17 00:00:00 2001 From: Vladimir Byko-Ianko Date: Wed, 15 Nov 2017 18:00:25 +0300 Subject: [PATCH] Getting ready generator_tool and generator for transit_cross_mwm section. --- defines.hpp | 1 + generator/generator_tool/generator_tool.cpp | 28 +++++++++++++-------- generator/routing_helpers.cpp | 4 +-- generator/routing_helpers.hpp | 2 +- generator/routing_index_generator.cpp | 26 ++++++++++++------- 5 files changed, 38 insertions(+), 23 deletions(-) diff --git a/defines.hpp b/defines.hpp index 5bac0f9a4f..358cf9136d 100644 --- a/defines.hpp +++ b/defines.hpp @@ -42,6 +42,7 @@ #define SEARCH_TOKENS_FILE_TAG "addrtags" #define TRAFFIC_KEYS_FILE_TAG "traffic" #define TRANSIT_FILE_TAG "transit" +#define TRANSIT_CROSS_MWM_FILE_TAG "transit_cross_mwm" #define UGC_FILE_TAG "ugc" #define ROUTING_MATRIX_FILE_TAG "mercedes" diff --git a/generator/generator_tool/generator_tool.cpp b/generator/generator_tool/generator_tool.cpp index 32717544f6..06f5592585 100644 --- a/generator/generator_tool/generator_tool.cpp +++ b/generator/generator_tool/generator_tool.cpp @@ -90,6 +90,7 @@ DEFINE_bool(make_cross_section, false, "Make cross section in routing file for c DEFINE_bool(make_routing_index, false, "Make sections with the routing information."); DEFINE_bool(make_cross_mwm, false, "Make section for cross mwm routing (for dynamic indexed routing)."); +DEFINE_bool(make_transit_cross_mwm, false, "Make section for cross mwm transit routing."); DEFINE_bool(disable_cross_mwm_progress, false, "Disable log of cross mwm section building progress."); DEFINE_string(srtm_path, "", @@ -191,8 +192,8 @@ int main(int argc, char ** argv) FLAGS_generate_index || FLAGS_generate_search_index || FLAGS_generate_cities_boundaries || FLAGS_calc_statistics || FLAGS_type_statistics || FLAGS_dump_types || FLAGS_dump_prefixes || FLAGS_dump_feature_names != "" || FLAGS_check_mwm || FLAGS_srtm_path != "" || - FLAGS_make_routing_index || FLAGS_make_cross_mwm || FLAGS_generate_traffic_keys || - FLAGS_transit_path != "" || FLAGS_ugc_data != "") + FLAGS_make_routing_index || FLAGS_make_cross_mwm || FLAGS_make_transit_cross_mwm || + FLAGS_generate_traffic_keys || FLAGS_transit_path != "" || FLAGS_ugc_data != "") { classificator::Load(); classif().SortClassificator(); @@ -200,11 +201,8 @@ int main(int argc, char ** argv) // Load mwm tree only if we need it std::unique_ptr countryParentGetter; - if (FLAGS_make_routing_index || FLAGS_make_cross_mwm) - { - countryParentGetter = - make_unique(); - } + if (FLAGS_make_routing_index || FLAGS_make_cross_mwm || FLAGS_make_transit_cross_mwm) + countryParentGetter = make_unique(); // Generate dat file. if (FLAGS_generate_features || FLAGS_make_coasts) @@ -343,7 +341,7 @@ int main(int argc, char ** argv) routing::BuildRoutingIndex(datFile, country, *countryParentGetter); } - if (FLAGS_make_cross_mwm) + if (FLAGS_make_cross_mwm || FLAGS_make_transit_cross_mwm) { if (!countryParentGetter) { @@ -353,9 +351,17 @@ int main(int argc, char ** argv) return -1; } - if (!routing::BuildCrossMwmSection(path, datFile, country, *countryParentGetter, - osmToFeatureFilename, FLAGS_disable_cross_mwm_progress)) - LOG(LCRITICAL, ("Error generating cross mwm section.")); + if (FLAGS_make_cross_mwm) + { + CHECK(routing::BuildCrossMwmSection(path, datFile, country, *countryParentGetter, + osmToFeatureFilename, FLAGS_disable_cross_mwm_progress), + ("Error generating cross mwm section.", path, datFile, country)); + } + + if (FLAGS_make_transit_cross_mwm) + { + ; // @todo(bykoianko) It's necessary to put here serialization of transit cross mwm section. + } } if (!FLAGS_ugc_data.empty()) diff --git a/generator/routing_helpers.cpp b/generator/routing_helpers.cpp index cb30c859de..6e6d1cf983 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, osmId); + auto const emplaced = featureIdToOsmId.emplace(featureId, osmId.OsmId()); if (emplaced.second) return; diff --git a/generator/routing_helpers.hpp b/generator/routing_helpers.hpp index 54f6057362..c9b5223a2e 100644 --- a/generator/routing_helpers.hpp +++ b/generator/routing_helpers.hpp @@ -31,5 +31,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 685dd5b05d..613506fb78 100644 --- a/generator/routing_index_generator.cpp +++ b/generator/routing_index_generator.cpp @@ -209,7 +209,7 @@ double CalcDistanceAlongTheBorders(vector const & borders, void CalcCrossMwmTransitions(string const & path, string const & mwmFile, string const & country, CountryParentNameGetterFn const & countryParentNameGetterFn, - map const & featureIdToOsmId, + map const & featureIdToOsmId, vector & transitions, CrossMwmConnectorPerVehicleType & connectors) { @@ -232,7 +232,7 @@ void CalcCrossMwmTransitions(string const & path, string const & mwmFile, string auto osmIt = featureIdToOsmId.find(featureId); CHECK(osmIt != featureIdToOsmId.end(), ("Can't find osm id for feature id", featureId)); - uint64_t const osmId = osmIt->second.OsmId(); + uint64_t const osmId = osmIt->second; bool prevPointIn = m2::RegionsContain(borders, f.GetPoint(0)); @@ -378,14 +378,8 @@ bool BuildRoutingIndex(string const & filename, string const & country, bool BuildCrossMwmSection(string const & path, string const & mwmFile, string const & country, CountryParentNameGetterFn const & countryParentNameGetterFn, - string const & osmToFeatureFile, bool disableCrossMwmProgress) + map const & featureIdToOsmId, bool disableCrossMwmProgress) { - LOG(LINFO, ("Building cross mwm section for", country)); - - map featureIdToOsmId; - if (!ParseFeatureIdToOsmIdMapping(osmToFeatureFile, featureIdToOsmId)) - return false; - CrossMwmConnectorPerVehicleType connectors; vector transitions; @@ -415,4 +409,18 @@ bool BuildCrossMwmSection(string const & path, string const & mwmFile, string co LOG(LINFO, ("Cross mwm section generated, size:", sectionSize, "bytes")); return true; } + +bool BuildCrossMwmSection(string const & path, string const & mwmFile, string const & country, + CountryParentNameGetterFn const & countryParentNameGetterFn, + string const & osmToFeatureFile, bool disableCrossMwmProgress) +{ + LOG(LINFO, ("Building cross mwm section for", country)); + + map featureIdToOsmId; + if (!ParseFeatureIdToOsmIdMapping(osmToFeatureFile, featureIdToOsmId)) + return false; + + return BuildCrossMwmSection(path, mwmFile, country, countryParentNameGetterFn, featureIdToOsmId, + disableCrossMwmProgress); +} } // namespace routing