1
0
forked from MTSR/mapserver
mapserver/server/tilerendererjob/incremental.go

49 lines
957 B
Go
Raw Normal View History

2019-01-24 17:56:37 +03:00
package tilerendererjob
import (
"github.com/sirupsen/logrus"
"mapserver/app"
"mapserver/coords"
"time"
)
func incrementalRender(ctx *app.App, jobs chan *coords.TileCoords) {
rstate := ctx.Config.RenderState
fields := logrus.Fields{
"LastMtime": rstate.LastMtime,
}
logrus.WithFields(fields).Info("Starting incremental rendering job")
for true {
start := time.Now()
result, err := ctx.BlockAccessor.FindMapBlocksByMtime(rstate.LastMtime, ctx.Config.RenderingFetchLimit, ctx.Config.Layers)
if err != nil {
panic(err)
}
if len(result.List) == 0 {
time.Sleep(5 * time.Second)
continue
}
2019-01-24 18:33:54 +03:00
tiles := renderMapblocks(ctx, jobs, result.List)
2019-01-24 17:56:37 +03:00
rstate.LastMtime = result.LastMtime
ctx.Config.Save()
t := time.Now()
elapsed := t.Sub(start)
fields := logrus.Fields{
2019-01-24 18:33:54 +03:00
"mapblocks": len(result.List),
"tiles": tiles,
"elapsed": elapsed,
2019-01-24 17:56:37 +03:00
}
logrus.WithFields(fields).Info("incremental rendering")
}
}