Class GpsData
- All Implemented Interfaces:
ArraySensorDataUnit
,Transferable
,Serializable
,Cloneable
,ManagedParameters
,PamCoordinate
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 Summary
Fields inherited from class PamUtils.LatLong
deg, FORMAT_DECIMAL, FORMAT_DECIMALMINUTES, FORMAT_MINUTESSECONDS, MetersPerMile
-
Constructor Summary
ConstructorDescriptionGpsData()
GpsData
(double latitude, double longitude, double height, double heading, double pitch, double roll, long timeInMillis) GpsData
(double latitude, double longitude, double speed, double courseOverGround, long timeInMillis, Double trueHeading, Double magneticHeading) Constructor used in viewer and Mixed ModeGpsData
(double latitude, double longitude, double height, long timeInMillis) Used for buoy data received over the network.Create a GPS data unit with a time and a lat longGpsData
(StringBuffer nmeaString, int stringType) Constructor to create a GPSData object from a lat long. -
Method Summary
Modifier and TypeMethodDescriptionaddDistanceMeters
(double addX, double addY) 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.addDistanceMeters
(double addX, double addY, double addZ) 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.addDistanceMeters
(PamVector movementVector) Add an x,y,z vector to the current location.clone()
static GpsData
getAverage
(GpsData gpsData1, GpsData gpsData2) double
Return the course over ground from the GPS.int
getDate()
double
double[]
Get the Euler angles which describe the rotation of this position.getField
(int streamer, ArraySensorFieldType fieldtype) Get a value for a specified field for a specified streamer.double
Gets the best available data on the vessels true heading.getHeading
(boolean noGPSCourse) Gets the best available data on the vessels true heading.int
getHours()
Get hours from NMEA date, not system timestatic String
getLongFixType
(String fixType) Get a longer string to describe the fix type.int
Get seconds from NMEA date, not system timeint
getMins()
Get minutes from NMEA date, not system timeGet 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.double
getPitch()
Get the pitch value, returning 0 if it's null.Hydrophone pitch in degrees, +ve means that the front of the hydrophone is up, -ve is down.getPredictedGPSData
(long predictionTime) 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.Get the quaternion which describe the rotation of this position.double
getRoll()
getRollD()
Hydrophone roll in degrees, +ve is roll to the left, -ve to the right.int
getSecs()
Get seconds from NMEA date, not system timedouble
getSpeed()
Returns the speed in knotsdouble
Gets the speed in metres per secondint
getTime()
long
long
Get the time in millisecondsgpsDataToGGA
(int nDecPlaces) gpsDataToRMC
(int nDecPlaces) boolean
isDataOk()
void
void
setCourseOverGround
(double courseOverGround) void
setDataOk
(boolean dataOk) void
setDate
(int date) void
setEulerAngles
(double[] angles) Set the Euler angles which describe the rotation of this position.void
setFixType
(String fixType) void
setGpsCalendar
(Calendar gpsCalendar) void
setMagneticHeading
(Double magneticHeading) void
setMagneticVariation
(Double magneticVariation) boolean
setOrientationField
(ArraySensorFieldType fieldType, Double val) Set a numeric value in a gps data orientation field.void
Hydrophone pitch in degrees, +ve means that the front of the hydrophone is up, -ve is down.void
Hydrophone roll in degrees, +ve is roll to the left, -ve to the right.void
setSpeed
(double speed) void
setTime
(int time) void
setTimeInMillis
(long timeInMillis) void
setTrueHeading
(Double trueHeading) Methods inherited from class PamUtils.LatLong
bearingTo, distanceTo, distanceToMetres, distanceToMetres3D, distanceToMetresX, distanceToMetresY, distanceToMiles, doubleDegrees2StringDegs, doubleDegrees2StringMins, equals, formatLatitude, formatLatitude, formatLongitude, formatLongitude, getCoordinate, getCrossTrackError, getDataFlavor, getDecimalMinutes, getFormatStyle, getHeight, getIntegerMinutes, getLatitude, getLongitude, getMean, getNumCoordinates, getPastedValue, getSeconds, getSignedDegrees, getTransferData, getTransferDataFlavors, isDataFlavorSupported, latLongArea, setCoordinate, setFormatStyle, setHeight, setLatitude, setLongitude, shortFormatLatitude, shortFormatLongitude, toString, travelDistanceMeters, travelDistanceMeters, TravelDistanceMiles, valueOfString, valueOfSubstring
-
Field Details
-
METERSPERMILE
public static final double METERSPERMILE- See Also:
-
-
Constructor Details
-
GpsData
public GpsData() -
GpsData
Constructor to create a GPSData object from a lat long.- Parameters:
latLong
- LatLong object.
-
GpsData
Create a GPS data unit with a time and a lat long- Parameters:
timeMillis
- time in millisecondslatLong
- 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
- latitudelongitude
- longitudespeed
- speed (knots)courseOverGround
- course over groundtimeInMillis
- java millisecond timetrueHeading
- true headingmagneticHeading
- 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
- - latitudelongitude
- -longitudeheight
- - heightheading
- - true heading in DEGREESpitch
- - pitch in DEGREESroll
- - roll in DEGRESStimeInMillis
- time in millis.
-
GpsData
-
-
Method Details
-
gpsDataToRMC
-
gpsDataToGGA
-
printGpsValues
public void printGpsValues() -
getTimeInMillis
public long getTimeInMillis() -
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
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
- Returns:
- true heading read from a gyro or similar device.
-
setTrueHeading
- Parameters:
trueHeading
- the trueHeading to set
-
setMagneticHeading
- Parameters:
magneticHeading
- the magneticHeading to set
-
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
- Returns:
- the magneticVariation
-
setMagneticVariation
- 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
-
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
-
getPredictedGPSData
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 predictionmaxInterpMillis
- max milliseconds to interpolate.- Returns:
- Interpolated GPS position.
-
clone
-
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
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
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
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
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
-
toFullString
-
summaryString
-
getFixType
- Returns:
- the fixType
-
setFixType
- Parameters:
fixType
- the fixType to set
-
setOrientationField
Set a numeric value in a gps data orientation field.- Parameters:
fieldType
-val
-- Returns:
-
getLongFixType
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
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 interfaceManagedParameters
- Overrides:
getParameterSet
in classLatLong
- Returns:
- description of the parameters in a class.
-
getField
Description copied from interface:ArraySensorDataUnit
Get a value for a specified field for a specified streamer.- Specified by:
getField
in interfaceArraySensorDataUnit
- Parameters:
streamer
- streamer indexfieldtype
- 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 interfaceArraySensorDataUnit
- Returns:
- time in milliseconds.
-
addDistanceMeters
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 classLatLong
- Parameters:
addX
- distance to travel East in metresaddY
- distance to travel North in metresaddZ
- vertical distance to add- Returns:
- new LatLong
-
addDistanceMeters
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 classLatLong
- Parameters:
addX
- distance to travel East in metresaddY
- distance to travel North in metres- Returns:
- new LatLong
-
addDistanceMeters
Description copied from class:LatLong
Add an x,y,z vector to the current location.- Overrides:
addDistanceMeters
in classLatLong
- Parameters:
movementVector
- two element x,y or three element x,y,z vector.- Returns:
- new LatLong.
-