fix root dir writing, refactor js getZxy

This commit is contained in:
Brandon Liu
2021-02-18 16:21:30 +08:00
parent ab8f1e889d
commit f309d81aa2
4 changed files with 79 additions and 52 deletions

View File

@@ -47,6 +47,7 @@ class Reader:
def root_entries(self):
return int.from_bytes(self.mmap[8:10],byteorder='little')
# TODO support recursive directories
def get(self,z,x,y):
val = self.root_dir.get((z,x,y))
if val:

View File

@@ -97,8 +97,8 @@ class Writer:
if len(leafdir_tiles):
self.write_leafdir(leafdir_tiles)
root = [group for group in itertools.groupby(self.tiles,key=by_parent) if group[0][0] == 0][0]
root_tiles = list(root[1])
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]
self.f.seek(0)
self.write_header(metadata,len(root_tiles) + len(self.leaves))
for entry in root_tiles: