1
0
forked from MTSR/mapserver
This commit is contained in:
Thomas Rudin 2019-01-13 16:37:03 +01:00
parent 7503c2c281
commit bc223722af
28 changed files with 209 additions and 210 deletions

View File

@ -1,89 +1,89 @@
package colormapping package colormapping
import ( import (
"mapserver/vfs" "bufio"
"bufio" "bytes"
"errors" "errors"
"bytes" "github.com/sirupsen/logrus"
"strings" "image/color"
"strconv" "mapserver/vfs"
"github.com/sirupsen/logrus" "strconv"
"image/color" "strings"
) )
type ColorMapping struct { type ColorMapping struct {
colors map[string]*color.RGBA colors map[string]*color.RGBA
} }
func (m *ColorMapping) GetColor(name string) *color.RGBA { func (m *ColorMapping) GetColor(name string) *color.RGBA {
return m.colors[name] return m.colors[name]
} }
func (m *ColorMapping) LoadBytes(buffer []byte) error { func (m *ColorMapping) LoadBytes(buffer []byte) error {
scanner := bufio.NewScanner(bytes.NewReader(buffer)) scanner := bufio.NewScanner(bytes.NewReader(buffer))
for scanner.Scan() { for scanner.Scan() {
txt := strings.Trim(scanner.Text(), " ") txt := strings.Trim(scanner.Text(), " ")
if len(txt) == 0 { if len(txt) == 0 {
//empty //empty
continue continue
} }
if strings.HasPrefix(txt, "#") { if strings.HasPrefix(txt, "#") {
//comment //comment
continue continue
} }
parts := strings.Fields(txt) parts := strings.Fields(txt)
if len(parts) < 4 { if len(parts) < 4 {
return errors.New("invalid line") return errors.New("invalid line")
} }
if len(parts) >= 4 { if len(parts) >= 4 {
r, err := strconv.ParseInt(parts[1], 10, 32) r, err := strconv.ParseInt(parts[1], 10, 32)
if err != nil { if err != nil {
return err return err
} }
g, err := strconv.ParseInt(parts[2], 10, 32) g, err := strconv.ParseInt(parts[2], 10, 32)
if err != nil { if err != nil {
return err return err
} }
b, err := strconv.ParseInt(parts[3], 10, 32) b, err := strconv.ParseInt(parts[3], 10, 32)
if err != nil { if err != nil {
return err return err
} }
c := color.RGBA{uint8(r),uint8(g),uint8(b), 0xFF} c := color.RGBA{uint8(r), uint8(g), uint8(b), 0xFF}
m.colors[parts[0]] = &c m.colors[parts[0]] = &c
} }
if len(parts) >= 5 { if len(parts) >= 5 {
//with alpha //with alpha
} }
} }
return nil return nil
} }
//TODO: colors from fs //TODO: colors from fs
func (m *ColorMapping) LoadVFSColors(useLocal bool, filename string) error { func (m *ColorMapping) LoadVFSColors(useLocal bool, filename string) error {
buffer, err := vfs.FSByte(useLocal, "/colors.txt") buffer, err := vfs.FSByte(useLocal, "/colors.txt")
if err != nil { if err != nil {
return err return err
} }
log.WithFields(logrus.Fields{"size": len(buffer), log.WithFields(logrus.Fields{"size": len(buffer),
"filename": filename, "filename": filename,
"useLocal": useLocal}).Info("Loading local colors file") "useLocal": useLocal}).Info("Loading local colors file")
return m.LoadBytes(buffer) return m.LoadBytes(buffer)
} }
func NewColorMapping() *ColorMapping { func NewColorMapping() *ColorMapping {
return &ColorMapping{colors: make(map[string]*color.RGBA)} return &ColorMapping{colors: make(map[string]*color.RGBA)}
} }

View File

