Start openlr_stat refactoring.

This commit is contained in:
Vladimir Byko-Ianko 2019-03-06 09:36:44 +03:00
parent 8dceb19e7c
commit c224d0eb08
2 changed files with 27 additions and 3 deletions

View file

@ -8,6 +8,23 @@
#include "std/iterator.hpp"
namespace
{
openlr::FunctionalRoadClass HighwayClassToFunctionalRoadClass(ftypes::HighwayClass const & hwClass)
{
switch (hwClass)
{
case ftypes::HighwayClass::Trunk: return openlr::FunctionalRoadClass::FRC0;
case ftypes::HighwayClass::Primary: return openlr::FunctionalRoadClass::FRC1;
case ftypes::HighwayClass::Secondary: return openlr::FunctionalRoadClass::FRC2;
case ftypes::HighwayClass::Tertiary: return openlr::FunctionalRoadClass::FRC3;
case ftypes::HighwayClass::LivingStreet: return openlr::FunctionalRoadClass::FRC4;
case ftypes::HighwayClass::Service: return openlr::FunctionalRoadClass::FRC5;
default: return openlr::FunctionalRoadClass::FRC7;
}
}
}
namespace openlr
{
RoadInfoGetter::RoadInfoGetter(DataSource const & dataSource)
@ -26,8 +43,13 @@ RoadInfoGetter::RoadInfo RoadInfoGetter::Get(FeatureID const & fid)
CHECK(g.GetOriginalFeatureByIndex(fid.m_index, ft), ());
RoadInfo info;
info.m_frc = GetFunctionalRoadClass(feature::TypesHolder(ft));
// info.m_frc = GetFunctionalRoadClass(feature::TypesHolder(ft));
info.m_fow = GetFormOfWay(feature::TypesHolder(ft));
info.m_hwClass = ftypes::GetHighwayClass(feature::TypesHolder(ft));
info.m_link = ftypes::IsLinkChecker::Instance()(ft);
info.m_oneWay = ftypes::IsOneWayChecker::Instance()(ft);
info.m_frc = HighwayClassToFunctionalRoadClass(info.m_hwClass);
it = m_cache.emplace(fid, info).first;
return it->second;

View file

@ -4,6 +4,7 @@
#include "openlr/road_type_checkers.hpp"
#include "indexer/feature_data.hpp"
#include "indexer/ftypes_matcher.hpp"
#include "std/map.hpp"
@ -22,10 +23,11 @@ class RoadInfoGetter final
public:
struct RoadInfo
{
RoadInfo() = default;
FunctionalRoadClass m_frc = FunctionalRoadClass::NotAValue;
FormOfWay m_fow = FormOfWay::NotAValue;
ftypes::HighwayClass m_hwClass = ftypes::HighwayClass::Undefined;
bool m_link = false;
bool m_oneWay = false;
};
RoadInfoGetter(DataSource const & dataSource);