@@ -20,45 +20,34 @@ struct ExtractionRelation
2020{
2121 class OsmIDTyped
2222 {
23- public:
24- OsmIDTyped (osmium::object_id_type _id, osmium::item_type _type)
25- : id(_id), type(_type)
26- {
27- }
23+ public:
24+ OsmIDTyped (osmium::object_id_type _id, osmium::item_type _type) : id(_id), type(_type) {}
2825
2926 std::uint64_t GetID () const { return std::uint64_t (id); }
3027 osmium::item_type GetType () const { return type; }
3128
32- std::uint64_t Hash () const
33- {
34- return id ^ (static_cast <std::uint64_t >(type) << 56 );
35- }
29+ std::uint64_t Hash () const { return id ^ (static_cast <std::uint64_t >(type) << 56 ); }
3630
37- private:
31+ private:
3832 osmium::object_id_type id;
3933 osmium::item_type type;
4034 };
4135
4236 using AttributesList = std::vector<std::pair<std::string, std::string>>;
4337 using MembersRolesList = std::vector<std::pair<std::uint64_t , std::string>>;
4438
45- explicit ExtractionRelation (const OsmIDTyped & _id)
46- : id(_id)
47- {
48- }
39+ explicit ExtractionRelation (const OsmIDTyped &_id) : id(_id) {}
4940
5041 void Clear ()
5142 {
5243 attributes.clear ();
5344 members_role.clear ();
5445 }
5546
56- const char * GetAttr (const std::string & attr) const
47+ const char *GetAttr (const std::string &attr) const
5748 {
5849 auto it = std::lower_bound (
59- attributes.begin (),
60- attributes.end (),
61- std::make_pair (attr, std::string ()));
50+ attributes.begin (), attributes.end (), std::make_pair (attr, std::string ()));
6251
6352 if (it != attributes.end () && (*it).first == attr)
6453 return (*it).second .c_str ();
@@ -72,18 +61,16 @@ struct ExtractionRelation
7261 std::sort (members_role.begin (), members_role.end ());
7362 }
7463
75- void AddMember (const OsmIDTyped & member_id, const char * role)
64+ void AddMember (const OsmIDTyped &member_id, const char *role)
7665 {
7766 members_role.emplace_back (std::make_pair (member_id.Hash (), std::string (role)));
7867 }
7968
80- const char * GetRole (const OsmIDTyped & member_id) const
69+ const char *GetRole (const OsmIDTyped &member_id) const
8170 {
8271 const auto hash = member_id.Hash ();
8372 auto it = std::lower_bound (
84- members_role.begin (),
85- members_role.end (),
86- std::make_pair (hash, std::string ()));
73+ members_role.begin (), members_role.end (), std::make_pair (hash, std::string ()));
8774
8875 if (it != members_role.end () && (*it).first == hash)
8976 return (*it).second .c_str ();
@@ -106,15 +93,15 @@ class ExtractionRelationContainer
10693 using RelationIDList = std::vector<ExtractionRelation::OsmIDTyped>;
10794 using RelationRefMap = std::unordered_map<std::uint64_t , RelationIDList>;
10895
109- void AddRelation (ExtractionRelation && rel)
96+ void AddRelation (ExtractionRelation &&rel)
11097 {
11198 rel.Prepare ();
11299
113100 BOOST_ASSERT (relations_data.find (rel.id .GetID ()) == relations_data.end ());
114101 relations_data.insert (std::make_pair (rel.id .GetID (), std::move (rel)));
115102 }
116103
117- void AddRelationMember (const OsmIDTyped & relation_id, const OsmIDTyped & member_id)
104+ void AddRelationMember (const OsmIDTyped &relation_id, const OsmIDTyped &member_id)
118105 {
119106 switch (member_id.GetType ())
120107 {
@@ -135,7 +122,7 @@ class ExtractionRelationContainer
135122 };
136123 }
137124
138- void Merge (ExtractionRelationContainer && other)
125+ void Merge (ExtractionRelationContainer &&other)
139126 {
140127 for (auto it : other.relations_data )
141128 {
@@ -144,11 +131,10 @@ class ExtractionRelationContainer
144131 (void )res; // prevent unused warning in release
145132 }
146133
147- auto MergeRefMap = [&](RelationRefMap & source, RelationRefMap & target)
148- {
134+ auto MergeRefMap = [&](RelationRefMap &source, RelationRefMap &target) {
149135 for (auto it : source)
150136 {
151- auto & v = target[it.first ];
137+ auto &v = target[it.first ];
152138 v.insert (v.end (), it.second .begin (), it.second .end ());
153139 }
154140 };
@@ -158,15 +144,12 @@ class ExtractionRelationContainer
158144 MergeRefMap (other.rel_refs , rel_refs);
159145 }
160146
161- std::size_t GetRelationsNum () const
162- {
163- return relations_data.size ();
164- }
147+ std::size_t GetRelationsNum () const { return relations_data.size (); }
165148
166- const RelationIDList & GetRelations (const OsmIDTyped & member_id) const
149+ const RelationIDList &GetRelations (const OsmIDTyped &member_id) const
167150 {
168- auto getFromMap = [this ](std::uint64_t id, const RelationRefMap & map) -> const RelationIDList &
169- {
151+ auto getFromMap = [this ](std::uint64_t id,
152+ const RelationRefMap &map) -> const RelationIDList & {
170153 auto it = map.find (id);
171154 if (it != map.end ())
172155 return it->second ;
@@ -192,11 +175,12 @@ class ExtractionRelationContainer
192175 return empty_rel_list;
193176 }
194177
195- const ExtractionRelation & GetRelationData (const ExtractionRelation::OsmIDTyped & rel_id) const
178+ const ExtractionRelation &GetRelationData (const ExtractionRelation::OsmIDTyped &rel_id) const
196179 {
197180 auto it = relations_data.find (rel_id.GetID ());
198181 if (it == relations_data.end ())
199- throw osrm::util::exception (" Can't find relation data for " + std::to_string (rel_id.GetID ()));
182+ throw osrm::util::exception (" Can't find relation data for " +
183+ std::to_string (rel_id.GetID ()));
200184
201185 return it->second ;
202186 }
0 commit comments