mapobjects stub
This commit is contained in:
parent
9f9e50329c
commit
0a702d240c
@ -26,12 +26,11 @@ func Render(tr *tilerenderer.TileRenderer,
|
||||
jobs := make(chan coords.TileCoords, 100)
|
||||
|
||||
fields := logrus.Fields{
|
||||
"workers": runtime.NumCPU(),
|
||||
"workers": runtime.NumCPU(),
|
||||
}
|
||||
logrus.WithFields(fields).Info("Starting initial render progress")
|
||||
|
||||
|
||||
for i := 0; i<runtime.NumCPU(); i++ {
|
||||
for i := 0; i < runtime.NumCPU(); i++ {
|
||||
go worker(tr, jobs)
|
||||
}
|
||||
|
||||
|
@ -10,13 +10,13 @@ import (
|
||||
)
|
||||
|
||||
type MapBlockAccessor struct {
|
||||
accessor db.DBAccessor
|
||||
c *cache.Cache
|
||||
accessor db.DBAccessor
|
||||
c *cache.Cache
|
||||
listeners []MapBlockListener
|
||||
}
|
||||
|
||||
type MapBlockListener interface {
|
||||
OnParsedMapBlock(block *mapblockparser.MapBlock)
|
||||
OnParsedMapBlock(block *mapblockparser.MapBlock, pos coords.MapBlockCoords)
|
||||
}
|
||||
|
||||
func getKey(pos coords.MapBlockCoords) string {
|
||||
@ -55,8 +55,8 @@ func (a *MapBlockAccessor) FindLatestMapBlocks(mintime int64, limit int) ([]*map
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, listener := range(a.listeners) {
|
||||
listener.OnParsedMapBlock(mapblock)
|
||||
for _, listener := range a.listeners {
|
||||
listener.OnParsedMapBlock(mapblock, block.Pos)
|
||||
}
|
||||
|
||||
a.c.Set(key, mapblock, cache.DefaultExpiration)
|
||||
@ -88,8 +88,8 @@ func (a *MapBlockAccessor) GetMapBlock(pos coords.MapBlockCoords) (*mapblockpars
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, listener := range(a.listeners) {
|
||||
listener.OnParsedMapBlock(mapblock)
|
||||
for _, listener := range a.listeners {
|
||||
listener.OnParsedMapBlock(mapblock, pos)
|
||||
}
|
||||
|
||||
a.c.Set(key, mapblock, cache.DefaultExpiration)
|
||||
|
@ -6,9 +6,11 @@ import (
|
||||
|
||||
type MapData struct {
|
||||
//mapblock position
|
||||
MBPos coords.MapBlockCoords
|
||||
MBPos coords.MapBlockCoords
|
||||
|
||||
//block position
|
||||
X, Y, Z int
|
||||
|
||||
Type string
|
||||
Data string
|
||||
Mtime int64
|
||||
@ -17,11 +19,12 @@ type MapData struct {
|
||||
type SearchQuery struct {
|
||||
//block position (not mapblock)
|
||||
Pos1, Pos2 coords.MapBlockCoords
|
||||
Type string
|
||||
Type string
|
||||
}
|
||||
|
||||
type DBAccessor interface {
|
||||
Migrate() error
|
||||
GetMapData(q SearchQuery) ([]MapData, error)
|
||||
SetMapData(pos coords.MapBlockCoords, data []MapData) error
|
||||
RemoveMapData(pos coords.MapBlockCoords) error
|
||||
AddMapData(data MapData) error
|
||||
}
|
||||
|
18
mapobject/clearmapdata.go
Normal file
18
mapobject/clearmapdata.go
Normal file
@ -0,0 +1,18 @@
|
||||
package mapobject
|
||||
|
||||
import (
|
||||
"mapserver/coords"
|
||||
"mapserver/mapblockparser"
|
||||
"mapserver/mapdb"
|
||||
)
|
||||
|
||||
type ClearMapData struct {
|
||||
db mapdb.DBAccessor
|
||||
}
|
||||
|
||||
func (this *ClearMapData) OnParsedMapBlock(block *mapblockparser.MapBlock, pos coords.MapBlockCoords) {
|
||||
err := this.db.RemoveMapData(pos)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
27
mapobject/poi.go
Normal file
27
mapobject/poi.go
Normal file
@ -0,0 +1,27 @@
|
||||
package mapobject
|
||||
|
||||
import (
|
||||
"mapserver/coords"
|
||||
"mapserver/mapblockparser"
|
||||
"mapserver/mapdb"
|
||||
)
|
||||
|
||||
type POI struct {
|
||||
db mapdb.DBAccessor
|
||||
}
|
||||
|
||||
func (this *POI) OnParsedMapBlock(block *mapblockparser.MapBlock, pos coords.MapBlockCoords) {
|
||||
var found bool
|
||||
for _, v := range(block.BlockMapping) {
|
||||
if v == "mapserver:poi" {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !found {
|
||||
return
|
||||
}
|
||||
|
||||
panic("OK") //XXX
|
||||
}
|
@ -7,7 +7,7 @@ import (
|
||||
type ParamsType struct {
|
||||
Help bool
|
||||
Version bool
|
||||
Debug bool
|
||||
Debug bool
|
||||
Dumpconfig bool
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user