1
0
forked from MTSR/mapserver

rendering limit params

This commit is contained in:
NatureFreshMilk 2019-01-21 13:45:35 +01:00
parent 13cab545b1
commit 1c8694c906
9 changed files with 54 additions and 49 deletions

View File

@ -10,13 +10,15 @@ import (
) )
type Config struct { type Config struct {
Port int `json:"port"` Port int `json:"port"`
EnableInitialRendering bool `json:"enableinitialrendering"` EnableInitialRendering bool `json:"enableinitialrendering"`
EnableIncrementalUpdate bool `json:"enableincrementalupdate"` EnableIncrementalUpdate bool `json:"enableincrementalupdate"`
Webdev bool `json:"webdev"` Webdev bool `json:"webdev"`
WebApi *WebApiConfig `json:"webapi"` WebApi *WebApiConfig `json:"webapi"`
RenderState *RenderStateType `json:"renderstate"` RenderState *RenderStateType `json:"renderstate"`
Layers []layer.Layer `json:"layers"` Layers []layer.Layer `json:"layers"`
InitialRenderingFetchLimit int `json:"initialrenderingfetchlimit"`
UpdateRenderingFetchLimit int `json:"updaterenderingfetchlimit"`
} }
type WebApiConfig struct { type WebApiConfig struct {
@ -72,9 +74,9 @@ func ParseConfig(filename string) (*Config, error) {
rstate := RenderStateType{ rstate := RenderStateType{
InitialRun: true, InitialRun: true,
LastX: coords.MinCoord-1, LastX: coords.MinCoord - 1,
LastY: coords.MinCoord-1, LastY: coords.MinCoord - 1,
LastZ: coords.MinCoord-1, LastZ: coords.MinCoord - 1,
LastMtime: 1, LastMtime: 1,
} }
@ -88,13 +90,15 @@ func ParseConfig(filename string) (*Config, error) {
} }
cfg := Config{ cfg := Config{
Port: 8080, Port: 8080,
EnableInitialRendering: true, EnableInitialRendering: true,
EnableIncrementalUpdate: true, EnableIncrementalUpdate: true,
Webdev: false, Webdev: false,
WebApi: &webapi, WebApi: &webapi,
RenderState: &rstate, RenderState: &rstate,
Layers: layers, Layers: layers,
InitialRenderingFetchLimit: 10000,
UpdateRenderingFetchLimit: 10000,
} }
info, err := os.Stat(filename) info, err := os.Stat(filename)

View File

@ -1,8 +1,8 @@
package coords package coords
import ( import (
"math"
"mapserver/layer" "mapserver/layer"
"math"
) )
const ( const (

View File

@ -1,9 +1,9 @@
package coords package coords
import ( import (
"testing"
"mapserver/layer"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"mapserver/layer"
"testing"
) )
func TestConvertMapblockToTile1(t *testing.T) { func TestConvertMapblockToTile1(t *testing.T) {

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, 10000) newlastcoords, mblist, err := ctx.BlockAccessor.FindLegacyMapBlocks(lastcoords, ctx.Config.InitialRenderingFetchLimit)
if err != nil { if err != nil {
panic(err) panic(err)
@ -59,9 +59,9 @@ func Job(ctx *app.App) {
tc = tc.GetZoomedOutTile() tc = tc.GetZoomedOutTile()
fields = logrus.Fields{ fields = logrus.Fields{
"X": tc.X, "X": tc.X,
"Y": tc.Y, "Y": tc.Y,
"Zoom": tc.Zoom, "Zoom": tc.Zoom,
"LayerId": tc.LayerId, "LayerId": tc.LayerId,
} }
logrus.WithFields(fields).Debug("Dispatching tile rendering") logrus.WithFields(fields).Debug("Dispatching tile rendering")
@ -80,10 +80,10 @@ func Job(ctx *app.App) {
ctx.Config.Save() ctx.Config.Save()
fields = logrus.Fields{ fields = logrus.Fields{
"count": len(mblist), "count": len(mblist),
"X": lastcoords.X, "X": lastcoords.X,
"Y": lastcoords.Y, "Y": lastcoords.Y,
"Z": lastcoords.Z, "Z": lastcoords.Z,
"validcount": len(validmblist), "validcount": len(validmblist),
} }
logrus.WithFields(fields).Info("Initial rendering") logrus.WithFields(fields).Info("Initial rendering")

View File

@ -5,14 +5,14 @@ import (
) )
type MapBlock struct { type MapBlock struct {
Pos coords.MapBlockCoords `json:"pos"` Pos coords.MapBlockCoords `json:"pos"`
Size int `json:"size"` Size int `json:"size"`
Version byte `json:"version"` Version byte `json:"version"`
Underground bool `json:"underground"` Underground bool `json:"underground"`
Mapdata []byte `json:"mapdata"` Mapdata []byte `json:"mapdata"`
Metadata Metadata `json:"metadata"` Metadata Metadata `json:"metadata"`
BlockMapping map[int]string `json:"blockmapping"` BlockMapping map[int]string `json:"blockmapping"`
Mtime int64 `json:"mtime"` Mtime int64 `json:"mtime"`
} }
type Metadata struct { type Metadata struct {

View File

@ -2,8 +2,8 @@ package mapblockparser
import ( import (
"errors" "errors"
"strconv"
"mapserver/coords" "mapserver/coords"
"strconv"
) )
func Parse(data []byte, mtime int64, pos coords.MapBlockCoords) (*MapBlock, error) { 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 := NewMapblock()
mapblock.Mtime = mtime mapblock.Mtime = mtime
mapblock.Pos = pos mapblock.Pos = pos
mapblock.Size = len(data) mapblock.Size = len(data)
offset := 0 offset := 0

View File

@ -3,9 +3,9 @@ package mapblockparser
import ( import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"mapserver/coords"
"strconv" "strconv"
"testing" "testing"
"mapserver/coords"
) )
func TestReadU16(t *testing.T) { func TestReadU16(t *testing.T) {
@ -39,7 +39,7 @@ func TestParse(t *testing.T) {
t.Error(err) 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 { if err != nil {
t.Error(err) t.Error(err)
@ -70,7 +70,7 @@ func TestParse2(t *testing.T) {
t.Error(err) 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 { if err != nil {
t.Error(err) t.Error(err)
@ -88,7 +88,7 @@ func TestParse3(t *testing.T) {
t.Error(err) t.Error(err)
} }
_, err = Parse(data, 0, coords.NewMapBlockCoords(0,0,0)) _, err = Parse(data, 0, coords.NewMapBlockCoords(0, 0, 0))
if err != nil { if err != nil {
t.Error(err) t.Error(err)

View File

@ -7,9 +7,9 @@ import (
"mapserver/colormapping" "mapserver/colormapping"
"mapserver/coords" "mapserver/coords"
"mapserver/db" "mapserver/db"
"mapserver/layer"
"mapserver/mapblockaccessor" "mapserver/mapblockaccessor"
"mapserver/testutils" "mapserver/testutils"
"mapserver/layer"
"os" "os"
"testing" "testing"
) )

View File

@ -17,7 +17,7 @@ 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, 10000) mblist, err := ctx.BlockAccessor.FindLatestMapBlocks(rstate.LastMtime, ctx.Config.UpdateRenderingFetchLimit)
if err != nil { if err != nil {
panic(err) panic(err)
@ -52,9 +52,9 @@ func Job(ctx *app.App) {
tc = tc.GetZoomedOutTile() tc = tc.GetZoomedOutTile()
fields = logrus.Fields{ fields = logrus.Fields{
"X": tc.X, "X": tc.X,
"Y": tc.Y, "Y": tc.Y,
"Zoom": tc.Zoom, "Zoom": tc.Zoom,
"LayerId": tc.LayerId, "LayerId": tc.LayerId,
} }
logrus.WithFields(fields).Debug("Dispatching tile rendering (update)") logrus.WithFields(fields).Debug("Dispatching tile rendering (update)")
@ -70,8 +70,9 @@ func Job(ctx *app.App) {
if len(mblist) > 0 { if len(mblist) > 0 {
fields = logrus.Fields{ fields = logrus.Fields{
"count": len(mblist), "count": len(mblist),
"lastmtime": rstate.LastMtime, "validcount": len(validmblist),
"lastmtime": rstate.LastMtime,
} }
logrus.WithFields(fields).Info("incremental update") logrus.WithFields(fields).Info("incremental update")
} }