forked from MTSR/mapserver
mapdb stub
This commit is contained in:
parent
49a7de02fc
commit
08407ce0da
4
main.go
4
main.go
@ -2,14 +2,14 @@ package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/sirupsen/logrus"
|
||||
"mapserver/app"
|
||||
"mapserver/initialrenderer"
|
||||
"mapserver/layerconfig"
|
||||
"mapserver/params"
|
||||
"mapserver/web"
|
||||
"mapserver/tileupdate"
|
||||
"fmt"
|
||||
"mapserver/web"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -38,7 +38,7 @@ func (a *MapBlockAccessor) FindLatestMapBlocks(mintime int64, limit int) ([]*map
|
||||
|
||||
mblist := make([]*mapblockparser.MapBlock, 0)
|
||||
|
||||
for _, block := range(blocks) {
|
||||
for _, block := range blocks {
|
||||
key := getKey(block.Pos)
|
||||
|
||||
mapblock, err := mapblockparser.Parse(block.Data, block.Mtime)
|
||||
|
27
mapdb/accessor.go
Normal file
27
mapdb/accessor.go
Normal file
@ -0,0 +1,27 @@
|
||||
package mapdb
|
||||
|
||||
import (
|
||||
"mapserver/coords"
|
||||
)
|
||||
|
||||
type MapData struct {
|
||||
//mapblock position
|
||||
MBPos coords.MapBlockCoords
|
||||
//block position
|
||||
X, Y, Z int
|
||||
Type string
|
||||
Data string
|
||||
Mtime int64
|
||||
}
|
||||
|
||||
type SearchQuery struct {
|
||||
//block position (not mapblock)
|
||||
Pos1, Pos2 coords.MapBlockCoords
|
||||
Type string
|
||||
}
|
||||
|
||||
type DBAccessor interface {
|
||||
Migrate() error
|
||||
GetMapData(q SearchQuery) ([]MapData, error)
|
||||
SetMapData(pos coords.MapBlockCoords, data []MapData) error
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
package tileupdate
|
||||
|
||||
import (
|
||||
"mapserver/app"
|
||||
"github.com/sirupsen/logrus"
|
||||
"mapserver/app"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -21,18 +21,18 @@ func Job(ctx *app.App){
|
||||
panic(err)
|
||||
}
|
||||
|
||||
for _, mb := range mblist {
|
||||
if mb.Mtime > t {
|
||||
t = mb.Mtime + 1
|
||||
}
|
||||
}
|
||||
|
||||
fields = logrus.Fields{
|
||||
"count": len(mblist),
|
||||
"time": t,
|
||||
}
|
||||
logrus.WithFields(fields).Info("incremental update")
|
||||
|
||||
for _, mb := range(mblist) {
|
||||
if mb.Mtime > t {
|
||||
t = mb.Mtime+1
|
||||
}
|
||||
}
|
||||
|
||||
time.Sleep(5 * time.Second)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user