com.mapquest
Class LatLng

java.lang.Object
  extended bycom.mapquest.MQObject
      extended bycom.mapquest.LatLng
All Implemented Interfaces:
java.lang.Cloneable

public class LatLng
extends MQObject

Contains a latitude/longitude pair.


Field Summary
static int CLASS_ID
           
static java.lang.String CLASS_NAME
           
 
Fields inherited from class com.mapquest.MQObject
DEFAULT_ID, DEFAULT_NAME, DEFAULT_VERSION, FORMAT_NUMERIC_ID, FORMAT_TEXT_NAME, INVALID_ID, INVALID_NAME, INVALID_VERSION
 
Constructor Summary
LatLng()
          Default constructor.
LatLng(double aLatitude, double aLongitude)
          Constructor for assigning latitude and longitude values.
LatLng(LatLng aLatLng)
          Copy constructor.
 
Method Summary
 double arcDistance(LatLng ll2)
          Calculates the distance between two lat/lng's in miles.
 double arcDistance(LatLng ll2, DistanceUnits lUnits)
          Calculates the distance between two lat/lng's in miles or meters.
 boolean equals(java.lang.Object otherObject)
          Compares this object to the specified object.
 int getClassId()
          Returns the numeric id of this class.
 java.lang.String getClassName()
          Returns the text name of this class.
 double getLatitude()
          Returns the latitude of this object.
 double getLongitude()
          Returns the latitude of this object.
 int hashCode()
          Returns a hash code for this LatLng.
 void init()
          Initializes object.
 void setLatitude(double aLatitude)
          Sets the latitude value.
 void setLatLng(double aLatitude, double aLongitude)
          Sets the latitude and longitude values.
 void setLongitude(double aLongitude)
          Sets the longitude value.
 java.lang.String toString()
          Converts the contents of this class to a comma-separated string.
 boolean valid()
          Returns a true if both the latitude and longitude values are set to a value other than the static "INVALID" value.
 
Methods inherited from class com.mapquest.MQObject
clone, getFormat, getIdWithVersion, getNameWithVersion, getObjectVersion, getTypeId, getTypeName, getVerboseConsoleOutput, setFormat, setObjectVersion, setVerboseConsoleOutput
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

CLASS_ID

public static final int CLASS_ID
See Also:
Constant Field Values

CLASS_NAME

public static final java.lang.String CLASS_NAME
See Also:
Constant Field Values
Constructor Detail

LatLng

public LatLng()
Default constructor.


LatLng

public LatLng(LatLng aLatLng)
Copy constructor.

Parameters:
aLatLng - A lat/long object that this object is to be initialized to.

LatLng

public LatLng(double aLatitude,
              double aLongitude)
Constructor for assigning latitude and longitude values.

Parameters:
aLatitude - The latitude value.
aLongitude - The longitude value.
Method Detail

init

public void init()
Initializes object.

Overrides:
init in class MQObject

getClassId

public int getClassId()
Returns the numeric id of this class.

Overrides:
getClassId in class MQObject
Returns:
the numeric id of this class.

getClassName

public java.lang.String getClassName()
Returns the text name of this class.

Overrides:
getClassName in class MQObject
Returns:
the text name of this class.

equals

public boolean equals(java.lang.Object otherObject)
Compares this object to the specified object. The result is true if and only if the argument is not null and is a LatLng object that has same attributes as this object.

Overrides:
equals in class MQObject
Parameters:
otherObject - the object to compare this LatLng against.
Returns:
true if the LatLng objects are equal; false otherwise.

hashCode

public int hashCode()
Returns a hash code for this LatLng.

Overrides:
hashCode in class MQObject
Returns:
a hash code value for this LatLng.

setLatLng

public void setLatLng(double aLatitude,
                      double aLongitude)
Sets the latitude and longitude values.

Parameters:
aLatitude - The latitude value.
aLongitude - The longitude value.

setLatitude

public void setLatitude(double aLatitude)
Sets the latitude value.

Parameters:
aLatitude - The latitude value to which this object is to be set.
Returns:
The latitude value of this object.

setLongitude

public void setLongitude(double aLongitude)
Sets the longitude value.

Parameters:
aLongitude - The longitude value to which this object is to be set.
Returns:
The longitude value of this object.

getLatitude

public double getLatitude()
Returns the latitude of this object.

Returns:
The latitude of this object.

getLongitude

public double getLongitude()
Returns the latitude of this object.

Returns:
The latitude of this object.

valid

public boolean valid()
Returns a true if both the latitude and longitude values are set to a value other than the static "INVALID" value.

Returns:
True if both the latitude and longitude values are not equal to the static "INVALID".

toString

public java.lang.String toString()
Description copied from class: MQObject
Converts the contents of this class to a comma-separated string.

Overrides:
toString in class MQObject
Returns:
The contents of this class in a comma-separated format. The class name forms a header for the string.

arcDistance

public double arcDistance(LatLng ll2)
Calculates the distance between two lat/lng's in miles.

Parameters:
ll2 - Second lat,lng position to calculate distance to.
Returns:
Returns the distance in miles.

arcDistance

public double arcDistance(LatLng ll2,
                          DistanceUnits lUnits)
Calculates the distance between two lat/lng's in miles or meters.

Parameters:
ll2 - Second lat,lng position to calculate distance to.
lUnits - Units to calculate distace, defaults to miles
Returns:
Returns the distance in meters or miles.