2019-01-04 10:41:01 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2019-01-18 11:13:37 +03:00
|
|
|
"encoding/json"
|
2019-01-09 10:56:39 +03:00
|
|
|
"github.com/sirupsen/logrus"
|
2019-01-18 10:47:38 +03:00
|
|
|
"mapserver/app"
|
2019-01-18 11:13:37 +03:00
|
|
|
"mapserver/initialrenderer"
|
|
|
|
"mapserver/layerconfig"
|
2019-01-18 10:47:38 +03:00
|
|
|
"mapserver/params"
|
2019-01-18 11:30:51 +03:00
|
|
|
"mapserver/web"
|
2019-01-18 15:07:01 +03:00
|
|
|
"mapserver/tileupdate"
|
2019-01-18 10:47:38 +03:00
|
|
|
"fmt"
|
2019-01-04 10:41:01 +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 11:13:37 +03:00
|
|
|
p := params.Parse()
|
2019-01-13 18:32:54 +03:00
|
|
|
|
2019-01-18 11:13:37 +03:00
|
|
|
if p.Help {
|
|
|
|
params.PrintHelp()
|
|
|
|
return
|
|
|
|
}
|
2019-01-13 18:32:54 +03:00
|
|
|
|
2019-01-18 11:13:37 +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 {
|
2019-01-18 11:30:51 +03:00
|
|
|
go initialrenderer.Render(ctx.Tilerenderer, layerconfig.DefaultLayers)
|
2019-01-18 11:12:51 +03:00
|
|
|
}
|
2019-01-17 10:34:21 +03:00
|
|
|
|
2019-01-18 15:07:01 +03:00
|
|
|
//Incremental update
|
|
|
|
if ctx.Config.EnableIncrementalUpdate {
|
|
|
|
go tileupdate.Job(ctx)
|
|
|
|
}
|
|
|
|
|
2019-01-18 11:30:51 +03:00
|
|
|
//Start http server
|
|
|
|
web.Serve(ctx)
|
|
|
|
|
2019-01-04 13:00:49 +03:00
|
|
|
}
|