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

Method BuildRoute

libs/map/routing_manager.cpp:1114–1180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1112}
1113
1114void RoutingManager::BuildRoute(uint32_t timeoutSec)
1115{
1116 CHECK_THREAD_CHECKER(m_threadChecker, ("BuildRoute"));
1117
1118 m_bmManager->GetEditSession().ClearGroup(UserMark::Type::TRANSIT);
1119
1120 auto routePoints = GetRoutePoints();
1121 if (routePoints.size() < 2)
1122 {
1123 CallRouteBuilded(RouterResultCode::Cancelled, storage::CountriesSet());
1124 CloseRouting(false /* remove route points */);
1125 return;
1126 }
1127
1128 // Update my position.
1129 for (auto & p : routePoints)
1130 {
1131 if (!p.m_isMyPosition)
1132 continue;
1133
1134 auto const & myPosition = m_bmManager->MyPositionMark();
1135 if (!myPosition.HasPosition())
1136 {
1137 CallRouteBuilded(RouterResultCode::NoCurrentPosition, storage::CountriesSet());
1138 return;
1139 }
1140 p.m_position = myPosition.GetPivot();
1141 }
1142
1143 // Check for equal points.
1144 for (size_t i = 0; i < routePoints.size(); i++)
1145 {
1146 for (size_t j = i + 1; j < routePoints.size(); j++)
1147 {
1148 if (routePoints[i].m_position.EqualDxDy(routePoints[j].m_position, mercator::kPointEqualityEps))
1149 {
1150 CallRouteBuilded(RouterResultCode::Cancelled, storage::CountriesSet());
1151 CloseRouting(false /* remove route points */);
1152 return;
1153 }
1154 }
1155 }
1156
1157 if (IsRoutingActive())
1158 CloseRouting(false /* remove route points */);
1159
1160 ShowPreviewSegments(routePoints);
1161
1162 // Route points preview.
1163 // Disabled preview zoom to fix https://github.com/organicmaps/organicmaps/issues/5409.
1164 // Uncomment next lines to enable back zoom on route point add/remove.
1165
1166 // m2::RectD rect = ShowPreviewSegments(routePoints);
1167 // rect.Scale(kRouteScaleMultiplier);
1168 // m_drapeEngine.SafeCall(&df::DrapeEngine::SetModelViewRect, rect, true /* applyRotation */,
1169 // -1 /* zoom */, true /* isAnim */, true /* useVisibleViewport */);
1170
1171 m_routingSession.ClearPositionAccumulator();

Callers 5

initializeGLMethod · 0.45
SubmitRoutingPointMethod · 0.45
OnRouteRecommendationMethod · 0.45
OnTapEventMethod · 0.45

Calls 12

ClearGroupMethod · 0.80
GetEditSessionMethod · 0.80
HasPositionMethod · 0.80
frontMethod · 0.80
CheckpointsClass · 0.50
sizeMethod · 0.45
GetPivotMethod · 0.45
EqualDxDyMethod · 0.45
reserveMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected