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:
@@ -19,8 +19,7 @@ double constexpr kEqDistToTrackPointM = 20.0;
|
||||
double constexpr kMaxDistToTrackForSkippingM = 100'000.0;
|
||||
} // namespace
|
||||
|
||||
CheckpointTrackProj::CheckpointTrackProj(kml::MarkGroupId guideId, size_t trackIdx,
|
||||
size_t trackPointIdx,
|
||||
CheckpointTrackProj::CheckpointTrackProj(kml::MarkGroupId guideId, size_t trackIdx, size_t trackPointIdx,
|
||||
geometry::PointWithAltitude const & projectedPoint,
|
||||
double distToProjectedPointM)
|
||||
: m_guideId(guideId)
|
||||
@@ -28,21 +27,22 @@ CheckpointTrackProj::CheckpointTrackProj(kml::MarkGroupId guideId, size_t trackI
|
||||
, m_trackPointIdx(trackPointIdx)
|
||||
, m_projectedPoint(projectedPoint)
|
||||
, m_distToProjectedPointM(distToProjectedPointM)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
std::pair<geometry::PointWithAltitude, double> GetProjectionAndDistOnSegment(
|
||||
m2::PointD const & point, geometry::PointWithAltitude const & startPath,
|
||||
geometry::PointWithAltitude const & endPath)
|
||||
{
|
||||
m2::PointD const projection =
|
||||
m2::ParametrizedSegment<m2::PointD>(startPath.GetPoint(), endPath.GetPoint())
|
||||
.ClosestPointTo(point);
|
||||
m2::ParametrizedSegment<m2::PointD>(startPath.GetPoint(), endPath.GetPoint()).ClosestPointTo(point);
|
||||
double const distM = mercator::DistanceOnEarth(projection, point);
|
||||
return std::make_pair(geometry::PointWithAltitude(projection, 0 /* altitude */), distM);
|
||||
}
|
||||
|
||||
bool GuidesConnections::IsActive() const { return !m_allTracks.empty(); }
|
||||
bool GuidesConnections::IsActive() const
|
||||
{
|
||||
return !m_allTracks.empty();
|
||||
}
|
||||
|
||||
std::vector<ConnectionToOsm> GuidesConnections::GetOsmConnections(size_t checkpointIdx) const
|
||||
{
|
||||
@@ -52,17 +52,14 @@ std::vector<ConnectionToOsm> GuidesConnections::GetOsmConnections(size_t checkpo
|
||||
return it->second;
|
||||
}
|
||||
|
||||
void GuidesConnections::UpdateOsmConnections(size_t checkpointIdx,
|
||||
std::vector<ConnectionToOsm> const & links)
|
||||
void GuidesConnections::UpdateOsmConnections(size_t checkpointIdx, std::vector<ConnectionToOsm> const & links)
|
||||
{
|
||||
auto const it = m_connectionsToOsm.find(checkpointIdx);
|
||||
CHECK(it != m_connectionsToOsm.cend(), (checkpointIdx));
|
||||
it->second.clear();
|
||||
for (auto const & link : links)
|
||||
{
|
||||
if (!link.m_fakeEnding.m_projections.empty())
|
||||
it->second.push_back(link);
|
||||
}
|
||||
if (it->second.empty())
|
||||
m_connectionsToOsm.erase(it);
|
||||
}
|
||||
@@ -80,9 +77,8 @@ void GuidesConnections::PullCheckpointsToTracks(std::vector<m2::PointD> const &
|
||||
CHECK(!tracks[trackIdx].empty(), (trackIdx));
|
||||
for (size_t pointIdx = 0; pointIdx < tracks[trackIdx].size() - 1; ++pointIdx)
|
||||
{
|
||||
auto const [checkpointProj, distM] =
|
||||
GetProjectionAndDistOnSegment(checkpoints[checkpointIdx], tracks[trackIdx][pointIdx],
|
||||
tracks[trackIdx][pointIdx + 1]);
|
||||
auto const [checkpointProj, distM] = GetProjectionAndDistOnSegment(
|
||||
checkpoints[checkpointIdx], tracks[trackIdx][pointIdx], tracks[trackIdx][pointIdx + 1]);
|
||||
|
||||
// Skip too far track.
|
||||
if (distM > kMaxDistToTrackForSkippingM)
|
||||
@@ -103,8 +99,7 @@ void GuidesConnections::PullCheckpointsToTracks(std::vector<m2::PointD> const &
|
||||
}
|
||||
}
|
||||
|
||||
void GuidesConnections::AddTerminalGuidePoint(size_t checkpointIdx, size_t neighbourIdx,
|
||||
m2::PointD const & curPoint)
|
||||
void GuidesConnections::AddTerminalGuidePoint(size_t checkpointIdx, size_t neighbourIdx, m2::PointD const & curPoint)
|
||||
{
|
||||
auto const it = m_checkpointsOnTracks.find(neighbourIdx);
|
||||
CHECK(it != m_checkpointsOnTracks.cend(), (neighbourIdx));
|
||||
@@ -114,25 +109,23 @@ void GuidesConnections::AddTerminalGuidePoint(size_t checkpointIdx, size_t neigh
|
||||
auto const trackIdx = neighbour.m_trackIdx;
|
||||
auto const & track = m_allTracks[guideId][trackIdx];
|
||||
|
||||
CHECK_GREATER(
|
||||
track.size(), 1,
|
||||
("checkpointIdx:", checkpointIdx, "neighbourIdx:", neighbourIdx, "trackIdx:", trackIdx));
|
||||
CHECK_GREATER(track.size(), 1,
|
||||
("checkpointIdx:", checkpointIdx, "neighbourIdx:", neighbourIdx, "trackIdx:", trackIdx));
|
||||
|
||||
// Connect start checkpoint to the starting point of the track.
|
||||
if (checkpointIdx == 0)
|
||||
{
|
||||
double const distToStartM = mercator::DistanceOnEarth(curPoint, track.front().GetPoint());
|
||||
m_checkpointsOnTracks[checkpointIdx] = CheckpointTrackProj(
|
||||
guideId, trackIdx, 0 /* trackPointIdx */, track.front() /* proj */, distToStartM);
|
||||
m_checkpointsOnTracks[checkpointIdx] =
|
||||
CheckpointTrackProj(guideId, trackIdx, 0 /* trackPointIdx */, track.front() /* proj */, distToStartM);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Connect finish checkpoint to the finish point of the track.
|
||||
double const distToSFinishM = mercator::DistanceOnEarth(curPoint, track.back().GetPoint());
|
||||
m_checkpointsOnTracks[checkpointIdx] =
|
||||
CheckpointTrackProj(guideId, trackIdx, track.size() - 2 /* trackPointIdx */,
|
||||
track.back() /* proj */, distToSFinishM);
|
||||
m_checkpointsOnTracks[checkpointIdx] = CheckpointTrackProj(guideId, trackIdx, track.size() - 2 /* trackPointIdx */,
|
||||
track.back() /* proj */, distToSFinishM);
|
||||
}
|
||||
|
||||
bool GuidesConnections::IsCheckpointAttached(size_t checkpointIdx) const
|
||||
@@ -153,8 +146,7 @@ std::vector<size_t> GetNeighbourIntermediatePoints(size_t checkpointIdx, size_t
|
||||
return neighbours;
|
||||
}
|
||||
|
||||
bool GuidesConnections::FitsForDirectLinkToGuide(size_t checkpointIdx,
|
||||
size_t checkpointsCount) const
|
||||
bool GuidesConnections::FitsForDirectLinkToGuide(size_t checkpointIdx, size_t checkpointsCount) const
|
||||
{
|
||||
auto it = m_checkpointsOnTracks.find(checkpointIdx);
|
||||
CHECK(it != m_checkpointsOnTracks.end(), (checkpointIdx));
|
||||
@@ -168,16 +160,13 @@ bool GuidesConnections::FitsForDirectLinkToGuide(size_t checkpointIdx,
|
||||
return true;
|
||||
|
||||
for (auto const neighbourIdx : GetNeighbourIntermediatePoints(checkpointIdx, checkpointsCount))
|
||||
{
|
||||
if (m_checkpointsOnTracks.find(neighbourIdx) == m_checkpointsOnTracks.end())
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void GuidesConnections::PullAdditionalCheckpointsToTracks(
|
||||
std::vector<m2::PointD> const & checkpoints)
|
||||
void GuidesConnections::PullAdditionalCheckpointsToTracks(std::vector<m2::PointD> const & checkpoints)
|
||||
{
|
||||
for (size_t i : {size_t(0), checkpoints.size() - 1})
|
||||
{
|
||||
@@ -195,7 +184,10 @@ void GuidesConnections::PullAdditionalCheckpointsToTracks(
|
||||
}
|
||||
}
|
||||
|
||||
bool GuidesConnections::IsAttached() const { return !m_checkpointsFakeEndings.empty(); }
|
||||
bool GuidesConnections::IsAttached() const
|
||||
{
|
||||
return !m_checkpointsFakeEndings.empty();
|
||||
}
|
||||
|
||||
FakeEnding GuidesConnections::GetFakeEnding(size_t checkpointIdx) const
|
||||
{
|
||||
@@ -208,7 +200,10 @@ FakeEnding GuidesConnections::GetFakeEnding(size_t checkpointIdx) const
|
||||
return FakeEnding();
|
||||
}
|
||||
|
||||
GuidesGraph const & GuidesConnections::GetGuidesGraph() const { return m_graph; }
|
||||
GuidesGraph const & GuidesConnections::GetGuidesGraph() const
|
||||
{
|
||||
return m_graph;
|
||||
}
|
||||
|
||||
void GuidesConnections::OverwriteFakeEnding(size_t checkpointIdx, FakeEnding const & newFakeEnding)
|
||||
{
|
||||
@@ -216,19 +211,19 @@ void GuidesConnections::OverwriteFakeEnding(size_t checkpointIdx, FakeEnding con
|
||||
}
|
||||
|
||||
// static
|
||||
void GuidesConnections::ExtendFakeEndingProjections(FakeEnding const & srcFakeEnding,
|
||||
FakeEnding & dstFakeEnding)
|
||||
void GuidesConnections::ExtendFakeEndingProjections(FakeEnding const & srcFakeEnding, FakeEnding & dstFakeEnding)
|
||||
{
|
||||
dstFakeEnding.m_originJunction = srcFakeEnding.m_originJunction;
|
||||
|
||||
for (auto const & proj : srcFakeEnding.m_projections)
|
||||
{
|
||||
if (!base::IsExist(dstFakeEnding.m_projections, proj))
|
||||
dstFakeEnding.m_projections.push_back(proj);
|
||||
}
|
||||
}
|
||||
|
||||
NumMwmId GuidesConnections::GetMwmId() const { return m_graph.GetMwmId(); }
|
||||
NumMwmId GuidesConnections::GetMwmId() const
|
||||
{
|
||||
return m_graph.GetMwmId();
|
||||
}
|
||||
|
||||
void GuidesConnections::SetGuidesGraphParams(NumMwmId mwmId, double maxSpeed)
|
||||
{
|
||||
@@ -254,11 +249,9 @@ void GuidesConnections::ConnectToGuidesGraph(std::vector<m2::PointD> const & che
|
||||
if (insertedSegment)
|
||||
{
|
||||
CHECK(!m_allTracks[proj.m_guideId][proj.m_trackIdx].empty(),
|
||||
("checkpointIdx:", checkpointIdx, "guideId:", proj.m_guideId,
|
||||
"trackIdx:", proj.m_trackIdx));
|
||||
("checkpointIdx:", checkpointIdx, "guideId:", proj.m_guideId, "trackIdx:", proj.m_trackIdx));
|
||||
|
||||
segmentOnTrack =
|
||||
m_graph.AddTrack(m_allTracks[proj.m_guideId][proj.m_trackIdx], proj.m_trackPointIdx);
|
||||
segmentOnTrack = m_graph.AddTrack(m_allTracks[proj.m_guideId][proj.m_trackIdx], proj.m_trackPointIdx);
|
||||
it->second = segmentOnTrack;
|
||||
}
|
||||
else
|
||||
@@ -279,8 +272,7 @@ void GuidesConnections::ConnectToGuidesGraph(std::vector<m2::PointD> const & che
|
||||
if (!(fitsForOsmLink && firstPointOnTrack == checkpointProj))
|
||||
{
|
||||
auto const & firstSegmentOnTrack = m_graph.FindSegment(segmentOnTrack, 0);
|
||||
AddConnectionToOsm(checkpointIdx, firstSegmentOnTrack, firstPointOnTrack,
|
||||
false /* fromCheckpoint */);
|
||||
AddConnectionToOsm(checkpointIdx, firstSegmentOnTrack, firstPointOnTrack, false /* fromCheckpoint */);
|
||||
}
|
||||
|
||||
auto const & lastPointIdx = m_allTracks[proj.m_guideId][proj.m_trackIdx].size() - 1;
|
||||
@@ -288,15 +280,13 @@ void GuidesConnections::ConnectToGuidesGraph(std::vector<m2::PointD> const & che
|
||||
if (!(fitsForOsmLink && lastPointOnTrack == checkpointProj))
|
||||
{
|
||||
auto const & lastSegmentOnTrack = m_graph.FindSegment(segmentOnTrack, lastPointIdx - 1);
|
||||
AddConnectionToOsm(checkpointIdx, lastSegmentOnTrack, lastPointOnTrack,
|
||||
false /* fromCheckpoint */);
|
||||
AddConnectionToOsm(checkpointIdx, lastSegmentOnTrack, lastPointOnTrack, false /* fromCheckpoint */);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GuidesConnections::AddConnectionToOsm(size_t checkpointIdx, Segment const & real,
|
||||
geometry::PointWithAltitude const & loop,
|
||||
bool fromCheckpoint)
|
||||
geometry::PointWithAltitude const & loop, bool fromCheckpoint)
|
||||
{
|
||||
LatLonWithAltitude const loopPoint(mercator::ToLatLon(loop.GetPoint()), loop.GetAltitude());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user