server

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2017 License: MIT Imports: 28 Imported by: 2

README

tegola's built in viewer code is stored in the static/ directory. To generate a bindata file so the static assets can be compiled into the binary, bindata-assetfs is used. Once bindata-assetfs is installed the following command can be used to generate the file for inclusion:

go-bindata-assetfs -pkg=server -ignore=.DS_Store static/...

bindata-assetfs also supports a debug mode which is descriped as "Do not embed the assets, but provide the embedding API. Contents will still be loaded from disk." This mode is ideal for development and can be configured using the following command:

go-bindata-assetfs -debug -pkg=server -ignore=.DS_Store static/...

Documentation

Overview

Package server implements the http frontend

Index

Constants

View Source
const (
	//	MaxTileSize is 500k. Currently just throws a warning when tile
	//	is larger than MaxTileSize
	MaxTileSize = 500000
	//	MaxZoom will not render tile beyond this zoom level
	MaxZoom = 20
)
View Source
const DefaultLogFormat = "{{.Time}}:{{.RequestIP}} —— Tile:{{.Z}}/{{.X}}/{{.Y}}"

Variables

View Source
var (
	//	set at runtime from main
	Version string
	//	configurable via the tegola config.toml file
	HostName string
	//	cache interface to use
	Cache cache.Interface
)

Functions

func Asset added in v0.4.0

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDir added in v0.4.0

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.

func AssetInfo added in v0.4.0

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames added in v0.4.0

func AssetNames() []string

AssetNames returns the names of the assets.

func MustAsset added in v0.4.0

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func RegisterMap

func RegisterMap(m Map) error

RegisterMap associates layers with map names

func RestoreAsset added in v0.4.0

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory

func RestoreAssets added in v0.4.0

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively

func Start

func Start(port string)

Start starts the tile server binding to the provided port

func TileCacheHandler added in v0.4.0

func TileCacheHandler(next http.Handler) http.Handler

TileCacheHandler implements a request cache for tiles on requests when the URLs have a /:z/:x/:y scheme suffix (i.e. /osm/1/3/4.pbf)

Types

type Capabilities added in v0.3.0

type Capabilities struct {
	Version string            `json:"version"`
	Maps    []CapabilitiesMap `json:"maps"`
}

type CapabilitiesLayer added in v0.3.0

type CapabilitiesLayer struct {
	Name    string   `json:"name"`
	Tiles   []string `json:"tiles"`
	MinZoom int      `json:"minzoom"`
	MaxZoom int      `json:"maxzoom"`
}

type CapabilitiesMap added in v0.3.0

type CapabilitiesMap struct {
	Name         string              `json:"name"`
	Attribution  string              `json:"attribution"`
	Bounds       [4]float64          `json:"bounds"`
	Center       [3]float64          `json:"center"`
	Tiles        []string            `json:"tiles"`
	Capabilities string              `json:"capabilities"`
	Layers       []CapabilitiesLayer `json:"layers"`
}

type HandleCapabilities added in v0.3.0

type HandleCapabilities struct{}

func (HandleCapabilities) ServeHTTP added in v0.3.0

func (req HandleCapabilities) ServeHTTP(w http.ResponseWriter, r *http.Request)

type HandleMapCapabilities added in v0.3.1

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

func (HandleMapCapabilities) ServeHTTP added in v0.3.1

func (req HandleMapCapabilities) ServeHTTP(w http.ResponseWriter, r *http.Request)

returns details about a map according to the tileJSON spec (https://github.com/mapbox/tilejson-spec/tree/master/2.1.0)

URI scheme: /capabilities/:map_name.json

map_name - map name in the config file

type HandleMapLayerZXY added in v0.3.1

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

func (HandleMapLayerZXY) ServeHTTP added in v0.3.1

func (req HandleMapLayerZXY) ServeHTTP(w http.ResponseWriter, r *http.Request)

URI scheme: /maps/:map_name/:layer_name/:z/:x/:y map_name - map name in the config file layer_name - name of the single map layer to render z, x, y - tile coordinates as described in the Slippy Map Tilenames specification

z - zoom level
x - row
y - column

type HandleMapStyle added in v0.4.0

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

func (HandleMapStyle) ServeHTTP added in v0.4.0

func (req HandleMapStyle) ServeHTTP(w http.ResponseWriter, r *http.Request)

returns details about a map according to the tileJSON spec (https://github.com/mapbox/tilejson-spec/tree/master/2.1.0)

URI scheme: /capabilities/:map_name.json

map_name - map name in the config file

type HandleMapZXY added in v0.3.1

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

func (HandleMapZXY) ServeHTTP added in v0.3.1

func (req HandleMapZXY) ServeHTTP(w http.ResponseWriter, r *http.Request)

URI scheme: /maps/:map_name/:z/:x/:y map_name - map name in the config file z, x, y - tile coordinates as described in the Slippy Map Tilenames specification

z - zoom level
x - row
y - column

type Layer

type Layer struct {
	//	optional. if not set, the ProviderLayerName will be used
	Name              string
	ProviderLayerName string
	MinZoom           int
	MaxZoom           int
	//	instantiated provider
	Provider mvt.Provider
	//	default tags to include when encoding the layer. provider tags take precedence
	DefaultTags map[string]interface{}
	GeomType    tegola.Geometry
}

func (*Layer) MVTName added in v0.4.0

func (l *Layer) MVTName() string

MVTName will return the value that will be encoded in the Name field when the layer is encoded as MVT

type Logger

type Logger struct {
	File   *os.File
	Format string
	sync.Mutex
	// contains filtered or unexported fields
}
var L *Logger

func (*Logger) Log

func (l *Logger) Log(item logItem)

type Map added in v0.3.1

type Map struct {
	Name string
	//	Contains an attribution to be displayed when the map is shown to a user.
	// 	This string is sanatized so it can't be abused as a vector for XSS or beacon tracking.
	Attribution string
	//	The maximum extent of available map tiles in WGS:84
	//	latitude and longitude values, in the order left, bottom, right, top.
	//	Default: [-180, -90, 180, 90]
	Bounds [4]float64
	//	The first value is the longitude, the second is latitude (both in
	//	WGS:84 values), the third value is the zoom level.
	Center [3]float64
	Layers []Layer
}

func NewMap added in v0.3.1

func NewMap(name string) Map

NewMap creates a new map with the necessary default values

func (*Map) FilterLayersByName added in v0.3.1

func (m *Map) FilterLayersByName(name string) (filteredLayers []Layer)

FilterByName returns a slice with the first layer that matches the provided name the slice return is for convenience. MVT tiles require unique layer names

func (*Map) FilterLayersByZoom added in v0.3.1

func (m *Map) FilterLayersByZoom(zoom int) (filteredLayers []Layer)

FilterByZoom returns layers that that are to be rendered between a min and max zoom

Jump to

Keyboard shortcuts

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