provider

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2021 License: MIT Imports: 9 Imported by: 21

Documentation

Index

Constants

View Source
const (

	// TypeStd declares a provider to be a standard provider
	TypeStd providerType = 1 << iota
	// TypeMvt declares a provider to be an mvt provider.
	TypeMvt

	// TypeAll should be all the types
	TypeAll = TypeStd & TypeMvt
)

Variables

View Source
var (
	// ErrCanceled is returned when cancel was requested
	ErrCanceled    = fmt.Errorf("provider: %v", context.Canceled)
	ErrUnsupported = errors.New("provider: unsupported")
	ErrNilInitFunc = errors.New("init function can not be nil")
)

Functions

func Cleanup

func Cleanup()

Cleanup is called at the end of the run to allow providers to cleanup

func ConvertFeatureID

func ConvertFeatureID(v interface{}) (uint64, error)

ConvertFeatureID attempts to convert an interface value to an uint64

func Drivers

func Drivers(types ...providerType) (l []string)

Drivers returns a list of registered drivers.

func MVTRegister added in v0.12.0

func MVTRegister(name string, init MVTInitFunc, cleanup CleanupFunc) error

MVTRegister the provider with the system. This call is generally made in the init functions of the provider.

the clean up function will be called during shutdown of the provider to allow the provider to do any cleanup.

The init function can not be nil, the cleanup function may be nil

func Register

func Register(name string, init InitFunc, cleanup CleanupFunc) error

Register the provider with the system. This call is generally made in the init functions of the provider.

the clean up function will be called during shutdown of the provider to allow the provider to do any cleanup.

The init function can not be nil, the cleanup function may be nil

Types

type CleanupFunc

type CleanupFunc func()

CleanupFunc is called to when the system is shuting down, this allows the provider to cleanup.

type ErrInvalidProviderType added in v0.12.0

type ErrInvalidProviderType struct {
	Name           string
	Type           providerType
	KnownProviders []string
}

ErrInvalidProviderType is return when the requested provider type is not known for the given name

func (ErrInvalidProviderType) Error added in v0.12.0

func (err ErrInvalidProviderType) Error() string

type ErrInvalidRegisteredProvider added in v0.12.0

type ErrInvalidRegisteredProvider struct {
	Name string
}

ErrInvalidRegisteredProvider is returned when something went wrong with the provider registration. This should never happen, in normal usage, and if it does it's an issue with the provider plugin.

func (ErrInvalidRegisteredProvider) Error added in v0.12.0

type ErrProviderAlreadyExists added in v0.11.0

type ErrProviderAlreadyExists struct {
	Name string
}

ErrProviderAlreadyExists is returned when the Provider being registered already exists in the registration system

func (ErrProviderAlreadyExists) Error added in v0.11.0

func (err ErrProviderAlreadyExists) Error() string

type ErrUnableToConvertFeatureID

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

func (ErrUnableToConvertFeatureID) Error

type ErrUnknownProvider added in v0.11.0

type ErrUnknownProvider struct {
	Name           string
	KnownProviders []string
}

ErrUnknownProvider is returned when no providers are registered or requested provider is not registered

func (ErrUnknownProvider) Error added in v0.11.0

func (err ErrUnknownProvider) Error() string

type Feature

type Feature struct {
	ID       uint64
	Geometry geom.Geometry
	SRID     uint64
	Tags     map[string]interface{}
}

type InitFunc

type InitFunc func(dicter dict.Dicter) (Tiler, error)

InitFunc initialize a provider given a config map. The init function should validate the config map, and report any errors. This is called by the For function.

type Layer added in v0.12.0

type Layer struct {
	// Name is the name of the Layer as recognized by the provider
	Name string
	// MVTName is the name of the layer to encode into the MVT.
	// this is often used when different provider layers are used
	// at different zoom levels but the MVT layer name is consistent
	MVTName string
}

Layer holds information about a query.

type LayerInfo

type LayerInfo interface {
	// Name is the name of the layer
	Name() string
	// GeomType is the geometry type of the layer
	GeomType() geom.Geometry
	// SRID is the srid of all the points in the layer
	SRID() uint64
}

LayerInfo is the important information about a layer

type Layerer added in v0.11.0

type Layerer interface {
	// Layers returns information about the various layers the provider supports
	Layers() ([]LayerInfo, error)
}

Layerer are objects that know about their layers

type MVTInitFunc added in v0.12.0

type MVTInitFunc func(dicter dict.Dicter) (MVTTiler, error)

MVTInitFunc initialize a provider given a config map. The init function should validate the config map, and report any errors. This is called by the For function.

type MVTTiler added in v0.12.0

type MVTTiler interface {
	Layerer

	// MVTForLayers will return a MVT byte array or an error for the given layer names.
	MVTForLayers(ctx context.Context, tile Tile, layers []Layer) ([]byte, error)
}

type Tile

type Tile interface {
	// ZXY returns the z, x and y values of the tile
	ZXY() (uint, uint, uint)
	// Extent returns the extent of the tile excluding any buffer
	Extent() (extent *geom.Extent, srid uint64)
	// BufferedExtent returns the extent of the tile including any buffer
	BufferedExtent() (extent *geom.Extent, srid uint64)
}

Tile is an interface used by Tiler, it is an unnecessary abstraction and is due to be removed. The tiler interface will, instead take a, *geom.Extent.

func NewTile added in v0.11.0

func NewTile(z, x, y, buf, srid uint) Tile

NewTile creates a new slippy tile with a Buffer

type Tiler

type Tiler interface {
	Layerer

	// TileFeature will stream decoded features to the callback function fn
	// if fn returns ErrCanceled, the TileFeatures method should stop processing
	TileFeatures(ctx context.Context, layer string, t Tile, fn func(f *Feature) error) error
}

Tiler is a Layers that allows one to encode features in that layer

type TilerUnion added in v0.12.0

type TilerUnion struct {
	Std Tiler
	Mvt MVTTiler
}

TilerUnion represents either a Std Tiler or and MVTTiler; only one should be not nil.

func For

func For(name string, config dict.Dicter) (val TilerUnion, err error)

For function returns a configure provider of the given type; The provider may be a mvt provider or a std provider. The correct entry in TilerUnion will not be nil. If there is an error both entries will be nil.

func (TilerUnion) Layers added in v0.12.0

func (tu TilerUnion) Layers() ([]LayerInfo, error)

Layers return the layers of the Tiler. It will only return Std layers if STD is defined other the MVT layers

Directories

Path Synopsis
The debug provider returns features that are helpful for debugging a tile including a box for the tile edges and a point in the middle of the tile with z,x,y values encoded
The debug provider returns features that are helpful for debugging a tile including a box for the tile edges and a point in the middle of the tile with z,x,y values encoded

Jump to

Keyboard shortcuts

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