From 1c8694c9060a3a1fb36048c756eebe26263e6dfe Mon Sep 17 00:00:00 2001 From: NatureFreshMilk Date: Mon, 21 Jan 2019 13:45:35 +0100 Subject: [PATCH] rendering limit params --- app/config.go | 38 +++++++++++++++++-------------- coords/tileconvert.go | 2 +- coords/tileconvert_test.go | 4 ++-- initialrenderer/job.go | 16 ++++++------- mapblockparser/mapblock.go | 16 ++++++------- mapblockparser/parse.go | 4 ++-- mapblockparser/parse_test.go | 8 +++---- mapblockrenderer/renderer_test.go | 2 +- tileupdate/job.go | 13 ++++++----- 9 files changed, 54 insertions(+), 49 deletions(-) diff --git a/app/config.go b/app/config.go index 56e3b60..811f171 100644 --- a/app/config.go +++ b/app/config.go @@ -10,13 +10,15 @@ import ( ) type Config struct { - Port int `json:"port"` - EnableInitialRendering bool `json:"enableinitialrendering"` - EnableIncrementalUpdate bool `json:"enableincrementalupdate"` - Webdev bool `json:"webdev"` - WebApi *WebApiConfig `json:"webapi"` - RenderState *RenderStateType `json:"renderstate"` - Layers []layer.Layer `json:"layers"` + Port int `json:"port"` + EnableInitialRendering bool `json:"enableinitialrendering"` + EnableIncrementalUpdate bool `json:"enableincrementalupdate"` + Webdev bool `json:"webdev"` + WebApi *WebApiConfig `json:"webapi"` + RenderState *RenderStateType `json:"renderstate"` + Layers []layer.Layer `json:"layers"` + InitialRenderingFetchLimit int `json:"initialrenderingfetchlimit"` + UpdateRenderingFetchLimit int `json:"updaterenderingfetchlimit"` } type WebApiConfig struct { @@ -72,9 +74,9 @@ func ParseConfig(filename string) (*Config, error) { rstate := RenderStateType{ InitialRun: true, - LastX: coords.MinCoord-1, - LastY: coords.MinCoord-1, - LastZ: coords.MinCoord-1, + LastX: coords.MinCoord - 1, + LastY: coords.MinCoord - 1, + LastZ: coords.MinCoord - 1, LastMtime: 1, } @@ -88,13 +90,15 @@ func ParseConfig(filename string) (*Config, error) { } cfg := Config{ - Port: 8080, - EnableInitialRendering: true, - EnableIncrementalUpdate: true, - Webdev: false, - WebApi: &webapi, - RenderState: &rstate, - Layers: layers, + Port: 8080, + EnableInitialRendering: true, + EnableIncrementalUpdate: true, + Webdev: false, + WebApi: &webapi, + RenderState: &rstate, + Layers: layers, + InitialRenderingFetchLimit: 10000, + UpdateRenderingFetchLimit: 10000, } info, err := os.Stat(filename) diff --git a/coords/tileconvert.go b/coords/tileconvert.go index 948dd2f..274ba35 100644 --- a/coords/tileconvert.go +++ b/coords/tileconvert.go @@ -1,8 +1,8 @@ package coords import ( - "math" "mapserver/layer" + "math" ) const ( diff --git a/coords/tileconvert_test.go b/coords/tileconvert_test.go index c75c1c1..bc0575f 100644 --- a/coords/tileconvert_test.go +++ b/coords/tileconvert_test.go @@ -1,9 +1,9 @@ package coords import ( - "testing" - "mapserver/layer" "github.com/stretchr/testify/assert" + "mapserver/layer" + "testing" ) func TestConvertMapblockToTile1(t *testing.T) { diff --git a/initialrenderer/job.go b/initialrenderer/job.go index a1453b9..5ee0b01 100644 --- a/initialrenderer/job.go +++ b/initialrenderer/job.go @@ -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, 10000) + newlastcoords, mblist, err := ctx.BlockAccessor.FindLegacyMapBlocks(lastcoords, ctx.Config.InitialRenderingFetchLimit) if err != nil { panic(err) @@ -59,9 +59,9 @@ func Job(ctx *app.App) { tc = tc.GetZoomedOutTile() fields = logrus.Fields{ - "X": tc.X, - "Y": tc.Y, - "Zoom": tc.Zoom, + "X": tc.X, + "Y": tc.Y, + "Zoom": tc.Zoom, "LayerId": tc.LayerId, } logrus.WithFields(fields).Debug("Dispatching tile rendering") @@ -80,10 +80,10 @@ func Job(ctx *app.App) { ctx.Config.Save() fields = logrus.Fields{ - "count": len(mblist), - "X": lastcoords.X, - "Y": lastcoords.Y, - "Z": lastcoords.Z, + "count": len(mblist), + "X": lastcoords.X, + "Y": lastcoords.Y, + "Z": lastcoords.Z, "validcount": len(validmblist), } logrus.WithFields(fields).Info("Initial rendering") diff --git a/mapblockparser/mapblock.go b/mapblockparser/mapblock.go index 6a70651..f5070ba 100644 --- a/mapblockparser/mapblock.go +++ b/mapblockparser/mapblock.go @@ -5,14 +5,14 @@ import ( ) type MapBlock struct { - Pos coords.MapBlockCoords `json:"pos"` - Size int `json:"size"` - Version byte `json:"version"` - Underground bool `json:"underground"` - Mapdata []byte `json:"mapdata"` - Metadata Metadata `json:"metadata"` - BlockMapping map[int]string `json:"blockmapping"` - Mtime int64 `json:"mtime"` + Pos coords.MapBlockCoords `json:"pos"` + Size int `json:"size"` + Version byte `json:"version"` + Underground bool `json:"underground"` + Mapdata []byte `json:"mapdata"` + Metadata Metadata `json:"metadata"` + BlockMapping map[int]string `json:"blockmapping"` + Mtime int64 `json:"mtime"` } type Metadata struct { diff --git a/mapblockparser/parse.go b/mapblockparser/parse.go index 655bf0f..7675f9c 100644 --- a/mapblockparser/parse.go +++ b/mapblockparser/parse.go @@ -2,8 +2,8 @@ package mapblockparser import ( "errors" - "strconv" "mapserver/coords" + "strconv" ) func Parse(data []byte, mtime int64, pos coords.MapBlockCoords) (*MapBlock, error) { @@ -13,7 +13,7 @@ func Parse(data []byte, mtime int64, pos coords.MapBlockCoords) (*MapBlock, erro mapblock := NewMapblock() mapblock.Mtime = mtime - mapblock.Pos = pos + mapblock.Pos = pos mapblock.Size = len(data) offset := 0 diff --git a/mapblockparser/parse_test.go b/mapblockparser/parse_test.go index 1fdfbbd..ba3ff51 100644 --- a/mapblockparser/parse_test.go +++ b/mapblockparser/parse_test.go @@ -3,9 +3,9 @@ package mapblockparser import ( "fmt" "io/ioutil" + "mapserver/coords" "strconv" "testing" - "mapserver/coords" ) func TestReadU16(t *testing.T) { @@ -39,7 +39,7 @@ func TestParse(t *testing.T) { t.Error(err) } - mapblock, err := Parse(data, 0, coords.NewMapBlockCoords(0,0,0)) + mapblock, err := Parse(data, 0, coords.NewMapBlockCoords(0, 0, 0)) if err != nil { t.Error(err) @@ -70,7 +70,7 @@ func TestParse2(t *testing.T) { t.Error(err) } - mapblock, err := Parse(data, 0, coords.NewMapBlockCoords(0,0,0)) + mapblock, err := Parse(data, 0, coords.NewMapBlockCoords(0, 0, 0)) if err != nil { t.Error(err) @@ -88,7 +88,7 @@ func TestParse3(t *testing.T) { t.Error(err) } - _, err = Parse(data, 0, coords.NewMapBlockCoords(0,0,0)) + _, err = Parse(data, 0, coords.NewMapBlockCoords(0, 0, 0)) if err != nil { t.Error(err) diff --git a/mapblockrenderer/renderer_test.go b/mapblockrenderer/renderer_test.go index aaf565b..bb35752 100644 --- a/mapblockrenderer/renderer_test.go +++ b/mapblockrenderer/renderer_test.go @@ -7,9 +7,9 @@ import ( "mapserver/colormapping" "mapserver/coords" "mapserver/db" + "mapserver/layer" "mapserver/mapblockaccessor" "mapserver/testutils" - "mapserver/layer" "os" "testing" ) diff --git a/tileupdate/job.go b/tileupdate/job.go index fa9bff1..16a1085 100644 --- a/tileupdate/job.go +++ b/tileupdate/job.go @@ -17,7 +17,7 @@ func Job(ctx *app.App) { logrus.WithFields(fields).Info("Starting incremental update") for true { - mblist, err := ctx.BlockAccessor.FindLatestMapBlocks(rstate.LastMtime, 10000) + mblist, err := ctx.BlockAccessor.FindLatestMapBlocks(rstate.LastMtime, ctx.Config.UpdateRenderingFetchLimit) if err != nil { panic(err) @@ -52,9 +52,9 @@ func Job(ctx *app.App) { tc = tc.GetZoomedOutTile() fields = logrus.Fields{ - "X": tc.X, - "Y": tc.Y, - "Zoom": tc.Zoom, + "X": tc.X, + "Y": tc.Y, + "Zoom": tc.Zoom, "LayerId": tc.LayerId, } logrus.WithFields(fields).Debug("Dispatching tile rendering (update)") @@ -70,8 +70,9 @@ func Job(ctx *app.App) { if len(mblist) > 0 { fields = logrus.Fields{ - "count": len(mblist), - "lastmtime": rstate.LastMtime, + "count": len(mblist), + "validcount": len(validmblist), + "lastmtime": rstate.LastMtime, } logrus.WithFields(fields).Info("incremental update") }