From 25ce5ed65ad600f1c0aba887af9b915c2f65c18d Mon Sep 17 00:00:00 2001 From: NatureFreshMilk Date: Thu, 17 Jan 2019 16:18:50 +0100 Subject: [PATCH] check first --- tilerenderer/renderer.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tilerenderer/renderer.go b/tilerenderer/renderer.go index 8f28c49..5fc2eb1 100644 --- a/tilerenderer/renderer.go +++ b/tilerenderer/renderer.go @@ -164,6 +164,13 @@ func (tr *TileRenderer) RenderImage(tc coords.TileCoords) (*image.NRGBA, error) return nil, err } + isEmpty := upperLeft == nil && upperRight == nil && lowerLeft == nil && lowerRight == nil + + if isEmpty && (tc.Zoom == 12 || tc.Zoom == 11) { + //don't cache empty zoomed tiles + return nil, nil + } + img := image.NewNRGBA( image.Rectangle{ image.Point{0, 0}, @@ -196,12 +203,6 @@ func (tr *TileRenderer) RenderImage(tc coords.TileCoords) (*image.NRGBA, error) png.Encode(buf, img) } - isEmpty := upperLeft == nil && upperRight == nil && lowerLeft == nil && lowerRight == nil - - if isEmpty && (tc.Zoom == 12 || tc.Zoom == 11 || tc.Zoom == 10) { - //don't cache empty zoomed tiles - return nil, nil - } tile := tiledb.Tile{Pos: tc, Data: buf.Bytes(), Mtime: time.Now().Unix()} tr.tdb.SetTile(&tile)