update job
This commit is contained in:
parent
3bb9d97e06
commit
13cab545b1
@ -109,7 +109,7 @@ func (db *Sqlite3Accessor) FindLegacyBlocks(lastpos coords.MapBlockCoords, limit
|
||||
const getLatestBlockQuery = `
|
||||
select pos,data,mtime
|
||||
from blocks b
|
||||
where b.mtime >= ?
|
||||
where b.mtime > ?
|
||||
order by b.mtime asc
|
||||
limit ?
|
||||
`
|
||||
|
@ -17,7 +17,7 @@ func Job(ctx *app.App) {
|
||||
lastcoords := coords.NewMapBlockCoords(rstate.LastX, rstate.LastY, rstate.LastZ)
|
||||
|
||||
for true {
|
||||
newlastcoords, mblist, err := ctx.BlockAccessor.FindLegacyMapBlocks(lastcoords, 1000)
|
||||
newlastcoords, mblist, err := ctx.BlockAccessor.FindLegacyMapBlocks(lastcoords, 10000)
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@ -3,6 +3,8 @@ package tileupdate
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"mapserver/app"
|
||||
"mapserver/coords"
|
||||
"mapserver/mapblockparser"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -15,25 +17,64 @@ func Job(ctx *app.App) {
|
||||
logrus.WithFields(fields).Info("Starting incremental update")
|
||||
|
||||
for true {
|
||||
mblist, err := ctx.BlockAccessor.FindLatestMapBlocks(rstate.LastMtime, 1000)
|
||||
mblist, err := ctx.BlockAccessor.FindLatestMapBlocks(rstate.LastMtime, 10000)
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
//only mapblocks with valid layer
|
||||
validmblist := make([]*mapblockparser.MapBlock, 0)
|
||||
|
||||
for _, mb := range mblist {
|
||||
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()
|
||||
|
||||
fields = logrus.Fields{
|
||||
"count": len(mblist),
|
||||
"lastmtime": rstate.LastMtime,
|
||||
if len(mblist) > 0 {
|
||||
fields = logrus.Fields{
|
||||
"count": len(mblist),
|
||||
"lastmtime": rstate.LastMtime,
|
||||
}
|
||||
logrus.WithFields(fields).Info("incremental update")
|
||||
}
|
||||
logrus.WithFields(fields).Info("incremental update")
|
||||
|
||||
time.Sleep(5 * time.Second)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user