mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 13:03:36 +00:00
Format all C++ and Java code via clang-format
Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
@@ -52,8 +52,7 @@ string const kRoutePointsFile = "route_points.dat";
|
||||
|
||||
uint32_t constexpr kInvalidTransactionId = 0;
|
||||
|
||||
void FillTurnsDistancesForRendering(vector<RouteSegment> const & segments,
|
||||
double baseDistance, vector<double> & turns)
|
||||
void FillTurnsDistancesForRendering(vector<RouteSegment> const & segments, double baseDistance, vector<double> & turns)
|
||||
{
|
||||
using namespace routing::turns;
|
||||
turns.clear();
|
||||
@@ -72,8 +71,7 @@ void FillTurnsDistancesForRendering(vector<RouteSegment> const & segments,
|
||||
}
|
||||
}
|
||||
|
||||
void FillTrafficForRendering(vector<RouteSegment> const & segments,
|
||||
vector<traffic::SpeedGroup> & traffic)
|
||||
void FillTrafficForRendering(vector<RouteSegment> const & segments, vector<traffic::SpeedGroup> & traffic)
|
||||
{
|
||||
traffic.clear();
|
||||
traffic.reserve(segments.size());
|
||||
@@ -150,8 +148,7 @@ string SerializeRoutePoints(vector<RouteMarkData> const & points)
|
||||
SerializeRoutePoint(pointNode.get(), p);
|
||||
json_array_append_new(pointsNode.get(), pointNode.release());
|
||||
}
|
||||
unique_ptr<char, JSONFreeDeleter> buffer(
|
||||
json_dumps(pointsNode.get(), JSON_COMPACT));
|
||||
unique_ptr<char, JSONFreeDeleter> buffer(json_dumps(pointsNode.get(), JSON_COMPACT));
|
||||
return string(buffer.get());
|
||||
}
|
||||
|
||||
@@ -312,31 +309,28 @@ drape_ptr<df::Subroute> CreateDrapeSubroute(vector<RouteSegment> const & segment
|
||||
RoutingManager::RoutingManager(Callbacks && callbacks, Delegate & delegate)
|
||||
: m_callbacks(std::move(callbacks))
|
||||
, m_delegate(delegate)
|
||||
, m_extrapolator(
|
||||
[this](location::GpsInfo const & gpsInfo) { this->OnExtrapolatedLocationUpdate(gpsInfo); })
|
||||
, m_extrapolator([this](location::GpsInfo const & gpsInfo) { this->OnExtrapolatedLocationUpdate(gpsInfo); })
|
||||
{
|
||||
m_extrapolator.Enable(true); // Keeps smooth arrow movement whether routing or not
|
||||
m_extrapolator.Enable(true); // Keeps smooth arrow movement whether routing or not
|
||||
m_routingSession.Init(
|
||||
#ifdef SHOW_ROUTE_DEBUG_MARKS
|
||||
[this](m2::PointD const & pt) {
|
||||
if (m_bmManager == nullptr)
|
||||
return;
|
||||
auto editSession = m_bmManager->GetEditSession();
|
||||
editSession.SetIsVisible(UserMark::Type::DEBUG_MARK, true);
|
||||
editSession.CreateUserMark<DebugMarkPoint>(pt);
|
||||
}
|
||||
[this](m2::PointD const & pt)
|
||||
{
|
||||
if (m_bmManager == nullptr)
|
||||
return;
|
||||
auto editSession = m_bmManager->GetEditSession();
|
||||
editSession.SetIsVisible(UserMark::Type::DEBUG_MARK, true);
|
||||
editSession.CreateUserMark<DebugMarkPoint>(pt);
|
||||
}
|
||||
#else
|
||||
nullptr
|
||||
nullptr
|
||||
#endif
|
||||
);
|
||||
|
||||
m_routingSession.SetRoutingCallbacks(
|
||||
[this](Route const & route, RouterResultCode code) { OnBuildRouteReady(route, code); },
|
||||
[this](Route const & route, RouterResultCode code) { OnRebuildRouteReady(route, code); },
|
||||
[this](uint64_t routeId, storage::CountriesSet const & absentCountries) {
|
||||
OnNeedMoreMaps(routeId, absentCountries);
|
||||
},
|
||||
[this](RouterResultCode code) { OnRemoveRoute(code); });
|
||||
m_routingSession.SetRoutingCallbacks([this](Route const & route, RouterResultCode code)
|
||||
{ OnBuildRouteReady(route, code); }, [this](Route const & route, RouterResultCode code)
|
||||
{ OnRebuildRouteReady(route, code); }, [this](uint64_t routeId, storage::CountriesSet const & absentCountries)
|
||||
{ OnNeedMoreMaps(routeId, absentCountries); }, [this](RouterResultCode code) { OnRemoveRoute(code); });
|
||||
|
||||
m_routingSession.SetCheckpointCallback([this](size_t passedCheckpointIdx)
|
||||
{
|
||||
@@ -347,7 +341,7 @@ RoutingManager::RoutingManager(Callbacks && callbacks, Delegate & delegate)
|
||||
// TODO(@bykoianko). Since routing system may invoke callbacks from different threads and here
|
||||
// we have to use gui thread, ASSERT is not correct. Uncomment it and delete condition after
|
||||
// refactoring of threads usage in routing system.
|
||||
//ASSERT_LESS(passedCheckpointIdx, pointsCount, ());
|
||||
// ASSERT_LESS(passedCheckpointIdx, pointsCount, ());
|
||||
if (passedCheckpointIdx >= pointsCount)
|
||||
return;
|
||||
|
||||
@@ -418,9 +412,8 @@ void RoutingManager::OnBuildRouteReady(Route const & route, RouterResultCode cod
|
||||
{
|
||||
m2::RectD routeRect = route.GetPoly().GetLimitRect();
|
||||
routeRect.Scale(kRouteScaleMultiplier);
|
||||
m_drapeEngine.SafeCall(&df::DrapeEngine::SetModelViewRect, routeRect,
|
||||
true /* applyRotation */, -1 /* zoom */, true /* isAnim */,
|
||||
true /* useVisibleViewport */);
|
||||
m_drapeEngine.SafeCall(&df::DrapeEngine::SetModelViewRect, routeRect, true /* applyRotation */, -1 /* zoom */,
|
||||
true /* isAnim */, true /* useVisibleViewport */);
|
||||
}
|
||||
|
||||
CallRouteBuilded(hasWarnings ? RouterResultCode::HasWarnings : code, storage::CountriesSet());
|
||||
@@ -473,8 +466,7 @@ void RoutingManager::OnLocationUpdate(location::GpsInfo const & info)
|
||||
m_extrapolator.OnLocationUpdate(info);
|
||||
}
|
||||
|
||||
RouterType RoutingManager::GetBestRouter(m2::PointD const & startPoint,
|
||||
m2::PointD const & finalPoint) const
|
||||
RouterType RoutingManager::GetBestRouter(m2::PointD const & startPoint, m2::PointD const & finalPoint) const
|
||||
{
|
||||
// todo Implement something more sophisticated here (or delete the method).
|
||||
return GetLastUsedRouter();
|
||||
@@ -507,7 +499,8 @@ void RoutingManager::SetRouterImpl(RouterType type)
|
||||
|
||||
m_loadAltitudes = vehicleType != VehicleType::Car;
|
||||
|
||||
auto const countryFileGetter = [this](m2::PointD const & p) -> string {
|
||||
auto const countryFileGetter = [this](m2::PointD const & p) -> string
|
||||
{
|
||||
// TODO (@gorshenin): fix CountryInfoGetter to return CountryFile
|
||||
// instances instead of plain strings.
|
||||
return m_callbacks.m_countryInfoGetter().GetRegionCountryId(p);
|
||||
@@ -518,27 +511,25 @@ void RoutingManager::SetRouterImpl(RouterType type)
|
||||
|
||||
auto & dataSource = m_callbacks.m_dataSourceGetter();
|
||||
|
||||
auto localFileChecker = [this](string const & countryFile) -> bool {
|
||||
MwmSet::MwmId const mwmId = m_callbacks.m_dataSourceGetter().GetMwmIdByCountryFile(
|
||||
platform::CountryFile(countryFile));
|
||||
auto localFileChecker = [this](string const & countryFile) -> bool
|
||||
{
|
||||
MwmSet::MwmId const mwmId =
|
||||
m_callbacks.m_dataSourceGetter().GetMwmIdByCountryFile(platform::CountryFile(countryFile));
|
||||
return mwmId.IsAlive();
|
||||
};
|
||||
|
||||
auto const getMwmRectByName = [this](string const & countryId) -> m2::RectD {
|
||||
return m_callbacks.m_countryInfoGetter().GetLimitRectForLeaf(countryId);
|
||||
};
|
||||
auto const getMwmRectByName = [this](string const & countryId) -> m2::RectD
|
||||
{ return m_callbacks.m_countryInfoGetter().GetLimitRectForLeaf(countryId); };
|
||||
|
||||
auto regionsFinder =
|
||||
make_unique<AbsentRegionsFinder>(countryFileGetter, localFileChecker, numMwmIds, dataSource);
|
||||
auto regionsFinder = make_unique<AbsentRegionsFinder>(countryFileGetter, localFileChecker, numMwmIds, dataSource);
|
||||
|
||||
std::unique_ptr<IRouter> router;
|
||||
if (type == RouterType::Ruler)
|
||||
router = make_unique<RulerRouter>();
|
||||
else
|
||||
router = make_unique<IndexRouter>(vehicleType, m_loadAltitudes, m_callbacks.m_countryParentNameGetterFn,
|
||||
countryFileGetter, getMwmRectByName, numMwmIds,
|
||||
MakeNumMwmTree(*numMwmIds, m_callbacks.m_countryInfoGetter()),
|
||||
m_routingSession, dataSource);
|
||||
router = make_unique<IndexRouter>(
|
||||
vehicleType, m_loadAltitudes, m_callbacks.m_countryParentNameGetterFn, countryFileGetter, getMwmRectByName,
|
||||
numMwmIds, MakeNumMwmTree(*numMwmIds, m_callbacks.m_countryInfoGetter()), m_routingSession, dataSource);
|
||||
|
||||
m_routingSession.SetRoutingSettings(GetRoutingSettings(vehicleType));
|
||||
m_routingSession.SetRouter(std::move(router), std::move(regionsFinder));
|
||||
@@ -563,8 +554,7 @@ void RoutingManager::RemoveRoute(bool deactivateFollowing)
|
||||
{
|
||||
m_transitReadManager->BlockTransitSchemeMode(false /* isBlocked */);
|
||||
// Remove all subroutes.
|
||||
m_drapeEngine.SafeCall(&df::DrapeEngine::RemoveSubroute,
|
||||
dp::DrapeID(), true /* deactivateFollowing */);
|
||||
m_drapeEngine.SafeCall(&df::DrapeEngine::RemoveSubroute, dp::DrapeID(), true /* deactivateFollowing */);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -584,9 +574,9 @@ void RoutingManager::RemoveRoute(bool deactivateFollowing)
|
||||
}
|
||||
}
|
||||
|
||||
void RoutingManager::CollectRoadWarnings(vector<routing::RouteSegment> const & segments,
|
||||
m2::PointD const & startPt, double baseDistance,
|
||||
GetMwmIdFn const & getMwmIdFn, RoadWarningsCollection & roadWarnings)
|
||||
void RoutingManager::CollectRoadWarnings(vector<routing::RouteSegment> const & segments, m2::PointD const & startPt,
|
||||
double baseDistance, GetMwmIdFn const & getMwmIdFn,
|
||||
RoadWarningsCollection & roadWarnings)
|
||||
{
|
||||
auto const isWarnedType = [](RoutingOptions::Road roadType)
|
||||
{
|
||||
@@ -613,8 +603,8 @@ void RoutingManager::CollectRoadWarnings(vector<routing::RouteSegment> const & s
|
||||
if (isWarnedType(currentType))
|
||||
{
|
||||
startDistance = currentDistance;
|
||||
auto const featureId = FeatureID(getMwmIdFn(segments[i].GetSegment().GetMwmId()),
|
||||
segments[i].GetSegment().GetFeatureId());
|
||||
auto const featureId =
|
||||
FeatureID(getMwmIdFn(segments[i].GetSegment().GetMwmId()), segments[i].GetSegment().GetFeatureId());
|
||||
auto const markPoint = i == 0 ? startPt : segments[i - 1].GetJunction().GetPoint();
|
||||
roadWarnings[currentType].push_back(RoadInfo(markPoint, featureId));
|
||||
}
|
||||
@@ -662,9 +652,7 @@ bool RoutingManager::InsertRoute(Route const & route)
|
||||
auto numMwmIds = make_shared<NumMwmIds>();
|
||||
m_delegate.RegisterCountryFilesOnRoute(numMwmIds);
|
||||
auto const getMwmId = [this, numMwmIds](routing::NumMwmId numMwmId)
|
||||
{
|
||||
return m_callbacks.m_dataSourceGetter().GetMwmIdByCountryFile(numMwmIds->GetFile(numMwmId));
|
||||
};
|
||||
{ return m_callbacks.m_dataSourceGetter().GetMwmIdByCountryFile(numMwmIds->GetFile(numMwmId)); };
|
||||
|
||||
RoadWarningsCollection roadWarnings;
|
||||
|
||||
@@ -672,9 +660,8 @@ bool RoutingManager::InsertRoute(Route const & route)
|
||||
shared_ptr<TransitRouteDisplay> transitRouteDisplay;
|
||||
if (isTransitRoute)
|
||||
{
|
||||
transitRouteDisplay = make_shared<TransitRouteDisplay>(*m_transitReadManager, getMwmId,
|
||||
m_callbacks.m_stringsBundleGetter,
|
||||
m_bmManager, m_transitSymbolSizes);
|
||||
transitRouteDisplay = make_shared<TransitRouteDisplay>(
|
||||
*m_transitReadManager, getMwmId, m_callbacks.m_stringsBundleGetter, m_bmManager, m_transitSymbolSizes);
|
||||
}
|
||||
|
||||
vector<RouteSegment> segments;
|
||||
@@ -686,57 +673,56 @@ bool RoutingManager::InsertRoute(Route const & route)
|
||||
|
||||
auto const startPt = route.GetSubrouteAttrs(subrouteIndex).GetStart().GetPoint();
|
||||
auto subroute = CreateDrapeSubroute(segments, startPt, distance,
|
||||
static_cast<double>(subroutesCount - subrouteIndex - 1),
|
||||
m_currentRouterType);
|
||||
static_cast<double>(subroutesCount - subrouteIndex - 1), m_currentRouterType);
|
||||
if (!subroute)
|
||||
continue;
|
||||
distance = segments.back().GetDistFromBeginningMerc();
|
||||
switch (m_currentRouterType)
|
||||
{
|
||||
case RouterType::Vehicle:
|
||||
{
|
||||
subroute->m_routeType = df::RouteType::Car;
|
||||
subroute->AddStyle(df::SubrouteStyle(df::kRouteColor, df::kRouteOutlineColor));
|
||||
FillTrafficForRendering(segments, subroute->m_traffic);
|
||||
FillTurnsDistancesForRendering(segments, subroute->m_baseDistance, subroute->m_turns);
|
||||
break;
|
||||
}
|
||||
case RouterType::Transit:
|
||||
{
|
||||
subroute->m_routeType = df::RouteType::Transit;
|
||||
if (!transitRouteDisplay->ProcessSubroute(segments, *subroute.get()))
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
case RouterType::Pedestrian:
|
||||
{
|
||||
subroute->m_routeType = df::RouteType::Pedestrian;
|
||||
subroute->AddStyle(df::SubrouteStyle(df::kRoutePedestrian, df::RoutePattern(4.0, 2.0)));
|
||||
break;
|
||||
}
|
||||
case RouterType::Bicycle:
|
||||
{
|
||||
subroute->m_routeType = df::RouteType::Bicycle;
|
||||
subroute->AddStyle(df::SubrouteStyle(df::kRouteBicycle, df::RoutePattern(8.0, 2.0)));
|
||||
FillTurnsDistancesForRendering(segments, subroute->m_baseDistance, subroute->m_turns);
|
||||
break;
|
||||
}
|
||||
case RouterType::Ruler:
|
||||
{
|
||||
subroute->m_routeType = df::RouteType::Ruler;
|
||||
subroute->AddStyle(df::SubrouteStyle(df::kRouteRuler, df::RoutePattern(16.0, 2.0)));
|
||||
break;
|
||||
}
|
||||
default: CHECK(false, ("Unknown router type"));
|
||||
case RouterType::Vehicle:
|
||||
{
|
||||
subroute->m_routeType = df::RouteType::Car;
|
||||
subroute->AddStyle(df::SubrouteStyle(df::kRouteColor, df::kRouteOutlineColor));
|
||||
FillTrafficForRendering(segments, subroute->m_traffic);
|
||||
FillTurnsDistancesForRendering(segments, subroute->m_baseDistance, subroute->m_turns);
|
||||
break;
|
||||
}
|
||||
case RouterType::Transit:
|
||||
{
|
||||
subroute->m_routeType = df::RouteType::Transit;
|
||||
if (!transitRouteDisplay->ProcessSubroute(segments, *subroute.get()))
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
case RouterType::Pedestrian:
|
||||
{
|
||||
subroute->m_routeType = df::RouteType::Pedestrian;
|
||||
subroute->AddStyle(df::SubrouteStyle(df::kRoutePedestrian, df::RoutePattern(4.0, 2.0)));
|
||||
break;
|
||||
}
|
||||
case RouterType::Bicycle:
|
||||
{
|
||||
subroute->m_routeType = df::RouteType::Bicycle;
|
||||
subroute->AddStyle(df::SubrouteStyle(df::kRouteBicycle, df::RoutePattern(8.0, 2.0)));
|
||||
FillTurnsDistancesForRendering(segments, subroute->m_baseDistance, subroute->m_turns);
|
||||
break;
|
||||
}
|
||||
case RouterType::Ruler:
|
||||
{
|
||||
subroute->m_routeType = df::RouteType::Ruler;
|
||||
subroute->AddStyle(df::SubrouteStyle(df::kRouteRuler, df::RoutePattern(16.0, 2.0)));
|
||||
break;
|
||||
}
|
||||
default: CHECK(false, ("Unknown router type"));
|
||||
}
|
||||
|
||||
CollectRoadWarnings(segments, startPt, subroute->m_baseDistance, getMwmId, roadWarnings);
|
||||
|
||||
auto const subrouteId = m_drapeEngine.SafeCallWithResult(&df::DrapeEngine::AddSubroute,
|
||||
df::SubrouteConstPtr(subroute.release()));
|
||||
auto const subrouteId =
|
||||
m_drapeEngine.SafeCallWithResult(&df::DrapeEngine::AddSubroute, df::SubrouteConstPtr(subroute.release()));
|
||||
|
||||
// TODO: we will send subrouteId to routing subsystem when we can partly update route.
|
||||
//route.SetSubrouteUid(subrouteIndex, static_cast<SubrouteUid>(subrouteId));
|
||||
// route.SetSubrouteUid(subrouteIndex, static_cast<SubrouteUid>(subrouteId));
|
||||
lock_guard<mutex> lock(m_drapeSubroutesMutex);
|
||||
m_drapeSubroutes.push_back(subrouteId);
|
||||
}
|
||||
@@ -749,9 +735,7 @@ bool RoutingManager::InsertRoute(Route const & route)
|
||||
if (isTransitRoute)
|
||||
{
|
||||
GetPlatform().RunTask(Platform::Thread::Gui, [transitRouteDisplay = std::move(transitRouteDisplay)]()
|
||||
{
|
||||
transitRouteDisplay->CreateTransitMarks();
|
||||
});
|
||||
{ transitRouteDisplay->CreateTransitMarks(); });
|
||||
}
|
||||
|
||||
bool const hasWarnings = !roadWarnings.empty();
|
||||
@@ -834,8 +818,8 @@ bool RoutingManager::CouldAddIntermediatePoint() const
|
||||
if (!IsRoutingActive())
|
||||
return false;
|
||||
|
||||
return m_bmManager->GetUserMarkIds(UserMark::Type::ROUTING).size()
|
||||
< RoutePointsLayout::kMaxIntermediatePointsCount + 2;
|
||||
return m_bmManager->GetUserMarkIds(UserMark::Type::ROUTING).size() <
|
||||
RoutePointsLayout::kMaxIntermediatePointsCount + 2;
|
||||
}
|
||||
|
||||
void RoutingManager::AddRoutePoint(RouteMarkData && markData, bool reorderIntermediatePoints)
|
||||
@@ -910,8 +894,7 @@ void RoutingManager::MoveRoutePoint(RouteMarkType currentType, size_t currentInt
|
||||
{
|
||||
ASSERT(m_bmManager != nullptr, ());
|
||||
RoutePointsLayout routePoints(*m_bmManager);
|
||||
routePoints.MoveRoutePoint(currentType, currentIntermediateIndex,
|
||||
targetType, targetIntermediateIndex);
|
||||
routePoints.MoveRoutePoint(currentType, currentIntermediateIndex, targetType, targetIntermediateIndex);
|
||||
}
|
||||
|
||||
void RoutingManager::MoveRoutePoint(size_t currentIndex, size_t targetIndex)
|
||||
@@ -920,7 +903,8 @@ void RoutingManager::MoveRoutePoint(size_t currentIndex, size_t targetIndex)
|
||||
|
||||
RoutePointsLayout routePoints(*m_bmManager);
|
||||
size_t const sz = routePoints.GetRoutePointsCount();
|
||||
auto const convertIndex = [sz](RouteMarkType & type, size_t & index) {
|
||||
auto const convertIndex = [sz](RouteMarkType & type, size_t & index)
|
||||
{
|
||||
if (index == 0)
|
||||
{
|
||||
type = RouteMarkType::Start;
|
||||
@@ -1051,10 +1035,10 @@ void RoutingManager::BuildRoute(uint32_t timeoutSec)
|
||||
// Disabled preview zoom to fix https://github.com/organicmaps/organicmaps/issues/5409.
|
||||
// Uncomment next lines to enable back zoom on route point add/remove.
|
||||
|
||||
//m2::RectD rect = ShowPreviewSegments(routePoints);
|
||||
//rect.Scale(kRouteScaleMultiplier);
|
||||
//m_drapeEngine.SafeCall(&df::DrapeEngine::SetModelViewRect, rect, true /* applyRotation */,
|
||||
// -1 /* zoom */, true /* isAnim */, true /* useVisibleViewport */);
|
||||
// m2::RectD rect = ShowPreviewSegments(routePoints);
|
||||
// rect.Scale(kRouteScaleMultiplier);
|
||||
// m_drapeEngine.SafeCall(&df::DrapeEngine::SetModelViewRect, rect, true /* applyRotation */,
|
||||
// -1 /* zoom */, true /* isAnim */, true /* useVisibleViewport */);
|
||||
|
||||
m_routingSession.ClearPositionAccumulator();
|
||||
m_routingSession.SetUserCurrentPosition(routePoints.front().m_position);
|
||||
@@ -1100,17 +1084,10 @@ kml::TrackId RoutingManager::SaveRoute()
|
||||
std::vector<geometry::PointWithAltitude> junctions;
|
||||
RoutingSession().GetRouteJunctionPoints(junctions);
|
||||
|
||||
junctions.erase(
|
||||
std::unique(
|
||||
junctions.begin(),
|
||||
junctions.end(),
|
||||
[](const geometry::PointWithAltitude & p1, const geometry::PointWithAltitude & p2)
|
||||
{
|
||||
return AlmostEqualAbs(p1, p2, kMwmPointAccuracy);
|
||||
}
|
||||
),
|
||||
junctions.end()
|
||||
);
|
||||
junctions.erase(std::unique(junctions.begin(), junctions.end(),
|
||||
[](geometry::PointWithAltitude const & p1, geometry::PointWithAltitude const & p2)
|
||||
{ return AlmostEqualAbs(p1, p2, kMwmPointAccuracy); }),
|
||||
junctions.end());
|
||||
|
||||
auto const routePoints = GetRoutePoints();
|
||||
std::string const from = GetNameFromPoint(routePoints.front());
|
||||
@@ -1139,21 +1116,18 @@ void RoutingManager::CheckLocationForRouting(location::GpsInfo const & info)
|
||||
if (state == SessionState::RouteNeedRebuild)
|
||||
{
|
||||
m_routingSession.RebuildRoute(
|
||||
mercator::FromLatLon(info.m_latitude, info.m_longitude),
|
||||
[this](Route const & route, RouterResultCode code) { OnRebuildRouteReady(route, code); },
|
||||
nullptr /* needMoreMapsCallback */, nullptr /* removeRouteCallback */,
|
||||
mercator::FromLatLon(info.m_latitude, info.m_longitude), [this](Route const & route, RouterResultCode code)
|
||||
{ OnRebuildRouteReady(route, code); }, nullptr /* needMoreMapsCallback */, nullptr /* removeRouteCallback */,
|
||||
RouterDelegate::kNoTimeout, SessionState::RouteRebuilding, true /* adjustToPrevRoute */);
|
||||
}
|
||||
}
|
||||
|
||||
void RoutingManager::CallRouteBuilded(RouterResultCode code,
|
||||
storage::CountriesSet const & absentCountries)
|
||||
void RoutingManager::CallRouteBuilded(RouterResultCode code, storage::CountriesSet const & absentCountries)
|
||||
{
|
||||
m_routingBuildingCallback(code, absentCountries);
|
||||
}
|
||||
|
||||
void RoutingManager::MatchLocationToRoute(location::GpsInfo & location,
|
||||
location::RouteMatchingInfo & routeMatchingInfo)
|
||||
void RoutingManager::MatchLocationToRoute(location::GpsInfo & location, location::RouteMatchingInfo & routeMatchingInfo)
|
||||
{
|
||||
if (!IsRoutingActive())
|
||||
return;
|
||||
@@ -1183,8 +1157,8 @@ void RoutingManager::SetDrapeEngine(ref_ptr<df::DrapeEngine> engine, bool is3dAl
|
||||
if (m_gpsInfoCache != nullptr)
|
||||
{
|
||||
auto routeMatchingInfo = GetRouteMatchingInfo(*m_gpsInfoCache);
|
||||
m_drapeEngine.SafeCall(&df::DrapeEngine::SetGpsInfo, *m_gpsInfoCache,
|
||||
m_routingSession.IsNavigable(), routeMatchingInfo);
|
||||
m_drapeEngine.SafeCall(&df::DrapeEngine::SetGpsInfo, *m_gpsInfoCache, m_routingSession.IsNavigable(),
|
||||
routeMatchingInfo);
|
||||
m_gpsInfoCache.reset();
|
||||
}
|
||||
|
||||
@@ -1232,17 +1206,22 @@ void RoutingManager::DistanceAltitude::Simplify(double altitudeDeviation)
|
||||
size_t m_ind = 0;
|
||||
|
||||
public:
|
||||
IterT(DistanceAltitude const & da, bool isBeg) : m_da(da)
|
||||
{
|
||||
m_ind = isBeg ? 0 : m_da.GetSize();
|
||||
}
|
||||
IterT(DistanceAltitude const & da, bool isBeg) : m_da(da) { m_ind = isBeg ? 0 : m_da.GetSize(); }
|
||||
|
||||
IterT(IterT const & rhs) = default;
|
||||
IterT & operator=(IterT const & rhs) { m_ind = rhs.m_ind; return *this; }
|
||||
IterT & operator=(IterT const & rhs)
|
||||
{
|
||||
m_ind = rhs.m_ind;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator!=(IterT const & rhs) const { return m_ind != rhs.m_ind; }
|
||||
|
||||
IterT & operator++() { ++m_ind; return *this; }
|
||||
IterT & operator++()
|
||||
{
|
||||
++m_ind;
|
||||
return *this;
|
||||
}
|
||||
IterT operator+(size_t inc) const
|
||||
{
|
||||
IterT res = *this;
|
||||
@@ -1251,25 +1230,25 @@ void RoutingManager::DistanceAltitude::Simplify(double altitudeDeviation)
|
||||
}
|
||||
int64_t operator-(IterT const & rhs) const { return int64_t(m_ind) - int64_t(rhs.m_ind); }
|
||||
|
||||
m2::PointD operator*() const { return { m_da.m_distances[m_ind], double(m_da.m_altitudes[m_ind]) }; }
|
||||
m2::PointD operator*() const { return {m_da.m_distances[m_ind], double(m_da.m_altitudes[m_ind])}; }
|
||||
};
|
||||
|
||||
std::vector<m2::PointD> out;
|
||||
|
||||
// 1. Deviation from approximated altitude.
|
||||
// double constexpr eps = 1.415; // ~sqrt(2)
|
||||
// struct DeviationFromApproxY
|
||||
// {
|
||||
// double operator()(m2::PointD const & a, m2::PointD const & b, m2::PointD const & x) const
|
||||
// {
|
||||
// double f = (x.x - a.x) / (b.x - a.x);
|
||||
// ASSERT(0 <= f && f <= 1, (f)); // distance is an icreasing function
|
||||
// double const approxY = (1 - f) * a.y + f * b.y;
|
||||
// return fabs(approxY - x.y);
|
||||
// }
|
||||
// } distFn;
|
||||
// SimplifyNearOptimal(20 /* maxFalseLookAhead */, IterT(*this, true), IterT(*this, false),
|
||||
// eps, distFn, AccumulateSkipSmallTrg(distFn, out, eps));
|
||||
// double constexpr eps = 1.415; // ~sqrt(2)
|
||||
// struct DeviationFromApproxY
|
||||
// {
|
||||
// double operator()(m2::PointD const & a, m2::PointD const & b, m2::PointD const & x) const
|
||||
// {
|
||||
// double f = (x.x - a.x) / (b.x - a.x);
|
||||
// ASSERT(0 <= f && f <= 1, (f)); // distance is an icreasing function
|
||||
// double const approxY = (1 - f) * a.y + f * b.y;
|
||||
// return fabs(approxY - x.y);
|
||||
// }
|
||||
// } distFn;
|
||||
// SimplifyNearOptimal(20 /* maxFalseLookAhead */, IterT(*this, true), IterT(*this, false),
|
||||
// eps, distFn, AccumulateSkipSmallTrg(distFn, out, eps));
|
||||
|
||||
// 2. Default square distance from segment.
|
||||
SimplifyDefault(IterT(*this, true), IterT(*this, false), math::Pow2(altitudeDeviation), out);
|
||||
@@ -1284,13 +1263,14 @@ void RoutingManager::DistanceAltitude::Simplify(double altitudeDeviation)
|
||||
}
|
||||
}
|
||||
|
||||
bool RoutingManager::DistanceAltitude::GenerateRouteAltitudeChart(
|
||||
uint32_t width, uint32_t height, vector<uint8_t> & imageRGBAData) const
|
||||
bool RoutingManager::DistanceAltitude::GenerateRouteAltitudeChart(uint32_t width, uint32_t height,
|
||||
vector<uint8_t> & imageRGBAData) const
|
||||
{
|
||||
if (GetSize() == 0)
|
||||
return false;
|
||||
|
||||
return maps::GenerateChart(width, height, m_distances, m_altitudes, GetStyleReader().GetCurrentStyle(), imageRGBAData);
|
||||
return maps::GenerateChart(width, height, m_distances, m_altitudes, GetStyleReader().GetCurrentStyle(),
|
||||
imageRGBAData);
|
||||
}
|
||||
|
||||
void RoutingManager::DistanceAltitude::CalculateAscentDescent(uint32_t & totalAscentM, uint32_t & totalDescentM) const
|
||||
@@ -1353,12 +1333,10 @@ void RoutingManager::ApplyRoutePointsTransaction(uint32_t transactionId)
|
||||
// If we apply a transaction we can remove all earlier transactions.
|
||||
// All older transactions must be kept since they can be applied or cancelled later.
|
||||
for (auto it = m_routePointsTransactions.begin(); it != m_routePointsTransactions.end();)
|
||||
{
|
||||
if (it->first <= transactionId)
|
||||
it = m_routePointsTransactions.erase(it);
|
||||
else
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
void RoutingManager::CancelRoutePointsTransaction(uint32_t transactionId)
|
||||
@@ -1370,12 +1348,10 @@ void RoutingManager::CancelRoutePointsTransaction(uint32_t transactionId)
|
||||
|
||||
// If we cancel a transaction we must remove all later transactions.
|
||||
for (auto it = m_routePointsTransactions.begin(); it != m_routePointsTransactions.end();)
|
||||
{
|
||||
if (it->first >= transactionId)
|
||||
it = m_routePointsTransactions.erase(it);
|
||||
else
|
||||
++it;
|
||||
}
|
||||
|
||||
// Revert route points.
|
||||
ASSERT(m_bmManager != nullptr, ());
|
||||
@@ -1427,8 +1403,7 @@ void RoutingManager::LoadRoutePoints(LoadRouteHandler const & handler)
|
||||
return;
|
||||
}
|
||||
|
||||
GetPlatform().RunTask(Platform::Thread::Gui,
|
||||
[this, handler, points = std::move(points)]() mutable
|
||||
GetPlatform().RunTask(Platform::Thread::Gui, [this, handler, points = std::move(points)]() mutable
|
||||
{
|
||||
ASSERT(m_bmManager != nullptr, ());
|
||||
// If we have found my position and the saved route used the user's position, we use my position as start point.
|
||||
@@ -1527,8 +1502,7 @@ void RoutingManager::OnExtrapolatedLocationUpdate(location::GpsInfo const & info
|
||||
m_gpsInfoCache = make_unique<location::GpsInfo>(gpsInfo);
|
||||
|
||||
auto routeMatchingInfo = GetRouteMatchingInfo(gpsInfo);
|
||||
m_drapeEngine.SafeCall(&df::DrapeEngine::SetGpsInfo, gpsInfo, m_routingSession.IsNavigable(),
|
||||
routeMatchingInfo);
|
||||
m_drapeEngine.SafeCall(&df::DrapeEngine::SetGpsInfo, gpsInfo, m_routingSession.IsNavigable(), routeMatchingInfo);
|
||||
}
|
||||
|
||||
void RoutingManager::DeleteSavedRoutePoints()
|
||||
@@ -1567,8 +1541,7 @@ m2::RectD RoutingManager::ShowPreviewSegments(vector<RouteMarkData> const & rout
|
||||
{
|
||||
rect.Add(routePoints[pointIndex].m_position);
|
||||
rect.Add(routePoints[pointIndex + 1].m_position);
|
||||
lock.Get()->AddRoutePreviewSegment(routePoints[pointIndex].m_position,
|
||||
routePoints[pointIndex + 1].m_position);
|
||||
lock.Get()->AddRoutePreviewSegment(routePoints[pointIndex].m_position, routePoints[pointIndex + 1].m_position);
|
||||
}
|
||||
return rect;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user