forked from MTSR/mapserver
working metadata parser
This commit is contained in:
parent
9abfa2fd83
commit
8eac64571a
10
mapblockaccessor/logger.go
Normal file
10
mapblockaccessor/logger.go
Normal 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"})
|
||||
}
|
@ -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
10
mapblockparser/logger.go
Normal 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"})
|
||||
}
|
@ -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)))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user