forked from organicmaps/organicmaps
Review fixes.
This commit is contained in:
parent
e1c98cd4f9
commit
7af04f0d49
5 changed files with 57 additions and 59 deletions
|
@ -388,24 +388,27 @@ bool IsTypeConformed(uint32_t type, StringIL const & path)
|
|||
return true;
|
||||
}
|
||||
|
||||
char const * HighwayClassToString(HighwayClass const & cls)
|
||||
{
|
||||
switch (cls)
|
||||
{
|
||||
case HighwayClass::Undefined: return "Undefined";
|
||||
case HighwayClass::Error: return "Error";
|
||||
case HighwayClass::Trunk: return "Trunk";
|
||||
case HighwayClass::Primary: return "Primary";
|
||||
case HighwayClass::Secondary: return "Secondary";
|
||||
case HighwayClass::Tertiary: return "Tertiary";
|
||||
case HighwayClass::LivingStreet: return "LivingStreet";
|
||||
case HighwayClass::Service: return "Service";
|
||||
case HighwayClass::Pedestrian: return "Pedestrian";
|
||||
case HighwayClass::Count: return "Count";
|
||||
}
|
||||
}
|
||||
|
||||
string DebugPrint(HighwayClass const cls)
|
||||
{
|
||||
stringstream out;
|
||||
out << "[ ";
|
||||
switch (cls)
|
||||
{
|
||||
case HighwayClass::Undefined: out << "Undefined"; break;
|
||||
case HighwayClass::Error: out << "Error"; break;
|
||||
case HighwayClass::Trunk: out << "Trunk"; break;
|
||||
case HighwayClass::Primary: out << "Primary"; break;
|
||||
case HighwayClass::Secondary: out << "Secondary"; break;
|
||||
case HighwayClass::Tertiary: out << "Tertiary"; break;
|
||||
case HighwayClass::LivingStreet: out << "LivingStreet"; break;
|
||||
case HighwayClass::Service: out << "Service"; break;
|
||||
case HighwayClass::Pedestrian: out << "Pedestrian"; break;
|
||||
case HighwayClass::Count: out << "Count"; break;
|
||||
}
|
||||
out << " ]";
|
||||
out << "[ " << HighwayClassToString(cls) << " ]";
|
||||
return out.str();
|
||||
}
|
||||
|
||||
|
@ -439,13 +442,12 @@ HighwayClass GetHighwayClass(feature::TypesHolder const & types)
|
|||
{c.GetTypeByPath({"highway", "path"}), HighwayClass::Pedestrian},
|
||||
};
|
||||
uint8_t constexpr kTruncLevel = 2;
|
||||
auto const highwayClassesEndIt = kHighwayClasses.cend();
|
||||
|
||||
for (auto t : types)
|
||||
{
|
||||
ftype::TruncValue(t, kTruncLevel);
|
||||
auto const it = kHighwayClasses.find(t);
|
||||
if (it != highwayClassesEndIt)
|
||||
if (it != kHighwayClasses.cend())
|
||||
return it->second;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,11 +15,10 @@ namespace
|
|||
using namespace routing;
|
||||
using namespace routing::turns;
|
||||
|
||||
class AStarRoutingResult : public IRoutingResult
|
||||
class RoutingResultGraph : public IRoutingResult
|
||||
{
|
||||
public:
|
||||
AStarRoutingResult(IRoadGraph::TEdgeVector const & routeEdges,
|
||||
AdjacentEdgesMap const & adjacentEdges,
|
||||
RoutingResultGraph(IRoadGraph::TEdgeVector const & routeEdges, TAdjacentEdgesMap const & adjacentEdges,
|
||||
TUnpackedPathSegments const & pathSegments)
|
||||
: m_routeEdges(routeEdges)
|
||||
, m_adjacentEdges(adjacentEdges)
|
||||
|
@ -34,11 +33,11 @@ public:
|
|||
}
|
||||
|
||||
// turns::IRoutingResult overrides:
|
||||
virtual TUnpackedPathSegments const & GetSegments() const override { return m_pathSegments; }
|
||||
TUnpackedPathSegments const & GetSegments() const override { return m_pathSegments; }
|
||||
|
||||
virtual void GetPossibleTurns(TNodeId node, m2::PointD const & ingoingPoint,
|
||||
m2::PointD const & junctionPoint, size_t & ingoingCount,
|
||||
TurnCandidates & outgoingTurns) const override
|
||||
void GetPossibleTurns(TNodeId node, m2::PointD const & ingoingPoint,
|
||||
m2::PointD const & junctionPoint, size_t & ingoingCount,
|
||||
TurnCandidates & outgoingTurns) const override
|
||||
{
|
||||
ingoingCount = 0;
|
||||
outgoingTurns.candidates.clear();
|
||||
|
@ -54,15 +53,15 @@ public:
|
|||
outgoingTurns.candidates = adjacentEdges->second.m_outgoingTurns.candidates;
|
||||
}
|
||||
|
||||
virtual double GetPathLength() const override { return m_routeLength; }
|
||||
double GetPathLength() const override { return m_routeLength; }
|
||||
|
||||
virtual m2::PointD const & GetStartPoint() const override
|
||||
m2::PointD const & GetStartPoint() const override
|
||||
{
|
||||
CHECK(!m_routeEdges.empty(), ());
|
||||
return m_routeEdges.front().GetStartJunction().GetPoint();
|
||||
}
|
||||
|
||||
virtual m2::PointD const & GetEndPoint() const override
|
||||
m2::PointD const & GetEndPoint() const override
|
||||
{
|
||||
CHECK(!m_routeEdges.empty(), ());
|
||||
return m_routeEdges.back().GetEndJunction().GetPoint();
|
||||
|
@ -70,7 +69,7 @@ public:
|
|||
|
||||
private:
|
||||
IRoadGraph::TEdgeVector const & m_routeEdges;
|
||||
AdjacentEdgesMap const & m_adjacentEdges;
|
||||
TAdjacentEdgesMap const & m_adjacentEdges;
|
||||
TUnpackedPathSegments const & m_pathSegments;
|
||||
double m_routeLength;
|
||||
};
|
||||
|
@ -146,7 +145,7 @@ void BicycleDirectionsEngine::Generate(IRoadGraph const & graph, vector<Junction
|
|||
// Checking for if |edge| is a fake edge.
|
||||
if (!outFeatureId.IsValid())
|
||||
continue;
|
||||
adjacentEdges.m_outgoingTurns.candidates.emplace_back(0. /* angle */, outFeatureId.m_index,
|
||||
adjacentEdges.m_outgoingTurns.candidates.emplace_back(0.0 /* angle */, outFeatureId.m_index,
|
||||
GetHighwayClass(outFeatureId));
|
||||
}
|
||||
|
||||
|
@ -158,29 +157,25 @@ void BicycleDirectionsEngine::Generate(IRoadGraph const & graph, vector<Junction
|
|||
m_pathSegments.push_back(move(pathSegment));
|
||||
}
|
||||
|
||||
AStarRoutingResult resultGraph(routeEdges, m_adjacentEdges, m_pathSegments);
|
||||
RoutingResultGraph resultGraph(routeEdges, m_adjacentEdges, m_pathSegments);
|
||||
RouterDelegate delegate;
|
||||
Route::TTimes turnAnnotationTimes;
|
||||
Route::TStreets streetNames;
|
||||
MakeTurnAnnotation(resultGraph, delegate, routeGeometry, turns, turnAnnotationTimes, streetNames);
|
||||
}
|
||||
|
||||
void BicycleDirectionsEngine::UpdateFeatureLoaderGuardIfNeeded(Index const & index, MwmSet::MwmId const & mwmId)
|
||||
Index::FeaturesLoaderGuard & BicycleDirectionsEngine::GetLoader(MwmSet::MwmId const & id)
|
||||
{
|
||||
if (!m_featuresLoaderGuard || mwmId != m_mwmIdFeaturesLoaderGuard)
|
||||
m_featuresLoaderGuard.reset(new Index::FeaturesLoaderGuard(index, mwmId));
|
||||
if (!m_loader || id != m_loader->GetId())
|
||||
m_loader = make_unique<Index::FeaturesLoaderGuard>(m_index, id);
|
||||
return *m_loader;
|
||||
}
|
||||
|
||||
ftypes::HighwayClass BicycleDirectionsEngine::GetHighwayClass(FeatureID const & featureId)
|
||||
{
|
||||
ftypes::HighwayClass highWayClass = ftypes::HighwayClass::Undefined;
|
||||
MwmSet::MwmId const & mwmId = featureId.m_mwmId;
|
||||
uint32_t const featureIndex = featureId.m_index;
|
||||
|
||||
FeatureType ft;
|
||||
UpdateFeatureLoaderGuardIfNeeded(m_index, mwmId);
|
||||
m_featuresLoaderGuard->GetFeatureByIndex(featureIndex, ft);
|
||||
highWayClass = ftypes::GetHighwayClass(ft);
|
||||
GetLoader(featureId.m_mwmId).GetFeatureByIndex(featureId.m_index, ft);
|
||||
auto const highWayClass = ftypes::GetHighwayClass(ft);
|
||||
ASSERT_NOT_EQUAL(highWayClass, ftypes::HighwayClass::Error, ());
|
||||
ASSERT_NOT_EQUAL(highWayClass, ftypes::HighwayClass::Undefined, ());
|
||||
return highWayClass;
|
||||
|
@ -191,7 +186,6 @@ void BicycleDirectionsEngine::LoadPathGeometry(FeatureID const & featureId, vect
|
|||
{
|
||||
pathSegment.Clear();
|
||||
|
||||
MwmSet::MwmId const & mwmId = featureId.m_mwmId;
|
||||
if (!featureId.IsValid())
|
||||
{
|
||||
ASSERT(false, ());
|
||||
|
@ -199,11 +193,12 @@ void BicycleDirectionsEngine::LoadPathGeometry(FeatureID const & featureId, vect
|
|||
}
|
||||
|
||||
FeatureType ft;
|
||||
UpdateFeatureLoaderGuardIfNeeded(m_index, mwmId);
|
||||
m_featuresLoaderGuard->GetFeatureByIndex(featureId.m_index, ft);
|
||||
pathSegment.m_highwayClass = ftypes::GetHighwayClass(ft);
|
||||
ASSERT_NOT_EQUAL(pathSegment.m_highwayClass, ftypes::HighwayClass::Error, ());
|
||||
ASSERT_NOT_EQUAL(pathSegment.m_highwayClass, ftypes::HighwayClass::Undefined, ());
|
||||
GetLoader(featureId.m_mwmId).GetFeatureByIndex(featureId.m_index, ft);
|
||||
auto const highwayClass = ftypes::GetHighwayClass(ft);
|
||||
ASSERT_NOT_EQUAL(highwayClass, ftypes::HighwayClass::Error, ());
|
||||
ASSERT_NOT_EQUAL(highwayClass, ftypes::HighwayClass::Undefined, ());
|
||||
|
||||
pathSegment.m_highwayClass = highwayClass;
|
||||
pathSegment.m_isLink = ftypes::IsLinkChecker::Instance()(ft);
|
||||
|
||||
ft.GetName(FeatureType::DEFAULT_LANG, pathSegment.m_name);
|
||||
|
|
|
@ -19,7 +19,7 @@ struct AdjacentEdges
|
|||
size_t m_ingoingTurnsCount;
|
||||
};
|
||||
|
||||
using AdjacentEdgesMap = map<TNodeId, AdjacentEdges>;
|
||||
using TAdjacentEdgesMap = map<TNodeId, AdjacentEdges>;
|
||||
|
||||
class BicycleDirectionsEngine : public IDirectionsEngine
|
||||
{
|
||||
|
@ -32,15 +32,14 @@ public:
|
|||
my::Cancellable const & cancellable) override;
|
||||
|
||||
private:
|
||||
void UpdateFeatureLoaderGuardIfNeeded(Index const & index, MwmSet::MwmId const & mwmId);
|
||||
Index::FeaturesLoaderGuard & GetLoader(MwmSet::MwmId const & id);
|
||||
ftypes::HighwayClass GetHighwayClass(FeatureID const & featureId);
|
||||
void LoadPathGeometry(FeatureID const & featureId, vector<m2::PointD> const & path,
|
||||
LoadedPathSegment & pathSegment);
|
||||
|
||||
AdjacentEdgesMap m_adjacentEdges;
|
||||
TAdjacentEdgesMap m_adjacentEdges;
|
||||
TUnpackedPathSegments m_pathSegments;
|
||||
unique_ptr<Index::FeaturesLoaderGuard> m_featuresLoaderGuard;
|
||||
MwmSet::MwmId m_mwmIdFeaturesLoaderGuard;
|
||||
unique_ptr<Index::FeaturesLoaderGuard> m_loader;
|
||||
Index const & m_index;
|
||||
};
|
||||
} // namespace routing
|
||||
|
|
|
@ -60,14 +60,12 @@ class OSRMRoutingResult : public turns::IRoutingResult
|
|||
{
|
||||
public:
|
||||
// turns::IRoutingResult overrides:
|
||||
virtual TUnpackedPathSegments const & GetSegments() const override
|
||||
TUnpackedPathSegments const & GetSegments() const override
|
||||
{
|
||||
return m_loadedSegments;
|
||||
}
|
||||
virtual void GetPossibleTurns(TNodeId node, m2::PointD const & ingoingPoint,
|
||||
m2::PointD const & junctionPoint,
|
||||
size_t & ingoingCount,
|
||||
turns::TurnCandidates & outgoingTurns) const override
|
||||
void GetPossibleTurns(TNodeId node, m2::PointD const & ingoingPoint, m2::PointD const & junctionPoint,
|
||||
size_t & ingoingCount, turns::TurnCandidates & outgoingTurns) const override
|
||||
{
|
||||
double const kReadCrossEpsilon = 1.0E-4;
|
||||
|
||||
|
@ -152,12 +150,14 @@ public:
|
|||
});
|
||||
}
|
||||
|
||||
virtual double GetPathLength() const override { return m_rawResult.shortestPathLength; }
|
||||
virtual m2::PointD const & GetStartPoint() const override
|
||||
double GetPathLength() const override { return m_rawResult.shortestPathLength; }
|
||||
|
||||
m2::PointD const & GetStartPoint() const override
|
||||
{
|
||||
return m_rawResult.sourceEdge.segmentPoint;
|
||||
}
|
||||
virtual m2::PointD const & GetEndPoint() const override
|
||||
|
||||
m2::PointD const & GetEndPoint() const override
|
||||
{
|
||||
return m_rawResult.targetEdge.segmentPoint;
|
||||
}
|
||||
|
|
|
@ -86,6 +86,8 @@ namespace integration
|
|||
storage::CountryInfoGetter const & infoGetter,
|
||||
TRouterFactory const & routerFactory)
|
||||
{
|
||||
// |infoGetter| should be a reference to an object which exists while the
|
||||
// result of the function is used.
|
||||
auto countryFileGetter = [&infoGetter](m2::PointD const & pt)
|
||||
{
|
||||
return infoGetter.GetRegionCountryId(pt);
|
||||
|
|
Loading…
Add table
Reference in a new issue