1
0
forked from MTSR/mapserver

render tile z:13 on initial rendering

This commit is contained in:
NatureFreshMilk 2019-01-21 11:31:50 +01:00
parent 99e55b0319
commit 3b2741f390
6 changed files with 26 additions and 10 deletions

View File

@ -1,7 +1,9 @@
package coords package coords
type MapBlockCoords struct { type MapBlockCoords struct {
X, Y, Z int X int `json:"x"`
Y int `json:"y"`
Z int `json:"z"`
} }
func NewMapBlockCoords(x, y, z int) MapBlockCoords { func NewMapBlockCoords(x, y, z int) MapBlockCoords {

View File

@ -32,8 +32,14 @@ func Job(ctx *app.App) {
lastcoords = *newlastcoords lastcoords = *newlastcoords
//for _, mb := range mblist { for _, mb := range mblist {
//} tc := coords.GetTileCoordsFromMapBlock(mb.Pos)
_, err = ctx.Tilerenderer.Render(tc)
if err != nil {
panic(err)
}
}
//Save current positions of initial run //Save current positions of initial run
rstate.LastX = lastcoords.X rstate.LastX = lastcoords.X

View File

@ -62,7 +62,7 @@ func (a *MapBlockAccessor) FindLegacyMapBlocks(lastpos coords.MapBlockCoords, li
key := getKey(block.Pos) key := getKey(block.Pos)
mapblock, err := mapblockparser.Parse(block.Data, block.Mtime) mapblock, err := mapblockparser.Parse(block.Data, block.Mtime, block.Pos)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
@ -100,7 +100,7 @@ func (a *MapBlockAccessor) FindLatestMapBlocks(mintime int64, limit int) ([]*map
key := getKey(block.Pos) key := getKey(block.Pos)
mapblock, err := mapblockparser.Parse(block.Data, block.Mtime) mapblock, err := mapblockparser.Parse(block.Data, block.Mtime, block.Pos)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -133,7 +133,7 @@ func (a *MapBlockAccessor) GetMapBlock(pos coords.MapBlockCoords) (*mapblockpars
return nil, nil return nil, nil
} }
mapblock, err := mapblockparser.Parse(block.Data, block.Mtime) mapblock, err := mapblockparser.Parse(block.Data, block.Mtime, pos)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -1,6 +1,11 @@
package mapblockparser package mapblockparser
import (
"mapserver/coords"
)
type MapBlock struct { type MapBlock struct {
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"`

View File

@ -3,15 +3,17 @@ package mapblockparser
import ( import (
"errors" "errors"
"strconv" "strconv"
"mapserver/coords"
) )
func Parse(data []byte, mtime int64) (*MapBlock, error) { func Parse(data []byte, mtime int64, pos coords.MapBlockCoords) (*MapBlock, error) {
if len(data) == 0 { if len(data) == 0 {
return nil, errors.New("no data") return nil, errors.New("no data")
} }
mapblock := NewMapblock() mapblock := NewMapblock()
mapblock.Mtime = mtime mapblock.Mtime = mtime
mapblock.Pos = pos
mapblock.Size = len(data) mapblock.Size = len(data)
offset := 0 offset := 0

View File

@ -5,6 +5,7 @@ import (
"io/ioutil" "io/ioutil"
"strconv" "strconv"
"testing" "testing"
"mapserver/coords"
) )
func TestReadU16(t *testing.T) { func TestReadU16(t *testing.T) {
@ -38,7 +39,7 @@ func TestParse(t *testing.T) {
t.Error(err) t.Error(err)
} }
mapblock, err := Parse(data, 0) mapblock, err := Parse(data, 0, coords.NewMapBlockCoords(0,0,0))
if err != nil { if err != nil {
t.Error(err) t.Error(err)
@ -69,7 +70,7 @@ func TestParse2(t *testing.T) {
t.Error(err) t.Error(err)
} }
mapblock, err := Parse(data, 0) mapblock, err := Parse(data, 0, coords.NewMapBlockCoords(0,0,0))
if err != nil { if err != nil {
t.Error(err) t.Error(err)
@ -87,7 +88,7 @@ func TestParse3(t *testing.T) {
t.Error(err) t.Error(err)
} }
_, err = Parse(data, 0) _, err = Parse(data, 0, coords.NewMapBlockCoords(0,0,0))
if err != nil { if err != nil {
t.Error(err) t.Error(err)