Documentation
¶
Index ¶
- Constants
- Variables
- func EnableCORS(s *Server) error
- func GetNested(something interface{}, keyParts []string) (interface{}, bool)
- func SimplifyShapes(s *Server) error
- type Cache
- type CacheConfig
- type Config
- type ConfigOption
- type Dict
- type ElasticsearchConfig
- type ElasticsearchSource
- type Handler
- type InMemoryCache
- type Layer
- type LayerConfig
- type NilCache
- type RedisCache
- type RedisConfig
- type Server
- type Source
- type SourceConfig
- type TileRequest
Constants ¶
const ( // ScrollSize is the max number of documents per scroll page ScrollSize = 250 // ScrollTimeout is the time.Duration to keep the scroll context alive ScrollTimeout = 10 * time.Second )
const ( // MinZoom is the default minimum zoom for a layer MinZoom = 0 // MaxZoom is the default maximum zoom for a layer MaxZoom = 22 // MinSimplify is the minimum simplification radius MinSimplify = 1.0 // MaxSimplify is the maximum simplification radius MaxSimplify = 10.0 // AllLayers is the special request parameter for returning all source layers AllLayers = "_all" )
Variables ¶
var ( // ErrNoValue occurs when trying to access a value that doesn't exist in the cache ErrNoValue = errors.New("No value exists in cache") )
var ( // Logger is the global logging instance Logger = logrus.New() )
Functions ¶
func EnableCORS ¶
EnableCORS configures the server for CORS (cross-origin resource sharing)
func SimplifyShapes ¶
SimplifyShapes enables geometry simplification based on the requested zoom level
Types ¶
type Cache ¶
type Cache interface {
// Exists determines whether or not there is a cache value for the given key
Exists(key string) bool
// Get retrieves the cached data given a key
Get(key string) ([]byte, error)
// Put stores a new value in the cache at a given key
Put(key string, val []byte) error
}
Cache is a generic interface for a tile server cache
func CreateCache ¶
func CreateCache(config *CacheConfig) (Cache, error)
CreateCache creates a new generic Cache from a CacheConfig
func NewInMemoryCache ¶
func NewInMemoryCache() Cache
NewInMemoryCache allocates a new InMemoryCache
func NewRedisCache ¶
func NewRedisCache(config *RedisConfig) (Cache, error)
NewRedisCache creates a new RedisCache given a RedisConfig
type CacheConfig ¶
type CacheConfig struct {
// Redis is an optional YAML key for configuring a RedisCache
Redis *RedisConfig `yaml:"redis"`
}
CacheConfig is a generic YAML cache configuration object
type Config ¶
type Config struct {
// Cache configures the tile server cache
Cache *CacheConfig `yaml:"cache"`
// Layers configures the tile server layers
Layers []LayerConfig `yaml:"layers"`
}
Config is a YAML server configuration object
type ConfigOption ¶
ConfigOption is a function that changes a configuration setting of the server.Server
func ConfigFile ¶
func ConfigFile(configFile *os.File) ConfigOption
ConfigFile loads a YAML configuration file from disk to set up the server
func InternalPort ¶
func InternalPort(internalPort uint16) ConfigOption
InternalPort changes the port number used for administrative endpoints (e.g. healthcheck)
func Port ¶
func Port(port uint16) ConfigOption
Port changes the port number used for serving tile data
type Dict ¶
type Dict map[string]interface{}
Dict is a type alias for map[string]interface{} that cleans up literals and also adds a helper method to implement the elastic.Query interface
type ElasticsearchConfig ¶
type ElasticsearchConfig struct {
// Host is the hostname part of the backend Elasticsearch cluster
Host string `yaml:"host"`
// Host is the port number of the backend Elasticsearch cluster
Port int `yaml:"port"`
// Index is the name of the Elasticsearch index used for retrieving feature data
Index string `yaml:"index"`
// GeometryField is the name of the document field that holds the feature geometry
GeometryField string `yaml:"geometryField"`
// SourceFields is a mapping from the feature property name to the source document
// field name
SourceFields map[string]string `yaml:"sourceFields"`
}
ElasticsearchConfig is the YAML configuration structure for configuring a new ElasticsearchSource
type ElasticsearchSource ¶
type ElasticsearchSource struct {
// ES is the internal Elasticsearch cluster client
ES *elastic.Client
// Index is the name of the Elasticsearch index used for retrieving feature data
Index string
// GeometryField is the name of the document field that holds the feature geometry
GeometryField string
// SourceFields is a mapping from the feature property name to the source document
// field name
SourceFields map[string]string
}
ElasticsearchSource is a Source implementation that retrieves feature data from an Elasticsearch cluster
func (*ElasticsearchSource) GetFeatures ¶
func (e *ElasticsearchSource) GetFeatures(ctx context.Context, req *TileRequest) (*geojson.FeatureCollection, error)
GetFeatures implements the Source interface, to get feature data from an Elasticsearch cluster
func (*ElasticsearchSource) HitToFeature ¶
HitToFeature converts an Elasticsearch hit object into a GeoJSON feature, by using the hit's geometry as the feature geometry, and mapping all other requested source fields to feature properties
type InMemoryCache ¶
type InMemoryCache struct {
// contains filtered or unexported fields
}
InMemoryCache implements the Cache interface backed by an in-memory map
func (*InMemoryCache) Exists ¶
func (i *InMemoryCache) Exists(key string) bool
Exists checks the internal map for the existence of the key
type Layer ¶
Layer is a configured, hydrated tile server layer
func CreateLayer ¶
func CreateLayer(layerConfig LayerConfig) (*Layer, error)
CreateLayer creates a new Layer given a LayerConfig
type LayerConfig ¶
type LayerConfig struct {
// Name is the effective name of the layer
Name string `yaml:"name"`
// Description is an optional short descriptor of the layer
Description string `yaml:"description"`
// Minzoom specifies the minimum z value for the layer
Minzoom int `yaml:"minzoom"`
// Maxzoom specifies the maximum z value for the layer
Maxzoom int `yaml:"maxzoom"`
// Source configures the underlying Source for the layer
Source SourceConfig `yaml:"source"`
}
LayerConfig represents a general YAML layer configuration object
type NilCache ¶
type NilCache struct{}
NilCache implements the Cache interface as a no-op
type RedisCache ¶
type RedisCache struct {
// Client is the backend Redis cluster client
Client *redis.Client
// TTL is how long each cache entry should remain before refresh
TTL time.Duration
}
RedisCache is a Redis-backed Cache implementation
func (*RedisCache) Exists ¶
func (r *RedisCache) Exists(key string) bool
Exists tries to get the cached value for a key, returning whether or not the key exists
type RedisConfig ¶
type RedisConfig struct {
// Host is the Redis cluster host name
Host string `yaml:"host"`
// Port is the Redis cluster port number
Port int `yaml:"port"`
// TTL is how long each cache entry should remain before refresh
TTL time.Duration `yaml:"ttl"`
}
RedisConfig is the YAML configuration for a RedisCache
type Server ¶
type Server struct {
// Port is the port number to bind the tile server
Port uint16
// InternalPort is the port number to bind the internal metrics endpoints
InternalPort uint16
// EnableCORS configures whether or not the tile server responds with CORS headers
EnableCORS bool
// Simplify configures whether or not the tile server simplifies outgoing feature
// geometries based on zoom level
Simplify bool
// Layers is the list of configured layers supported by the tile server
Layers []Layer
// Cache is an optional cache object that the server uses to cache responses
Cache Cache
}
Server is a tilenol server instance
func NewServer ¶
func NewServer(configOpts ...ConfigOption) (*Server, error)
NewServer creates a new server instance pre-configured with the given ConfigOption's
type Source ¶
type Source interface {
// GetFeatures retrieves the GeoJSON FeatureCollection for the given request
GetFeatures(context.Context, *TileRequest) (*geojson.FeatureCollection, error)
}
Source is a generic interface for all feature data sources
func NewElasticsearchSource ¶
func NewElasticsearchSource(config *ElasticsearchConfig) (Source, error)
NewElasticsearchSource creates a new Source that retrieves feature data from an Elasticsearch cluster
type SourceConfig ¶
type SourceConfig struct {
// Elasticsearch is an optional YAML key for configuring an ElasticsearchConfig
Elasticsearch *ElasticsearchConfig `yaml:"elasticsearch"`
}
SourceConfig represents a generic YAML source configuration object
type TileRequest ¶
TileRequest is an object containing the tile request context
func (*TileRequest) MapTile ¶
func (t *TileRequest) MapTile() maptile.Tile
MapTile creates a maptile.Tile object from the TileRequest