Format all C++ and Java code via clang-format

Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
Konstantin Pastbin
2025-08-17 14:32:37 +07:00
parent 9f0290c0ec
commit bfffa1fff4
2169 changed files with 56441 additions and 64188 deletions

View File

@@ -16,8 +16,7 @@ double constexpr kMinSegmentLengthM = 200.0;
double constexpr kHalfSegmentLengthM = kMinSegmentLengthM / 2.0;
// Returns true if roads count between |mwmId1| and |mwmId2| in |graph| exceeds max value.
bool MwmRoadsAreFilled(routing::NumMwmId const & mwmId1, routing::NumMwmId const & mwmId2,
CrossBorderGraph & graph)
bool MwmRoadsAreFilled(routing::NumMwmId const & mwmId1, routing::NumMwmId const & mwmId2, CrossBorderGraph & graph)
{
auto const it = graph.m_mwms.find(mwmId1);
if (it == graph.m_mwms.end())
@@ -44,8 +43,7 @@ void WriteEndingToSteam(CrossBorderSegmentEnding const & segEnding, std::ofstrea
output << kDelim << point.m_lat << kDelim << point.m_lon << kDelim << segEnding.m_numMwmId;
}
void WriteSegmentToStream(RegionSegmentId const & segId, CrossBorderSegment const & seg,
std::ofstream & output)
void WriteSegmentToStream(RegionSegmentId const & segId, CrossBorderSegment const & seg, std::ofstream & output)
{
CHECK(output.is_open(), ());
@@ -58,8 +56,7 @@ void WriteSegmentToStream(RegionSegmentId const & segId, CrossBorderSegment cons
namespace routing
{
RoadsFromOsm GetRoadsFromOsm(generator::SourceReader & reader,
feature::CountriesFilesAffiliation const & mwmMatcher,
RoadsFromOsm GetRoadsFromOsm(generator::SourceReader & reader, feature::CountriesFilesAffiliation const & mwmMatcher,
std::vector<std::string> const & highways)
{
RoadsFromOsm roadsFromOsm;
@@ -173,8 +170,7 @@ std::pair<NodePoints, CrossBorderIndexes> GetCrossBorderPoints(
return std::make_pair(nodePoints, crossBorderIndexes);
}
std::optional<std::pair<m2::PointD, double>> GetPointInMwm(NodePoints const & points, size_t index,
bool forward)
std::optional<std::pair<m2::PointD, double>> GetPointInMwm(NodePoints const & points, size_t index, bool forward)
{
auto const & pointOnBorder = points[index];
@@ -206,13 +202,11 @@ std::optional<std::pair<m2::PointD, double>> GetPointInMwm(NodePoints const & po
}
bool FillCrossBorderGraph(CrossBorderGraph & graph, RegionSegmentId & curSegmentId,
std::vector<uint64_t> const & nodeIds,
std::unordered_map<uint64_t, ms::LatLon> const & nodes,
std::vector<uint64_t> const & nodeIds, std::unordered_map<uint64_t, ms::LatLon> const & nodes,
feature::CountriesFilesAffiliation const & mwmMatcher,
std::unordered_map<std::string, NumMwmId> const & regionToIdMap)
{
auto const & [nodePoints, crossBorderIndexes] =
GetCrossBorderPoints(nodeIds, nodes, mwmMatcher, regionToIdMap);
auto const & [nodePoints, crossBorderIndexes] = GetCrossBorderPoints(nodeIds, nodes, mwmMatcher, regionToIdMap);
bool insertedRoad = false;

View File

@@ -27,10 +27,7 @@ struct RoadData
{
RoadData() = default;
RoadData(std::set<std::string> regions, OsmElement && way)
: m_regions(std::move(regions)), m_way(std::move(way))
{
}
RoadData(std::set<std::string> regions, OsmElement && way) : m_regions(std::move(regions)), m_way(std::move(way)) {}
std::set<std::string> m_regions;
OsmElement m_way;
@@ -47,15 +44,13 @@ struct RoadsFromOsm
};
// Reads roads from |reader| and finds its mwms with |mwmMatcher|.
RoadsFromOsm GetRoadsFromOsm(generator::SourceReader & reader,
feature::CountriesFilesAffiliation const & mwmMatcher,
RoadsFromOsm GetRoadsFromOsm(generator::SourceReader & reader, feature::CountriesFilesAffiliation const & mwmMatcher,
std::vector<std::string> const & highways);
// Fills |graph| with new segments starting from |curSegmentId|. Segments are calculated from the
// road consisting of |nodeIds| from OSM.
bool FillCrossBorderGraph(CrossBorderGraph & graph, RegionSegmentId & curSegmentId,
std::vector<uint64_t> const & nodeIds,
std::unordered_map<uint64_t, ms::LatLon> const & nodes,
std::vector<uint64_t> const & nodeIds, std::unordered_map<uint64_t, ms::LatLon> const & nodes,
feature::CountriesFilesAffiliation const & mwmMatcher,
std::unordered_map<std::string, routing::NumMwmId> const & regionToIdMap);
@@ -63,6 +58,5 @@ bool FillCrossBorderGraph(CrossBorderGraph & graph, RegionSegmentId & curSegment
bool WriteGraphToFile(CrossBorderGraph const & graph, std::string const & path, bool overwrite);
// Logs statistics about segments in |graph|.
void ShowRegionsStats(CrossBorderGraph const & graph,
std::shared_ptr<routing::NumMwmIds> numMwmIds);
void ShowRegionsStats(CrossBorderGraph const & graph, std::shared_ptr<routing::NumMwmIds> numMwmIds);
} // namespace routing

View File

@@ -22,7 +22,6 @@
#include <gflags/gflags.h>
DEFINE_string(path_resources, "", "CoMaps resources directory");
DEFINE_string(path_roads_file, "", "OSM file in o5m format.");
DEFINE_string(path_res_file, "", "Path to the resulting file with roads for generator_tool.");
@@ -31,13 +30,12 @@ int main(int argc, char ** argv)
{
using namespace routing;
gflags::SetUsageMessage(
"Reads OSM file, generates text file with main cross-mwm roads for generator_tool.");
gflags::SetUsageMessage("Reads OSM file, generates text file with main cross-mwm roads for generator_tool.");
gflags::ParseCommandLineFlags(&argc, &argv, true);
auto const toolName = base::FileNameFromFullPath(argv[0]);
if (FLAGS_path_resources.empty() || !Platform::IsDirectory(FLAGS_path_resources) ||
FLAGS_path_roads_file.empty() || FLAGS_path_res_file.empty())
if (FLAGS_path_resources.empty() || !Platform::IsDirectory(FLAGS_path_resources) || FLAGS_path_roads_file.empty() ||
FLAGS_path_res_file.empty())
{
gflags::ShowUsageWithFlagsRestrict(argv[0], toolName.c_str());
return EXIT_FAILURE;
@@ -45,12 +43,10 @@ int main(int argc, char ** argv)
GetPlatform().SetResourceDir(FLAGS_path_resources);
feature::CountriesFilesAffiliation mwmMatcher(GetPlatform().ResourcesDir(),
false /* haveBordersForWholeWorld */);
feature::CountriesFilesAffiliation mwmMatcher(GetPlatform().ResourcesDir(), false /* haveBordersForWholeWorld */);
// These types are used in maps_generator (maps_generator/genrator/steps.py in filter_roads function).
std::vector<std::string> const highwayTypes{"motorway", "trunk", "primary", "secondary",
"tertiary"};
std::vector<std::string> const highwayTypes{"motorway", "trunk", "primary", "secondary", "tertiary"};
generator::SourceReader reader(FLAGS_path_roads_file);
RoadsFromOsm const & roadsFromOsm = GetRoadsFromOsm(reader, mwmMatcher, highwayTypes);
@@ -60,7 +56,8 @@ int main(int argc, char ** argv)
std::unordered_map<std::string, NumMwmId> regionsToIds;
numMwmIds->ForEachId([&regionsToIds, &numMwmIds](NumMwmId id) {
numMwmIds->ForEachId([&regionsToIds, &numMwmIds](NumMwmId id)
{
std::string const & region = numMwmIds->GetFile(id).GetName();
CHECK(regionsToIds.emplace(region, id).second, (id, region));
});
@@ -81,9 +78,8 @@ int main(int argc, char ** argv)
if (wayData.m_regions.size() == 1)
continue;
bool const foundSegments =
FillCrossBorderGraph(graph, curSegmentId, wayData.m_way.Nodes(), roadsFromOsm.m_nodes,
mwmMatcher, regionsToIds);
bool const foundSegments = FillCrossBorderGraph(graph, curSegmentId, wayData.m_way.Nodes(), roadsFromOsm.m_nodes,
mwmMatcher, regionsToIds);
LOG(LINFO, ("Found segments for", wayId, ":", foundSegments));
}