cached rendered tiles

This commit is contained in:
NatureFreshMilk 2019-01-17 11:38:13 +01:00
parent 5955bb835a
commit 82edf3eeee

View File

@ -3,6 +3,7 @@ package tilerenderer
import (
"errors"
"image"
"time"
"bytes"
"image/png"
"image/draw"
@ -153,6 +154,13 @@ func (tr *TileRenderer) RenderImage(tc coords.TileCoords) (*image.NRGBA, error)
draw.Draw(img, rect, lowerRight, image.ZP, draw.Src)
}
buf := new(bytes.Buffer)
if img != nil {
png.Encode(buf, img)
}
tile := tiledb.Tile{Pos: tc, Data: buf.Bytes(), Mtime: time.Now().Unix()}
tr.tdb.SetTile(&tile)
return img, nil
}