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:
@@ -5,7 +5,6 @@
|
||||
|
||||
#include "geometry/mercator.hpp"
|
||||
|
||||
|
||||
namespace routing
|
||||
{
|
||||
namespace turns
|
||||
@@ -15,16 +14,13 @@ using namespace ftypes;
|
||||
|
||||
bool IsHighway(HighwayClass hwClass, bool isLink)
|
||||
{
|
||||
return (hwClass == HighwayClass::Trunk || hwClass == HighwayClass::Primary) &&
|
||||
!isLink;
|
||||
return (hwClass == HighwayClass::Trunk || hwClass == HighwayClass::Primary) && !isLink;
|
||||
}
|
||||
|
||||
bool IsSmallRoad(HighwayClass hwClass)
|
||||
{
|
||||
return hwClass == HighwayClass::LivingStreet ||
|
||||
hwClass == HighwayClass::Service ||
|
||||
hwClass == HighwayClass::ServiceMinor ||
|
||||
hwClass == HighwayClass::Pedestrian;
|
||||
return hwClass == HighwayClass::LivingStreet || hwClass == HighwayClass::Service ||
|
||||
hwClass == HighwayClass::ServiceMinor || hwClass == HighwayClass::Pedestrian;
|
||||
}
|
||||
|
||||
int CalcDiffRoadClasses(HighwayClass const left, HighwayClass const right)
|
||||
@@ -38,14 +34,11 @@ T FindDirectionByAngle(std::vector<std::pair<double, T>> const & lowerBounds, do
|
||||
ASSERT_GREATER_OR_EQUAL(angle, -180., (angle));
|
||||
ASSERT_LESS_OR_EQUAL(angle, 180., (angle));
|
||||
ASSERT(!lowerBounds.empty(), ());
|
||||
ASSERT(is_sorted(lowerBounds.rbegin(), lowerBounds.rend(), base::LessBy(&std::pair<double, T>::first)),
|
||||
());
|
||||
ASSERT(is_sorted(lowerBounds.rbegin(), lowerBounds.rend(), base::LessBy(&std::pair<double, T>::first)), ());
|
||||
|
||||
for (auto const & lower : lowerBounds)
|
||||
{
|
||||
if (angle >= lower.first)
|
||||
return lower.second;
|
||||
}
|
||||
|
||||
ASSERT(false, ("The angle is not covered by the table. angle = ", angle));
|
||||
return T::None;
|
||||
@@ -55,20 +48,13 @@ CarDirection InvertDirection(CarDirection const dir)
|
||||
{
|
||||
switch (dir)
|
||||
{
|
||||
case CarDirection::TurnSlightRight:
|
||||
return CarDirection::TurnSlightLeft;
|
||||
case CarDirection::TurnRight:
|
||||
return CarDirection::TurnLeft;
|
||||
case CarDirection::TurnSharpRight:
|
||||
return CarDirection::TurnSharpLeft;
|
||||
case CarDirection::TurnSlightLeft:
|
||||
return CarDirection::TurnSlightRight;
|
||||
case CarDirection::TurnLeft:
|
||||
return CarDirection::TurnRight;
|
||||
case CarDirection::TurnSharpLeft:
|
||||
return CarDirection::TurnSharpRight;
|
||||
default:
|
||||
return dir;
|
||||
case CarDirection::TurnSlightRight: return CarDirection::TurnSlightLeft;
|
||||
case CarDirection::TurnRight: return CarDirection::TurnLeft;
|
||||
case CarDirection::TurnSharpRight: return CarDirection::TurnSharpLeft;
|
||||
case CarDirection::TurnSlightLeft: return CarDirection::TurnSlightRight;
|
||||
case CarDirection::TurnLeft: return CarDirection::TurnRight;
|
||||
case CarDirection::TurnSharpLeft: return CarDirection::TurnSharpRight;
|
||||
default: return dir;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -79,8 +65,8 @@ CarDirection RightmostDirection(double const angle)
|
||||
{50., CarDirection::TurnRight},
|
||||
{10., CarDirection::TurnSlightRight},
|
||||
// For sure it's incorrect to give directions TurnLeft or TurnSlighLeft if we need the rightmost turn.
|
||||
// So GoStraight direction is given even for needed sharp left turn when other turns on the left and are more sharp.
|
||||
// The reason: the rightmost turn is the most straight one here.
|
||||
// So GoStraight direction is given even for needed sharp left turn when other turns on the left and are more
|
||||
// sharp. The reason: the rightmost turn is the most straight one here.
|
||||
{-180., CarDirection::GoStraight}};
|
||||
|
||||
return FindDirectionByAngle(kLowerBounds, angle);
|
||||
@@ -94,12 +80,8 @@ CarDirection LeftmostDirection(double const angle)
|
||||
CarDirection IntermediateDirection(double const angle)
|
||||
{
|
||||
static std::vector<std::pair<double, CarDirection>> const kLowerBounds = {
|
||||
{145., CarDirection::TurnSharpRight},
|
||||
{50., CarDirection::TurnRight},
|
||||
{10., CarDirection::TurnSlightRight},
|
||||
{-10., CarDirection::GoStraight},
|
||||
{-50., CarDirection::TurnSlightLeft},
|
||||
{-145., CarDirection::TurnLeft},
|
||||
{145., CarDirection::TurnSharpRight}, {50., CarDirection::TurnRight}, {10., CarDirection::TurnSlightRight},
|
||||
{-10., CarDirection::GoStraight}, {-50., CarDirection::TurnSlightLeft}, {-145., CarDirection::TurnLeft},
|
||||
{-180., CarDirection::TurnSharpLeft}};
|
||||
|
||||
return FindDirectionByAngle(kLowerBounds, angle);
|
||||
@@ -120,15 +102,15 @@ double CalcEstimatedTimeToPass(double const distanceMeters, HighwayClass const h
|
||||
double speedKmph = 0;
|
||||
switch (highwayClass)
|
||||
{
|
||||
case HighwayClass::Trunk: speedKmph = 100.0; break;
|
||||
case HighwayClass::Primary: speedKmph = 70.0; break;
|
||||
case HighwayClass::Secondary: speedKmph = 70.0; break;
|
||||
case HighwayClass::Tertiary: speedKmph = 50.0; break;
|
||||
case HighwayClass::LivingStreet: speedKmph = 20.0; break;
|
||||
case HighwayClass::Service:
|
||||
case HighwayClass::ServiceMinor: speedKmph = 10.0; break;
|
||||
case HighwayClass::Pedestrian: speedKmph = 5.0; break;
|
||||
default: speedKmph = 50.0; break;
|
||||
case HighwayClass::Trunk: speedKmph = 100.0; break;
|
||||
case HighwayClass::Primary: speedKmph = 70.0; break;
|
||||
case HighwayClass::Secondary: speedKmph = 70.0; break;
|
||||
case HighwayClass::Tertiary: speedKmph = 50.0; break;
|
||||
case HighwayClass::LivingStreet: speedKmph = 20.0; break;
|
||||
case HighwayClass::Service:
|
||||
case HighwayClass::ServiceMinor: speedKmph = 10.0; break;
|
||||
case HighwayClass::Pedestrian: speedKmph = 5.0; break;
|
||||
default: speedKmph = 50.0; break;
|
||||
}
|
||||
return distanceMeters / measurement_utils::KmphToMps(speedKmph);
|
||||
}
|
||||
@@ -138,8 +120,7 @@ bool PathIsFakeLoop(std::vector<geometry::PointWithAltitude> const & path)
|
||||
return path.size() == 2 && path[0] == path[1];
|
||||
}
|
||||
|
||||
double CalcRouteDistanceM(std::vector<geometry::PointWithAltitude> const & junctions, uint32_t start,
|
||||
uint32_t end)
|
||||
double CalcRouteDistanceM(std::vector<geometry::PointWithAltitude> const & junctions, uint32_t start, uint32_t end)
|
||||
{
|
||||
double res = 0.0;
|
||||
|
||||
@@ -169,8 +150,8 @@ bool RoutePointIndex::operator==(RoutePointIndex const & index) const
|
||||
std::string DebugPrint(RoutePointIndex const & index)
|
||||
{
|
||||
std::stringstream out;
|
||||
out << "RoutePointIndex [ m_segmentIndex == " << index.m_segmentIndex
|
||||
<< ", m_pathIndex == " << index.m_pathIndex << " ]" << std::endl;
|
||||
out << "RoutePointIndex [ m_segmentIndex == " << index.m_segmentIndex << ", m_pathIndex == " << index.m_pathIndex
|
||||
<< " ]" << std::endl;
|
||||
return out.str();
|
||||
}
|
||||
|
||||
@@ -179,13 +160,12 @@ RoutePointIndex GetFirstOutgoingPointIndex(size_t outgoingSegmentIndex)
|
||||
return RoutePointIndex({outgoingSegmentIndex, 0 /* m_pathIndex */});
|
||||
}
|
||||
|
||||
RoutePointIndex GetLastIngoingPointIndex(TUnpackedPathSegments const & segments,
|
||||
size_t const outgoingSegmentIndex)
|
||||
RoutePointIndex GetLastIngoingPointIndex(TUnpackedPathSegments const & segments, size_t const outgoingSegmentIndex)
|
||||
{
|
||||
ASSERT_GREATER(outgoingSegmentIndex, 0, ());
|
||||
ASSERT(segments[outgoingSegmentIndex - 1].IsValid(), ());
|
||||
return RoutePointIndex({outgoingSegmentIndex - 1,
|
||||
segments[outgoingSegmentIndex - 1].m_path.size() - 1 /* m_pathIndex */});
|
||||
return RoutePointIndex(
|
||||
{outgoingSegmentIndex - 1, segments[outgoingSegmentIndex - 1].m_path.size() - 1 /* m_pathIndex */});
|
||||
}
|
||||
|
||||
m2::PointD GetPointByIndex(TUnpackedPathSegments const & segments, RoutePointIndex const & index)
|
||||
@@ -198,9 +178,10 @@ double CalcOneSegmentTurnAngle(TurnInfo const & turnInfo)
|
||||
ASSERT_GREATER_OR_EQUAL(turnInfo.m_ingoing->m_path.size(), 2, ());
|
||||
ASSERT_GREATER_OR_EQUAL(turnInfo.m_outgoing->m_path.size(), 2, ());
|
||||
|
||||
return math::RadToDeg(PiMinusTwoVectorsAngle(turnInfo.m_ingoing->m_path.back().GetPoint(),
|
||||
turnInfo.m_ingoing->m_path[turnInfo.m_ingoing->m_path.size() - 2].GetPoint(),
|
||||
turnInfo.m_outgoing->m_path[1].GetPoint()));
|
||||
return math::RadToDeg(
|
||||
PiMinusTwoVectorsAngle(turnInfo.m_ingoing->m_path.back().GetPoint(),
|
||||
turnInfo.m_ingoing->m_path[turnInfo.m_ingoing->m_path.size() - 2].GetPoint(),
|
||||
turnInfo.m_outgoing->m_path[1].GetPoint()));
|
||||
}
|
||||
|
||||
double CalcPathTurnAngle(LoadedPathSegment const & segment, size_t const pathIndex)
|
||||
|
||||
Reference in New Issue
Block a user