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

50 lines
977 B
Go
Raw Normal View History

2019-01-24 17:56:37 +03:00
package tilerendererjob
import (
"mapserver/app"
"mapserver/coords"
"time"
2019-01-25 19:57:38 +03:00
"github.com/sirupsen/logrus"
2019-01-24 17:56:37 +03:00
)
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)
}
2019-01-27 20:54:09 +03:00
if len(result.List) == 0 && !result.HasMore {
2019-01-24 17:56:37 +03:00
time.Sleep(5 * time.Second)
continue
}
2019-01-27 20:54:09 +03:00
rstate.LastMtime = result.LastMtime
ctx.Config.Save()
2019-01-24 18:33:54 +03:00
tiles := renderMapblocks(ctx, jobs, result.List)
2019-01-24 17:56:37 +03:00
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")
}
}