gpkg

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2019 License: MIT Imports: 20 Imported by: 0

README

GeoPackage

This provider connects to GeoPackage databases (See http://www.geopackage.org/ http://www.opengeospatial.org/standards/geopackage)

The connection between tegola and a GeoPackage is configured in a tegola.toml file. An example minimum connection config:

[[providers]]
name = "sample_gpkg"
type = "gpkg"
filepath = "/path/to/my/sample_gpkg.gpkg"
Connection Properties
  • name (string): [Required] provider name is referenced from map layers.
  • type (string): [Required] the type of data provider. must be "gpkg" to use this data provider.
  • filepath (string): [Required] The system file path to the GeoPackage file you wish to connect to.

Provider Layers

In addition to the connection configuration above, Provider Layers need to be configured. A Provider Layer tells tegola how to query a GeoPackage for a certain layer. An example minimum config:

[[providers.layers]]
name = "land_polygons"
tablename = "land_polygons"
id_fieldname = "fid"
Provider Layers 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.
  • id_fieldname (string): [Optional] the name of the feature id field. defaults to fid
  • fields ([]string): [Optional] a list of fields (column names) to include as feature tags. Can be used if sql is not defined.
  • sql (string): [*Required] custom SQL to use use. Required if tablename is not defined. Supports the following WHERE-clause tokens:
    • !BBOX! - [Required] will be replaced with the bounding box of the tile before the query is sent to the database. To support this token, your custom SQL must do a couple of things.
      • You must join your feature table to the spatial index table: i.e. JOIN feature_table ft rtree_feature_table_geom si ON ft.fid = rt.si
      • Include the following fields in your SELECT clause: si.minx, si.miny, si.maxx, si.maxy
      • Note that the id field for your feature table may be something other than fid
    • !ZOOM! - [Optional] Currently allowed, but does nothing.

*Required: either the tablename or sql must be defined, but not both.

Example minimum custom SQL config

[[providers.layers]]
name = "a_points"
sql = "SELECT fid, geom, amenity, religion, tourism, shop, si.minx, si.miny, si.maxx, si.maxy FROM land_polygons lp JOIN rtree_land_polygons_geom si ON lp.fid = si.id WHERE !BBOX!"

Documentation

Index

Constants

View Source
const (
	EnvelopeTypeNone    = envelopeType(0)
	EnvelopeTypeXY      = envelopeType(1)
	EnvelopeTypeXYZ     = envelopeType(2)
	EnvelopeTypeXYM     = envelopeType(3)
	EnvelopeTypeXYZM    = envelopeType(4)
	EnvelopeTypeInvalid = envelopeType(5)
)
View Source
const (
	Name                 = "gpkg"
	DefaultSRID          = tegola.WebMercator
	DefaultIDFieldName   = "fid"
	DefaultGeomFieldName = "geom"
)
View Source
const (
	ConfigKeyFilePath    = "filepath"
	ConfigKeyLayers      = "layers"
	ConfigKeyLayerName   = "name"
	ConfigKeyTableName   = "tablename"
	ConfigKeySQL         = "sql"
	ConfigKeyGeomIDField = "id_fieldname"
	ConfigKeyFields      = "fields"
)

config keys

Variables

View Source
var (
	ErrMissingLayerName = errors.New("gpkg: layer is missing 'name'")
)
View Source
var Magic = [2]byte{0x47, 0x50}

Magic is the magic number encode in the header. It should be 0x4750

Functions

func AutoConfig added in v0.7.0

func AutoConfig(gpkgPath string) (map[string]interface{}, error)

Creates a config instance of the type NewTileProvider() requires including all available feature

tables in the gpkg at 'gpkgPath'.

func Cleanup

func Cleanup()

Cleanup will close all database connections and destroy all previously instantiated Provider instances

func NewTileProvider

func NewTileProvider(config dict.Dicter) (provider.Tiler, error)

Types

type BinaryHeader

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

BinaryHeader is the gpkg header that accompainies every feature.

func NewBinaryHeader

func NewBinaryHeader(data []byte) (*BinaryHeader, error)

NewBinaryHeader decodes the data into the BinaryHeader

func (*BinaryHeader) Envelope

func (h *BinaryHeader) Envelope() []float64

Envelope is the bounding box of the feature, used for searching. If the EnvelopeType is EvelopeTypeNone, then there isn't a envelope encoded and a search without an index will need to be preformed. This is to save space.

func (*BinaryHeader) EnvelopeType

func (h *BinaryHeader) EnvelopeType() envelopeType

EnvelopeType is the type of the envelope that is provided.

func (*BinaryHeader) IsGeometryEmpty

func (h *BinaryHeader) IsGeometryEmpty() bool

IsGeometryEmpty tells us if the geometry should be considered empty.

func (*BinaryHeader) IsStandardGeometry

func (h *BinaryHeader) IsStandardGeometry() bool

IsStandardGeometery is the geometry a core/extended geometry type, or a user defined geometry type.

func (*BinaryHeader) Magic

func (h *BinaryHeader) Magic() [2]byte

Magic is the magic number encode in the header. It should be 0x4750

func (*BinaryHeader) SRSId

func (h *BinaryHeader) SRSId() int32

SRSId is the SRS id of the feature.

func (*BinaryHeader) Size

func (h *BinaryHeader) Size() int

Size is the size of the header in bytes.

func (*BinaryHeader) Version

func (h *BinaryHeader) Version() uint8

Version is the version number encode in the header.

type ErrInvalidFilePath

type ErrInvalidFilePath struct {
	FilePath string
}

func (ErrInvalidFilePath) Error

func (e ErrInvalidFilePath) Error() string

type GeomColumn

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

type GeomTableDetails

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

type Layer

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

func (Layer) GeomType

func (l Layer) GeomType() geom.Geometry

func (Layer) Name

func (l Layer) Name() string

func (Layer) SRID

func (l Layer) SRID() uint64

type Provider

type Provider struct {
	// path to the geopackage file
	Filepath string
	// contains filtered or unexported fields
}

func (*Provider) Close

func (p *Provider) Close() error

Close will close the Provider's database connection

func (*Provider) Layers

func (p *Provider) Layers() ([]provider.LayerInfo, error)

func (*Provider) TileFeatures

func (p *Provider) TileFeatures(ctx context.Context, layer string, tile provider.Tile, fn func(f *provider.Feature) error) error

Jump to

Keyboard shortcuts

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