Documentation
¶
Overview ¶
Package common gives a set of generic structs and functions for geodata manipulations. It is used to process geodata in a universal format, regardless of the source of this data.
Index ¶
- Constants
- Variables
- type Attributes
- func (a Attributes) AppendNullFloat(name string, f null.Float) Attributes
- func (a Attributes) AppendNullFloatSlice(name string, s []null.Float) Attributes
- func (a Attributes) AppendNullInt(name string, i null.Int) Attributes
- func (a Attributes) AppendNullString(name string, s null.String) Attributes
- func (a Attributes) GetFloat64(key string) (f float64, err error)
- func (a Attributes) GetInt64(key string) (i int64, err error)
- func (a Attributes) GetString(key string) (f string, err error)
- func (a Attributes) GetType(key string) (string, error)
- type AxisWGS84
- type CardinalAxis
- type Cellular
- type FrameSplitter
- type Location
- type PointWGS84
- type Position
Constants ¶
const ( Proto = "proto" Odometer = "odometer" Satellites = "sats" HDOP = "hdop" VDOP = "vdop" PDOP = "pdop" Move = "move" DigInput = "dinput" DigOutput = "doutput" AnInput = "ainput" )
Variables ¶
var ( // ErrAttributesNoItem is returned when the attribute with given key is not present. ErrAttributesNoItem = errors.New("no item with given key") // ErrAttributesNotInt64 is returned when the attribute with given key is not of type int64. ErrAttributesNotInt64 = errors.New("value is not int64") // ErrAttributesNotFloat64 is returned when the attribute with given key is not of type float64. ErrAttributesNotFloat64 = errors.New("value is not float64") // ErrAttributesNotString is returned when the attribute with given key is not of type string. ErrAttributesNotString = errors.New("value is not string") )
var ( // ErrBadData is returned when the data is inconsistent with protocol specification. // It signals that communication session can be terminated. ErrBadData = errors.New("data is bad to protocol specification") )
Functions ¶
This section is empty.
Types ¶
type Attributes ¶
type Attributes map[string]interface{}
Attributes is a generic attributes struct. It is used for key-value attributes for common purposes.
func (Attributes) AppendNullFloat ¶
func (a Attributes) AppendNullFloat(name string, f null.Float) Attributes
AppendNullFloat appends a null float to the attribute.
func (Attributes) AppendNullFloatSlice ¶
func (a Attributes) AppendNullFloatSlice(name string, s []null.Float) Attributes
AppendNullFloatSlice appends a null float slice to the attribute.
func (Attributes) AppendNullInt ¶
func (a Attributes) AppendNullInt(name string, i null.Int) Attributes
AppendNullInt appends a null int to the attribute.
func (Attributes) AppendNullString ¶
func (a Attributes) AppendNullString(name string, s null.String) Attributes
AppendNullString appends a null string to the attribute.
func (Attributes) GetFloat64 ¶
func (a Attributes) GetFloat64(key string) (f float64, err error)
GetFloat64 returns the float64 value of the attribute.
func (Attributes) GetInt64 ¶
func (a Attributes) GetInt64(key string) (i int64, err error)
GetInt64 returns the int64 value of the attribute.
type AxisWGS84 ¶
type AxisWGS84 struct {
Coordinate float64
Cardinal CardinalAxis
}
AxisWGS84 is the WGS84 axis of a coordinate system.
func ParseAxisWGS84 ¶
func ParseAxisWGS84(coord string, c CardinalAxis) (AxisWGS84, error)
ParseAxisWGS84 parses a string into a AxisWGS84.
type CardinalAxis ¶
type CardinalAxis string
CardinalAxis is the cardinal axis of a coordinate system.
const ( North CardinalAxis = "N" South CardinalAxis = "S" East CardinalAxis = "E" West CardinalAxis = "W" )
func ParseCardinalAxis ¶
func ParseCardinalAxis(raw string) (cp CardinalAxis, err error)
ParseCardinalAxis parses a string into a CardinalAxis.
func (CardinalAxis) Sign ¶
func (c CardinalAxis) Sign() float64
Sign returns the floating point sign of the coordinate.
type Cellular ¶
type Cellular struct {
// CellID - CID, CI - A GSM Cell ID
CellID int64
// LAC - Location Area Code
LAC int64
// MCC - Mobile Country Code
MCC int64
// MNC - Mobile Network Code
MNC int64
}
Cellular is a generic cellular struct.
type FrameSplitter ¶
type FrameSplitter interface {
// Splitter returns bufio.SplitFunc to split incoming bytes stream into byte data frames that can be decoded later.
Splitter() bufio.SplitFunc
// Error returns error if any registered.
// Use it to signal that communication session can be terminated.
Error() error
// BadData returns bad data if any registered.
// Use it to log which bytes couldn't be parsed.
BadData() []byte
}
FrameSplitter is a contract to split incoming bytes stream into byte data frames that can be decoded later.
type Location ¶
type Location struct {
geom.Coordinates
Valid bool
}
Location is a generic location struct.
type PointWGS84 ¶
PointWGS84 is the WGS84 point of a coordinate system.
func ParsePointWGS84 ¶
func ParsePointWGS84(lon string, cardLon CardinalAxis, lat string, cardLat CardinalAxis) (PointWGS84, error)
ParsePointWGS84 parses a pair string lon/lat into a PointWGS84.
func (PointWGS84) LocationXY ¶
func (w PointWGS84) LocationXY() Location
LocationXY is the XY location of a coordinate system.
func (PointWGS84) LocationXYZ ¶
func (w PointWGS84) LocationXYZ(z float64) Location
LocationXYZ is the XYZ location of a coordinate system.
type Position ¶
type Position struct {
Location
Cellular *Cellular
Protocol string
DeviceID string
Attributes Attributes
DeviceTime time.Time
Speed null.Float
Course null.Float
}
Position is a generic position struct.
func (Position) MarshalZerologObject ¶
MarshalZerologObject implements zerolog.LogObjectMarshaler.