Class AISTracker

  • All Implemented Interfaces:
    TrackEventEmitter

    @ThreadSafe
    public class AISTracker
    extends java.lang.Object
    implements TrackEventEmitter
    An AisTracker receives AISMessages and based on these it maintains a collection of all known tracks, including their position, speed, course, etc. If a certain track has not received any updates for a while it enters status 'stale' and will receive no further updates. Instead a new track is created if more AISMessages are received from the same vessel later on.
    • Constructor Summary

      Constructors 
      Constructor Description
      AISTracker()
      Construct an AISTracker which processes all received AISMessages.
      AISTracker​(java.util.function.Predicate<dk.tbsalling.aismessages.ais.messages.AISMessage> messageFilter)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      AISTrack getAisTrack​(long mmsi)
      Lookup a tracked AisTrack with the given mmsi no.
      java.util.Set<AISTrack> getAisTracks()
      Extract an immutable copy of all tracks currently tracked.
      int getNumberOfAisTracks()
      Count the no. of tracks currently being tracked.
      java.time.Instant getTimeOfLastPruning()  
      java.time.Instant getWallclock()  
      boolean isShutdown()  
      boolean isTracked​(long mmsi)
      Check if a given vessel is currently tracked by the tracker.
      void registerSubscriber​(java.lang.Object subscriber)  
      void shutdown()
      Shut down the tracker
      void update​(dk.tbsalling.aismessages.ais.messages.AISMessage aisMessage)
      Update the tracker with a new AIS message.
      void update​(dk.tbsalling.aismessages.ais.messages.AISMessage aisMessage, java.time.Instant messageTimestamp)
      Update the tracker with a new AIS message.
      void update​(java.io.InputStream nmeaInputStream)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AISTracker

        public AISTracker()
        Construct an AISTracker which processes all received AISMessages.
      • AISTracker

        public AISTracker​(java.util.function.Predicate<dk.tbsalling.aismessages.ais.messages.AISMessage> messageFilter)
    • Method Detail

      • update

        public void update​(java.io.InputStream nmeaInputStream)
                    throws java.io.IOException
        Throws:
        java.io.IOException
      • update

        public void update​(dk.tbsalling.aismessages.ais.messages.AISMessage aisMessage)
        Update the tracker with a new AIS message. If there is a reception timestamp in the meta data of the AIS message, then it will be used as the message timestamp. If not, current system time will be used as the timestamp.
        Parameters:
        aisMessage - the AIS message.
      • update

        public void update​(dk.tbsalling.aismessages.ais.messages.AISMessage aisMessage,
                           java.time.Instant messageTimestamp)
        Update the tracker with a new AIS message.
        Parameters:
        aisMessage - the AIS message.
        messageTimestamp - the time this AIS message was received.
      • isTracked

        public boolean isTracked​(long mmsi)
        Check if a given vessel is currently tracked by the tracker.
        Parameters:
        mmsi - The MMSI no.
        Returns:
        true if the vessel is currently tracked, false if not.
      • getNumberOfAisTracks

        public int getNumberOfAisTracks()
        Count the no. of tracks currently being tracked.
        Returns:
        the no of tracks.
      • getAisTrack

        public AISTrack getAisTrack​(long mmsi)
        Lookup a tracked AisTrack with the given mmsi no.
        Parameters:
        mmsi - the mmsi no. to lookup.
        Returns:
        The tracked AisTrack or null if no such track is currently tracked.
      • getAisTracks

        public java.util.Set<AISTrack> getAisTracks()
        Extract an immutable copy of all tracks currently tracked.
        Returns:
        An immutable set of all tracks currently tracked.
      • getWallclock

        public java.time.Instant getWallclock()
      • getTimeOfLastPruning

        public java.time.Instant getTimeOfLastPruning()
      • isShutdown

        public boolean isShutdown()
      • shutdown

        public void shutdown()
        Shut down the tracker