mapserver/main.go

83 lines
1.4 KiB
Go
Raw Normal View History

2019-01-04 10:41:01 +03:00
package main
import (
2019-01-07 10:56:02 +03:00
"flag"
2019-01-04 15:02:17 +03:00
"fmt"
2019-01-17 16:20:29 +03:00
"mapserver/initialrenderer"
2019-01-13 18:32:54 +03:00
"mapserver/colormapping"
"mapserver/db"
"mapserver/mapblockaccessor"
"mapserver/mapblockrenderer"
"mapserver/params"
"mapserver/worldconfig"
2019-01-09 10:56:39 +03:00
"github.com/sirupsen/logrus"
2019-01-17 15:44:39 +03:00
"mapserver/tilerenderer"
2019-01-17 10:34:21 +03:00
"mapserver/tiledb"
2019-01-17 15:44:39 +03:00
"mapserver/layerconfig"
2019-01-04 10:41:01 +03:00
)
2019-01-08 10:47:28 +03:00
const (
Version = "2.0-DEV"
2019-01-07 10:56:02 +03:00
)
2019-01-04 13:00:49 +03:00
func main() {
2019-01-13 18:32:54 +03:00
logrus.SetLevel(logrus.InfoLevel)
2019-01-04 15:02:17 +03:00
p := params.Parse()
2019-01-07 10:56:02 +03:00
2019-01-04 13:00:49 +03:00
if p.Help {
2019-01-07 10:56:02 +03:00
flag.PrintDefaults()
return
}
if p.Version {
fmt.Print("Mapserver version: ")
fmt.Println(Version)
2019-01-04 12:44:41 +03:00
return
}
2019-01-04 15:02:17 +03:00
worldcfg := worldconfig.Parse(p.Worlddir + "world.mt")
2019-01-13 18:32:54 +03:00
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)
2019-01-17 10:34:21 +03:00
tdb, err := tiledb.NewSqliteAccessor("tiles.sqlite")
2019-01-13 18:32:54 +03:00
2019-01-17 10:34:21 +03:00
if err != nil {
panic(err)
2019-01-17 09:45:32 +03:00
}
2019-01-17 10:34:21 +03:00
err = tdb.Migrate()
2019-01-13 18:32:54 +03:00
2019-01-17 10:34:21 +03:00
if err != nil {
panic(err)
2019-01-13 18:32:54 +03:00
}
2019-01-09 10:56:39 +03:00
2019-01-17 17:14:13 +03:00
tr := tilerenderer.NewTileRenderer(r, tdb, a, layerconfig.DefaultLayers)
2019-01-17 15:44:39 +03:00
2019-01-17 16:20:29 +03:00
initialrenderer.Render(tr, layerconfig.DefaultLayers)
2019-01-17 10:34:21 +03:00
2019-01-04 13:00:49 +03:00
}