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 ifsql
is not defined.id_fieldname
(string): [Optional] the name of the feature id field. defaults tofid
fields
([]string): [Optional] a list of fields (column names) to include as feature tags. Can be used ifsql
is not defined.sql
(string): [*Required] custom SQL to use use. Required iftablename
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
- You must join your feature table to the spatial index table: i.e.
- !ZOOM! - [Optional] Currently allowed, but does nothing.
- !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.
*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
- Variables
- func AutoConfig(gpkgPath string) (map[string]interface{}, error)
- func Cleanup()
- func NewTileProvider(config dict.Dicter) (provider.Tiler, error)
- type BinaryHeader
- func (h *BinaryHeader) Envelope() []float64
- func (h *BinaryHeader) EnvelopeType() envelopeType
- func (h *BinaryHeader) IsGeometryEmpty() bool
- func (h *BinaryHeader) IsStandardGeometry() bool
- func (h *BinaryHeader) Magic() [2]byte
- func (h *BinaryHeader) SRSId() int32
- func (h *BinaryHeader) Size() int
- func (h *BinaryHeader) Version() uint8
- type ErrInvalidFilePath
- type GeomColumn
- type GeomTableDetails
- type Layer
- type Provider
Constants ¶
const ( EnvelopeTypeNone = envelopeType(0) EnvelopeTypeXY = envelopeType(1) EnvelopeTypeXYZ = envelopeType(2) EnvelopeTypeXYM = envelopeType(3) EnvelopeTypeXYZM = envelopeType(4) EnvelopeTypeInvalid = envelopeType(5) )
const ( Name = "gpkg" DefaultSRID = tegola.WebMercator DefaultIDFieldName = "fid" DefaultGeomFieldName = "geom" )
const ( ConfigKeyFilePath = "filepath" ConfigKeyLayers = "layers" ConfigKeyLayerName = "name" ConfigKeyTableName = "tablename" ConfigKeySQL = "sql" ConfigKeyGeomIDField = "id_fieldname" ConfigKeyFields = "fields" )
config keys
Variables ¶
var (
ErrMissingLayerName = errors.New("gpkg: layer is missing 'name'")
)
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
Creates a config instance of the type NewTileProvider() requires including all available feature
tables in the gpkg at 'gpkgPath'.
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
}