@ -5,15 +5,15 @@ import (
) )
func TestNewMapping(t *testing.T) { func TestNewMapping(t *testing.T) {
m := NewColorMapping() m := NewColorMapping()
err := m.LoadVFSColors(false, "/colors.txt") err := m.LoadVFSColors(false, "/colors.txt")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
c := m.GetColor("scifi_nodes:blacktile2") c := m.GetColor("scifi_nodes:blacktile2")
if c == nil { if c == nil {
panic("no color") panic("no color")
} }
} }

View File

@ -1,10 +1,11 @@
package colormapping package colormapping
import ( import (
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
var log *logrus.Entry var log *logrus.Entry
func init(){
func init() {
log = logrus.WithFields(logrus.Fields{"prefix": "colormapping"}) log = logrus.WithFields(logrus.Fields{"prefix": "colormapping"})
} }

View File

@ -9,7 +9,6 @@ const (
maxValue = 1<<(numBitsPerComponent-1) - 1 maxValue = 1<<(numBitsPerComponent-1) - 1
) )
func CoordToPlain(c MapBlockCoords) int64 { func CoordToPlain(c MapBlockCoords) int64 {
return int64(c.Z)<<(2*numBitsPerComponent) + return int64(c.Z)<<(2*numBitsPerComponent) +
int64(c.Y)<<numBitsPerComponent + int64(c.Y)<<numBitsPerComponent +

View File

@ -1,42 +1,42 @@
package coords package coords
import ( import (
"testing" "github.com/sirupsen/logrus"
"github.com/sirupsen/logrus" "testing"
) )
var log *logrus.Entry var log *logrus.Entry
func init(){
func init() {
log = logrus.WithFields(logrus.Fields{"prefix": "coords/convert_test"}) log = logrus.WithFields(logrus.Fields{"prefix": "coords/convert_test"})
} }
func testCoordConvert(t *testing.T, mb MapBlockCoords){ func testCoordConvert(t *testing.T, mb MapBlockCoords) {
log.WithFields(logrus.Fields{"coords":mb}).Info("MapblockCoords") log.WithFields(logrus.Fields{"coords": mb}).Info("MapblockCoords")
p := CoordToPlain(mb) p := CoordToPlain(mb)
log.WithFields(logrus.Fields{"plain":p}).Info("MapblockCoords") log.WithFields(logrus.Fields{"plain": p}).Info("MapblockCoords")
mb2 := PlainToCoord(p) mb2 := PlainToCoord(p)
log.WithFields(logrus.Fields{"coords2":mb2}).Info("MapblockCoords") log.WithFields(logrus.Fields{"coords2": mb2}).Info("MapblockCoords")
if mb.X != mb2.X {
t.Fatal("X mismatch")
}
if mb.X != mb2.X { if mb.Y != mb2.Y {
t.Fatal("X mismatch") t.Fatal("Y mismatch")
} }
if mb.Y != mb2.Y { if mb.Z != mb2.Z {
t.Fatal("Y mismatch") t.Fatal("Z mismatch")
} }
if mb.Z != mb2.Z {
t.Fatal("Z mismatch")
}
} }
func TestConvertPlainMapBlock(t *testing.T){ func TestConvertPlainMapBlock(t *testing.T) {
testCoordConvert(t, NewMapBlockCoords(10, 0, -10)) testCoordConvert(t, NewMapBlockCoords(10, 0, -10))
testCoordConvert(t, NewMapBlockCoords(-2048, 2047, -10)) testCoordConvert(t, NewMapBlockCoords(-2048, 2047, -10))
testCoordConvert(t, NewMapBlockCoords(-3, 0, 2047)) //0...2047 testCoordConvert(t, NewMapBlockCoords(-3, 0, 2047)) //0...2047
} }

View File

@ -1,18 +1,18 @@
package coords package coords
type MapBlockCoords struct { type MapBlockCoords struct {
X,Y,Z int X, Y, Z int
} }
func NewMapBlockCoords(x,y,z int) MapBlockCoords { func NewMapBlockCoords(x, y, z int) MapBlockCoords {
return MapBlockCoords{X:x, Y:y, Z:z} return MapBlockCoords{X: x, Y: y, Z: z}
} }
type MapBlockRange struct { type MapBlockRange struct {
pos1, pos2 MapBlockCoords pos1, pos2 MapBlockCoords
} }
const ( const (
MaxCoord = 2047 MaxCoord = 2047
MinCoord = -2047 MinCoord = -2047
) )

View File

@ -4,7 +4,6 @@ const (
MAX_ZOOM = 13 MAX_ZOOM = 13
) )
func GetTileCoordsFromMapBlock(mbc MapBlockCoords) TileCoords { func GetTileCoordsFromMapBlock(mbc MapBlockCoords) TileCoords {
return TileCoords{X:mbc.X, Y:(mbc.Z + 1) * -1, Zoom:MAX_ZOOM}; return TileCoords{X: mbc.X, Y: (mbc.Z + 1) * -1, Zoom: MAX_ZOOM}
} }

View File

@ -1,44 +1,44 @@
package coords package coords
import ( import (
"math" "math"
) )
type TileCoords struct { type TileCoords struct {
X,Y int X, Y int
Zoom int Zoom int
} }
type TileQuadrants struct { type TileQuadrants struct {
UpperLeft, UpperRight, LowerLeft, LowerRight TileCoords UpperLeft, UpperRight, LowerLeft, LowerRight TileCoords
} }
func NewTileCoords(x,y,zoom int) TileCoords { func NewTileCoords(x, y, zoom int) TileCoords {
return TileCoords{X:x, Y:y, Zoom:zoom} return TileCoords{X: x, Y: y, Zoom: zoom}
} }
func (tc TileCoords) GetZoomedOutTile() TileCoords { func (tc TileCoords) GetZoomedOutTile() TileCoords {
return TileCoords{ return TileCoords{
X: int(math.Floor(float64(tc.X) / 2.0)), X: int(math.Floor(float64(tc.X) / 2.0)),
Y: int(math.Floor(float64(tc.Y) / 2.0)), Y: int(math.Floor(float64(tc.Y) / 2.0)),
Zoom: tc.Zoom - 1} Zoom: tc.Zoom - 1}
} }
func (tc TileCoords) GetZoomedQuadrantsFromTile() TileQuadrants { func (tc TileCoords) GetZoomedQuadrantsFromTile() TileQuadrants {
nextZoom := tc.Zoom + 1 nextZoom := tc.Zoom + 1
nextZoomX := tc.X * 2 nextZoomX := tc.X * 2
nextZoomY := tc.Y * 2 nextZoomY := tc.Y * 2
upperLeft := TileCoords{X: nextZoomX, Y:nextZoomY, Zoom:nextZoom} upperLeft := TileCoords{X: nextZoomX, Y: nextZoomY, Zoom: nextZoom}
upperRight := TileCoords{X: nextZoomX + 1, Y: nextZoomY, Zoom:nextZoom} upperRight := TileCoords{X: nextZoomX + 1, Y: nextZoomY, Zoom: nextZoom}
lowerLeft := TileCoords{X: nextZoomX, Y: nextZoomY + 1, Zoom:nextZoom} lowerLeft := TileCoords{X: nextZoomX, Y: nextZoomY + 1, Zoom: nextZoom}
lowerRight := TileCoords{X: nextZoomX + 1, Y: nextZoomY + 1, Zoom:nextZoom} lowerRight := TileCoords{X: nextZoomX + 1, Y: nextZoomY + 1, Zoom: nextZoom}
return TileQuadrants{ return TileQuadrants{
UpperLeft: upperLeft, UpperLeft: upperLeft,
UpperRight: upperRight, UpperRight: upperRight,
LowerLeft: lowerLeft, LowerLeft: lowerLeft,
LowerRight: lowerRight, LowerRight: lowerRight,
} }
} }

View File

@ -5,9 +5,9 @@ import (
) )
type Block struct { type Block struct {
Pos coords.MapBlockCoords Pos coords.MapBlockCoords
Data []byte Data []byte
Mtime int64 Mtime int64
} }
type DBAccessor interface { type DBAccessor interface {

View File

@ -5,6 +5,7 @@ import (
) )
var log *logrus.Entry var log *logrus.Entry
func init(){
func init() {
log = logrus.WithFields(logrus.Fields{"prefix": "db"}) log = logrus.WithFields(logrus.Fields{"prefix": "db"})
} }

View File

@ -27,14 +27,14 @@ end;
//TODO: postgres test //TODO: postgres test
type Sqlite3Accessor struct { type Sqlite3Accessor struct {
db *sql.DB db *sql.DB
filename string filename string
} }
func (db *Sqlite3Accessor) Migrate() error { func (db *Sqlite3Accessor) Migrate() error {
//RW connection //RW connection
rwdb, err := sql.Open("sqlite3", db.filename + "?mode=rw") rwdb, err := sql.Open("sqlite3", db.filename+"?mode=rw")
if err != nil { if err != nil {
return err return err
} }
@ -48,7 +48,7 @@ func (db *Sqlite3Accessor) Migrate() error {
} }
if !hasMtime { if !hasMtime {
log.WithFields(logrus.Fields{"filename":db.filename}).Info("Migrating database") log.WithFields(logrus.Fields{"filename": db.filename}).Info("Migrating database")
start := time.Now() start := time.Now()
_, err = rwdb.Exec(migrateScript) _, err = rwdb.Exec(migrateScript)
if err != nil { if err != nil {
@ -56,7 +56,7 @@ func (db *Sqlite3Accessor) Migrate() error {
} }
t := time.Now() t := time.Now()
elapsed := t.Sub(start) elapsed := t.Sub(start)
log.WithFields(logrus.Fields{"elapsed":elapsed}).Info("Migration completed") log.WithFields(logrus.Fields{"elapsed": elapsed}).Info("Migration completed")
} }
return nil return nil
@ -64,7 +64,7 @@ func (db *Sqlite3Accessor) Migrate() error {
func convertRows(pos int64, data []byte, mtime int64) Block { func convertRows(pos int64, data []byte, mtime int64) Block {
c := coords.PlainToCoord(pos) c := coords.PlainToCoord(pos)
return Block{Pos:c, Data:data, Mtime:mtime} return Block{Pos: c, Data: data, Mtime: mtime}
} }
func (db *Sqlite3Accessor) FindLatestBlocks(mintime int64, limit int) ([]Block, error) { func (db *Sqlite3Accessor) FindLatestBlocks(mintime int64, limit int) ([]Block, error) {
@ -100,9 +100,8 @@ func (db *Sqlite3Accessor) GetBlock(pos coords.MapBlockCoords) (*Block, error) {
return nil, nil return nil, nil
} }
func NewSqliteAccessor(filename string) (*Sqlite3Accessor, error) { func NewSqliteAccessor(filename string) (*Sqlite3Accessor, error) {
db, err := sql.Open("sqlite3", filename + "?mode=ro") db, err := sql.Open("sqlite3", filename+"?mode=ro")
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -1,15 +1,14 @@
package db package db
import ( import (
_ "github.com/mattn/go-sqlite3"
"io/ioutil" "io/ioutil"
"mapserver/coords" "mapserver/coords"
"mapserver/testutils"
"os" "os"
"testing" "testing"
"mapserver/testutils"
_ "github.com/mattn/go-sqlite3"
) )
func TestMigrateEmpty(t *testing.T) { func TestMigrateEmpty(t *testing.T) {
tmpfile, err := ioutil.TempFile("", "TestMigrateEmpty.*.sqlite") tmpfile, err := ioutil.TempFile("", "TestMigrateEmpty.*.sqlite")
if err != nil { if err != nil {

View File

@ -1,10 +1,11 @@
package mapblockaccessor package mapblockaccessor
import ( import (
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
var log *logrus.Entry var log *logrus.Entry
func init(){
func init() {
log = logrus.WithFields(logrus.Fields{"prefix": "mapblockaccessor"}) log = logrus.WithFields(logrus.Fields{"prefix": "mapblockaccessor"})
} }

View File

@ -1,17 +1,17 @@
package mapblockaccessor package mapblockaccessor
import ( import (
"fmt"
"github.com/patrickmn/go-cache"
"mapserver/coords" "mapserver/coords"
"mapserver/db" "mapserver/db"
"mapserver/mapblockparser" "mapserver/mapblockparser"
"github.com/patrickmn/go-cache"
"time" "time"
"fmt"
) )
type MapBlockAccessor struct { type MapBlockAccessor struct {
accessor db.DBAccessor accessor db.DBAccessor
c *cache.Cache c *cache.Cache
} }
func getKey(pos coords.MapBlockCoords) string { func getKey(pos coords.MapBlockCoords) string {

View File

@ -1,13 +1,13 @@
package mapblockaccessor package mapblockaccessor
import ( import (
"os" "github.com/sirupsen/logrus"
"io/ioutil" "io/ioutil"
"mapserver/coords" "mapserver/coords"
"testing"
"mapserver/testutils"
"mapserver/db" "mapserver/db"
"github.com/sirupsen/logrus" "mapserver/testutils"
"os"
"testing"
) )
func TestSimpleAccess(t *testing.T) { func TestSimpleAccess(t *testing.T) {

View File

@ -6,17 +6,17 @@ import (
type CountedReader struct { type CountedReader struct {
Reader *bytes.Reader Reader *bytes.Reader
Count int Count int
} }
func (r *CountedReader) Read(p []byte) (int, error){ func (r *CountedReader) Read(p []byte) (int, error) {
i,err := r.Reader.Read(p) i, err := r.Reader.Read(p)
r.Count += i r.Count += i
return i, err return i, err
} }
func (r *CountedReader) ReadByte() (byte, error){ func (r *CountedReader) ReadByte() (byte, error) {
i,err := r.Reader.ReadByte() i, err := r.Reader.ReadByte()
r.Count++ r.Count++
return i, err return i, err
} }

View File

@ -1,10 +1,11 @@
package mapblockparser package mapblockparser
import ( import (
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
var log *logrus.Entry var log *logrus.Entry
func init(){
func init() {
log = logrus.WithFields(logrus.Fields{"prefix": "mapblockaccessor"}) log = logrus.WithFields(logrus.Fields{"prefix": "mapblockaccessor"})
} }

View File

@ -8,13 +8,13 @@ type MapBlock struct {
BlockMapping map[int]string BlockMapping map[int]string
} }
func getNodePos(x,y,z int) int { func getNodePos(x, y, z int) int {
return x + (y * 16) + (z * 256) return x + (y * 16) + (z * 256)
} }
func (mb *MapBlock) GetNodeName(x,y,z int) string { func (mb *MapBlock) GetNodeName(x, y, z int) string {
pos := getNodePos(x,y,z) pos := getNodePos(x, y, z)
id := readU16(mb.Mapdata, pos * 2) id := readU16(mb.Mapdata, pos*2)
return mb.BlockMapping[id] return mb.BlockMapping[id]
} }

View File

@ -5,10 +5,10 @@ import (
"bytes" "bytes"
"compress/zlib" "compress/zlib"
"errors" "errors"
"github.com/sirupsen/logrus"
"io" "io"
"strconv" "strconv"
"strings" "strings"
"github.com/sirupsen/logrus"
) )
const ( const (

View File

@ -1,10 +1,11 @@
package mapblockrenderer package mapblockrenderer
import ( import (
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
var log *logrus.Entry var log *logrus.Entry
func init(){
func init() {
log = logrus.WithFields(logrus.Fields{"prefix": "mapblockrenderer"}) log = logrus.WithFields(logrus.Fields{"prefix": "mapblockrenderer"})
} }

View File

@ -1,14 +1,14 @@
package mapblockrenderer package mapblockrenderer
import ( import (
"errors"
"github.com/sirupsen/logrus"
"image"
"image/draw"
"mapserver/colormapping" "mapserver/colormapping"
"mapserver/coords" "mapserver/coords"
"mapserver/mapblockaccessor" "mapserver/mapblockaccessor"
"image"
"image/draw"
"errors"
"time" "time"
"github.com/sirupsen/logrus"
) )
type MapBlockRenderer struct { type MapBlockRenderer struct {
@ -21,9 +21,9 @@ func NewMapBlockRenderer(accessor *mapblockaccessor.MapBlockAccessor, colors *co
} }
const ( const (
IMG_SCALE = 16 IMG_SCALE = 16
IMG_SIZE = IMG_SCALE * 16 IMG_SIZE = IMG_SCALE * 16
EXPECTED_BLOCKS_PER_FLAT_MAPBLOCK = 16*16 EXPECTED_BLOCKS_PER_FLAT_MAPBLOCK = 16 * 16
) )
func (r *MapBlockRenderer) Render(pos1, pos2 coords.MapBlockCoords) (*image.NRGBA, error) { func (r *MapBlockRenderer) Render(pos1, pos2 coords.MapBlockCoords) (*image.NRGBA, error) {
@ -34,12 +34,12 @@ func (r *MapBlockRenderer) Render(pos1, pos2 coords.MapBlockCoords) (*image.NRGB
if pos1.Z != pos2.Z { if pos1.Z != pos2.Z {
return nil, errors.New("Z does not line up") return nil, errors.New("Z does not line up")
} }
start := time.Now() start := time.Now()
defer func(){ defer func() {
t := time.Now() t := time.Now()
elapsed := t.Sub(start) elapsed := t.Sub(start)
log.WithFields(logrus.Fields{"elapsed":elapsed}).Debug("Rendering completed") log.WithFields(logrus.Fields{"elapsed": elapsed}).Debug("Rendering completed")
}() }()
upLeft := image.Point{0, 0} upLeft := image.Point{0, 0}
@ -78,7 +78,7 @@ func (r *MapBlockRenderer) Render(pos1, pos2 coords.MapBlockCoords) (*image.NRGB
continue continue
} }
nodeName := mb.GetNodeName(x,y,z) nodeName := mb.GetNodeName(x, y, z)
if nodeName == "" { if nodeName == "" {
continue continue

View File

@ -8,7 +8,7 @@ type ParamsType struct {
Worlddir string Worlddir string
Port int Port int
Help bool Help bool
Version bool Version bool
} }
func Parse() ParamsType { func Parse() ParamsType {

View File

@ -1,17 +1,15 @@
package testutils package testutils
import ( import (
"database/sql" "database/sql"
_ "github.com/mattn/go-sqlite3" "fmt"
_ "github.com/mattn/go-sqlite3"
"io" "io"
"path/filepath"
"os" "os"
"fmt" "path/filepath"
"runtime" "runtime"
) )
const emptyBlocksScript = ` const emptyBlocksScript = `
create table blocks ( create table blocks (
pos int, pos int,
@ -40,11 +38,10 @@ func copy(src, dst string) error {
} }
func CreateTestDatabase(filename string) error { func CreateTestDatabase(filename string) error {
_, currentfilename, _, _ := runtime.Caller(0) _, currentfilename, _, _ := runtime.Caller(0)
return copy(filepath.Dir(currentfilename) + "/testdata/map.sqlite", filename) return copy(filepath.Dir(currentfilename)+"/testdata/map.sqlite", filename)
} }
func CreateEmptyDatabase(filename string) { func CreateEmptyDatabase(filename string) {
db, err := sql.Open("sqlite3", filename) db, err := sql.Open("sqlite3", filename)
if err != nil { if err != nil {

View File

@ -5,10 +5,10 @@ import (
) )
type Tile struct { type Tile struct {
Pos coords.TileCoords Pos coords.TileCoords
LayerId int LayerId int
Data []byte Data []byte
Mtime int64 Mtime int64
} }
type DBAccessor interface { type DBAccessor interface {

View File

@ -1,10 +1,11 @@
package tilerenderer package tilerenderer
import ( import (
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
var log *logrus.Entry var log *logrus.Entry
func init(){
func init() {
log = logrus.WithFields(logrus.Fields{"prefix": "tilerenderer"}) log = logrus.WithFields(logrus.Fields{"prefix": "tilerenderer"})
} }

View File

@ -1,25 +1,25 @@
package tilerenderer package tilerenderer
import ( import (
"mapserver/coords" "image"
"mapserver/mapblockrenderer" "mapserver/coords"
"mapserver/tiledb" "mapserver/mapblockrenderer"
"image" "mapserver/tiledb"
) )
type TileRenderer struct { type TileRenderer struct {
mapblockrenderer *mapblockrenderer.MapBlockRenderer mapblockrenderer *mapblockrenderer.MapBlockRenderer
tiledb *tiledb.DBAccessor tiledb *tiledb.DBAccessor
} }
func NewTileRenderer(mapblockrenderer *mapblockrenderer.MapBlockRenderer, tiledb *tiledb.DBAccessor) *TileRenderer { func NewTileRenderer(mapblockrenderer *mapblockrenderer.MapBlockRenderer, tiledb *tiledb.DBAccessor) *TileRenderer {
return &TileRenderer{ return &TileRenderer{
mapblockrenderer: mapblockrenderer, mapblockrenderer: mapblockrenderer,
tiledb: tiledb, tiledb: tiledb,
} }
} }
//TODO layerConfig //TODO layerConfig
func (tr *TileRenderer) Render(tc coords.TileCoords, layerId int) (*image.NRGBA, error) { func (tr *TileRenderer) Render(tc coords.TileCoords, layerId int) (*image.NRGBA, error) {
return nil, nil return nil, nil
} }

View File

@ -1,39 +1,39 @@
package worldconfig package worldconfig
import ( import (
"fmt"
"bufio" "bufio"
"fmt"
"os" "os"
"strings"
"strconv" "strconv"
"strings"
) )
const ( const (
BACKEND_SQLITE3 string = "sqlite3" BACKEND_SQLITE3 string = "sqlite3"
BACKEND_FILES string = "files" BACKEND_FILES string = "files"
BACKEND_POSTGRES string = "postgresql" BACKEND_POSTGRES string = "postgresql"
) )
const ( const (
CONFIG_BACKEND string = "backend" CONFIG_BACKEND string = "backend"
CONFIG_PLAYER_BACKEND string = "player_backend" CONFIG_PLAYER_BACKEND string = "player_backend"
CONFIG_PSQL_CONNECTION string = "pgsql_connection" CONFIG_PSQL_CONNECTION string = "pgsql_connection"
CONFIG_PSQL_PLAYER_CONNECTION string = "pgsql_player_connection" CONFIG_PSQL_PLAYER_CONNECTION string = "pgsql_player_connection"
) )
type PsqlConfig struct { type PsqlConfig struct {
Host string Host string
Port int Port int
Username string Username string
Password string Password string
DbName string DbName string
} }
type WorldConfig struct { type WorldConfig struct {
Backend string Backend string
PlayerBackend string PlayerBackend string
PsqlConnection PsqlConfig PsqlConnection PsqlConfig
PsqlPlayerConnection PsqlConfig PsqlPlayerConnection PsqlConfig
} }

View File

@ -1,8 +1,8 @@
package worldconfig package worldconfig
import ( import (
"testing"
"fmt" "fmt"
"testing"
) )
func TestParseSqlite(t *testing.T) { func TestParseSqlite(t *testing.T) {