Documentation ¶
Index ¶
Constants ¶
const HistoryMax = 100
HistoryMax is the maximum number of points allowed to be stored in the history
const HistoryMin = 60
HistoryMin is the number of positions retained when the history is full
const RTree_M = 5 //max entries per node.
const RTree_m = 2 //min entries per node. 40% of M is best
Variables ¶
var UnknownInfo = ShipInfo{ Draught: 0, Length: 0, Width: 0, LengthOffset: 0, WidthOffset: 0, VesselType: ShipType(0), }
UnknownInfo contains the default values used when there is no information available about a ship-related property. Should have been const but time.Time isn't.
var UnknownPos = ShipPos{ Pos: geo.Point{math.NaN(), math.NaN()}, PosAccuracy: false, NavStatus: ShipNavStatus(15), BowHeading: uint16(math.NaN()), Course: float32(math.NaN()), Speed: float32(math.NaN()), RateOfTurn: float32(math.NaN()), }
UnknownPos contains the default values used when there is no information available about a position-related property. Should have been const, but math.NaN() is a function and 0.0/0.0 (or any indirection thereof) gives a division by zero error. This is intentional: https://github.com/golang/go/issues/2196#issuecomment-66058380
Functions ¶
Types ¶
type Accuracy ¶
type Accuracy bool
Accuracy contains the accuracy of the ships position.
func (Accuracy) MarshalJSON ¶
MarshalJSON is used by the json Marshaler. The json value of the Accuracy-object is the string description of the accuracy.
type Geometry ¶
Geometry is used to create GeoJSON "geometry" fields. Works for both GeoJSON "Point" and "LineString" objects.
func (Geometry) MarshalJSON ¶
MarshalJSON returns either a GeoJSON "Point" or a GeoJSON "LineString" object.
type Mmsi ¶
type Mmsi uint32
Mmsi stands for Maritime Mobile Service Identity and is used to identify the sender of AIS messages. It should be displayed as 9 digits.
func (Mmsi) CountryCode ¶
CountryCode returns the country identified by the "Maritime Identification Digits" of the mmsi.
type RTree ¶
type RTree struct {
// contains filtered or unexported fields
}
RTree is a two-dimensional R*-tree implementation with float64 positions and uint32 values
func (*RTree) FindWithin ¶
FindWithin returns all the boats that overlaps a given rectangle of the map [0].
func (*RTree) InsertData ¶
InsertData inserts a new boat into the tree structure.
func (*RTree) NumOfBoats ¶
NumOfBoats return the total number of boats stored in the structure.
type ShipDB ¶
type ShipDB struct {
// contains filtered or unexported fields
}
ShipDB contains all the ships.
func NewShipDB ¶
func NewShipDB() *ShipDB
NewShipDB creates and returns a pointer to a new ShipInfo object.
func (*ShipDB) Select ¶
Select returns the info about the ship and its tracklog as a geojson FeatureCollection object.
func (*ShipDB) UpdateDynamic ¶
UpdateDynamic updates the ship's dynamic information.
func (*ShipDB) UpdateStatic ¶
UpdateStatic updates the ship's static information.
type ShipInfo ¶
type ShipInfo struct { VesselType ShipType `json:"vesseltype,omitempty"` Draught uint8 `json:"draught,omitempty"` Length uint16 `json:"length,omitempty"` Width uint16 `json:"width,omitempty"` LengthOffset int16 `json:"lengthoffset,omitempty"` // from center WidthOffset int16 `json:"widthoffset,omitempty"` // from center Callsign string `json:"callSign,omitempty"` ShipName string `json:"name,omitempty"` Dest string `json:"destination,omitempty"` ETA time.Time `json:"eta,omitempty"` }
ShipInfo stores information gathered from AIS message 5 and 24.
type ShipNavStatus ¶
type ShipNavStatus uint8
ShipNavStatus contains the navigation status code. E.g. "Under way using engine", "At anchor", "Not under command", etc.
func (*ShipNavStatus) MarshalJSON ¶
func (s *ShipNavStatus) MarshalJSON() ([]byte, error)
MarshalJSON is used by the json Marshaler. The json value of the ShipNavStatus-object is the navigation status as a string.
func (*ShipNavStatus) Stopped ¶
func (s *ShipNavStatus) Stopped() bool
Stopped returns true if the ship is "At anchor" or "Moored".
func (*ShipNavStatus) String ¶
func (s *ShipNavStatus) String() string
String() returns the navigation status as a string.
type ShipPos ¶
type ShipPos struct { At time.Time `json:"time,omitempty"` // Calculated from UTCSecond and time packet was received Pos geo.Point `json:"position"` // A GeoJSON object must have a position, therefore this field can not be omitted PosAccuracy Accuracy `json:"accuracy,omitempty"` // High or low BowHeading uint16 `json:"heading,omitempty"` // in degrees with zero north Course float32 `json:"cog,omitempty"` // Direction of movement, in degrees with zero north Speed float32 `json:"sog,omitempty"` // in knots RateOfTurn float32 `json:"rateofturn,omitempty"` // in degrees/minute }
ShipPos stores information gathered from AIS message type 1-3, 18-19 and 27.
type ShipType ¶
type ShipType uint8
ShipType contains the ship type code. E.g. "Fishing", "Sailing", "Tug", "Cargo", etc.
func (ShipType) MarshalJSON ¶
MarshalJSON is used by the json Marshaler The json value of the ShipType-object is the ship type as a string.