Documentation ¶
Overview ¶
Package wkbcommon contains code common to WKB and EWKB encoding.
Package wkbcommon contains code common to WKB and EWKB encoding.
Index ¶
- Constants
- Variables
- func ReadByte(r io.Reader) (byte, error)
- func ReadFlatCoords0(r io.Reader, byteOrder binary.ByteOrder, stride int) ([]float64, error)
- func ReadFlatCoords1(r io.Reader, byteOrder binary.ByteOrder, stride int) ([]float64, error)
- func ReadFlatCoords2(r io.Reader, byteOrder binary.ByteOrder, stride int) ([]float64, []int, error)
- func ReadFloatArray(r io.Reader, byteOrder binary.ByteOrder, array []float64) error
- func ReadUInt32(r io.Reader, byteOrder binary.ByteOrder) (uint32, error)
- func WriteByte(w io.Writer, value byte) error
- func WriteEmptyPointAsNaN(w io.Writer, byteOrder binary.ByteOrder, numCoords int) error
- func WriteFlatCoords0(w io.Writer, byteOrder binary.ByteOrder, coord []float64) error
- func WriteFlatCoords1(w io.Writer, byteOrder binary.ByteOrder, coords []float64, stride int) error
- func WriteFlatCoords2(w io.Writer, byteOrder binary.ByteOrder, flatCoords []float64, ends []int, ...) error
- func WriteFloatArray(w io.Writer, byteOrder binary.ByteOrder, array []float64) error
- func WriteUInt32(w io.Writer, byteOrder binary.ByteOrder, value uint32) error
- type EmptyPointHandling
- type ErrGeometryTooLarge
- type ErrUnexpectedType
- type ErrUnknownByteOrder
- type ErrUnknownType
- type ErrUnsupportedByteOrder
- type ErrUnsupportedType
- type Type
- type WKBOption
- type WKBParams
Constants ¶
const ( XDRID = 0 NDRID = 1 )
Byte order IDs.
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 ¶
var ( XDR = binary.BigEndian NDR = binary.LittleEndian )
Byte orders.
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 ReadFlatCoords0 ¶
ReadFlatCoords0 reads flat coordinates 0.
func ReadFlatCoords1 ¶
ReadFlatCoords1 reads flat coordinates 1.
func ReadFlatCoords2 ¶
ReadFlatCoords2 reads flat coordinates 2.
func ReadFloatArray ¶
ReadFloatArray reads a []float64 from r.
func ReadUInt32 ¶
ReadUInt32 reads a uint32 from r.
func WriteEmptyPointAsNaN ¶
WriteEmptyPointAsNaN outputs EmptyPoint as NaN values.
func WriteFlatCoords0 ¶
WriteFlatCoords0 writes flat coordinates 0.
func WriteFlatCoords1 ¶
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 ¶
WriteFloatArray writes a []float64 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 ¶
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 WKBOption ¶
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 ¶
InitWKBParams initializes WKBParams from an initial parameter and some options.