Skip to content

Commit

Permalink
Merge pull request #601 from cldellow/warn-about-osmconvert-pbfs
Browse files Browse the repository at this point in the history
warn the user when using sub-optimal PBFs
  • Loading branch information
systemed authored Dec 5, 2023
2 parents c01d9ee + 5e04240 commit f409626
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/read_pbf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,12 @@ int PbfReader::ReadPbfFile(unordered_set<string> const &nodeKeys, unsigned int t

std::map<std::size_t, std::pair< std::size_t, std::size_t> > blocks;

// Track the filesize - note that we can't rely on tellg(), as
// its meant to be an opaque token useful only for seeking.
size_t filesize = 0;
while (true) {
BlobHeader bh = readHeader(*infile);
filesize += bh.datasize();
if (infile->eof()) {
break;
}
Expand All @@ -327,6 +331,21 @@ int PbfReader::ReadPbfFile(unordered_set<string> const &nodeKeys, unsigned int t

std::size_t total_blocks = blocks.size();

// PBFs generated by Osmium have 8,000 entities per block,
// and each block is about 64KB.
//
// PBFs generated by osmconvert (e.g., BBBike PBFs) have as
// many entities as fit in 31MB. Each block is about 16MB.
//
// Osmium PBFs seem to be processed about 3x faster than osmconvert
// PBFs, so try to hint to the user when they could speed up their
// pipeline.
if (filesize / total_blocks > 1000000) {
std::cout << "warning: PBF has very large blocks, which may slow processing" << std::endl;
std::cout << " to fix: osmium cat -f pbf your-file.osm.pbf -o optimized.osm.pbf" << std::endl;
}


std::vector<ReadPhase> all_phases = { ReadPhase::Nodes, ReadPhase::RelationScan, ReadPhase::Ways, ReadPhase::Relations };
for(auto phase: all_phases) {
// Launch the pool with threadNum threads
Expand Down

0 comments on commit f409626

Please sign in to comment.