1
0
forked from MTSR/mapserver
mapserver/main.go

64 lines
905 B
Go
Raw Normal View History

2019-01-04 10:41:01 +03:00
package main
import (
2019-01-17 16:20:29 +03:00
"mapserver/initialrenderer"
2019-01-09 10:56:39 +03:00
"github.com/sirupsen/logrus"
2019-01-17 15:44:39 +03:00
"mapserver/layerconfig"
2019-01-18 10:47:38 +03:00
"mapserver/app"
"mapserver/params"
2019-01-18 11:11:13 +03:00
"encoding/json"
2019-01-18 10:47:38 +03:00
"fmt"
2019-01-04 10:41:01 +03:00
)
2019-01-18 10:47:38 +03:00
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-18 10:47:38 +03:00
//Parse command line
2019-01-13 18:32:54 +03:00
2019-01-18 10:47:38 +03:00
p := params.Parse()
2019-01-13 18:32:54 +03:00
2019-01-18 10:47:38 +03:00
if p.Help {
params.PrintHelp()
return
}
2019-01-13 18:32:54 +03:00
2019-01-18 10:47:38 +03:00
if p.Version {
fmt.Print("Mapserver version: ")
fmt.Println(app.Version)
return
}
2019-01-13 18:32:54 +03:00
2019-01-18 11:03:57 +03:00
//parse Config
cfg, err := app.ParseConfig("mapserver.json")
if err != nil {
panic(err)
}
2019-01-18 11:11:13 +03:00
if p.Dumpconfig {
str, err := json.MarshalIndent(cfg, "", " ")
if err != nil {
panic(err)
}
2019-01-17 09:45:32 +03:00
2019-01-18 11:11:13 +03:00
fmt.Println(string(str))
return
}
//setup app context
2019-01-18 11:03:57 +03:00
ctx, err := app.Setup(p, cfg)
2019-01-13 18:32:54 +03:00
2019-01-17 10:34:21 +03:00
if err != nil {
2019-01-18 10:47:38 +03:00
//error case
2019-01-17 10:34:21 +03:00
panic(err)
2019-01-13 18:32:54 +03:00
}
2019-01-09 10:56:39 +03:00
2019-01-18 10:47:38 +03:00
//run initial rendering
2019-01-18 11:12:51 +03:00
if ctx.Config.EnableInitialRendering {
initialrenderer.Render(ctx.Tilerenderer, layerconfig.DefaultLayers)
}
2019-01-17 10:34:21 +03:00
2019-01-04 13:00:49 +03:00
}