Package GPS

Class GpsData

All Implemented Interfaces:
ArraySensorDataUnit, Transferable, Serializable, Cloneable, ManagedParameters, PamCoordinate

public class GpsData extends LatLong implements Cloneable, ManagedParameters, ArraySensorDataUnit
Note on times for GPS data ...

The GpsDataUnit will contain time from the main PAMCalendar in line with the rest of PAMGuard. However the GpsData object within the data unit will contain the correct time, hopefully including milliseconds, unpacked from the GPS data itself.

Position data extends LatLong and provides much of the functionality required for a position in the marine environment.

Position data stores a latitude, longitude, height, heading, pitch and roll. These are the 6 essentially bits of information which allow for the position of an object to be described with reference to the planet. All, some or none of these fields can be stored in this class.

PositionData also stores useful functions for predicting position and decoding position data e.g. NMEA.

For reference the Euler angle convention in PAMGUARD is as follows.

Heading- 0==north, 90==east 180=south, 270==west

Pitch- 90=-g, 0=0g, -90=g i.e. pointing downwards is -90, level is 0 and pointing upwards is 90

Tilt 0->180 -camera turning towards left to upside down 0->-180 camera turning right to upside down

All angles are in DEGREES.

Author:
Doug Gillespie, Paul Redmond, David McLaren
See Also:
  • Field Details

  • Constructor Details

    • GpsData

      public GpsData()
    • GpsData

      public GpsData(LatLong latLong)
      Constructor to create a GPSData object from a lat long.
      Parameters:
      latLong - LatLong object.
    • GpsData

      public GpsData(long timeMillis, LatLong latLong)
      Create a GPS data unit with a time and a lat long
      Parameters:
      timeMillis - time in milliseconds
      latLong - LatLong object
    • GpsData

      public GpsData(double latitude, double longitude, double speed, double courseOverGround, long timeInMillis, Double trueHeading, Double magneticHeading)
      Constructor used in viewer and Mixed Mode
      Parameters:
      latitude - latitude
      longitude - longitude
      speed - speed (knots)
      courseOverGround - course over ground
      timeInMillis - java millisecond time
      trueHeading - true heading
      magneticHeading - magnetic heading
    • GpsData

      public GpsData(double latitude, double longitude, double height, long timeInMillis)
      Used for buoy data received over the network.
      Parameters:
      latitude -
      longitude -
      timeInMillis -
    • GpsData

      public GpsData(double latitude, double longitude, double height, double heading, double pitch, double roll, long timeInMillis)
      Parameters:
      latitude - - latitude
      longitude - -longitude
      height - - height
      heading - - true heading in DEGREES
      pitch - - pitch in DEGREES
      roll - - roll in DEGRESS
      timeInMillis - time in millis.
    • GpsData

      public GpsData(StringBuffer nmeaString, int stringType)
  • Method Details

    • gpsDataToRMC

      public String gpsDataToRMC(int nDecPlaces)
    • gpsDataToGGA

      public String gpsDataToGGA(int nDecPlaces)
    • printGpsValues

      public void printGpsValues()
    • getTimeInMillis

      public long getTimeInMillis()
    • getGpsCalendar

      public Calendar getGpsCalendar()
    • getDate

      public int getDate()
    • getHeading

      public double getHeading()
      Gets the best available data on the vessels true heading. If true heading data is available (e.g. from a Gyro compass), then that is returned. If true heading is not available, then attempt to use magnetic heading (e.g. from a fluxgate compass, which should be automatically corrected for magnetic variation. Finally, if neither true or magnetic heading data are available, just return course over ground from the GPS. Note that in this last case, the data may be inaccurate at low speeds or in a cross current.
      Returns:
      Best Heading in degrees relative to true North.
    • getHeading

      public Double getHeading(boolean noGPSCourse)
      Gets the best available data on the vessels true heading. If true heading data is available (e.g. from a Gyro compass), then that is returned. If true heading is not available, then attempt to use magnetic heading (e.g. from a fluxgate compass, which should be automatically corrected for magnetic variation. Finally, if neither true or magnetic heading data are available, this function will either return course over ground from the GPS of null depending on the value of the noGPSCourse parameter. Note that in this last case, the data may be inaccurate at low speeds or in a cross current. NB: Some modules (e.g. DIFAR, and maybe others?) create and allow for Headings on the interval of (-180, 180).
      Parameters:
      noGPSCourse - set true if you only want courses from proper heading sensors. If noGPSSource is true and gyro or fluxgate data are unavailable null will be returned.
      Returns:
      heading
    • getTrueHeading

      public Double getTrueHeading()
      Returns:
      true heading read from a gyro or similar device.
    • setTrueHeading

      public void setTrueHeading(Double trueHeading)
      Parameters:
      trueHeading - the trueHeading to set
    • setMagneticHeading

      public void setMagneticHeading(Double magneticHeading)
      Parameters:
      magneticHeading - the magneticHeading to set
    • getMagneticHeading

      public Double getMagneticHeading()
      Returns:
      the magnetic heading (read from a fluxgate compass)
    • getCourseOverGround

      public double getCourseOverGround()
      Return the course over ground from the GPS. Note that this is the direction the vessel is moving in relative to the earth and may not be the direction the vessel is pointing in.
      Returns:
      the course over ground.
    • setCourseOverGround

      public void setCourseOverGround(double courseOverGround)
      Parameters:
      courseOverGround - the courseOverGround to set
    • getSpeed

      public double getSpeed()
      Returns the speed in knots
    • getSpeedMetric

      public double getSpeedMetric()
      Gets the speed in metres per second
      Returns:
      speed in metres per second
    • getTime

      public int getTime()
    • setSpeed

      public void setSpeed(double speed)
    • getHours

      public int getHours()
      Get hours from NMEA date, not system time
      Returns:
      hours from NMEA data.
    • getMagneticVariation

      public Double getMagneticVariation()
      Returns:
      the magneticVariation
    • setMagneticVariation

      public void setMagneticVariation(Double magneticVariation)
      Parameters:
      magneticVariation - the magneticVariation to set
    • getMins

      public int getMins()
      Get minutes from NMEA date, not system time
      Returns:
      mins from NMEA data.
    • getSecs

      public int getSecs()
      Get seconds from NMEA date, not system time
      Returns:
      seconds from NMEA data.
    • getMillis

      public int getMillis()
      Get seconds from NMEA date, not system time
      Returns:
      seconds from NMEA data.
    • setDate

      public void setDate(int date)
    • setGpsCalendar

      public void setGpsCalendar(Calendar gpsCalendar)
    • setTime

      public void setTime(int time)
    • setTimeInMillis

      public void setTimeInMillis(long timeInMillis)
    • getDistanceFromLast

      public double getDistanceFromLast()
    • isDataOk

      public boolean isDataOk()
    • setDataOk

      public void setDataOk(boolean dataOk)
    • getPredictedGPSData

      public GpsData getPredictedGPSData(long predictionTime)
    • getPredictedGPSData

      public GpsData getPredictedGPSData(long predictionTime, long maxInterpMillis)
      Predict where the gps position will be at a given time based on the current speed and heading, but interpolating to some maximum amount.
      Parameters:
      predictionTime - time of prediction
      maxInterpMillis - max milliseconds to interpolate.
      Returns:
      Interpolated GPS position.
    • clone

      public GpsData clone()
      Overrides:
      clone in class LatLong
    • getPitchD

      public Double getPitchD()
      Hydrophone pitch in degrees, +ve means that the front of the hydrophone is up, -ve is down. Values will be between -90 and + 90.
      Returns:
      the pitch in degrees.
    • getPitch

      public double getPitch()
      Get the pitch value, returning 0 if it's null.
      Returns:
      pitch in degrees
    • setPitch

      public void setPitch(Double pitch)
      Hydrophone pitch in degrees, +ve means that the front of the hydrophone is up, -ve is down. Values will be between -90 and + 90.
      Parameters:
      pitch - the pitch to set
    • getRollD

      public Double getRollD()
      Hydrophone roll in degrees, +ve is roll to the left, -ve to the right.
      Returns:
      the roll
    • getRoll

      public double getRoll()
      Returns:
      the roll and 0 if it's null.
    • setRoll

      public void setRoll(Double roll)
      Hydrophone roll in degrees, +ve is roll to the left, -ve to the right.
      Parameters:
      roll - the roll to set
    • getEulerAngles

      public double[] getEulerAngles()
      Get the Euler angles which describe the rotation of this position. m
      Returns:
      Euler angles [heading, pitch, roll] in RADIANS. See class description for angle conventions
    • getQuaternion

      public PamQuaternion getQuaternion()
      Get the quaternion which describe the rotation of this position. m
      Returns:
      quaternion.
    • setEulerAngles

      public void setEulerAngles(double[] angles)
      Set the Euler angles which describe the rotation of this position. m
      Parameters:
      angles - -Euler angles [heading, pitch, roll] in Degrees. See class description for angle conventions
    • getAverage

      public static GpsData getAverage(GpsData gpsData1, GpsData gpsData2)
    • toFullString

      public String toFullString()
    • summaryString

      public String summaryString()
    • getFixType

      public String getFixType()
      Returns:
      the fixType
    • setFixType

      public void setFixType(String fixType)
      Parameters:
      fixType - the fixType to set
    • setOrientationField

      public boolean setOrientationField(ArraySensorFieldType fieldType, Double val)
      Set a numeric value in a gps data orientation field.
      Parameters:
      fieldType -
      val -
      Returns:
    • getLongFixType

      public static String getLongFixType(String fixType)
      Get a longer string to describe the fix type. This will be one of A=Autonomous, D=DGPS, E=DR, N = Output Data Not Valid
      Parameters:
      fixType -
      Returns:
      longer descriptive string
    • getParameterSet

      public PamParameterSet getParameterSet()
      Description copied from class: LatLong
      Get the auto-generated parameter set, and then add in the fields that are not included because they are not public and do not have getters. Note: for each field, we search the current class and (if that fails) the superclass. It's done this way because LatLong might be used directly (and thus the field would be found in the class) and it also might be used as a superclass to something else (e.g. Vessel) in which case the field would only be found in the superclass.
      Specified by:
      getParameterSet in interface ManagedParameters
      Overrides:
      getParameterSet in class LatLong
      Returns:
      description of the parameters in a class.
    • getField

      public Double getField(int streamer, ArraySensorFieldType fieldtype)
      Description copied from interface: ArraySensorDataUnit
      Get a value for a specified field for a specified streamer.
      Specified by:
      getField in interface ArraySensorDataUnit
      Parameters:
      streamer - streamer index
      fieldtype - Depth, heading, pitch or roll.
      Returns:
      Value in metres or degrees (not radians)
    • getTimeMilliseconds

      public long getTimeMilliseconds()
      Description copied from interface: ArraySensorDataUnit
      Get the time in milliseconds
      Specified by:
      getTimeMilliseconds in interface ArraySensorDataUnit
      Returns:
      time in milliseconds.
    • addDistanceMeters

      public GpsData addDistanceMeters(double addX, double addY, double addZ)
      Description copied from class: LatLong
      Add distances in metres East and metres North to a LatLong
      Note that this assumes a flat earth model away from poles, so it's possible to create stupid values. It's intended for small localised shifts in the vicinity of a single detection.
      Overrides:
      addDistanceMeters in class LatLong
      Parameters:
      addX - distance to travel East in metres
      addY - distance to travel North in metres
      addZ - vertical distance to add
      Returns:
      new LatLong
    • addDistanceMeters

      public GpsData addDistanceMeters(double addX, double addY)
      Description copied from class: LatLong
      Add distances in metres East and metres North to a LatLong
      Note that this assumes a flat earth model away from poles, so it's possible to create stupid values. It's intended for small localised shifts in the vicinity of a single detection.
      Overrides:
      addDistanceMeters in class LatLong
      Parameters:
      addX - distance to travel East in metres
      addY - distance to travel North in metres
      Returns:
      new LatLong
    • addDistanceMeters

      public GpsData addDistanceMeters(PamVector movementVector)
      Description copied from class: LatLong
      Add an x,y,z vector to the current location.
      Overrides:
      addDistanceMeters in class LatLong
      Parameters:
      movementVector - two element x,y or three element x,y,z vector.
      Returns:
      new LatLong.