com.AndrewGray.geoutils
Class LatLong

java.lang.Object
  |
  +--com.AndrewGray.geoutils.LatLong

public class LatLong
extends java.lang.Object

class defining LatLong data type for storage and manipulation of Latitude/Longitude pairs. Constructors allow for a variety of initialisation methods. Note that:
Longitudes;
     Easterlies are positive, westerlies negative,
Latitudes;
     Northerlies positive, southerlies negative.

Disclaimer & Warranty
The software is supplied as-is. No warranty, or statement of fitness of purpose is given.

All emphasis is on the user to verify values. In particular, this software should not be used for safety critical applications such as navigation, aeronautics, etc.

In obtaining this software you agree that liability of the copyright holder for damages, including any general, special, incidental or consequential damages arising out of the use or inability to use the software be limited to the purchase cost thereof. This includes but is not limited to loss of data or data being rendered inaccurate or losses sustained by you or third parties or a failure of the software to operate with any other software, even if such holder or other party has been advised of the possibility of such damages.

Copyright © 2004 by Andrew Gray

Author:
Andrew Gray

Constructor Summary
LatLong()
          create LatLong initialised at the meridian and on equator
LatLong(double lat, double lon)
          Create a LatLong from 2 doubles representing Radian lat/long
LatLong(double lat, double lon, boolean degrees)
          Create a LatLong from 2 doubles representing either Degrees or Radians lat/long
LatLong(int[] lat, int[] lon)
          This contructor takes two int array of Lat and Long
LatLong(int la_d, int la_m, int la_s, int lo_d, int lo_m, int lo_s)
          This contructor takes six ints as Lat(Degrees,Minutes) and Long(Degrees,Minutes)
LatLong(java.lang.String raw)
          create a new LatLong from a string of the format returned by getRawString
 
Method Summary
 double getLatitude()
          returns the latitude represented by this LatLong
 double getLatitudeD()
          returns the latitude represented by this LatLong
 int[] getLatitudeDMS()
          returns the latitude represented by this LatLong
 double getLongitude()
          returns the longitude represented by this LatLong
 double getLongitudeD()
          returns the longitude represented by this LatLong
 int[] getLongitudeDMS()
          returns the longitude represented by this LatLong
 java.lang.String getRawString()
          return String representation of this LatLong.
 boolean isExtremeLatitude()
          Return true if this LatLong represents an extreme latitude.
 boolean isLatitudeNorth()
          return true if latitude is North of equator
 boolean isLongitudeEast()
          return true if longitude is East of meridian
 java.lang.String toString()
          Produce human readable representation of this LatLong with degrees and minutes only.
 java.lang.String toStringL()
          Produce a human readable representation of this LatLong with degrees, minutes and seconds.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LatLong

public LatLong()
create LatLong initialised at the meridian and on equator

LatLong

public LatLong(double lat,
               double lon)
Create a LatLong from 2 doubles representing Radian lat/long
Parameters:
lat - the number of radians of latitude
lon - the number of radians of longitude

LatLong

public LatLong(double lat,
               double lon,
               boolean degrees)
Create a LatLong from 2 doubles representing either Degrees or Radians lat/long
Parameters:
lat - latitude value
lon - longitude value
degrees - is true then values are in degrees, otherwise radians

LatLong

public LatLong(int la_d,
               int la_m,
               int la_s,
               int lo_d,
               int lo_m,
               int lo_s)
This contructor takes six ints as Lat(Degrees,Minutes) and Long(Degrees,Minutes)
Parameters:
la_d - Degrees of latitude
la_m - Minutes of latitude
la_s - Seconds of latitude
lo_d - Degrees of longitude
lo_m - minutes of longitude
lo_s - Seconds of longitude

LatLong

public LatLong(int[] lat,
               int[] lon)
        throws java.lang.IllegalArgumentException
This contructor takes two int array of Lat and Long
Parameters:
lat - Degrees of latitude
lon - Degrees of longitude

LatLong

public LatLong(java.lang.String raw)
        throws java.lang.IllegalArgumentException,
               java.lang.NumberFormatException
create a new LatLong from a string of the format returned by getRawString
Parameters:
raw - the rawString to convert.
Throws:
java.lang.IllegalArgumentException - if the string does not contain two colon separated numbers
java.lang.NumberFormatException - if the two number are not valid longs
Method Detail

getLatitude

public double getLatitude()
returns the latitude represented by this LatLong
Returns:
signed latitude in radians

getLongitude

public double getLongitude()
returns the longitude represented by this LatLong
Returns:
signed longitude in radians

getLatitudeD

public double getLatitudeD()
returns the latitude represented by this LatLong
Returns:
signed latitude in degrees

getLongitudeD

public double getLongitudeD()
returns the longitude represented by this LatLong
Returns:
signed longitude in degrees

getLatitudeDMS

public int[] getLatitudeDMS()
returns the latitude represented by this LatLong
Returns:
unsigned latitude as 3 element int array; Deg,Min,Sec

getLongitudeDMS

public int[] getLongitudeDMS()
returns the longitude represented by this LatLong
Returns:
unsigned longitude as 3 element int array; Deg,Min,Sec

isLatitudeNorth

public boolean isLatitudeNorth()
return true if latitude is North of equator

isLongitudeEast

public boolean isLongitudeEast()
return true if longitude is East of meridian

toString

public java.lang.String toString()
Produce human readable representation of this LatLong with degrees and minutes only. Degrees & minutes symbols included.
Note that not all platforms correctly render the degree symbol which is only available as a unicode character.
Overrides:
toString in class java.lang.Object
Returns:
human readable representation of this LatLong

toStringL

public java.lang.String toStringL()
Produce a human readable representation of this LatLong with degrees, minutes and seconds. Degrees, minutes & second symbols included.
Note that not all platforms correctly render the degree symbol which is only available as a unicode character.
Returns:
human readable representation of this LatLong

isExtremeLatitude

public boolean isExtremeLatitude()
Return true if this LatLong represents an extreme latitude.
Returns:
true if this LatLong is at an extreme latitude.

getRawString

public java.lang.String getRawString()
return String representation of this LatLong. Intended for external storage purposes such a applet/cookie use.