1
0
forked from MTSR/mapserver
mapserver/mapblockaccessor/mapblockaccessor.go
2019-01-10 17:50:31 +01:00

34 lines
683 B
Go

package mapblockaccessor
import (
"mapserver/coords"
"mapserver/db"
"mapserver/mapblockparser"
)
type MapBlockAccessor struct {
accessor db.DBAccessor
}
func NewMapBlockAccessor(accessor db.DBAccessor) *MapBlockAccessor {
return &MapBlockAccessor{accessor: accessor}
}
func (a *MapBlockAccessor) Update(pos coords.MapBlockCoords, mb *mapblockparser.MapBlock) {
//TODO: cache
}
func (a *MapBlockAccessor) GetMapBlock(pos coords.MapBlockCoords) (*mapblockparser.MapBlock, error) {
block, err := a.accessor.GetBlock(pos)
if err != nil {
return nil, err
}
mapblock, err := mapblockparser.Parse(block.Data)
if err != nil {
return nil, err
}
return mapblock, nil
}