-
Notifications
You must be signed in to change notification settings - Fork 22
/
initial.go
65 lines (46 loc) · 1.26 KB
/
initial.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package tilerendererjob
import (
"mapserver/app"
"mapserver/settings"
"time"
"github.com/sirupsen/logrus"
)
type InitialRenderEvent struct {
Progress float64 `json:"progress"`
}
func initialRender(ctx *app.App) {
logrus.Info("Starting initial rendering job")
for true {
start := time.Now()
result, err := ctx.MapBlockAccessor.FindNextLegacyBlocks(ctx.Settings, ctx.Config.Layers, ctx.Config.RenderingFetchLimit)
if err != nil {
logrus.Error("Error in initial rendering run, trying to continue: " + err.Error())
continue
}
if len(result.List) == 0 && !result.HasMore {
ctx.Settings.SetBool(settings.SETTING_INITIAL_RUN, false)
ev := InitialRenderEvent{
Progress: 1,
}
ctx.WebEventbus.Emit("initial-render-progress", &ev)
logrus.Info("initial rendering complete")
return
}
tiles := renderMapblocks(ctx, result.List)
t := time.Now()
elapsed := t.Sub(start)
ev := InitialRenderEvent{
Progress: result.Progress,
}
ctx.WebEventbus.Emit("initial-render-progress", &ev)
fields := logrus.Fields{
"mapblocks": len(result.List),
"tiles": tiles,
"progress%": int(result.Progress * 100),
"elapsed": elapsed,
}
logrus.WithFields(fields).Info("Initial rendering")
//tile gc
ctx.TileDB.GC()
}
}