mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 04:53:36 +00:00
Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run: git remote add om-historic [om-historic.git repo url] git fetch --tags om-historic git replace squashed-history historic-commits
This commit is contained in:
58
generator/centers_table_builder.cpp
Normal file
58
generator/centers_table_builder.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
#include "generator/centers_table_builder.hpp"
|
||||
|
||||
#include "indexer/centers_table.hpp"
|
||||
#include "indexer/feature_algo.hpp"
|
||||
#include "indexer/features_offsets_table.hpp"
|
||||
#include "indexer/features_vector.hpp"
|
||||
|
||||
#include "coding/files_container.hpp"
|
||||
|
||||
#include "base/exception.hpp"
|
||||
|
||||
#include "defines.hpp"
|
||||
|
||||
namespace indexer
|
||||
{
|
||||
bool BuildCentersTableFromDataFile(std::string const & filename, bool forceRebuild)
|
||||
{
|
||||
try
|
||||
{
|
||||
search::CentersTableBuilder builder;
|
||||
|
||||
{
|
||||
FilesContainerR rcont(filename);
|
||||
if (!forceRebuild && rcont.IsExist(CENTERS_FILE_TAG))
|
||||
return true;
|
||||
|
||||
auto const table = feature::FeaturesOffsetsTable::Load(rcont);
|
||||
if (!table)
|
||||
{
|
||||
LOG(LERROR, ("Can't load offsets table from:", filename));
|
||||
return false;
|
||||
}
|
||||
|
||||
feature::DataHeader const header(rcont);
|
||||
FeaturesVector const features(rcont, header, table.get(), nullptr);
|
||||
|
||||
builder.SetGeometryParams(header.GetBounds());
|
||||
features.ForEach([&](FeatureType & ft, uint32_t featureId)
|
||||
{
|
||||
builder.Put(featureId, feature::GetCenter(ft));
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
FilesContainerW writeContainer(filename, FileWriter::OP_WRITE_EXISTING);
|
||||
auto writer = writeContainer.GetWriter(CENTERS_FILE_TAG);
|
||||
builder.Freeze(*writer);
|
||||
}
|
||||
}
|
||||
catch (RootException const & e)
|
||||
{
|
||||
LOG(LERROR, ("Failed to build centers table:", e.Msg()));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
} // namespace indexer
|
||||
Reference in New Issue
Block a user