1
0
forked from MTSR/mapserver

mapobject setup

This commit is contained in:
NatureFreshMilk 2019-01-23 13:41:26 +01:00
parent c969907b7b
commit 4d1426a466
3 changed files with 21 additions and 37 deletions

View File

@ -1,17 +0,0 @@
package mapobject
import (
"mapserver/mapblockparser"
"mapserver/mapobjectdb"
)
type ClearMapData struct {
db mapobjectdb.DBAccessor
}
func (this *ClearMapData) OnParsedMapBlock(block *mapblockparser.MapBlock) {
err := this.db.RemoveMapData(block.Pos)
if err != nil {
panic(err)
}
}

View File

@ -5,22 +5,6 @@ import (
"mapserver/mapobjectdb"
)
type POI struct {
db mapobjectdb.DBAccessor
}
func (this *POI) OnParsedMapBlock(block *mapblockparser.MapBlock) {
var found bool
for _, v := range block.BlockMapping {
if v == "mapserver:poi" {
found = true
break
}
}
if !found {
return
}
func onPoiBlock(id int, block *mapblockparser.MapBlock, odb mapobjectdb.DBAccessor) {
panic("OK") //XXX
}

View File

@ -2,9 +2,26 @@ package mapobject
import (
"mapserver/app"
"mapserver/mapblockparser"
)
func Setup(ctx *app.App) {
ctx.BlockAccessor.AddListener(&ClearMapData{db: ctx.Objectdb})
ctx.BlockAccessor.AddListener(&POI{db: ctx.Objectdb})
type Listener struct {
ctx *app.App
}
func (this *Listener) OnParsedMapBlock(block *mapblockparser.MapBlock) {
err := this.ctx.Objectdb.RemoveMapData(block.Pos)
if err != nil {
panic(err)
}
for id, name := range block.BlockMapping {
if name == "mapserver:poi" {
onPoiBlock(id, block, this.ctx.Objectdb)
}
}
}
func Setup(ctx *app.App) {
ctx.BlockAccessor.AddListener(&Listener{ctx: ctx})
}