Skip to content

Commit

Permalink
pmtiles: always set leafStart when closing file [#794] (#795)
Browse files Browse the repository at this point in the history
* the leafStart was only assigned in flushEntries, which never happens if there is only a root directory.
* resulted in erroneous leafDirectoryOffset and tileDataLength in the pmtiles header.
  • Loading branch information
bdon authored Jan 30, 2025
1 parent 5483eb4 commit 0d01bc5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/pmtiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ void PMTiles::close(std::string &metadata) {
// add all tiles to directories, writing leaf directories as we go
std::vector<pmtiles::entryv3> rootEntries;
std::vector<pmtiles::entryv3> entries;
leafStart = outputStream.tellp();
if (isSparse) {
for (auto it : sparseIndex) {
appendTileEntry(it.first, it.second, rootEntries, entries);
Expand Down Expand Up @@ -120,7 +121,6 @@ void PMTiles::flushEntries(std::vector<pmtiles::entryv3> &rootEntries, std::vect
// write the leaf directory to disk
std::lock_guard<std::mutex> lock(fileMutex);
uint64_t location = outputStream.tellp();
if (leafStart==0) leafStart=location;
uint64_t length = compressed.size();
outputStream << compressed;

Expand Down

0 comments on commit 0d01bc5

Please sign in to comment.