forked from MTSR/mapserver
cached rendered tiles
This commit is contained in:
parent
5955bb835a
commit
82edf3eeee
@ -3,6 +3,7 @@ package tilerenderer
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"image"
|
"image"
|
||||||
|
"time"
|
||||||
"bytes"
|
"bytes"
|
||||||
"image/png"
|
"image/png"
|
||||||
"image/draw"
|
"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)
|
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
|
return img, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user