1
0
forked from MTSR/mapserver

tile render timing

This commit is contained in:
NatureFreshMilk 2019-01-21 16:27:31 +01:00
parent d0e23bb114
commit a2d8d3ba67
11 changed files with 36 additions and 32 deletions

View File

@ -5,8 +5,8 @@ import (
"mapserver/db"
"mapserver/mapblockaccessor"
"mapserver/mapblockrenderer"
"mapserver/params"
"mapserver/mapobjectdb"
"mapserver/params"
"mapserver/tilerenderer"
"mapserver/worldconfig"
)
@ -20,8 +20,8 @@ type App struct {
Config *Config
Worldconfig worldconfig.WorldConfig
Blockdb db.DBAccessor
Objectdb mapobjectdb.DBAccessor
Blockdb db.DBAccessor
Objectdb mapobjectdb.DBAccessor
BlockAccessor *mapblockaccessor.MapBlockAccessor
Colormapping *colormapping.ColorMapping

View File

@ -5,8 +5,8 @@ import (
"mapserver/db"
"mapserver/mapblockaccessor"
"mapserver/mapblockrenderer"
"mapserver/params"
"mapserver/mapobjectdb"
"mapserver/params"
"mapserver/tilerenderer"
"mapserver/worldconfig"

View File

@ -4,6 +4,7 @@ import (
"github.com/sirupsen/logrus"
"mapserver/app"
"mapserver/coords"
"time"
)
func Job(ctx *app.App) {
@ -16,6 +17,8 @@ func Job(ctx *app.App) {
lastcoords := coords.NewMapBlockCoords(rstate.LastX, rstate.LastY, rstate.LastZ)
for true {
start := time.Now()
hasMore, newlastcoords, mblist, err := ctx.BlockAccessor.FindLegacyMapBlocks(lastcoords, ctx.Config.InitialRenderingFetchLimit, ctx.Config.Layers)
if err != nil {
@ -73,11 +76,15 @@ func Job(ctx *app.App) {
rstate.LastZ = lastcoords.Z
ctx.Config.Save()
t := time.Now()
elapsed := t.Sub(start)
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,
"elapsed": elapsed,
}
logrus.WithFields(fields).Info("Initial rendering")
}

View File

@ -4,8 +4,8 @@ import (
"fmt"
"mapserver/coords"
"mapserver/db"
"mapserver/mapblockparser"
"mapserver/layer"
"mapserver/mapblockparser"
"time"
cache "github.com/patrickmn/go-cache"

View File

@ -10,7 +10,7 @@ type MapBlock struct {
Version byte `json:"version"`
Underground bool `json:"underground"`
Mapdata []byte `json:"mapdata"`
Metadata *Metadata `json:"metadata"`
Metadata *Metadata `json:"metadata"`
BlockMapping map[int]string `json:"blockmapping"`
Mtime int64 `json:"mtime"`
}

View File

@ -10,7 +10,6 @@ type Tile struct {
Mtime int64
}
type MapObject struct {
//mapblock position
MBPos coords.MapBlockCoords

View File

@ -4,8 +4,7 @@ import (
"mapserver/coords"
)
func (db *Sqlite3Accessor) GetMapData(q SearchQuery) ([]MapObject, error){
func (db *Sqlite3Accessor) GetMapData(q SearchQuery) ([]MapObject, error) {
return nil, nil
}

View File

@ -6,7 +6,6 @@ import (
"mapserver/coords"
)
const getTileQuery = `
select data,mtime from tiles t
where t.layerid = ?

View File

@ -10,8 +10,8 @@ import (
"mapserver/layer"
"mapserver/mapblockaccessor"
"mapserver/mapblockrenderer"
"mapserver/testutils"
"mapserver/mapobjectdb"
"mapserver/testutils"
"os"
"testing"
)

View File

@ -64,8 +64,8 @@ func Job(ctx *app.App) {
if len(mblist) > 0 {
fields = logrus.Fields{
"count": len(mblist),
"lastmtime": rstate.LastMtime,
"count": len(mblist),
"lastmtime": rstate.LastMtime,
}
logrus.WithFields(fields).Info("incremental update")
}

View File

@ -1,10 +1,10 @@
package web
import (
"fmt"
"github.com/gorilla/websocket"
"mapserver/app"
"net/http"
"github.com/gorilla/websocket"
"fmt"
)
type WS struct {
@ -20,19 +20,19 @@ func (t *WS) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
conn, _ := upgrader.Upgrade(resp, req, nil)
for {
// Read message from browser
msgType, msg, err := conn.ReadMessage()
if err != nil {
return
}
// Print the message to the console
fmt.Printf("%s sent: %s\n", conn.RemoteAddr(), string(msg))
// Write message back to browser
if err = conn.WriteMessage(msgType, msg); err != nil {
return
}
// Read message from browser
msgType, msg, err := conn.ReadMessage()
if err != nil {
return
}
// Print the message to the console
fmt.Printf("%s sent: %s\n", conn.RemoteAddr(), string(msg))
// Write message back to browser
if err = conn.WriteMessage(msgType, msg); err != nil {
return
}
}
}