Documentation ¶
Index ¶
- Constants
- Variables
- func EncodeHeaderFlags(byteOrder binary.ByteOrder, envelope EnvelopeType, extendGeom bool, ...) headerFlags
- type BinaryHeader
- func (h *BinaryHeader) Encode() ([]byte, error)
- func (h *BinaryHeader) EncodeTo(data *bytes.Buffer) error
- func (h *BinaryHeader) Endian() binary.ByteOrder
- 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 EnvelopeType
- type GeometryType
- type Handle
- type MaybeBool
- type SpatialReferenceSystem
- type StandardBinary
- type TableDescription
Constants ¶
const ( EnvelopeTypeNone = EnvelopeType(0) EnvelopeTypeXY = EnvelopeType(1) EnvelopeTypeXYZ = EnvelopeType(2) EnvelopeTypeXYM = EnvelopeType(3) EnvelopeTypeXYZM = EnvelopeType(4) EnvelopeTypeInvalid = EnvelopeType(5) )
const ( ErrEnvelopeEnvelopeTypeMismatch = errors.String("envelope and envelope type mismatch") ErrInvalidEnvelopeType = errors.String("invalid envelope type") ErrInsufficentBytes = errors.String("not enough bytes") ErrInvalidMagicNumber = errors.String("invalid magic number") ErrNilStandardBinary = errors.String("standard binary is nil") ErrNilHandler = errors.String("gpkg handler is nil") )
const ( // SPATIALITE database driver name SPATIALITE = "spatialite" // ApplicationID is the required application id for the file ApplicationID = 0x47504B47 // "GPKG" // UserVersion is the version of the GPKG file format. We support // 1.2.1, so the the decimal representation is 10201 (1 digit for the major // two digit for the minor and bug-fix). UserVersion = 0x000027D9 // 10201 // TableSpatialRefSysSQL is the normative sql for the required spatial ref // table. http://www.geopackage.org/spec/#gpkg_spatial_ref_sys_sql TableSpatialRefSysSQL = `` /* 245-byte string literal not displayed */ // TableContentsSQL is the normative sql for the required contents table. // http://www.geopackage.org/spec/#gpkg_contents_sql TableContentsSQL = `` /* 427-byte string literal not displayed */ // TableGeometryColumnsSQL is the normative sql for the geometry columns table that is // required if the contents table has at least one table with a data_type of features // http://www.geopackage.org/spec/#gpkg_geometry_columns_sql TableGeometryColumnsSQL = `` /* 654-byte string literal not displayed */ // https://www.geopackage.org/spec/#gpkg_extensions_sql TableExtensionsSQL = `` /* 245-byte string literal not displayed */ )
const ( // ORNone is for basic SRS ORNone = "none" OREPSG = "epsg" )
Organization names
const ( DataTypeFeatures = "features" DataTypeAttributes = "attributes" DataTypeTitles = "titles" )
const ( No = MaybeBool(0) Yes = MaybeBool(1) Maybe = MaybeBool(2) Prohibited = No Mandatory = Yes Optional = Maybe )
const ( // Geometry is the Normative type for a geometry Geometry = GeometryType(0) // Point is the Normative type for a point geometry Point = GeometryType(1) // Linestring is the Normative type for a linestring geometry Linestring = GeometryType(2) // Polygon is the Normative type for a polygon geometry Polygon = GeometryType(3) // MultiPoint is the Normative type for a multipoint geometry MultiPoint = GeometryType(4) // MultiLinestring is the Normative type for a multilinestring geometry MultiLinestring = GeometryType(5) // MultiPolygon is the Normative type for a multipolygon geometry MultiPolygon = GeometryType(6) // GeometryCollection is the Normative type for a collection of geometries GeometryCollection = GeometryType(7) )
Variables ¶
var KnownSRS = map[int32]SpatialReferenceSystem{ -1: { Name: "any", ID: -1, Organization: ORNone, OrganizationCoordsysID: -1, Definition: "", Description: "any", }, 0: { Name: "any", ID: 0, Organization: ORNone, OrganizationCoordsysID: 0, Definition: "", Description: "any", }, 4326: { Name: "WGS 84", ID: 4326, Organization: OREPSG, OrganizationCoordsysID: 4326, Definition: ` GEOGCS["WGS 84", DATUM["WGS_1984", SPHEROID["WGS 84",6378137,298.257223563, AUTHORITY["EPSG","7030"]], AUTHORITY["EPSG","6326"]], PRIMEM["Greenwich",0, AUTHORITY["EPSG","8901"]], UNIT["degree",0.0174532925199433, AUTHORITY["EPSG","9122"]], AUTHORITY["EPSG","4326"]] `, Description: "World Geodetic System: WGS 84", }, 3857: { Name: "WebMercator", ID: 3857, Organization: OREPSG, OrganizationCoordsysID: 3857, Definition: ` PROJCS["WGS 84 / Pseudo-Mercator", GEOGCS["WGS 84", DATUM["WGS_1984", SPHEROID["WGS 84",6378137,298.257223563, AUTHORITY["EPSG","7030"]], AUTHORITY["EPSG","6326"]], PRIMEM["Greenwich",0, AUTHORITY["EPSG","8901"]], UNIT["degree",0.0174532925199433, AUTHORITY["EPSG","9122"]], AUTHORITY["EPSG","4326"]], PROJECTION["Mercator_1SP"], PARAMETER["central_meridian",0], PARAMETER["scale_factor",1], PARAMETER["false_easting",0], PARAMETER["false_northing",0], UNIT["metre",1, AUTHORITY["EPSG","9001"]], AXIS["X",EAST], AXIS["Y",NORTH], EXTENSION["PROJ4","+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs"], AUTHORITY["EPSG","3857"]] `, Description: "WGS83 / Web Mercator", }, }
var Magic = [2]byte{0x47, 0x50}
Magic is the magic number encode in the header. It should be 0x4750
Functions ¶
func EncodeHeaderFlags ¶
func EncodeHeaderFlags(byteOrder binary.ByteOrder, envelope EnvelopeType, extendGeom bool, emptyGeom bool) headerFlags
Types ¶
type BinaryHeader ¶
type BinaryHeader struct {
// contains filtered or unexported fields
}
BinaryHeader is the gpkg header that accompainies every feature.
func DecodeBinaryHeader ¶
func DecodeBinaryHeader(data []byte) (*BinaryHeader, error)
DecodeBinaryHeader decodes the data into the BinaryHeader
func NewBinaryHeader ¶
func NewBinaryHeader(byteOrder binary.ByteOrder, srsid int32, envelope []float64, et EnvelopeType, extendGeom bool, emptyGeom bool) (*BinaryHeader, error)
NewBinaryHeader returns a new binary header
func (*BinaryHeader) Encode ¶
func (h *BinaryHeader) Encode() ([]byte, error)
func (*BinaryHeader) Endian ¶
func (h *BinaryHeader) Endian() binary.ByteOrder
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
IsStandardGeometry 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 EnvelopeType ¶
type EnvelopeType uint8
func (EnvelopeType) NumberOfElements ¶
func (et EnvelopeType) NumberOfElements() int
NumberOfElements that the particular Evnelope Type will have.
func (EnvelopeType) String ¶
func (et EnvelopeType) String() string
type GeometryType ¶
type GeometryType uint8
GeometryType describes the type of geometry to find for a table
func TypeForGeometry ¶
func TypeForGeometry(g geom.Geometry) GeometryType
func (GeometryType) String ¶
func (gt GeometryType) String() string
type Handle ¶
Handle is the handle to the DB
func (*Handle) AddGeometryTable ¶
func (h *Handle) AddGeometryTable(table TableDescription) error
AddGeometryTable will add the given features table to the metadata tables This should be called after creating the table.
func (*Handle) CalculateGeometryExtent ¶
CalculateGeometryExtent will grab all the geometries from the given table, use it to calculate the extent of all geometries in that table.
func (*Handle) UpdateGeometryExtent ¶
UpdateGeometryExtent will modify the extent for the given table by adding the passed in extent to the extent of the table. Growing the extent as necessary.
func (*Handle) UpdateSRS ¶
func (h *Handle) UpdateSRS(srss ...SpatialReferenceSystem) error
UpdateSRS will insert or update the srs table with the given srs
type SpatialReferenceSystem ¶
type SpatialReferenceSystem struct { Name string ID int Organization string OrganizationCoordsysID int Definition string Description string }
SpatialReferenceSystem describes the SRS
type StandardBinary ¶
type StandardBinary struct { Header *BinaryHeader SRSID int32 Geometry geom.Geometry }
StandardBinary is the binary encoding pluse some meta data should be stored as a blob
func DecodeGeometry ¶
func DecodeGeometry(bytes []byte) (*StandardBinary, error)
func (StandardBinary) Encode ¶
func (sb StandardBinary) Encode() ([]byte, error)
func (*StandardBinary) Extent ¶
func (sb *StandardBinary) Extent() *geom.Extent
func (*StandardBinary) Scan ¶
func (sb *StandardBinary) Scan(value interface{}) error
type TableDescription ¶
type TableDescription struct { Name string ShortName string Description string GeometryField string GeometryType GeometryType SRS int32 Z MaybeBool M MaybeBool }
TableDescription describes a content table