mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-20 13:23:59 +00:00
committed by
Konstantin Pastbin
parent
c9cbb64f12
commit
76ffc99abd
41
tools/openlr/road_info_getter.cpp
Normal file
41
tools/openlr/road_info_getter.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
#include "openlr/road_info_getter.hpp"
|
||||
|
||||
#include "indexer/classificator.hpp"
|
||||
#include "indexer/feature.hpp"
|
||||
#include "indexer/data_source.hpp"
|
||||
|
||||
#include "base/assert.hpp"
|
||||
|
||||
namespace openlr
|
||||
{
|
||||
// RoadInfoGetter::RoadInfo ------------------------------------------------------------------------
|
||||
RoadInfoGetter::RoadInfo::RoadInfo(FeatureType & ft)
|
||||
: m_hwClass(ftypes::GetHighwayClass(feature::TypesHolder(ft)))
|
||||
, m_link(ftypes::IsLinkChecker::Instance()(ft))
|
||||
, m_oneWay(ftypes::IsOneWayChecker::Instance()(ft))
|
||||
, m_isRoundabout(ftypes::IsRoundAboutChecker::Instance()(ft))
|
||||
{
|
||||
}
|
||||
|
||||
// RoadInfoGetter ----------------------------------------------------------------------------------
|
||||
RoadInfoGetter::RoadInfoGetter(DataSource const & dataSource)
|
||||
: m_dataSource(dataSource)
|
||||
{
|
||||
}
|
||||
|
||||
RoadInfoGetter::RoadInfo RoadInfoGetter::Get(FeatureID const & fid)
|
||||
{
|
||||
auto it = m_cache.find(fid);
|
||||
if (it != end(m_cache))
|
||||
return it->second;
|
||||
|
||||
FeaturesLoaderGuard g(m_dataSource, fid.m_mwmId);
|
||||
auto ft = g.GetOriginalFeatureByIndex(fid.m_index);
|
||||
CHECK(ft, ());
|
||||
|
||||
RoadInfo info(*ft);
|
||||
it = m_cache.emplace(fid, info).first;
|
||||
|
||||
return it->second;
|
||||
}
|
||||
} // namespace openlr
|
||||
Reference in New Issue
Block a user