Class AbstractGPS

    • Field Detail

      • NUM_DECIMALS

        public static final int NUM_DECIMALS
        the number of decimals to user.
        See Also:
        Constant Field Values
      • m_Longitude

        protected Coordinate m_Longitude
        longitude
      • m_Latitude

        protected Coordinate m_Latitude
        latitude
    • Constructor Detail

      • AbstractGPS

        public AbstractGPS()
        Default constructor.
      • AbstractGPS

        public AbstractGPS​(String s)
        Initialize GPS with latitude and longitude in string representation.
        Parameters:
        s - the string representation to parse
        See Also:
        fromString(String)
      • AbstractGPS

        public AbstractGPS​(String s,
                           boolean swapped)
        Initialize GPS with latitude and longitude in string representation.
        Parameters:
        s - the string representation to parse
        swapped - whether format is 'long lat' instead of 'lat long'
        See Also:
        fromString(String)
      • AbstractGPS

        public AbstractGPS​(AbstractGPS gps)
        Initialize GPS with latitude and longitude from the specified object.
        Parameters:
        gps - the GPS object to use the lat/lon from
      • AbstractGPS

        public AbstractGPS​(double lat,
                           double lon)
        Initialize GPS with latitude and longitude (in decimal notation).
        Parameters:
        lat - latitude
        lon - longitude
      • AbstractGPS

        public AbstractGPS​(Coordinate lat,
                           Coordinate lon)
        Initialize GPS with latitude and longitude.
        Parameters:
        lat - latitude
        lon - longitude
    • Method Detail

      • getLongitude

        public Coordinate getLongitude()
        Returns the longitude.
        Returns:
        the coordinate
      • getLatitude

        public Coordinate getLatitude()
        Returns the latitude.
        Returns:
        the coordinate
      • clone

        protected abstract AbstractGPS clone()
        Creates a copy of itself.
        Overrides:
        clone in class Object
        Returns:
        the copy
      • compareTo

        public int compareTo​(AbstractGPS o)
        Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
        Specified by:
        compareTo in interface Comparable<AbstractGPS>
        Parameters:
        o - the object to be compared.
        Returns:
        a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
        Throws:
        ClassCastException - if the specified object's type prevents it from being compared to this object.
      • equals

        public boolean equals​(Object o)
        Returns whether the two objects are the same.
        Overrides:
        equals in class Object
        Parameters:
        o - the object to be compared
        Returns:
        true if the object is the same as this one
      • preprocess

        protected String preprocess​(String s)
        Removes the parentheses and comma in the string: "(north, west)" becomes "north west"
      • parse

        protected abstract Coordinate[] parse​(String s,
                                              boolean swapped)
        Parses the string.
        Parameters:
        s - the string to parse
        swapped - "long lat" instead of "lat long"
        Returns:
        the coordinates (lat/long), null if failed to parse
      • parse

        protected Coordinate[] parse​(String s)
        Parses the string.
        Parameters:
        s - the string to parse
        Returns:
        the coordinates (lat/long), null if failed to parse
      • isValid

        public boolean isValid​(String s)
        Checks whether the string can be parsed.
        Parameters:
        s - the string to check
        Returns:
        true if successfully parsed
      • isValid

        public boolean isValid​(String s,
                               boolean swapped)
        Checks whether the string can be parsed.
        Parameters:
        s - the string to check
        swapped - "long lat" instead of "lat long"
        Returns:
        true if successfully parsed
      • fromString

        public void fromString​(String s)
        Parses the string to get the long/lat values from. If failed to parse, default coordinates are used.
        Parameters:
        s - the string to parse
      • fromString

        public void fromString​(String s,
                               boolean swapped)
        Parses the string to get the long/lat values from. If failed to parse, default coordinates are used.
        Parameters:
        s - the string to parse
        swapped - "long lat" instead of "lat long"
      • toString

        public abstract String toString()
        Turns the GPS object back into its string representation.
        Overrides:
        toString in class Object
        Returns:
        the string representation