1
0
forked from MTSR/mapserver
mapserver/main.go
NatureFreshMilk 4218baedd2 main stub
2019-01-17 13:44:39 +01:00

88 lines
1.4 KiB
Go

package main
import (
"flag"
"fmt"
"mapserver/colormapping"
"mapserver/db"
"mapserver/mapblockaccessor"
"mapserver/mapblockrenderer"
"mapserver/params"
"mapserver/worldconfig"
"github.com/sirupsen/logrus"
"mapserver/tilerenderer"
"mapserver/tiledb"
"mapserver/layerconfig"
"mapserver/coords"
)
const (
Version = "2.0-DEV"
)
func main() {
logrus.SetLevel(logrus.InfoLevel)
p := params.Parse()
if p.Help {
flag.PrintDefaults()
return
}
if p.Version {
fmt.Print("Mapserver version: ")
fmt.Println(Version)
return
}
worldcfg := worldconfig.Parse(p.Worlddir + "world.mt")
logrus.WithFields(logrus.Fields{"version": Version}).Info("Starting mapserver")
if worldcfg.Backend != worldconfig.BACKEND_SQLITE3 {
panic("no sqlite3 backend found!")
}
a, err := db.NewSqliteAccessor("map.sqlite")
if err != nil {
panic(err)
}
err = a.Migrate()
if err != nil {
panic(err)
}
cache := mapblockaccessor.NewMapBlockAccessor(a)
c := colormapping.NewColorMapping()
err = c.LoadVFSColors(false, "/colors.txt")
if err != nil {
panic(err)
}
r := mapblockrenderer.NewMapBlockRenderer(cache, c)
tdb, err := tiledb.NewSqliteAccessor("tiles.sqlite")
if err != nil {
panic(err)
}
err = tdb.Migrate()
if err != nil {
panic(err)
}
tr := tilerenderer.NewTileRenderer(r, tdb, layerconfig.DefaultLayers)
tc := coords.NewTileCoords(0,0,9,0)
_, err = tr.Render(tc)
if err != nil {
panic(err)
}
}