MCPcopy Create free account
hub / github.com/comaps/comaps / GetMatchingStreetImpl

Method GetMatchingStreetImpl

libs/search/features_layer_matcher.cpp:110–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108
109template <class FeatureGetterT>
110uint32_t FeaturesLayerMatcher::GetMatchingStreetImpl(FeatureID const & id, FeatureGetterT && getter)
111{
112 // Check if this feature is modified - the logic will be different.
113 string streetName;
114 bool const edited = osm::Editor::Instance().GetEditedFeatureStreet(id, streetName);
115
116 // Check the cached result value.
117 auto entry = m_matchingStreetsCache.Get(id.m_index);
118 if (!edited && !entry.second)
119 return entry.first;
120
121 uint32_t & result = entry.first;
122 result = kInvalidId;
123
124 FeatureType * pFeature = getter();
125 if (pFeature == nullptr)
126 return result;
127
128 FeatureID streetId;
129 if (!edited && m_reverseGeocoder.GetOriginalStreetByHouse(*pFeature, streetId))
130 {
131 result = streetId.m_index;
132 return result;
133 }
134
135 // Get nearby streets and calculate the resulting index.
136 auto const & streets = GetNearbyStreets(*pFeature);
137
138 if (edited)
139 {
140 auto const ret =
141 find_if(streets.begin(), streets.end(), [&streetName](Street const & st) { return st.m_name == streetName; });
142 if (ret != streets.end())
143 {
144 result = ret->m_id.m_index;
145 return result;
146 }
147 }
148
149 // If there is no saved street for feature, assume that it's a nearest street if it's too close.
150 if (!streets.empty() && streets[0].m_distanceMeters < kMaxApproxStreetDistanceM)
151 result = streets[0].m_id.m_index;
152
153 return result;
154}
155} // namespace search

Callers

nothing calls this directly

Calls 6

GetMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected