diff options
author | Добрый Ээх <bukharaev@gmail.com> | 2016-12-02 13:13:01 +0300 |
---|---|---|
committer | Добрый Ээх <bukharaev@gmail.com> | 2016-12-07 12:31:39 +0300 |
commit | e02d12f4b6f2a045704f0ef3b7d9337c72bee217 (patch) | |
tree | 6f5b943fe8060416e29b8d2dccfcf7649f225990 /generator | |
parent | 16e93e3951349fa662adab754b21d810f19d7340 (diff) |
index graph: serialize by vehicle sections
Diffstat (limited to 'generator')
-rw-r--r-- | generator/routing_index_generator.cpp | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/generator/routing_index_generator.cpp b/generator/routing_index_generator.cpp index 00ca430b67..eb7e13e382 100644 --- a/generator/routing_index_generator.cpp +++ b/generator/routing_index_generator.cpp @@ -5,6 +5,7 @@ #include "routing/index_graph.hpp" #include "routing/index_graph_serializer.hpp" #include "routing/pedestrian_model.hpp" +#include "routing/vehicle_mask.hpp" #include "indexer/feature.hpp" #include "indexer/feature_processor.hpp" @@ -17,7 +18,6 @@ #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; @@ -57,17 +57,16 @@ public: graph.Import(joints); } - unordered_set<uint32_t> const & GetCarFeatureIds() const { return m_carFeatureIds; } + unordered_map<uint32_t, VehicleMask> const & GetMasks() const { return m_masks; } private: void ProcessFeature(FeatureType const & f, uint32_t id) { - if (!IsRoad(f)) + VehicleMask const mask = CalcVehicleMask(f); + if (!mask) return; - if (m_carModel->IsRoad(f)) - m_carFeatureIds.insert(id); - + m_masks[id] = mask; f.ParseGeometry(FeatureType::BEST_GEOMETRY); for (size_t i = 0; i < f.GetPointsCount(); ++i) @@ -77,16 +76,24 @@ private: } } - bool IsRoad(FeatureType const & f) const + VehicleMask CalcVehicleMask(FeatureType const & f) { - return m_pedestrianModel->IsRoad(f) || m_bicycleModel->IsRoad(f) || m_carModel->IsRoad(f); + VehicleMask mask = 0; + if (m_pedestrianModel->IsRoad(f)) + mask |= kPedestrianMask; + if (m_bicycleModel->IsRoad(f)) + mask |= kBicycleMask; + if (m_carModel->IsRoad(f)) + mask |= kCarMask; + + return mask; } 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; + unordered_map<uint32_t, VehicleMask> m_masks; }; } // namespace @@ -107,7 +114,7 @@ bool BuildRoutingIndex(string const & filename, string const & country) FileWriter writer = cont.GetWriter(ROUTING_FILE_TAG); auto const startPos = writer.Pos(); - IndexGraphSerializer::Serialize(graph, processor.GetCarFeatureIds(), writer); + IndexGraphSerializer::Serialize(graph, processor.GetMasks(), writer); auto const sectionSize = writer.Pos() - startPos; LOG(LINFO, ("Routing section created:", sectionSize, "bytes,", graph.GetNumRoads(), "roads,", |