Skip to content

Commit 0d01bc5

Browse files
authored
pmtiles: always set leafStart when closing file [#794] (#795)
* 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.
1 parent 5483eb4 commit 0d01bc5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/pmtiles.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ void PMTiles::close(std::string &metadata) {
2828
// add all tiles to directories, writing leaf directories as we go
2929
std::vector<pmtiles::entryv3> rootEntries;
3030
std::vector<pmtiles::entryv3> entries;
31+
leafStart = outputStream.tellp();
3132
if (isSparse) {
3233
for (auto it : sparseIndex) {
3334
appendTileEntry(it.first, it.second, rootEntries, entries);
@@ -120,7 +121,6 @@ void PMTiles::flushEntries(std::vector<pmtiles::entryv3> &rootEntries, std::vect
120121
// write the leaf directory to disk
121122
std::lock_guard<std::mutex> lock(fileMutex);
122123
uint64_t location = outputStream.tellp();
123-
if (leafStart==0) leafStart=location;
124124
uint64_t length = compressed.size();
125125
outputStream << compressed;
126126

0 commit comments

Comments
 (0)