mirror of
https://github.com/protomaps/PMTiles.git
synced 2026-02-04 19:01:08 +00:00
detect and decompress gzipped tile data
This commit is contained in:
@@ -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)))
|
||||
|
||||
Reference in New Issue
Block a user