mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2025-06-28 06:12:08 +02:00
Render transparent tiles if command line flag is set.
This commit is contained in:
@ -17,14 +17,15 @@ import (
|
||||
|
||||
func main() {
|
||||
var (
|
||||
webPort int
|
||||
webHost string
|
||||
webDir string
|
||||
mapDir string
|
||||
redisPort int
|
||||
redisHost string
|
||||
colorsFile string
|
||||
workers int
|
||||
webPort int
|
||||
webHost string
|
||||
webDir string
|
||||
mapDir string
|
||||
redisPort int
|
||||
redisHost string
|
||||
colorsFile string
|
||||
workers int
|
||||
transparent bool
|
||||
)
|
||||
flag.IntVar(&webPort, "web-port", 8808, "port of the web server")
|
||||
flag.IntVar(&webPort, "p", 8808, "port of the web server (shorthand)")
|
||||
@ -41,6 +42,8 @@ func main() {
|
||||
flag.IntVar(&workers, "workers", 1, "number of workers to render tiles")
|
||||
flag.StringVar(&colorsFile, "colors", "colors.txt", "colors used to render map tiles.")
|
||||
flag.StringVar(&colorsFile, "c", "colors.txt", "colors used to render map tiles (shorthand).")
|
||||
flag.BoolVar(&transparent, "transparent", false, "Render transparent blocks.")
|
||||
flag.BoolVar(&transparent, "t", false, "Render transparent blocks (shorthand).")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
@ -56,7 +59,7 @@ func main() {
|
||||
log.Fatalf("ERROR: problem loading colors: %s", err)
|
||||
}
|
||||
redisAddress := fmt.Sprintf("%s:%d", redisHost, redisPort)
|
||||
tu := newTileUpdater(mapDir, redisAddress, colors, workers)
|
||||
tu := newTileUpdater(mapDir, redisAddress, colors, transparent, workers)
|
||||
go tu.doUpdates()
|
||||
router.Path("/update").Methods("POST").Handler(tu)
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ type tileUpdater struct {
|
||||
redisAddress string
|
||||
colors *common.Colors
|
||||
workers int
|
||||
transparent bool
|
||||
cond *sync.Cond
|
||||
mu sync.Mutex
|
||||
}
|
||||
@ -56,12 +57,18 @@ func (c xz) parent() xzm {
|
||||
Mask: 1 << (zr<<1 | xr)}
|
||||
}
|
||||
|
||||
func newTileUpdater(mapDir, redisAddress string, colors *common.Colors, workers int) *tileUpdater {
|
||||
func newTileUpdater(
|
||||
mapDir, redisAddress string,
|
||||
colors *common.Colors,
|
||||
transparent bool,
|
||||
workers int) *tileUpdater {
|
||||
|
||||
tu := tileUpdater{
|
||||
mapDir: mapDir,
|
||||
redisAddress: redisAddress,
|
||||
changes: map[xz]bool{},
|
||||
colors: colors,
|
||||
transparent: transparent,
|
||||
workers: workers}
|
||||
tu.cond = sync.NewCond(&tu.mu)
|
||||
return &tu
|
||||
@ -113,7 +120,7 @@ func (tu *tileUpdater) doUpdates() {
|
||||
log.Printf("WARN: Cannot connect to redis server: %s", err)
|
||||
continue
|
||||
}
|
||||
btc := common.NewBaseTileCreator(client, tu.colors, baseDir, true)
|
||||
btc := common.NewBaseTileCreator(client, tu.colors, tu.transparent, baseDir, true)
|
||||
done.Add(1)
|
||||
go updateBaseTiles(jobs, btc, &done)
|
||||
}
|
||||
|
Reference in New Issue
Block a user