1
0
forked from MTSR/mapserver
This commit is contained in:
NatureFreshMilk 2019-01-24 13:55:29 +01:00
parent ccd5c4096b
commit f132363342
3 changed files with 21 additions and 13 deletions

View File

@ -55,6 +55,10 @@ func NewMetadata() *Metadata {
return &md return &md
} }
func (md *Metadata) GetMetadata(x, y, z int) map[string]string {
return md.GetPairsMap(getNodePos(x, y, z))
}
func (md *Metadata) GetPairsMap(pos int) map[string]string { func (md *Metadata) GetPairsMap(pos int) map[string]string {
pairsMap := md.Pairs[pos] pairsMap := md.Pairs[pos]
if pairsMap == nil { if pairsMap == nil {

View File

@ -7,19 +7,23 @@ import (
func onPoiBlock(id int, block *mapblockparser.MapBlock, odb mapobjectdb.DBAccessor) { func onPoiBlock(id int, block *mapblockparser.MapBlock, odb mapobjectdb.DBAccessor) {
for x:=0; x<16; x++ { for x := 0; x < 16; x++ {
for y:=0; y<16; y++ { for y := 0; y < 16; y++ {
for z:=0; z<16; z++ { for z := 0; z < 16; z++ {
name := block.GetNodeName(x,y,z) name := block.GetNodeName(x, y, z)
if name == "mapserver:poi" { if name == "mapserver:poi" {
md := block.Metadata.GetMetadata(x, y, z)
o := mapobjectdb.NewMapObject(&block.Pos, x, y, z, "poi") o := mapobjectdb.NewMapObject(&block.Pos, x, y, z, "poi")
o.Attributes["name"] = "test" o.Attributes["name"] = md["name"]
o.Attributes["category"] = md["category"]
o.Attributes["url"] = md["url"]
o.Attributes["active"] = md["active"]
o.Attributes["owner"] = md["owner"]
odb.AddMapData(o) odb.AddMapData(o)
} }
} }
} }
} }
panic("OK") //XXX
} }

View File

@ -31,12 +31,12 @@ type MapObject struct {
func NewMapObject(MBPos *coords.MapBlockCoords, x int, y int, z int, _type string) *MapObject { func NewMapObject(MBPos *coords.MapBlockCoords, x int, y int, z int, _type string) *MapObject {
o := MapObject{ o := MapObject{
MBPos: MBPos, MBPos: MBPos,
Type: _type, Type: _type,
X: MBPos.X + x, X: MBPos.X + x,
Y: MBPos.Y + y, Y: MBPos.Y + y,
Z: MBPos.Z + z, Z: MBPos.Z + z,
Mtime: time.Now().Unix(), Mtime: time.Now().Unix(),
Attributes: make(map[string]string), Attributes: make(map[string]string),
} }