Whole file

protomaps/pmtiles

The author described this change as python writer: fix logical error when a packed leaf directory overflows [#37]. It counts as a record because the check below fails on the code as it stood at a32947688 and passes on df8256f10, with nothing else changed between the two runs.

Fix saved2022-03-20
Sharing licenceBSD-3-Clause · LICENSE
Change size+1 2

What the code was meant to do, written into the code itself as a save note

python writer: fix logical error when a packed leaf directory overflows [#37]

The change

3939
4040 for group in itertools.groupby(entries_in_leaves,key=by_parent):
4141 subpyramid_entries = list(group[1])
42+ root = subpyramid_entries[0]
4243 if len(packed_entries) + len(subpyramid_entries) <= max_dir_size:
4344 # the first item MUST be the root of the pyramid (sorted) - but it may have multiple roots
44- root = subpyramid_entries[0]
4545 packed_entries.extend(subpyramid_entries)
4646 packed_roots.append((root.z,root.x,root.y))
4747 else:
4848 # flush the current packed entries
49- root = packed_entries[0]
5049
5150 for p in packed_roots:
5251 root_entries.append(Entry(p[0],p[1],p[2],current_offset,17 * len(packed_entries),True))

The check that tells the two apart

failpass·python/test/test_writer.py::TestTilePyramid::test_leafdir_overflow

Check file python/test/test_writer.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before ita32947688adede92a2d3ad4032dc798730af58f7
Broken version dated2022-03-17
Modulepython.pmtiles.writer
Units changedmake_pyramid
Fingerprint0c5d001e1e2ab9eb
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in protomaps/pmtiles