Documentation
¶
Index ¶
- Constants
- Variables
- func CheckErr(err error, message string)
- func Matches(matches *[]Match, db *ShipDB, logger *l.Logger) string
- type Accuracy
- type Geometry
- type Match
- type Mmsi
- type RTree
- type ShipDB
- func (db *ShipDB) CheckPresence(s *ship, now time.Time) ShipState
- func (db *ShipDB) Coords(mmsi uint32) (lat, long float64)
- func (db *ShipDB) Known(mmsi uint32) bool
- func (db *ShipDB) Select(mmsi uint32, logger *l.Logger) string
- func (db *ShipDB) UpdateDynamic(mmsi uint32, update ShipPos)
- func (db *ShipDB) UpdateStatic(mmsi uint32, update ShipInfo)
- type ShipInfo
- type ShipNavStatus
- type ShipPos
- type ShipState
- type ShipType
Constants ¶
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: float32(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 (*ShipDB) CheckPresence ¶
Check whether the ship has stopped sending, and compact history if it left the area. `s.mu` should be held while calling this.
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 // Calculated from UTCSecond and time packet was received Pos geo.Point // A GeoJSON object must have a position, therefore this field can not be omitted PosAccuracy Accuracy // High or low BowHeading float32 // Orientation of the ship, in degrees with zero north Course float32 // Direction of movement, in degrees with zero north Speed float32 // Speed over ground, in knots RateOfTurn float32 // in degrees/minute }
ShipPos stores information gathered from AIS message type 1-3, 18-19 and 27.
type ShipState ¶
type ShipState uint8
The presence of the ship. Is either `ShipUnknown`, `ShipLeftArea`, ShipInactive` or `ShipPresent`.
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.