#ifndef EXTRACTION_RELATION_HPP #define EXTRACTION_RELATION_HPP #include #include #include #include #include namespace osrm { namespace extractor { struct ExtractionRelation { using AttributesMap = std::unordered_map; using OsmIDTyped = std::pair; struct OsmIDTypedHash { std::size_t operator()(const OsmIDTyped &id) const { return id.first ^ (static_cast(id.second) << 56); } }; ExtractionRelation() : is_restriction(false) {} void clear() { is_restriction = false; values.clear(); } bool IsRestriction() const { return is_restriction; } AttributesMap &GetMember(const osmium::RelationMember &member) { return values[OsmIDTyped(member.ref(), member.type())]; } bool is_restriction; std::unordered_map values; }; // It contains data of all parsed relations for each node/way element class ExtractionRelationContainer { public: using AttributesMap = ExtractionRelation::AttributesMap; using OsmIDTyped = ExtractionRelation::OsmIDTyped; using RelationList = std::vector; void AddRelation(const ExtractionRelation &rel) { BOOST_ASSERT(!rel.is_restriction); for (auto it : rel.values) data[it.first].push_back(it.second); } const RelationList &Get(const OsmIDTyped &id) const { const auto it = data.find(id); if (it != data.end()) return it->second; static RelationList empty; return empty; } private: std::unordered_map data; }; } // namespace extractor } // namespace osrm #endif // EXTRACTION_RELATION_HPP