wkt

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2024 License: MIT Imports: 10 Imported by: 15

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(r io.Reader) (geo geom.Geometry, err error)

func DecodeBytes

func DecodeBytes(b []byte) (geo geom.Geometry, err error)

func DecodeString

func DecodeString(s string) (geo geom.Geometry, err error)

func Encode

func Encode(w io.Writer, geo geom.Geometry) error

func EncodeBytes

func EncodeBytes(geo geom.Geometry) ([]byte, error)

func EncodeString

func EncodeString(geo geom.Geometry) (string, error)

func MustDecode

func MustDecode(geo geom.Geometry, err error) geom.Geometry

func MustEncode

func MustEncode(geo geom.Geometry) string

MustEncode will use the default encoder to encode the provided Geometry if there is an error encoding the geometry, the function will panic.

Types

type Decoder

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

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

func (*Decoder) Decode

func (d *Decoder) Decode() (geom.Geometry, error)

type Encoder

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

Encoder holds the necessary configurations and state for a WKT Encoder

func NewDefaultEncoder

func NewDefaultEncoder(w io.Writer) Encoder

NewDefaultEncoder creates a new encoder that writes to w using the defaults of strict = false, precision = 10, and fmt = 'g'.

func NewEncoder

func NewEncoder(w io.Writer, strict bool, precision int, fmt byte) Encoder

NewEncoder creates a new encoder that writes to w

strict causes the encoder to return errors if the geometries have empty sub geometries where not allowed by the wkt spec. When Strict false, empty geometries are ignored.

Point: can be empty
MultiPoint: can have empty points
LineString: cannot have empty points
MultiLineString: can have empty line strings non-empty line strings cannot have empty points
Polygon: cannot have empty line strings, non-empty line strings cannot have empty points
MultiPolygon: can have empty polygons, polygons cannot have empty linestrings, line strings cannot have empty points
Collection: can have empty geometries

The precision and fmt are passed into strconv.FormatFloat https://golang.org/pkg/strconv/#FormatFloat

func (Encoder) Encode

func (enc Encoder) Encode(geo geom.Geometry) error

Encode traverses the geometry and writes its WKT representation to the encoder's io.Writer and returns the first error it may have gotten.

func (Encoder) EncodeString

func (enc Encoder) EncodeString(geo geom.Geometry) (string, error)

EncodeString is like Encode except it will return a string instead of encode to the internal io.Writer

func (Encoder) MustEncode

func (enc Encoder) MustEncode(geo geom.Geometry) string

MustEncode is like Encode except it will panic if there is an error

func (Encoder) NewEncoder

func (enc Encoder) NewEncoder(w io.Writer) Encoder

NewEncoder will clone the attributes of the current Encoder and swap out the writer

type ErrSyntax

type ErrSyntax struct {
	Line int
	Char int

	Type  string
	Issue string
}

ErrSyntax encode a syntax error that occured during Parsing

func (ErrSyntax) Error

func (errsy ErrSyntax) Error() string

Directories

Path Synopsis
internal
cmd/fuzz/fuzz
Package fuzz provides primitives to generate random geom geometry types.
Package fuzz provides primitives to generate random geom geometry types.

Jump to

Keyboard shortcuts

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