writer

package
v0.0.0-...-e4eb1ea Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: BSD-2-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MagicBytes = []byte{0x66, 0x67, 0x62, 0x03, 0x66, 0x67, 0x62, 0x00}

MagicBytes is the identifier sequence for a flatgeobuf file.

Functions

func WithMemory

func WithMemory() writerOption

Use memory instead of temporary file when generating index or execute HeaderUpdater. Effective only when includeIndex is true or when HeaderUpdater is provided.

Warning: this option could use arbitrarily large amounts of memory.

Types

type Column

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

func NewColumn

func NewColumn(builder *flatbuffers.Builder) *Column

func (*Column) Build

func (c *Column) Build() flatbuffers.UOffsetT

func (*Column) SetDescription

func (c *Column) SetDescription(description string) *Column

func (*Column) SetMetadata

func (c *Column) SetMetadata(metadata string) *Column

func (*Column) SetName

func (c *Column) SetName(name string) *Column

func (*Column) SetNullable

func (c *Column) SetNullable(nullable bool) *Column

func (*Column) SetPrecision

func (c *Column) SetPrecision(precision int) *Column

func (*Column) SetPrimaryKey

func (c *Column) SetPrimaryKey(primaryKey bool) *Column

func (*Column) SetScale

func (c *Column) SetScale(scale int) *Column

func (*Column) SetTitle

func (c *Column) SetTitle(title string) *Column

func (*Column) SetType

func (c *Column) SetType(typ flattypes.ColumnType) *Column

func (*Column) SetUnique

func (c *Column) SetUnique(unique bool) *Column

func (*Column) SetWidth

func (c *Column) SetWidth(width int) *Column

type Crs

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

Crs is a builder for flatgeobuf.Crs, which represents the coordinate reference system associated with the data stored in the flatgeobuf. This is not required to be set at all.

func NewCrs

func NewCrs(builder *flatbuffers.Builder) *Crs

func (*Crs) Build

func (c *Crs) Build() flatbuffers.UOffsetT

func (*Crs) SetCode

func (c *Crs) SetCode(code int32) *Crs

func (*Crs) SetCodeString

func (c *Crs) SetCodeString(codeString string) *Crs

func (*Crs) SetDescription

func (c *Crs) SetDescription(description string) *Crs

func (*Crs) SetName

func (c *Crs) SetName(name string) *Crs

func (*Crs) SetOrg

func (c *Crs) SetOrg(org string) *Crs

type Feature

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

func NewFeature

func NewFeature(builder *flatbuffers.Builder) *Feature

func (*Feature) Build

func (f *Feature) Build() flatbuffers.UOffsetT

func (*Feature) SetColumns

func (f *Feature) SetColumns(columns []Column) *Feature

func (*Feature) SetGeometry

func (f *Feature) SetGeometry(geometry *Geometry) *Feature

func (*Feature) SetProperties

func (f *Feature) SetProperties(properties []byte) *Feature

type FeatureGenerator

type FeatureGenerator interface {
	// Generate generates a feature. Returns nil if there are no more features
	// to generate.
	Generate() *Feature
}

FeatureGenerator is an interface for generating features.

type Geometry

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

func NewGeometry

func NewGeometry(builder *flatbuffers.Builder) *Geometry

func (*Geometry) Build

func (g *Geometry) Build() flatbuffers.UOffsetT

func (*Geometry) SetEnds

func (g *Geometry) SetEnds(ends []uint32) *Geometry

func (*Geometry) SetM

func (g *Geometry) SetM(m []float64) *Geometry

func (*Geometry) SetParts

func (g *Geometry) SetParts(parts []Geometry) *Geometry

func (*Geometry) SetT

func (g *Geometry) SetT(t []float64) *Geometry

func (*Geometry) SetTM

func (g *Geometry) SetTM(tm []uint64) *Geometry

func (*Geometry) SetType

func (g *Geometry) SetType(typ flattypes.GeometryType) *Geometry

func (*Geometry) SetXY

func (g *Geometry) SetXY(xy []float64) *Geometry

func (*Geometry) SetZ

func (g *Geometry) SetZ(z []float64) *Geometry

type GeometryExtended

type GeometryExtended struct {
	*Geometry
}

func NewGeometryExtended

func NewGeometryExtended(geometry *Geometry) *GeometryExtended

func (*GeometryExtended) BoundingBox

func (g *GeometryExtended) BoundingBox() (minX, minY, maxX, maxY float64)
type Header struct {
	// contains filtered or unexported fields
}

Header is the writer responsible for writting the header of the flatgeobuf to a given writer. It handles all the flatbuffer details.

func NewHeader

func NewHeader(builder *flatbuffers.Builder) *Header

func (*Header) Build

func (h *Header) Build() flatbuffers.UOffsetT

func (*Header) Builder

func (h *Header) Builder() *flatbuffers.Builder

func (*Header) SetColumns

func (h *Header) SetColumns(columns []*Column) *Header

func (*Header) SetCrs

func (h *Header) SetCrs(crs *Crs) *Header

func (*Header) SetDescription

func (h *Header) SetDescription(description string) *Header

func (*Header) SetEnvelope

func (h *Header) SetEnvelope(envelope []float64) *Header

func (*Header) SetFeaturesCount

func (h *Header) SetFeaturesCount(featuresCount uint64) *Header

func (*Header) SetGeometryType

func (h *Header) SetGeometryType(geometryType flattypes.GeometryType) *Header

func (*Header) SetHasM

func (h *Header) SetHasM(hasM bool) *Header

func (*Header) SetHasT

func (h *Header) SetHasT(hasT bool) *Header

func (*Header) SetHasTm

func (h *Header) SetHasTm(hasTm bool) *Header

func (*Header) SetHasZ

func (h *Header) SetHasZ(hasZ bool) *Header

func (*Header) SetIndexNodeSize

func (h *Header) SetIndexNodeSize(indexNodeSize uint16) *Header

func (*Header) SetMetadata

func (h *Header) SetMetadata(metadata string) *Header

func (*Header) SetName

func (h *Header) SetName(name string) *Header

func (*Header) SetTitle

func (h *Header) SetTitle(title string) *Header

type HeaderUpdater

type HeaderUpdater interface {
	Update(header *Header)
}

HeaderUpdater is an interface for updating the Header after all entries for the flatgeobuf file have been processed. Usefull to set metadata that depends on what has been added.

type Index

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

func NewIndex

func NewIndex(p *index.PackedRTree) *Index

func (*Index) Write

func (i *Index) Write(w io.Writer) (int, error)

type Writer

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

Writer is a type that allows constructing a valid flatgeobuf file that has a Header, an optional Index and collection of Features.

func NewWriter

func NewWriter(header *Header, includeIndex bool,
	featureGenerator FeatureGenerator, headerUpdater HeaderUpdater,
	opts ...writerOption,
) *Writer

NewWriter returns a new writer instance that will write a flatgeobuf file with the given Header, a possible Index (depending on includeIndex), a FeatureGenerator that will provide the Features to be written and a HeaderUpdater that will be used to update the Header after all features have been generated.

func (*Writer) Write

func (w *Writer) Write(ioWriter io.Writer) (int, error)

Write writes the flatgeobuf file represented by the given io.Writer.

Jump to

Keyboard shortcuts

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