wkbcommon

package
v1.4.1-0...-a4d69fd Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2021 License: BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package wkbcommon contains code common to WKB and EWKB encoding.

Package wkbcommon contains code common to WKB and EWKB encoding.

Index

Constants

View Source
const (
	XDRID = 0
	NDRID = 1
)

Byte order IDs.

View Source
const (
	PointID              = 1
	LineStringID         = 2
	PolygonID            = 3
	MultiPointID         = 4
	MultiLineStringID    = 5
	MultiPolygonID       = 6
	GeometryCollectionID = 7
	PolyhedralSurfaceID  = 15
	TINID                = 16
	TriangleID           = 17
)

Geometry type IDs.

Variables

Byte orders.

View Source
var MaxGeometryElements = [4]int{
	0,
	-1,
	-1,
	-1,
}

MaxGeometryElements is the maximum number of elements that will be decoded at different levels. Its primary purpose is to prevent corrupt inputs from causing excessive memory allocations (which could be used as a denial of service attack).

This is a variable, so you can override it in your application code by importing the `github.com/twpayne/go-geom/encoding/wkbcommon` module and setting the value of `wkbcommon.MaxGeometryElements`.

FIXME This should be Codec-specific, not global. FIXME Consider overall per-geometry limit rather than per-level limit.

Functions

func ReadByte

func ReadByte(r io.Reader) (byte, error)

ReadByte reads a byte from r.

func ReadFlatCoords0

func ReadFlatCoords0(r io.Reader, byteOrder binary.ByteOrder, stride int) ([]float64, error)

ReadFlatCoords0 reads flat coordinates 0.

func ReadFlatCoords1

func ReadFlatCoords1(r io.Reader, byteOrder binary.ByteOrder, stride int) ([]float64, error)

ReadFlatCoords1 reads flat coordinates 1.

func ReadFlatCoords2

func ReadFlatCoords2(r io.Reader, byteOrder binary.ByteOrder, stride int) ([]float64, []int, error)

ReadFlatCoords2 reads flat coordinates 2.

func ReadFloatArray

func ReadFloatArray(r io.Reader, byteOrder binary.ByteOrder, array []float64) error

ReadFloatArray reads a []float64 from r.

func ReadUInt32

func ReadUInt32(r io.Reader, byteOrder binary.ByteOrder) (uint32, error)

ReadUInt32 reads a uint32 from r.

func WriteByte

func WriteByte(w io.Writer, value byte) error

WriteByte wrties a byte to w.

func WriteEmptyPointAsNaN

func WriteEmptyPointAsNaN(w io.Writer, byteOrder binary.ByteOrder, numCoords int) error

WriteEmptyPointAsNaN outputs EmptyPoint as NaN values.

func WriteFlatCoords0

func WriteFlatCoords0(w io.Writer, byteOrder binary.ByteOrder, coord []float64) error

WriteFlatCoords0 writes flat coordinates 0.

func WriteFlatCoords1

func WriteFlatCoords1(w io.Writer, byteOrder binary.ByteOrder, coords []float64, stride int) error

WriteFlatCoords1 writes flat coordinates 1.

func WriteFlatCoords2

func WriteFlatCoords2(w io.Writer, byteOrder binary.ByteOrder, flatCoords []float64, ends []int, stride int) error

WriteFlatCoords2 writes flat coordinates 2.

func WriteFloatArray

func WriteFloatArray(w io.Writer, byteOrder binary.ByteOrder, array []float64) error

WriteFloatArray writes a []float64 to w.

func WriteUInt32

func WriteUInt32(w io.Writer, byteOrder binary.ByteOrder, value uint32) error

WriteUInt32 writes a uint32 to w.

Types

type EmptyPointHandling

type EmptyPointHandling uint8

EmptyPointHandling is the mechanism to handle an empty point.

const (
	// EmptyPointHandlingError will error if an empty point is found.
	EmptyPointHandlingError EmptyPointHandling = iota
	// EmptyPointHandlingNaN will decipher empty points with NaN as coordinates.
	// This is in line with Requirement 152 of the GeoPackage spec (http://www.geopackage.org/spec/).
	EmptyPointHandlingNaN
)

type ErrGeometryTooLarge

type ErrGeometryTooLarge struct {
	Level int
	N     int
	Limit int
}

An ErrGeometryTooLarge is returned when the geometry is too large.

func (ErrGeometryTooLarge) Error

func (e ErrGeometryTooLarge) Error() string

type ErrUnexpectedType

type ErrUnexpectedType struct {
	Got  interface{}
	Want interface{}
}

An ErrUnexpectedType is returned when an unexpected type is encountered.

func (ErrUnexpectedType) Error

func (e ErrUnexpectedType) Error() string

type ErrUnknownByteOrder

type ErrUnknownByteOrder byte

An ErrUnknownByteOrder is returned when an unknown byte order is encountered.

func (ErrUnknownByteOrder) Error

func (e ErrUnknownByteOrder) Error() string

type ErrUnknownType

type ErrUnknownType Type

An ErrUnknownType is returned when an unknown type is encountered.

func (ErrUnknownType) Error

func (e ErrUnknownType) Error() string

type ErrUnsupportedByteOrder

type ErrUnsupportedByteOrder struct{}

An ErrUnsupportedByteOrder is returned when an unsupported byte order is encountered.

func (ErrUnsupportedByteOrder) Error

func (e ErrUnsupportedByteOrder) Error() string

type ErrUnsupportedType

type ErrUnsupportedType Type

An ErrUnsupportedType is returned when an unsupported type is encountered.

func (ErrUnsupportedType) Error

func (e ErrUnsupportedType) Error() string

type Type

type Type uint32

A Type is a WKB code.

type WKBOption

type WKBOption func(WKBParams) WKBParams

WKBOption is an option to set on WKBParams.

func WKBOptionEmptyPointHandling

func WKBOptionEmptyPointHandling(h EmptyPointHandling) WKBOption

WKBOptionEmptyPointHandling sets the params to the specified EmptyPointHandling.

type WKBParams

type WKBParams struct {
	EmptyPointHandling EmptyPointHandling
}

WKBParams are parameters for encoding and decoding WKB items.

func InitWKBParams

func InitWKBParams(params WKBParams, opts ...WKBOption) WKBParams

InitWKBParams initializes WKBParams from an initial parameter and some options.

Jump to

Keyboard shortcuts

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