2015-07-26 16:33:29 +02:00
|
|
|
// Copyright 2014, 2015 by Sascha L. Teichmann
|
2014-09-14 15:28:03 +02:00
|
|
|
// Use of this source code is governed by the MIT license
|
|
|
|
// that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
"fmt"
|
|
|
|
"log"
|
2015-07-26 11:55:38 +02:00
|
|
|
|
|
|
|
"bitbucket.org/s_l_teichmann/mtsatellite/common"
|
2014-09-14 15:28:03 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
var (
|
2015-07-27 19:03:47 +02:00
|
|
|
port int
|
|
|
|
host string
|
|
|
|
xMin, yMin, zMin int
|
|
|
|
xMax, yMax, zMax int
|
|
|
|
colorsFile string
|
|
|
|
outDir string
|
|
|
|
numWorkers int
|
|
|
|
skipBaseLevel bool
|
|
|
|
skipPyramid bool
|
|
|
|
transparent bool
|
|
|
|
transparentDim float64
|
|
|
|
version bool
|
2014-09-14 15:28:03 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
flag.IntVar(&port, "port", 6379, "port to of mtredisalize server")
|
|
|
|
flag.IntVar(&port, "p", 6379, "port to of mtredisalize server (shorthand)")
|
|
|
|
flag.StringVar(&host, "host", "localhost", "host to mtredisalize server")
|
2014-09-20 21:57:01 +02:00
|
|
|
flag.IntVar(&xMin, "xmin", -1933, "x min of the area to tile")
|
|
|
|
flag.IntVar(&xMax, "xmax", 1932, "x max of the area to tile")
|
2015-07-27 19:03:47 +02:00
|
|
|
flag.IntVar(&yMin, "ymin", common.MinHeight, "Minimum y in blocks.")
|
|
|
|
flag.IntVar(&yMax, "ymax", common.MaxHeight, "Maximum y in blocks.")
|
2014-09-20 21:57:01 +02:00
|
|
|
flag.IntVar(&zMin, "zmin", -1933, "z min of the area to tile")
|
|
|
|
flag.IntVar(&zMax, "zmax", 1932, "z max of the area to tile")
|
2014-09-14 17:12:28 +02:00
|
|
|
flag.StringVar(&colorsFile, "colors", "colors.txt", "definition of colors")
|
2014-09-14 15:28:03 +02:00
|
|
|
flag.StringVar(&outDir, "output-dir", "map", "directory with the resulting image tree")
|
|
|
|
flag.StringVar(&outDir, "o", "map", "directory with the resulting image tree")
|
2014-09-27 13:23:34 +02:00
|
|
|
flag.IntVar(&numWorkers, "workers", 1, "number of workers")
|
2014-09-14 15:28:03 +02:00
|
|
|
flag.IntVar(&numWorkers, "w", 1, "number of workers (shorthand)")
|
2014-09-14 21:56:41 +02:00
|
|
|
flag.BoolVar(&skipBaseLevel, "skip-base-level", false, "Do not generate base level tiles")
|
|
|
|
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)")
|
2014-10-26 18:36:47 +01:00
|
|
|
flag.BoolVar(&transparent, "transparent", false, "Render transparent blocks.")
|
|
|
|
flag.BoolVar(&transparent, "t", false, "Render transparent blocks (shorthand).")
|
2015-07-26 11:55:38 +02:00
|
|
|
flag.Float64Var(&transparentDim,
|
|
|
|
"transparent-dim", common.DefaultTransparentDim*100.0,
|
|
|
|
"Extra dimming of transparent nodes each depth meter in percent.")
|
|
|
|
flag.Float64Var(&transparentDim,
|
|
|
|
"td", common.DefaultTransparentDim*100.0,
|
|
|
|
"Extra fimming of transparent nodes each depth meter in percent. (shorthand)")
|
2015-07-26 22:04:16 +02:00
|
|
|
flag.BoolVar(&version, "version", false, "Print version and exit.")
|
2014-09-14 15:28:03 +02:00
|
|
|
|
|
|
|
flag.Parse()
|
|
|
|
|
2015-07-26 22:04:16 +02:00
|
|
|
if version {
|
|
|
|
common.PrintVersionAndExit()
|
|
|
|
}
|
|
|
|
|
2014-09-14 17:12:28 +02:00
|
|
|
if !skipBaseLevel {
|
2015-07-26 11:55:38 +02:00
|
|
|
td := common.Clamp32f(float32(transparentDim/100.0), 0.0, 1.0)
|
2014-09-14 17:12:28 +02:00
|
|
|
address := fmt.Sprintf("%s:%d", host, port)
|
2015-06-21 22:47:06 +02:00
|
|
|
if err := createBaseLevel(
|
2014-10-26 18:36:47 +01:00
|
|
|
address,
|
2015-07-27 19:03:47 +02:00
|
|
|
xMin, yMin, zMin, xMax, yMax, zMax,
|
2015-07-26 11:55:38 +02:00
|
|
|
transparent, td,
|
2014-10-26 18:36:47 +01:00
|
|
|
colorsFile,
|
|
|
|
outDir,
|
|
|
|
numWorkers); err != nil {
|
2014-09-14 21:56:41 +02:00
|
|
|
log.Fatalf("Creating base level tiles failed: %s", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if !skipPyramid {
|
2015-06-21 22:47:06 +02:00
|
|
|
if err := createPyramid(outDir, numWorkers); err != nil {
|
2014-09-14 21:56:41 +02:00
|
|
|
log.Fatalf("Creating pyramid tiles failed: %s", err)
|
2014-09-14 15:28:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|