added flag to generate gzipped MVT PBF

This commit is contained in:
Taro Matsuzawa 2017-12-10 21:12:41 +09:00
parent 66d17625d8
commit b60a8f42f2

View File

@ -17,6 +17,8 @@ import yaml
import sys
import itertools
import gzip
def GetTM2Source(file):
with open(file,'r') as stream:
tm2source = yaml.load(stream)
@ -43,6 +45,8 @@ DBSession = sessionmaker(bind=engine)
session = DBSession()
session.execute(prepared)
gziped = os.getenv('GZIP') == 'true'
def bounds(zoom,x,y):
inProj = pyproj.Proj(init='epsg:4326')
outProj = pyproj.Proj(init='epsg:3857')
@ -81,6 +85,8 @@ def get_mvt(zoom,x,y):
final_tile = b''
for layer in layers:
final_tile = final_tile + io.BytesIO(layer).getvalue()
if gziped:
final_tile = gzip.compress(final_tile)
return final_tile
class GetTile(tornado.web.RequestHandler):