1
0
forked from MTSR/mapserver

working metadata parser

This commit is contained in:
NatureFreshMilk 2019-01-11 08:58:12 +01:00
parent 9abfa2fd83
commit 8eac64571a
4 changed files with 30 additions and 0 deletions

View File

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

View File

@ -7,6 +7,7 @@ import (
"mapserver/db"
"os"
"testing"
"github.com/sirupsen/logrus"
)
func copy(src, dst string) error {
@ -55,6 +56,7 @@ func GetTestDatabase() db.DBAccessor {
}
func TestSimpleAccess(t *testing.T) {
logrus.SetLevel(logrus.DebugLevel)
a := GetTestDatabase()
cache := NewMapBlockAccessor(a)
mb, err := cache.GetMapBlock(coords.NewMapBlockCoords(0, 0, 0))

10
mapblockparser/logger.go Normal file
View File

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

View File

@ -8,6 +8,7 @@ import (
"io"
"strconv"
"strings"
"github.com/sirupsen/logrus"
)
const (
@ -49,9 +50,16 @@ func parseMetadata(mapblock *MapBlock, data []byte) (int, error) {
metadata := buf.Bytes()
log.WithFields(logrus.Fields{"metadata-length": len(metadata)}).Debug("Parsing metadata")
offset := 0
version := metadata[offset]
if version == 0 {
//No data?
return cr.Count, nil
}
if version != 2 {
return 0, errors.New("Wrong metadata version: " + strconv.Itoa(int(version)))
}