Documentation
¶
Index ¶
- Constants
- Variables
- func BuildDBConfig(uri string) (*pgxpool.Config, error)
- func BuildURI(config dict.Dicter) (*url.URL, *url.Values, error)
- func Cleanup()
- func ConfigTLS(sslMode string, sslKey string, sslCert string, sslRootCert string, ...) error
- func NewMVTTileProvider(config dict.Dicter) (provider.MVTTiler, error)
- func NewTileProvider(config dict.Dicter) (provider.Tiler, error)
- type ErrGeomFieldNotFound
- type ErrInvalidSSLMode
- type ErrInvalidURI
- type ErrLayerNotFound
- type ErrUnclosedToken
- type Layer
- type Provider
- func (p *Provider) Close()
- func (p *Provider) Collectors(prefix string, cfgFn func(configKey string) map[string]interface{}) ([]observability.Collector, error)
- func (p *Provider) Layer(name string) (Layer, bool)
- func (p Provider) Layers() ([]provider.LayerInfo, error)
- func (p Provider) MVTForLayers(ctx context.Context, tile provider.Tile, layers []provider.Layer) ([]byte, error)
- func (p Provider) TileFeatures(ctx context.Context, layer string, tile provider.Tile, ...) error
Constants ¶
const ( EnvSQLDebugName = "TEGOLA_SQL_DEBUG" EnvSQLDebugLayer = "LAYER_SQL" EnvSQLDebugExecute = "EXECUTE_SQL" )
const ( DefaultURI = "" DefaultPort = 5432 DefaultSRID = tegola.WebMercator DefaultMaxConn = 100 DefaultMaxConnIdleTime = "30m" DefaultMaxConnLifetime = "1h" DefaultSSLMode = "prefer" DefaultSSLKey = "" DefaultSSLCert = "" )
const ( ConfigKeyURI = "uri" ConfigKeyHost = "host" ConfigKeyPort = "port" ConfigKeyDB = "database" ConfigKeyUser = "user" ConfigKeyPassword = "password" ConfigKeySSLMode = "ssl_mode" ConfigKeySSLKey = "ssl_key" ConfigKeySSLCert = "ssl_cert" ConfigKeySSLRootCert = "ssl_root_cert" ConfigKeyMaxConn = "max_connections" ConfigKeyMaxConnIdleTime = "max_connection_idle_time" ConfigKeyMaxConnLifetime = "max_connection_lifetime" ConfigKeySRID = "srid" ConfigKeyLayers = "layers" ConfigKeyLayerName = "name" ConfigKeyTablename = "tablename" ConfigKeySQL = "sql" ConfigKeyFields = "fields" ConfigKeyGeomField = "geometry_fieldname" ConfigKeyGeomIDField = "id_fieldname" ConfigKeyGeomType = "geometry_type" )
const ( MVTProviderType = "mvt_postgis" ProviderType = "postgis" )
const Name = "postgis"
Variables ¶
var (
ErrNilLayer = errors.New("layer is nil")
)
Functions ¶
func BuildDBConfig ¶ added in v0.15.0
BuildDBConfig build db config with defaults
func BuildURI ¶ added in v0.15.0
TODO: (iwpnd) to be removed/refactored in v0.17.0 BuildURI creates a database URI from config
func Cleanup ¶ added in v0.8.0
func Cleanup()
Cleanup will close all database connections and destroy all previously instantiated Provider instances
func ConfigTLS ¶ added in v0.7.0
func ConfigTLS(sslMode string, sslKey string, sslCert string, sslRootCert string, cc *pgxpool.Config) error
derived from github.com/jackc/pgx configTLS (https://github.com/jackc/pgx/blob/master/conn.go)
func NewMVTTileProvider ¶ added in v0.12.0
func NewTileProvider ¶ added in v0.6.0
NewTileProvider instantiates and returns a new postgis provider or an error. The function will validate that the config object looks good before trying to create a driver. This Provider supports the following fields in the provided map[string]interface{} map:
host (string): [Required] postgis database host port (int): [Required] postgis database port (required) database (string): [Required] postgis database name user (string): [Required] postgis database user password (string): [Required] postgis database password srid (int): [Optional] The default SRID for the provider. Defaults to WebMercator (3857) but also supports WGS84 (4326) max_connections : [Optional] The max connections to maintain in the connection pool. Default is 100. 0 means no max. layers (map[string]struct{}) — This is map of layers keyed by the layer name. supports the following properties name (string): [Required] the name of the layer. This is used to reference this layer from map layers. tablename (string): [*Required] the name of the database table to query against. Required if sql is not defined. geometry_fieldname (string): [Optional] the name of the filed which contains the geometry for the feature. defaults to geom id_fieldname (string): [Optional] the name of the feature id field. defaults to gid fields ([]string): [Optional] a list of fields to include alongside the feature. Can be used if sql is not defined. srid (int): [Optional] the SRID of the layer. Supports 3857 (WebMercator) or 4326 (WGS84). sql (string): [*Required] custom SQL to use use. Required if tablename is not defined. Supports the following tokens: !BBOX! - [Required] will be replaced with the bounding box of the tile before the query is sent to the database. !ZOOM! - [Optional] will be replaced with the "Z" (zoom) value of the requested tile.
Types ¶
type ErrGeomFieldNotFound ¶ added in v0.9.0
func (ErrGeomFieldNotFound) Error ¶ added in v0.9.0
func (e ErrGeomFieldNotFound) Error() string
type ErrInvalidSSLMode ¶ added in v0.7.0
type ErrInvalidSSLMode string
func (ErrInvalidSSLMode) Error ¶ added in v0.7.0
func (e ErrInvalidSSLMode) Error() string
type ErrInvalidURI ¶ added in v0.15.0
func (ErrInvalidURI) Error ¶ added in v0.15.0
func (e ErrInvalidURI) Error() string
func (ErrInvalidURI) Unwrap ¶ added in v0.15.0
func (e ErrInvalidURI) Unwrap() error
type ErrLayerNotFound ¶ added in v0.6.0
type ErrLayerNotFound struct {
LayerName string
}
func (ErrLayerNotFound) Error ¶ added in v0.6.0
func (e ErrLayerNotFound) Error() string
type ErrUnclosedToken ¶ added in v0.8.0
type ErrUnclosedToken string
func (ErrUnclosedToken) Error ¶ added in v0.8.0
func (e ErrUnclosedToken) Error() string
type Layer ¶ added in v0.4.0
type Layer struct {
// contains filtered or unexported fields
}
layer holds information about a query.
func (Layer) GeomFieldName ¶ added in v0.4.0
func (Layer) IDFieldName ¶ added in v0.4.0
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider provides the postgis data provider.
func CreateProvider ¶ added in v0.12.0
CreateProvider instantiates and returns a new postgis provider or an error. The function will validate that the config object looks good before trying to create a driver. This Provider supports the following fields in the provided map[string]interface{} map:
host (string): [Required] postgis database host port (int): [Required] postgis database port (required) database (string): [Required] postgis database name user (string): [Required] postgis database user password (string): [Required] postgis database password srid (int): [Optional] The default SRID for the provider. Defaults to WebMercator (3857) but also supports WGS84 (4326) max_connections : [Optional] The max connections to maintain in the connection pool. Default is 100. 0 means no max. layers (map[string]struct{}) — This is map of layers keyed by the layer name. supports the following properties name (string): [Required] the name of the layer. This is used to reference this layer from map layers. tablename (string): [*Required] the name of the database table to query against. Required if sql is not defined. geometry_fieldname (string): [Optional] the name of the filed which contains the geometry for the feature. defaults to geom id_fieldname (string): [Optional] the name of the feature id field. defaults to gid fields ([]string): [Optional] a list of fields to include alongside the feature. Can be used if sql is not defined. srid (int): [Optional] the SRID of the layer. Supports 3857 (WebMercator) or 4326 (WGS84). sql (string): [*Required] custom SQL to use use. Required if tablename is not defined. Supports the following tokens: !BBOX! - [Required] will be replaced with the bounding box of the tile before the query is sent to the database. !ZOOM! - [Optional] will be replaced with the "Z" (zoom) value of the requested tile.
func (*Provider) Close ¶ added in v0.8.0
func (p *Provider) Close()
Close will close the Provider's database connectio
func (*Provider) Collectors ¶ added in v0.14.0
func (*Provider) Layer ¶ added in v0.4.0
Layer fetches an individual layer from the provider, if it's configured if no name is provider, the first layer is returned
func (Provider) Layers ¶ added in v0.4.0
Layers returns meta data about the various layers which are configured with the provider