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

@@ -1,6 +1,6 @@
#include "generator/raw_generator.hpp"
//#include "generator/complex_loader.hpp"
// #include "generator/complex_loader.hpp"
#include "generator/features_processing_helpers.hpp"
#include "generator/final_processor_cities.hpp"
#include "generator/final_processor_coastline.hpp"
@@ -23,22 +23,17 @@ namespace
class Stats
{
public:
Stats(size_t logCallCountThreshold)
: m_timer(true /* start */), m_logCallCountThreshold(logCallCountThreshold)
{
}
Stats(size_t logCallCountThreshold) : m_timer(true /* start */), m_logCallCountThreshold(logCallCountThreshold) {}
void Log(std::vector<OsmElement> const & elements, uint64_t pos, bool forcePrint = false)
{
for (auto const & e : elements)
{
if (e.IsNode())
++m_nodeCounter;
else if (e.IsWay())
++m_wayCounter;
else if (e.IsRelation())
++m_relationCounter;
}
m_element_counter += elements.size();
if (!forcePrint && m_callCount != m_logCallCountThreshold)
@@ -51,12 +46,11 @@ public:
auto const posMiB = pos / kBytesInMiB;
auto const elapsedSeconds = m_timer.ElapsedSeconds();
auto const avgSpeedMiBPerSec = posMiB / elapsedSeconds;
auto const speedMiBPerSec =
(pos - m_prevFilePos) / (elapsedSeconds - m_prevElapsedSeconds) / kBytesInMiB;
auto const speedMiBPerSec = (pos - m_prevFilePos) / (elapsedSeconds - m_prevElapsedSeconds) / kBytesInMiB;
LOG(LINFO, ("Read", m_element_counter, "elements [pos:", posMiB,
"MiB, avg read speed:", avgSpeedMiBPerSec, " MiB/s, read speed:", speedMiBPerSec,
"MiB/s [n:", m_nodeCounter, ", w:", m_wayCounter, ", r:", m_relationCounter, "]]"));
LOG(LINFO, ("Read", m_element_counter, "elements [pos:", posMiB, "MiB, avg read speed:", avgSpeedMiBPerSec,
" MiB/s, read speed:", speedMiBPerSec, "MiB/s [n:", m_nodeCounter, ", w:", m_wayCounter,
", r:", m_relationCounter, "]]"));
m_prevFilePos = pos;
m_prevElapsedSeconds = elapsedSeconds;
@@ -86,8 +80,7 @@ RawGenerator::RawGenerator(feature::GenerateInfo & genInfo, size_t threadsCount,
, m_cache(std::make_shared<generator::cache::IntermediateData>(m_intermediateDataObjectsCache, genInfo))
, m_queue(std::make_shared<FeatureProcessorQueue>())
, m_translators(std::make_shared<TranslatorCollection>())
{
}
{}
void RawGenerator::ForceReloadCache()
{
@@ -95,11 +88,11 @@ void RawGenerator::ForceReloadCache()
m_cache = std::make_shared<cache::IntermediateData>(m_intermediateDataObjectsCache, m_genInfo);
}
void RawGenerator::GenerateCountries(bool isTests/* = false*/)
void RawGenerator::GenerateCountries(bool isTests /* = false*/)
{
// if (!m_genInfo.m_complexHierarchyFilename.empty())
// m_hierarchyNodesSet = GetOrCreateComplexLoader(m_genInfo.m_complexHierarchyFilename).GetIdsSet();
// auto const complexFeaturesMixer = std::make_shared<ComplexFeaturesMixer>(m_hierarchyNodesSet);
// if (!m_genInfo.m_complexHierarchyFilename.empty())
// m_hierarchyNodesSet = GetOrCreateComplexLoader(m_genInfo.m_complexHierarchyFilename).GetIdsSet();
// auto const complexFeaturesMixer = std::make_shared<ComplexFeaturesMixer>(m_hierarchyNodesSet);
AffiliationInterfacePtr affiliation;
if (isTests)
@@ -108,8 +101,8 @@ void RawGenerator::GenerateCountries(bool isTests/* = false*/)
}
else
{
affiliation = std::make_shared<feature::CountriesFilesIndexAffiliation>(
m_genInfo.m_targetDir, m_genInfo.m_haveBordersForWholeWorld);
affiliation = std::make_shared<feature::CountriesFilesIndexAffiliation>(m_genInfo.m_targetDir,
m_genInfo.m_haveBordersForWholeWorld);
}
auto processor = CreateProcessor(ProcessorType::Country, affiliation, m_queue);
@@ -118,14 +111,14 @@ void RawGenerator::GenerateCountries(bool isTests/* = false*/)
/// and dispatches FB into Coastline, World, Country, City processors.
/// Now we have at least 2x similar work in OsmElement->GetNameAndType->FeatureBuilder (for Country and World).
m_translators->Append(CreateTranslator(TranslatorType::Country, processor, m_cache, m_genInfo,
isTests ? nullptr : affiliation));
m_translators->Append(
CreateTranslator(TranslatorType::Country, processor, m_cache, m_genInfo, isTests ? nullptr : affiliation));
m_finalProcessors.emplace(CreateCountryFinalProcessor(affiliation, false));
m_finalProcessors.emplace(CreatePlacesFinalProcessor(affiliation));
}
void RawGenerator::GenerateWorld(bool cutBordersByWater/* = true */)
void RawGenerator::GenerateWorld(bool cutBordersByWater /* = true */)
{
auto processor = CreateProcessor(ProcessorType::World, m_queue, m_genInfo.m_popularPlacesFilename);
m_translators->Append(CreateTranslator(TranslatorType::World, processor, m_cache, m_genInfo));
@@ -144,9 +137,8 @@ void RawGenerator::GenerateCustom(std::shared_ptr<TranslatorInterface> const & t
m_translators->Append(translator);
}
void RawGenerator::GenerateCustom(
std::shared_ptr<TranslatorInterface> const & translator,
std::shared_ptr<FinalProcessorIntermediateMwmInterface> const & finalProcessor)
void RawGenerator::GenerateCustom(std::shared_ptr<TranslatorInterface> const & translator,
std::shared_ptr<FinalProcessorIntermediateMwmInterface> const & finalProcessor)
{
m_translators->Append(translator);
m_finalProcessors.emplace(finalProcessor);
@@ -184,8 +176,8 @@ RawGenerator::FinalProcessorPtr RawGenerator::CreateCoslineFinalProcessor()
return finalProcessor;
}
RawGenerator::FinalProcessorPtr RawGenerator::CreateCountryFinalProcessor(
AffiliationInterfacePtr const & affiliations, bool addAds)
RawGenerator::FinalProcessorPtr RawGenerator::CreateCountryFinalProcessor(AffiliationInterfacePtr const & affiliations,
bool addAds)
{
auto finalProcessor = std::make_shared<CountryFinalProcessor>(affiliations, m_genInfo.m_tmpDir, m_threadsCount);
finalProcessor->SetIsolinesDir(m_genInfo.m_isolinesDir);
@@ -197,9 +189,8 @@ RawGenerator::FinalProcessorPtr RawGenerator::CreateCountryFinalProcessor(
if (m_genInfo.m_emitCoasts)
{
finalProcessor->SetCoastlines(
m_genInfo.GetIntermediateFileName(WORLD_COASTS_FILE_NAME, ".geom"),
m_genInfo.GetTmpFileName(WORLD_COASTS_FILE_NAME));
finalProcessor->SetCoastlines(m_genInfo.GetIntermediateFileName(WORLD_COASTS_FILE_NAME, ".geom"),
m_genInfo.GetTmpFileName(WORLD_COASTS_FILE_NAME));
}
finalProcessor->SetCityBoundariesFiles(m_genInfo.GetIntermediateFileName(CITY_BOUNDARIES_COLLECTOR_FILENAME));
@@ -212,7 +203,7 @@ RawGenerator::FinalProcessorPtr RawGenerator::CreateWorldFinalProcessor(bool cut
if (cutBordersByWater)
{
// This file should exist or read exception will be thrown otherwise.
coastlineGeom = m_genInfo.GetIntermediateFileName(WORLD_COASTS_FILE_NAME, RAW_GEOM_FILE_EXTENSION);
coastlineGeom = m_genInfo.GetIntermediateFileName(WORLD_COASTS_FILE_NAME, RAW_GEOM_FILE_EXTENSION);
}
auto finalProcessor = std::make_shared<WorldFinalProcessor>(m_genInfo.m_tmpDir, coastlineGeom);
@@ -230,8 +221,7 @@ RawGenerator::FinalProcessorPtr RawGenerator::CreatePlacesFinalProcessor(Affilia
bool RawGenerator::GenerateFilteredFeatures()
{
SourceReader reader =
m_genInfo.m_osmFileName.empty() ? SourceReader() : SourceReader(m_genInfo.m_osmFileName);
SourceReader reader = m_genInfo.m_osmFileName.empty() ? SourceReader() : SourceReader(m_genInfo.m_osmFileName);
std::unique_ptr<ProcessorOsmElementsInterface> sourceProcessor;
switch (m_genInfo.m_osmFileType)
@@ -266,13 +256,13 @@ bool RawGenerator::GenerateFilteredFeatures()
++idx;
isEnd = idx < m_chunkSize;
stats.Log(elements, reader.Pos(), isEnd/* forcePrint */);
stats.Log(elements, reader.Pos(), isEnd /* forcePrint */);
if (isEnd)
elements.resize(idx);
translators.Emit(std::move(elements));
} while (!isEnd);
}
while (!isEnd);
LOG(LINFO, ("OSM source input was processed."));
if (!translators.Finish())