Class Latitude

java.lang.Object
rgu.transport.geospatial.Latitude
All Implemented Interfaces:
Comparable<Latitude>

public final class Latitude extends Object implements Comparable<Latitude>
Represents a Latitude from -90 degrees (inclusive) to +90 degrees (inclusive) to 7 decimal places.
Author:
Lee A. Christie
  • Field Details

    • EQUATOR

      public static final Latitude EQUATOR
      The value 0.
  • Method Details

    • parseLatitude

      public static Latitude parseLatitude(String string)
      Parses the specified string to a latitude.
      Parameters:
      string - the latitude as a string
      Returns:
      a Latitude
    • of

      public static Latitude of(BigDecimal decimal)
      Returns a latitude of the specified decimal value.
      Parameters:
      decimal - the latitude as a decimal
      Returns:
      a Latitude
    • ofRounded

      public static Latitude ofRounded(double value)
      Rounds the specified double to a latitude.
      Parameters:
      value - the latitude as a double, finite
      Returns:
      a Latitude
    • parseLatitudeTruncate

      public static Latitude parseLatitudeTruncate(String string)
      Parses the specified string to a latitude.
      Parameters:
      string - the latitude as a string
      Returns:
      a Latitude
    • decimalValue

      public BigDecimal decimalValue()
      Returns the latitude as a decimal to 7 decimal places. For example parseLatitude("57.1497").doubleValue() returns 57.1497000
      Returns:
      the latitude as a decimal
    • doubleValue

      public double doubleValue()
      Returns the latitude as a double. For example parseLatitude("57.1497").doubleValue() returns 57.1497
      Returns:
      the latitude as a double
    • hashCode

      public int hashCode()
      Returns a hash code for this latitude.
      Overrides:
      hashCode in class Object
      Returns:
      a hash code
    • equals

      public boolean equals(Object other)
      Returns true if the other object is the same latitude value.
      Overrides:
      equals in class Object
      Parameters:
      other - the other object
      Returns:
      true if equal, false otherwise
    • toString

      public String toString()
      Returns a String object representing this latitude's value.
      Overrides:
      toString in class Object
      Returns:
      a string representation
    • compareTo

      public int compareTo(Latitude other)
      Compares two latitudes numerically.
      Specified by:
      compareTo in interface Comparable<Latitude>
      Returns:
      0 if this latitude is the same as the other latitude, less than 0 if less, or greater than 0 if greater than the other latitude.
    • write

      public void write(ObjectOutputStream out) throws IOException
      Writes this latitude to the specified output stream.
      Parameters:
      out - the output stream, not null
      Throws:
      IOException - if an exception occurred writing
    • read

      public static Latitude read(ObjectInputStream in) throws IOException
      Reads a latitude from the specified input stream.
      Parameters:
      in - the input stream, not null
      Returns:
      the latitude
      Throws:
      IOException - if an exception occurred reading