mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2025-07-12 13:00:33 +02:00
Render transparent tiles if command line flag is set.
This commit is contained in:
@ -48,6 +48,7 @@ func order(a, b int) (int, int) {
|
||||
func createBaseLevel(
|
||||
address string,
|
||||
xMin, zMin, xMax, zMax int,
|
||||
transparent bool,
|
||||
colorsFile, outDir string,
|
||||
numWorkers int) (err error) {
|
||||
|
||||
@ -71,7 +72,7 @@ func createBaseLevel(
|
||||
return
|
||||
}
|
||||
done.Add(1)
|
||||
btc := common.NewBaseTileCreator(client, colors, baseDir, false)
|
||||
btc := common.NewBaseTileCreator(client, colors, transparent, baseDir, false)
|
||||
go createTiles(btc, jobs, &done)
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@ func main() {
|
||||
numWorkers int
|
||||
skipBaseLevel bool
|
||||
skipPyramid bool
|
||||
transparent bool
|
||||
)
|
||||
|
||||
flag.IntVar(&port, "port", 6379, "port to of mtredisalize server")
|
||||
@ -39,6 +40,8 @@ func main() {
|
||||
flag.BoolVar(&skipBaseLevel, "sb", false, "Do not generate base level tiles (shorthand)")
|
||||
flag.BoolVar(&skipPyramid, "skip-pyramid", false, "Do not generate pyramid tiles")
|
||||
flag.BoolVar(&skipPyramid, "sp", false, "Do not generate pyramid tiles (shorthand)")
|
||||
flag.BoolVar(&transparent, "transparent", false, "Render transparent blocks.")
|
||||
flag.BoolVar(&transparent, "t", false, "Render transparent blocks (shorthand).")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
@ -46,7 +49,12 @@ func main() {
|
||||
if !skipBaseLevel {
|
||||
address := fmt.Sprintf("%s:%d", host, port)
|
||||
if err = createBaseLevel(
|
||||
address, xMin, zMin, xMax, zMax, colorsFile, outDir, numWorkers); err != nil {
|
||||
address,
|
||||
xMin, zMin, xMax, zMax,
|
||||
transparent,
|
||||
colorsFile,
|
||||
outDir,
|
||||
numWorkers); err != nil {
|
||||
log.Fatalf("Creating base level tiles failed: %s", err)
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ func main() {
|
||||
colorsfile string
|
||||
outfile string
|
||||
shaded bool
|
||||
transparent bool
|
||||
)
|
||||
|
||||
flag.IntVar(&port, "port", 6379, "port to of mtredisalize server")
|
||||
@ -41,6 +42,7 @@ func main() {
|
||||
flag.StringVar(&outfile, "output", "out.png", "image file of result")
|
||||
flag.StringVar(&outfile, "o", "out.png", "image file of result (shorthand)")
|
||||
flag.BoolVar(&shaded, "shaded", true, "draw relief")
|
||||
flag.BoolVar(&transparent, "transparent", false, "render transparent blocks")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
@ -70,7 +72,7 @@ func main() {
|
||||
q1x, q1y, q1z := int16(x), int16(y), int16(z)
|
||||
q2x, q2y, q2z := q1x+int16(width)-1, q1y+int16(depth)-1, q1z+int16(height)-1
|
||||
|
||||
renderer := common.NewRenderer(width, height)
|
||||
renderer := common.NewRenderer(width, height, transparent)
|
||||
renderer.SetPos(q1x, q1z)
|
||||
yOrder := common.NewYOrder(renderer, 512)
|
||||
|
||||
@ -106,7 +108,7 @@ func main() {
|
||||
if shaded {
|
||||
image = renderer.CreateShadedImage(
|
||||
16, 16, (width-2)*16, (height-2)*16,
|
||||
colors.Colors, color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff})
|
||||
colors, color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff})
|
||||
} else {
|
||||
image = renderer.CreateImage(
|
||||
colors.Colors, color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff})
|
||||
|
@ -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