Package PamUtils

Class LatLong

java.lang.Object
PamUtils.LatLong
All Implemented Interfaces:
Transferable, Serializable, Cloneable, ManagedParameters, PamCoordinate
Direct Known Subclasses:
GpsData, LatLongTime, ReceiverReference

public class LatLong extends Object implements Serializable, Cloneable, Transferable, PamCoordinate, ManagedParameters
Class for handling and formatting latitude and longitude data. Only contains two variables, which are assumed to be in decimal degrees. Also contains a number of other static variables for formatting other lat long data.
Author:
Doug Gillespie
See Also:
  • Field Details Link icon

  • Constructor Details Link icon

    • LatLong Link icon

      public LatLong(double latitude, double longitude)
    • LatLong Link icon

      public LatLong(double latitude, double longitude, double height)
    • LatLong Link icon

      public LatLong()
    • LatLong Link icon

      public LatLong(LatLong locLatLong)
    • LatLong Link icon

      public LatLong(String string) throws NullPointerException
      USE WITH CAUTION uses LatLong.valueOfSubstring
      Parameters:
      LatLong -
      Throws:
      NullPointerException
  • Method Details Link icon

    • getFormatStyle Link icon

      public static int getFormatStyle()
      Returns:
      Returns the formatStyle.
    • getDataFlavor Link icon

      public static DataFlavor getDataFlavor()
    • setFormatStyle Link icon

      public static void setFormatStyle(int formatStyle)
      Parameters:
      formatStyle - The formatStyle to set.
    • clone Link icon

      public LatLong clone()
    • getLatitude Link icon

      public double getLatitude()
      Returns:
      Returns the latitude.
    • setLatitude Link icon

      public void setLatitude(double latitude)
      Parameters:
      latitude - The latitude to set.
    • getLongitude Link icon

      public double getLongitude()
      Returns:
      Returns the longitude.
    • setLongitude Link icon

      public void setLongitude(double longitude)
      Parameters:
      longitude - The longitude to set.
    • formatLatitude Link icon

      public String formatLatitude()
      formats the latitude string
      Returns:
      formated latitude string
    • formatLatitude Link icon

      public static String formatLatitude(double latlong)
      convert a double decimal degrees into a formatted latlong string
      Parameters:
      latlong -
      Returns:
      a string representation of a Latitude
    • valueOfString Link icon

      public static LatLong valueOfString(String string)
      must be separated by comma, then see valueOfSubstring
      Parameters:
      string -
      Returns:
      LatLong
    • valueOfSubstring Link icon

      public static Double valueOfSubstring(String angleString)
      must contain degree sign � -5� S will produce a north value if neither N, S or - will assume positive 57�19.800' N or 10�48.000' W
      Parameters:
      string -
      Returns:
      the angle
    • formatLongitude Link icon

      public String formatLongitude()
      formats the longitude as a string
      Returns:
      formatted longitude string
    • formatLongitude Link icon

      public static String formatLongitude(double latlong)
      convert a double decimal degrees into a formatted latlong string
      Parameters:
      latlong -
      Returns:
      a string representation of a Longitude
    • doubleDegrees2StringDegs Link icon

      public static String doubleDegrees2StringDegs(double latlong)
    • doubleDegrees2StringMins Link icon

      public static String doubleDegrees2StringMins(double latlong)
    • getSignedDegrees Link icon

      public static int getSignedDegrees(double latLong)
    • getDecimalMinutes Link icon

      public static double getDecimalMinutes(double latLong)
    • shortFormatLatitude Link icon

      public String shortFormatLatitude()
    • shortFormatLongitude Link icon

      public String shortFormatLongitude()
    • getIntegerMinutes Link icon

      public static int getIntegerMinutes(double latLong)
    • getSeconds Link icon

      public static double getSeconds(double latLong)
    • latLongArea Link icon

      public static net.sf.geographiclib.PolygonResult latLongArea(LatLong[] latLongList)
      Calculate the area of a latitude and longitude polygon in meters squared. Also calculates the perimeter. Geodisic calculations are WGS84.
      Parameters:
      latLongList - - a list of latitude and longitude values. The length of list must be greater than 3.
      Returns:
      PolygonResult which contains multiple measurements, including area, perimeter and number of vertices.
    • travelDistanceMeters Link icon

      public LatLong travelDistanceMeters(double trueHeading, double distance)
      Parameters:
      trueHeading - Heading relative to True North -degrees
      distance - Distance to travel in meters.
      Returns:
      New Latlong in decimal degrees
    • travelDistanceMeters Link icon

      public LatLong travelDistanceMeters(double trueHeading, double xydistance, double heightDistance)
      Travel a distance and a height in metres.
      Parameters:
      trueHeading - true heading
      xydistance - horizontal distance in metres
      heightDistance - hight distance in metres
      Returns:
      new position
    • TravelDistanceMiles Link icon

      public LatLong TravelDistanceMiles(double trueHeading, double distance)
      Parameters:
      trueHeading - Heading relative to True North- degrees
      distance - Distance to travel in nautical miles.
      Returns:
      New Latlong in decimal degrees
    • addDistanceMeters Link icon

      public LatLong addDistanceMeters(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. It's intended for small localised shifts in the vicinity of a single detection.
      Parameters:
      addX - distance to travel East in metres
      addY - distance to travel North in metres
      Returns:
      new LatLong
    • addDistanceMeters Link icon

      public LatLong 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. It's intended for small localised shifts in the vicinity of a single detection.
      Parameters:
      addX - distance to travel East in metres
      addY - distance to travel North in metres
      addZ - vertical distance to add
      Returns:
      new LatLong
    • addDistanceMeters Link icon

      public LatLong addDistanceMeters(PamVector movementVector)
      Add an x,y,z vector to the current location.
      Parameters:
      movementVector - two element x,y or three element x,y,z vector.
      Returns:
      new LatLong.
    • distanceToMiles Link icon

      public double distanceToMiles(LatLong destination)
      Calculate the distance from this positions to some other position in miles.
      Parameters:
      destination - destiantion position
      Returns:
      distance in miles
    • distanceToMetres Link icon

      public double distanceToMetres(LatLong destination)
      Calculate the distance from this positions to some other position in metres.
      Parameters:
      destination - destination position
      Returns:
      distance in metres
    • distanceToMetres3D Link icon

      public double distanceToMetres3D(LatLong destination)
      Calculate the distance from this positions to some other position in three dimensions (i.e. including any height or depth changes) in metres.
      Parameters:
      destination - destination position
      Returns:
      distance in metres
    • distanceToMetresX Link icon

      public double distanceToMetresX(LatLong destination)
      Calculate the distance in metres along the X coordinate from the lat long to some other lat long.
      Parameters:
      destination - destination coordinate
      Returns:
      distance in metres
    • distanceToMetresY Link icon

      public double distanceToMetresY(LatLong destination)
      Calculate the distance in metres along the Y coordinate from the lat long to some other lat long.
      Parameters:
      destination - destination coordinate
      Returns:
      distance in metres
    • equals Link icon

      public boolean equals(LatLong ll)
    • getMean Link icon

      public static LatLong getMean(LatLong[] lls)
    • bearingTo Link icon

      public double bearingTo(LatLong destination)
      Get the bearing in degree to this latlong to another latlong.
      Does not do a full great circle calculation, but uses rectangular trigonometry.
      Parameters:
      destination - destination lat long
      Returns:
      angle to destination in degrees.
    • getCrossTrackError Link icon

      public double getCrossTrackError(LatLong latLong1, LatLong latLong2)
      Clculate the perpendicular distance from this LatLong to a line joining latLong1 and latLong2
      Returns:
      cross track error in metres
    • getHeight Link icon

      public double getHeight()
      Returns:
      the height
    • setHeight Link icon

      public void setHeight(double height)
      Parameters:
      height - the height to set
    • toString Link icon

      public String toString()
      Overrides:
      toString in class Object
    • getTransferData Link icon

      public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException
      Specified by:
      getTransferData in interface Transferable
      Throws:
      UnsupportedFlavorException
      IOException
    • getTransferDataFlavors Link icon

      public DataFlavor[] getTransferDataFlavors()
      Specified by:
      getTransferDataFlavors in interface Transferable
    • isDataFlavorSupported Link icon

      public boolean isDataFlavorSupported(DataFlavor flavor)
      Specified by:
      isDataFlavorSupported in interface Transferable
    • getPastedValue Link icon

      public static LatLong getPastedValue()
    • getCoordinate Link icon

      public double getCoordinate(int iCoordinate)
      Description copied from interface: PamCoordinate
      Get an indexed coordinate.
      Specified by:
      getCoordinate in interface PamCoordinate
      Parameters:
      iCoordinate - coordinate index.
      Returns:
      coordinate value.
    • setCoordinate Link icon

      public void setCoordinate(int iCoordinate, double value)
      Description copied from interface: PamCoordinate
      Set a coordinate value
      Specified by:
      setCoordinate in interface PamCoordinate
      Parameters:
      iCoordinate - index of coordinate (0,1,2)
      value - value to set.
    • getNumCoordinates Link icon

      public int getNumCoordinates()
      Specified by:
      getNumCoordinates in interface PamCoordinate
      Returns:
      the number of coordinates.
    • distanceTo Link icon

      public double[] distanceTo(LatLong other)
      Returns the position of this minus the position of the other Lat Long in metres, i.e. it is the distance you'd have to travel in x,y and x to get from 'other' to this.
      Parameters:
      other - Other lat long.
      Returns:
      distance to travel from this to other (x,y,z).
    • getParameterSet Link icon

      public PamParameterSet getParameterSet()
      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
      Returns:
      description of the parameters in a class.