From f439b3bf4c9a2cc11f163a510e2ff55d809a120b Mon Sep 17 00:00:00 2001 From: Brandon Liu Date: Wed, 19 May 2021 12:56:51 +0800 Subject: [PATCH] handle case where there are not root tiles, only leaf directories [#13] --- python/pmtiles/writer.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/python/pmtiles/writer.py b/python/pmtiles/writer.py index 3e2e021..eea3f1f 100644 --- a/python/pmtiles/writer.py +++ b/python/pmtiles/writer.py @@ -95,8 +95,10 @@ class Writer: if len(leafdir_tiles): self.write_leafdir(leafdir_tiles,leafdir_len) - root = [(group[0],list(group[1])) for group in itertools.groupby(self.tiles,key=by_parent) if group[0][0] == 0][0] - root_tiles = root[1] + root_tiles = [] + root = [(group[0],list(group[1])) for group in itertools.groupby(self.tiles,key=by_parent) if group[0][0] == 0] + if root: + root_tiles = root[0][1] self.f.seek(0) self.write_header(metadata,len(root_tiles) + len(self.leaves)) for entry in root_tiles: