1
0
forked from MTSR/mapserver

update job

This commit is contained in:
NatureFreshMilk 2019-01-21 13:41:47 +01:00
parent 3bb9d97e06
commit 13cab545b1
3 changed files with 49 additions and 8 deletions

View File

@ -109,7 +109,7 @@ func (db *Sqlite3Accessor) FindLegacyBlocks(lastpos coords.MapBlockCoords, limit
const getLatestBlockQuery = ` const getLatestBlockQuery = `
select pos,data,mtime select pos,data,mtime
from blocks b from blocks b
where b.mtime >= ? where b.mtime > ?
order by b.mtime asc order by b.mtime asc
limit ? limit ?
` `

View File

@ -17,7 +17,7 @@ func Job(ctx *app.App) {
lastcoords := coords.NewMapBlockCoords(rstate.LastX, rstate.LastY, rstate.LastZ) lastcoords := coords.NewMapBlockCoords(rstate.LastX, rstate.LastY, rstate.LastZ)
for true { for true {
newlastcoords, mblist, err := ctx.BlockAccessor.FindLegacyMapBlocks(lastcoords, 1000) newlastcoords, mblist, err := ctx.BlockAccessor.FindLegacyMapBlocks(lastcoords, 10000)
if err != nil { if err != nil {
panic(err) panic(err)

View File

@ -3,6 +3,8 @@ package tileupdate
import ( import (
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"mapserver/app" "mapserver/app"
"mapserver/coords"
"mapserver/mapblockparser"
"time" "time"
) )
@ -15,25 +17,64 @@ func Job(ctx *app.App) {
logrus.WithFields(fields).Info("Starting incremental update") logrus.WithFields(fields).Info("Starting incremental update")
for true { for true {
mblist, err := ctx.BlockAccessor.FindLatestMapBlocks(rstate.LastMtime, 1000) mblist, err := ctx.BlockAccessor.FindLatestMapBlocks(rstate.LastMtime, 10000)
if err != nil { if err != nil {
panic(err) panic(err)
} }
//only mapblocks with valid layer
validmblist := make([]*mapblockparser.MapBlock, 0)
for _, mb := range mblist { for _, mb := range mblist {
if mb.Mtime > rstate.LastMtime { if mb.Mtime > rstate.LastMtime {
rstate.LastMtime = mb.Mtime + 1 rstate.LastMtime = mb.Mtime
}
tc := coords.GetTileCoordsFromMapBlock(mb.Pos, ctx.Config.Layers)
if tc == nil {
continue
}
validmblist = append(validmblist, mb)
for tc.Zoom > 1 {
tc = tc.GetZoomedOutTile()
ctx.Tiledb.RemoveTile(tc)
}
}
//Render zoom 12-1
for _, mb := range validmblist {
tc := coords.GetTileCoordsFromMapBlock(mb.Pos, ctx.Config.Layers)
for tc.Zoom > 1 {
tc = tc.GetZoomedOutTile()
fields = logrus.Fields{
"X": tc.X,
"Y": tc.Y,
"Zoom": tc.Zoom,
"LayerId": tc.LayerId,
}
logrus.WithFields(fields).Debug("Dispatching tile rendering (update)")
_, err = ctx.Tilerenderer.Render(tc)
if err != nil {
panic(err)
}
} }
} }
ctx.Config.Save() ctx.Config.Save()
if len(mblist) > 0 {
fields = logrus.Fields{ fields = logrus.Fields{
"count": len(mblist), "count": len(mblist),
"lastmtime": rstate.LastMtime, "lastmtime": rstate.LastMtime,
} }
logrus.WithFields(fields).Info("incremental update") logrus.WithFields(fields).Info("incremental update")
}
time.Sleep(5 * time.Second) time.Sleep(5 * time.Second)
} }