Documentation ¶
Index ¶
- func GeohashDecode(hash string) (lat, lon float64, err error)
- func GeohashEncode(lat, lon float64, precision int) (string, error)
- type BBox
- type Geometry
- type GeometryType
- type Object
- func BBoxFromCenter(lat float64, lon float64, meters float64) Object
- func Make2DPoint(x, y float64) Object
- func Make2DRect(minX, minY, maxX, maxY float64) Object
- func Make3DPoint(x, y, z float64) Object
- func Make3DRect(minX, minY, minZ, maxX, maxY, maxZ float64) Object
- func MakeString(str string) Object
- func ParseJSON(json string) Object
- func ParseJSONWithErrors(json string) (Object, error)
- func WrapBinary(data []byte) Object
- func (o Object) AppendJSON(b []byte) []byte
- func (o Object) AppendString(b []byte) []byte
- func (o Object) BBox() BBox
- func (o Object) Binary() []byte
- func (g Object) CalculatedBBox() BBox
- func (g Object) CalculatedPoint() Position
- func (o Object) Center(transformer func(minIn, maxIn [3]float64) (minOut, maxOut [3]float64)) [3]float64
- func (o Object) Dims() int
- func (o Object) ExData() []byte
- func (g Object) Geohash(precision int) (string, error)
- func (o Object) Geometry() Geometry
- func (o Object) GeometryType() GeometryType
- func (g Object) Intersects(o Object) bool
- func (g Object) IntersectsBBox(bbox BBox) bool
- func (g Object) IsBBoxDefined() bool
- func (o Object) IsGeometry() bool
- func (o Object) JSON() string
- func (o Object) Members() []byte
- func (g Object) Nearby(center Position, meters float64) bool
- func (o Object) Position() Position
- func (o Object) PositionCount() int
- func (o Object) Rect(transformer func(minIn, maxIn [3]float64) (minOut, maxOut [3]float64)) (min, max [3]float64)
- func (o Object) SetExData(data []byte) Object
- func (g Object) Sparse(amount byte) []Object
- func (o Object) String() string
- func (o Object) StringBytes() []byte
- func (g Object) Within(o Object) bool
- func (g Object) WithinBBox(bbox BBox) bool
- type Position
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GeohashDecode ¶
Types ¶
type Geometry ¶
type Geometry struct { Data []byte Dims int Type GeometryType Simple bool }
func (Geometry) PositionCount ¶
type GeometryType ¶
type GeometryType byte
GeometryType represents a geojson geometry type
const ( Unknown GeometryType = iota Point MultiPoint LineString MultiLineString Polygon MultiPolygon GeometryCollection Feature FeatureCollection )
func (GeometryType) String ¶
func (t GeometryType) String() string
type Object ¶
type Object struct {
// contains filtered or unexported fields
}
Object represents a packed geobin object
func Make2DPoint ¶
Make2DPoint returns a simple 2D point object.
func Make2DRect ¶
Make2DRect returns a simple 2D point object.
func Make3DPoint ¶
Make3DPoint returns a simple 3D point object.
func Make3DRect ¶
Make3DRect returns a simple 3D rect object.
func MakeString ¶
MakeString returns a non-geometry string object.
func ParseJSONWithErrors ¶
func WrapBinary ¶
WrapBinary creates an object by wrapping data.
func (Object) AppendJSON ¶
AppendJSON appends the JSON representation of the object to to the provided input bytes and returns the modified slice.
func (Object) AppendString ¶
AppendString appends the string representation of the object to to the provided input bytes and returns the modified slice.
func (Object) CalculatedBBox ¶
CalculatedBBox is exterior bbox containing the object.
func (Object) CalculatedPoint ¶
CalculatedPoint is a point representation of the object.
func (Object) Center ¶
func (o Object) Center( transformer func(minIn, maxIn [3]float64) (minOut, maxOut [3]float64), ) [3]float64
Center returns a point that represents the center point of the object's bounding box. The transformer function allows for transforming the the bouning area.
func (Object) Dims ¶
Dims returns the number of dimensions for the geometry object. The result will be 0, 2, or 3.
func (Object) GeometryType ¶
func (o Object) GeometryType() GeometryType
GeometryType returns the geometry type for the object.
func (Object) Intersects ¶
Intersects detects if the object intersects another object.
func (Object) IntersectsBBox ¶
IntersectsBBox detects if the object intersects a bbox.
func (Object) IsBBoxDefined ¶
IsBBoxDefined returns true if the object has a defined bbox.
func (Object) IsGeometry ¶
IsGeometry returns true if the object is a geometry.
func (Object) JSON ¶
JSON returns a JSON representation of the object. Geometries are converted to GeoJSON and strings are simple JSON strings.
func (Object) Members ¶
Members returns the Members component of the object. This is a JSON document containing the "id" and "properties" members. returns nil if no members are defined.
func (Object) PositionCount ¶
PositionCount returns the total number of points in the geometry.
func (Object) Rect ¶
func (o Object) Rect( transformer func(minIn, maxIn [3]float64) (minOut, maxOut [3]float64), ) (min, max [3]float64)
Rect returns the bounding box of the Object. The transformer parameter allows for transforming the bounding box prior to returning.
func (Object) SetExData ¶
SetExData creates a copy of the object with the ExData component set to the specified data. The original object is not altered.
func (Object) StringBytes ¶
StringBytes returns a string representation of the object as bytes.
func (Object) WithinBBox ¶
WithinBBox detects if the object is fully contained inside a bbox.
type Position ¶
type Position struct {
X, Y, Z float64
}
Position represents an 3D point
func (Position) Destination ¶
Destination calculates a new position based on the distance and bearing.
func (Position) DistanceTo ¶
DistanceTo calculates the distance to a position