tms

package
v0.0.13-a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2016 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package diglet/tms is an HTTP Tile Server that also support JSON-RPC & WebSocket requests. Tile subscriptions are also available to support real-time map applications with large feature sets.

Index

Constants

View Source
const (
	GetTile         string = "get_tile"
	GetRawTile      string = "get_raw_tile"
	GetTileset      string = "get_tileset"
	ListTilesets    string = "list_tilesets"
	SubscribeTile   string = "subscribe_tile"
	UnsubscribeTile string = "unsubscribe_tile"
)
View Source
const CacheName = ".diglet.cache"

Variables

View Source
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")
		} else {
			sigs := make(chan os.Signal, 1)
			done := make(chan bool, 1)
			signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
			defer os.Remove(filepath.Join(mbt, CacheName))
			go func() {
				err := server.Run()
				util.Error(err)
				done <- true
			}()
			go func() {
				<-sigs
				done <- true
			}()
			<-done
		}
	},
	Flags: []cli.Flag{
		cli.StringFlag{
			Name:  "port",
			Value: "8080",
			Usage: "Port to bind",
		},
		cli.StringFlag{
			Name:  "cert, tls-certificate",
			Usage: "Path to .pem TLS Certificate. Both cert & key required to serve HTTPS",
		},
		cli.StringFlag{
			Name:  "key, tls-private-key",
			Usage: "Path to .pem TLS Private Key. Both cert & key required to serve HTTPS",
		},
		cli.BoolFlag{
			Name:  "tms-origin",
			Usage: "NOT IMPLEMENTED: Use TMS origin, SW origin w/ Y increasing North-wise. Default uses NW origin inscreasing South-wise (Slippy tilenames)",
		},
	},
}

Functions

func MBTServer

func MBTServer(mbtPath string, port string) (app *dig.App, err error)

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

func InitCache

func InitCache(path string) (cache *Cache, err error)

func (*Cache) Close

func (c *Cache) Close()

func (*Cache) Destroy

func (c *Cache) Destroy()

func (*Cache) DropBucket

func (c *Cache) DropBucket(bucket string) (ok bool)

func (*Cache) Get

func (c *Cache) Get(bucket, key string) (value []byte, ok bool)

func (*Cache) Map

func (c *Cache) Map(bucket string, fn func(value []byte) ([]byte, error)) (err error)

func (*Cache) Put

func (c *Cache) Put(bucket, key string, value []byte) (err error)

type IoHub

type IoHub struct {
	// contains filtered or unexported fields
}

func NewHub

func NewHub(tilesets *TilesetIndex) (h *IoHub)

type TileCache

type TileCache struct {
	*Cache
}

func InitTileCache

func InitTileCache(path string) (cache *TileCache, err error)

func (*TileCache) GetTile

func (c *TileCache) GetTile(tileset, key string) (tile *mbtiles.Tile, ok bool)

func (*TileCache) MapTiles

func (c *TileCache) MapTiles(tileset string, fn func(value *mbtiles.Tile) (*mbtiles.Tile, error)) (err error)

func (*TileCache) PutTile

func (c *TileCache) PutTile(tileset, key string, tile *mbtiles.Tile) (err error)

type TileXYZ

type TileXYZ struct {
	Tileset string `json:"tileset"`
	X       int    `json:"x"`
	Y       int    `json:"y"`
	Z       int    `json:"z"`
}

func (TileXYZ) String

func (xyz TileXYZ) String() string

type TilesetIndex

type TilesetIndex struct {
	Path     string
	Tilesets map[string]*mbtiles.Tileset
	Events   chan TsEvent
	// contains filtered or unexported fields
}

TilesetIndex is a container for tilesets loaded from disk

func NewTilesetIndex

func NewTilesetIndex(mbtilesDir string) (tsi *TilesetIndex, err error)

NewTilesetIndex creates a new tileset index, but does not read the tile tilesets from disk

func ReadTilesets

func ReadTilesets(mbtilesDir string) (tsi *TilesetIndex, err error)

ReadTilesets create a new tilesetindex and read the tilesets contents from disk It spawns goroutine that will refresh Tilesets from disk on changes

type TilesetTopic

type TilesetTopic struct {
	// contains filtered or unexported fields
}

hub maintains the set of active connections and broadcasts messages to the connections.

type TsEvent

type TsEvent struct {
	Name string
	Op   TsOp
}

func (*TsEvent) String

func (tse *TsEvent) String() string

type TsOp

type TsOp uint32
const (
	Upsert TsOp = 1 << iota
	Remove
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL