diff options
author | Добрый Ээх <bukharaev@gmail.com> | 2016-12-01 11:48:33 +0300 |
---|---|---|
committer | Добрый Ээх <bukharaev@gmail.com> | 2016-12-07 12:31:39 +0300 |
commit | 16e93e3951349fa662adab754b21d810f19d7340 (patch) | |
tree | d48d3b51005d04a44af698be308d588416dd9a35 /generator | |
parent | e86680646f078572655373c9591d294f952aba28 (diff) |
index graph serializer: car x2 optimization
Diffstat (limited to 'generator')
-rw-r--r-- | generator/generator_tool/generator_tool.cpp | 2 | ||||
-rw-r--r-- | generator/routing_index_generator.cpp | 38 | ||||
-rw-r--r-- | generator/routing_index_generator.hpp | 2 |
3 files changed, 35 insertions, 7 deletions
diff --git a/generator/generator_tool/generator_tool.cpp b/generator/generator_tool/generator_tool.cpp index 6e54cbb911..a44271cf01 100644 --- a/generator/generator_tool/generator_tool.cpp +++ b/generator/generator_tool/generator_tool.cpp @@ -240,7 +240,7 @@ int main(int argc, char ** argv) routing::BuildRoadAltitudes(datFile, FLAGS_srtm_path); if (FLAGS_generate_routing) - routing::BuildRoutingIndex(datFile); + routing::BuildRoutingIndex(datFile, country); if (FLAGS_generate_restrictions) { diff --git a/generator/routing_index_generator.cpp b/generator/routing_index_generator.cpp index e806f74e00..00ca430b67 100644 --- a/generator/routing_index_generator.cpp +++ b/generator/routing_index_generator.cpp @@ -1,8 +1,10 @@ #include "generator/routing_index_generator.hpp" +#include "routing/bicycle_model.hpp" +#include "routing/car_model.hpp" #include "routing/index_graph.hpp" #include "routing/index_graph_serializer.hpp" -#include "routing/routing_helpers.hpp" +#include "routing/pedestrian_model.hpp" #include "indexer/feature.hpp" #include "indexer/feature_processor.hpp" @@ -13,7 +15,9 @@ #include "base/logging.hpp" #include "std/bind.hpp" +#include "std/shared_ptr.hpp" #include "std/unordered_map.hpp" +#include "std/unordered_set.hpp" #include "std/vector.hpp" using namespace feature; @@ -25,6 +29,16 @@ namespace class Processor final { public: + Processor(string const & country) + : m_pedestrianModel(PedestrianModelFactory().GetVehicleModelForCountry(country)) + , m_bicycleModel(BicycleModelFactory().GetVehicleModelForCountry(country)) + , m_carModel(CarModelFactory().GetVehicleModelForCountry(country)) + { + CHECK(m_pedestrianModel, ()); + CHECK(m_bicycleModel, ()); + CHECK(m_carModel, ()); + } + void ProcessAllFeatures(string const & filename) { feature::ForEachFromDat(filename, bind(&Processor::ProcessFeature, this, _1, _2)); @@ -43,12 +57,17 @@ public: graph.Import(joints); } + unordered_set<uint32_t> const & GetCarFeatureIds() const { return m_carFeatureIds; } + private: void ProcessFeature(FeatureType const & f, uint32_t id) { - if (!IsRoad(feature::TypesHolder(f))) + if (!IsRoad(f)) return; + if (m_carModel->IsRoad(f)) + m_carFeatureIds.insert(id); + f.ParseGeometry(FeatureType::BEST_GEOMETRY); for (size_t i = 0; i < f.GetPointsCount(); ++i) @@ -58,18 +77,27 @@ private: } } + bool IsRoad(FeatureType const & f) const + { + return m_pedestrianModel->IsRoad(f) || m_bicycleModel->IsRoad(f) || m_carModel->IsRoad(f); + } + + shared_ptr<IVehicleModel> m_pedestrianModel; + shared_ptr<IVehicleModel> m_bicycleModel; + shared_ptr<IVehicleModel> m_carModel; unordered_map<uint64_t, Joint> m_posToJoint; + unordered_set<uint32_t> m_carFeatureIds; }; } // namespace namespace routing { -bool BuildRoutingIndex(string const & filename) +bool BuildRoutingIndex(string const & filename, string const & country) { LOG(LINFO, ("Building routing index for", filename)); try { - Processor processor; + Processor processor(country); processor.ProcessAllFeatures(filename); IndexGraph graph; @@ -79,7 +107,7 @@ bool BuildRoutingIndex(string const & filename) FileWriter writer = cont.GetWriter(ROUTING_FILE_TAG); auto const startPos = writer.Pos(); - IndexGraphSerializer::Serialize(graph, writer); + IndexGraphSerializer::Serialize(graph, processor.GetCarFeatureIds(), writer); auto const sectionSize = writer.Pos() - startPos; LOG(LINFO, ("Routing section created:", sectionSize, "bytes,", graph.GetNumRoads(), "roads,", diff --git a/generator/routing_index_generator.hpp b/generator/routing_index_generator.hpp index 439157270a..f5158c904d 100644 --- a/generator/routing_index_generator.hpp +++ b/generator/routing_index_generator.hpp @@ -4,5 +4,5 @@ namespace routing { -bool BuildRoutingIndex(string const & filename); +bool BuildRoutingIndex(string const & filename, string const & country); } // namespace routing |