Class Longitude

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

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

    • PRIME_MERIDIAN

      public static final Longitude PRIME_MERIDIAN
      The value 0.
  • Method Details

    • parseLongitude

      public static Longitude parseLongitude(String string)
      Parses the specified string to a longitude.
      Parameters:
      string - the longitude as a string
      Returns:
      a Longitude
    • of

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

      public static Longitude ofRounded(double value)
      Rounds the specified double to a longitude.
      Parameters:
      value - the longitude as a double, finite
      Returns:
      a Longitude
    • parseLongitudeTruncate

      public static Longitude parseLongitudeTruncate(String string)
      Parses the specified string to a longitude.
      Parameters:
      string - the longitude as a string
      Returns:
      a Longitude
    • decimalValue

      public BigDecimal decimalValue()
      Returns the longitude as a decimal to 7 decimal places. For example parseLongitude("-2.0943").doubleValue() returns -2.0943000
      Returns:
      the longitude as a decimal
    • doubleValue

      public double doubleValue()
      Returns the longitude as a double. For example parseLongitude("-2.0943").doubleValue() returns -2.0943
      Returns:
      the longitude as a double
    • hashCode

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

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

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

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

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

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