Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Gorbushin <m.gorbushin@corp.mail.ru>2019-03-11 17:07:55 +0300
committerVlad Mihaylenko <vxmihaylenko@gmail.com>2019-03-15 13:03:17 +0300
commitebc8469783327487b12dc9fcc65b2228d28a4397 (patch)
tree7908bdc91008fa9b20df27f9bd0177a4fdbbf6b0 /routing
parent2073918d1560b4d1e7c6b299dfffbe52d7236369 (diff)
[routing] increase speed of creating JointSegment
Diffstat (limited to 'routing')
-rw-r--r--routing/index_graph.cpp59
1 files changed, 22 insertions, 37 deletions
diff --git a/routing/index_graph.cpp b/routing/index_graph.cpp
index b9153ccfa7..dd97466b62 100644
--- a/routing/index_graph.cpp
+++ b/routing/index_graph.cpp
@@ -278,17 +278,6 @@ void IndexGraph::ReconstructJointSegment(Segment const & parent,
{
CHECK_EQUAL(firstChildren.size(), lastPointIds.size(), ());
- auto const step = [this](Segment const & from, Segment const & to, bool isOutgoing, SegmentEdge & edge)
- {
- if (IsRestricted(m_restrictions, from, to, isOutgoing))
- return false;
-
- RouteWeight weight = CalcSegmentWeight(isOutgoing ? to : from) +
- GetPenalties(isOutgoing ? from : to, isOutgoing ? to : from);
- edge = SegmentEdge(to, weight);
- return true;
- };
-
for (size_t i = 0; i < firstChildren.size(); ++i)
{
auto const & firstChild = firstChildren[i];
@@ -309,10 +298,24 @@ void IndexGraph::ReconstructJointSegment(Segment const & parent,
if (m_roadAccess.GetPointType(parent.GetRoadPoint(isOutgoing)) == RoadAccess::Type::No)
continue;
+ // Check firstChild for UTurn.
+ RoadPoint rp = parent.GetRoadPoint(isOutgoing);
+ if (IsUTurn(parent, firstChild) && m_roadIndex.GetJointId(rp) == Joint::kInvalidId
+ && !m_geometry->GetRoad(parent.GetFeatureId()).IsEndPointId(rp.GetPointId()))
+ {
+ continue;
+ }
+
+ if (parent.GetFeatureId() != firstChild.GetFeatureId() &&
+ IsRestricted(m_restrictions, parent, firstChild, isOutgoing))
+ {
+ continue;
+ }
+
// Check current JointSegment for bad road access between segments.
+ rp = firstChild.GetRoadPoint(isOutgoing);
uint32_t start = currentPointId;
bool noRoadAccess = false;
- RoadPoint rp = firstChild.GetRoadPoint(isOutgoing);
do
{
if (m_roadAccess.GetPointType(rp) == RoadAccess::Type::No)
@@ -328,45 +331,27 @@ void IndexGraph::ReconstructJointSegment(Segment const & parent,
if (noRoadAccess)
continue;
- // Check firstChild for UTurn.
- rp = parent.GetRoadPoint(isOutgoing);
- if (IsUTurn(parent, firstChild) && m_roadIndex.GetJointId(rp) == Joint::kInvalidId
- && !m_geometry->GetRoad(parent.GetFeatureId()).IsEndPointId(rp.GetPointId()))
- {
- continue;
- }
-
bool forward = currentPointId < lastPointId;
Segment current = firstChild;
Segment prev = parent;
- SegmentEdge edge;
RouteWeight summaryWeight;
- bool hasRestriction = false;
do
{
- if (step(prev, current, isOutgoing, edge)) // Access ok
- {
- if (isOutgoing || prev != parent)
- summaryWeight += edge.GetWeight();
+ RouteWeight const weight = CalcSegmentWeight(isOutgoing ? current : prev) +
+ GetPenalties(isOutgoing ? prev : current, isOutgoing ? current : prev);
- if (prev == parent)
- parentWeights.emplace_back(edge.GetWeight());
- }
- else
- {
- hasRestriction = true;
- break;
- }
+ if (isOutgoing || prev != parent)
+ summaryWeight += weight;
+
+ if (prev == parent)
+ parentWeights.emplace_back(weight);
prev = current;
current.Next(forward);
currentPointId = increment(currentPointId);
} while (currentPointId != lastPointId);
- if (hasRestriction)
- continue;
-
jointEdges.emplace_back(isOutgoing ? JointSegment(firstChild, prev) :
JointSegment(prev, firstChild),
summaryWeight);