diff --git a/python/pmtiles/writer.py b/python/pmtiles/writer.py index 1c2ca6c..8ac70a7 100644 --- a/python/pmtiles/writer.py +++ b/python/pmtiles/writer.py @@ -1,3 +1,4 @@ +import gzip import itertools import json from contextlib import contextmanager @@ -20,6 +21,10 @@ class Writer: self.leaves = [] def write_tile(self,z,x,y,data): + # if the tile is GZIP-encoded, it won't work with range queries + # until transfer-encoding: gzip is well supported. + if data[0:2] == b'\x1f\x8b': + data = gzip.decompress(data) hsh = hash(data) if hsh in self.hash_to_offset: self.tiles.append((z,x,y,self.hash_to_offset[hsh],len(data)))