check if tiles in db

This commit is contained in:
NatureFreshMilk 2019-01-17 11:27:31 +01:00
parent acd2e0c8d0
commit 5955bb835a
2 changed files with 17 additions and 6 deletions

View File

@ -10,6 +10,7 @@ import (
"mapserver/mapblockrenderer" "mapserver/mapblockrenderer"
"mapserver/layerconfig" "mapserver/layerconfig"
"mapserver/tiledb" "mapserver/tiledb"
"github.com/sirupsen/logrus"
) )
type TileRenderer struct { type TileRenderer struct {
@ -75,6 +76,8 @@ func (tr *TileRenderer) RenderImage(tc coords.TileCoords) (*image.NRGBA, error)
return cachedimg.(*image.NRGBA), nil return cachedimg.(*image.NRGBA), nil
} }
log.WithFields(logrus.Fields{"x": tc.X, "y": tc.Y, "zoom": tc.Zoom}).Debug("RenderImage")
var layer *layerconfig.Layer var layer *layerconfig.Layer
for _, l := range(tr.layers) { for _, l := range(tr.layers) {
@ -131,16 +134,24 @@ func (tr *TileRenderer) RenderImage(tc coords.TileCoords) (*image.NRGBA, error)
) )
rect := image.Rect(0, 0, 128, 128) rect := image.Rect(0, 0, 128, 128)
draw.Draw(img, rect, upperLeft, image.ZP, draw.Src) if upperLeft != nil {
draw.Draw(img, rect, upperLeft, image.ZP, draw.Src)
}
rect = image.Rect(128, 0, 256, 128) rect = image.Rect(128, 0, 256, 128)
draw.Draw(img, rect, upperRight, image.ZP, draw.Src) if upperRight != nil {
draw.Draw(img, rect, upperRight, image.ZP, draw.Src)
}
rect = image.Rect(0, 128, 128, 256) rect = image.Rect(0, 128, 128, 256)
draw.Draw(img, rect, lowerLeft, image.ZP, draw.Src) if lowerLeft != nil {
draw.Draw(img, rect, lowerLeft, image.ZP, draw.Src)
}
rect = image.Rect(128, 128, 256, 256) rect = image.Rect(128, 128, 256, 256)
draw.Draw(img, rect, lowerRight, image.ZP, draw.Src) if lowerRight != nil {
draw.Draw(img, rect, lowerRight, image.ZP, draw.Src)
}
return img, nil return img, nil

View File

@ -17,7 +17,7 @@ import (
) )
func TestTileRender(t *testing.T) { func TestTileRender(t *testing.T) {
logrus.SetLevel(logrus.InfoLevel) logrus.SetLevel(logrus.DebugLevel)
tmpfile, err := ioutil.TempFile("", "TestTileRender.*.sqlite") tmpfile, err := ioutil.TempFile("", "TestTileRender.*.sqlite")
if err != nil { if err != nil {
@ -58,7 +58,7 @@ func TestTileRender(t *testing.T) {
panic("no renderer") panic("no renderer")
} }
coord := coords.NewTileCoords(0,0,12,0) coord := coords.NewTileCoords(0,0,11,0)
data, err := tr.Render(coord) data, err := tr.Render(coord)