Documentation
¶
Overview ¶
Package flatgeobuf provides FlatGeobuf format support for the orb geometry library. It enables reading and writing FlatGeobuf files with orb.Geometry types and geojson.Feature/FeatureCollection with properties.
Index ¶
- Variables
- func Write(w io.Writer, geometries []orb.Geometry, opts *Options) error
- func WriteFeature(w io.Writer, f *geojson.Feature, opts *Options) error
- func WriteFeatures(w io.Writer, fc *geojson.FeatureCollection, opts *Options) error
- type CRS
- type ColumnInfo
- type Header
- type Options
- type Reader
- func (r *Reader) Close() error
- func (r *Reader) Header() *Header
- func (r *Reader) ReadAll() (*geojson.FeatureCollection, error)
- func (r *Reader) ReadGeometries() ([]orb.Geometry, error)
- func (r *Reader) Search(bounds orb.Bound) (*geojson.FeatureCollection, error)
- func (r *Reader) SearchGeometries(bounds orb.Bound) ([]orb.Geometry, error)
Constants ¶
This section is empty.
Variables ¶
var ( ErrNilGeometry = errors.New("flatgeobuf: nil geometry") ErrUnsupportedType = errors.New("flatgeobuf: unsupported geometry type") ErrInvalidData = errors.New("flatgeobuf: invalid data") ErrNoIndex = errors.New("flatgeobuf: file has no spatial index") ErrInvalidColumn = errors.New("flatgeobuf: invalid column type") ErrPropertyMismatch = errors.New("flatgeobuf: property type mismatch") )
Common errors returned by this package.
Functions ¶
func Write ¶
Write writes geometries to FlatGeobuf format. This is a convenience function for writing geometry-only data without properties.
func WriteFeature ¶
WriteFeature writes a single feature to FlatGeobuf format.
func WriteFeatures ¶
WriteFeatures writes a FeatureCollection to FlatGeobuf format.
Types ¶
type CRS ¶
type CRS struct {
Code int // EPSG code (e.g., 4326 for WGS84)
Name string // CRS name
Description string // CRS description
WKT string // Well-Known Text representation
}
CRS represents a coordinate reference system.
type ColumnInfo ¶
type ColumnInfo struct {
Name string // Column name
Type string // Column type ("Bool", "Int", "Long", "Double", "String", "Json", etc.)
Title string // Column title (human-readable)
Description string // Column description
Nullable bool // Whether the column can contain null values
}
ColumnInfo describes a property column in a FlatGeobuf file.
type Header ¶
type Header struct {
Name string // Layer name
Description string // Layer description
GeometryType string // Geometry type ("Point", "Polygon", "Unknown", etc.)
FeaturesCount uint64 // Number of features in the file
Envelope [4]float64 // Bounding box [minX, minY, maxX, maxY]
CRS *CRS // Coordinate reference system
HasIndex bool // Whether the file has a spatial index
Columns []ColumnInfo // Property column schema
}
Header contains metadata about a FlatGeobuf file.
type Options ¶
type Options struct {
Name string // Layer name
Description string // Layer description
IncludeIndex bool // Include spatial index (default: true)
CRS *CRS // Coordinate reference system (optional)
}
Options configures FlatGeobuf writing.
func DefaultOptions ¶
func DefaultOptions() *Options
DefaultOptions returns default options for writing FlatGeobuf files.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader provides read access to a FlatGeobuf file.
func NewReader ¶
NewReader creates a reader from a file path. The file is memory-mapped for efficient access.
func NewReaderFromData ¶
NewReaderFromData creates a reader from byte data.
func (*Reader) Close ¶
Close releases resources associated with the reader. This is important for memory-mapped files.
func (*Reader) ReadAll ¶
func (r *Reader) ReadAll() (*geojson.FeatureCollection, error)
ReadAll reads all features as a FeatureCollection.
func (*Reader) ReadGeometries ¶
ReadGeometries reads all geometries without properties.