Exemplo n.º 1
0
Arquivo: cmd.go Projeto: buckhx/diglet
	Usage:       "Builds an mbtiles database from the input data source",
	Description: "Builds an mbtiles database from the given format",
	ArgsUsage:   "input_source",
	Action: func(c *cli.Context) { //TODO break out into functions
		// get kwargs & vars
		out := c.String("output")
		desc := c.String("desc")
		layer := c.String("layer-name")
		zmin := c.Int("min")
		zmax := c.Int("max")
		extent := c.Int("extent")
		upsert := c.Bool("upsert")
		force := c.Bool("force")
		// validate
		if len(c.Args()) == 0 || out == "" {
			util.Die(c, "input_source & --out required")
		} else if zmax < zmin || zmin < 0 || zmax > 23 {
			util.Die(c, "--max > --min, --min > 0 --max < 24 not satisfied")
		}
		// execute
		source, err := getSource(c)
		util.Check(err)
		if force {
			os.Remove(out)
		}
		tiles, err := InitTiles(out, upsert, desc, extent)
		util.Check(err)
		err = tiles.Build(source, layer, zmin, zmax)
		util.Check(err)
		// finalize
		file, _ := os.Open(out)
Exemplo n.º 2
0
Arquivo: cmd.go Projeto: buckhx/diglet
	"github.com/buckhx/diglet/util"
	"github.com/codegangsta/cli"
)

var Cmd = cli.Command{
	Name:        "tms",
	Aliases:     []string{"serve"},
	Usage:       "Starts the diglet Tile Map Service",
	Description: "Starts the diglet Tile Map Service. Uses Slippy maps tilenames by default.",
	ArgsUsage:   "mbtiles_directory",
	Action: func(c *cli.Context) {
		port := c.String("port")
		args := c.Args()
		if len(args) < 1 {
			util.Die(c, "directory path to serve mbtiles from is required")
		}
		mbt := args[0]
		if mbt == "" {
			util.Die(c, "mbtiles_directory is required")
		}
		cert := c.String("cert")
		key := c.String("key")
		server, err := MBTServer(mbt, port)
		if err != nil {
			util.Die(c, err.Error())
		}
		if (cert != "") && (key != "") {
			server.RunTLS(&cert, &key)
		} else if cert != "" || key != "" {
			util.Die(c, "Both cert & key are required to serve over TLS/SSL")