com.javadocmd.simplelatlng
Class LatLng

java.lang.Object
  extended by com.javadocmd.simplelatlng.LatLng
All Implemented Interfaces:
Serializable

public class LatLng
extends Object
implements Serializable

A representation of a single point in latitude and longitude. All data is handled in degrees and will be normalized if possible to the +/- 90 latitude, +/- 180 longitude region.

Note that attempting to create a LatLng with invalid values (NaN, negative infinity, positive infinity) will throw IllegalArgumentExceptions.

Author:
Tyler Coles
See Also:
Serialized Form

Constructor Summary
LatLng(double latitude, double longitude)
          Creates a LatLng point.
 
Method Summary
static boolean degreesEqual(double degree1, double degree2)
          Tests whether two angles fall within the tolerance allowed in LatLngConfig.
 boolean equals(Object obj)
           
 double getLatitude()
          Get latitude for this point in degrees.
 long getLatitudeInternal()
          Get the internal long representation of this point's latitude in degrees.
 double getLongitude()
          Get longitude for this point in degrees.
 long getLongitudeInternal()
          Get the internal long representation of this point's longitude in degrees.
 int hashCode()
           
 boolean isPolar()
          Returns true if this LatLng represents a polar coordinate (+/- 90 degrees latitude).
static LatLng random()
          Creates a random latitude and longitude.
static LatLng random(Random r)
          Creates a random latitude and longitude.
 void setLatitudeLongitude(double latitude, double longitude)
          Sets the latitude and longitude for this point.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LatLng

public LatLng(double latitude,
              double longitude)
Creates a LatLng point.

Parameters:
latitude - the latitude in degrees.
longitude - the longitude in degrees.
Method Detail

random

public static LatLng random()
Creates a random latitude and longitude. (Not inclusive of (-90, 0))


random

public static LatLng random(Random r)
Creates a random latitude and longitude. (Not inclusive of (-90, 0))

Parameters:
r - the random number generator to use, if you want to be specific or are creating many LatLngs at once.

degreesEqual

public static boolean degreesEqual(double degree1,
                                   double degree2)
Tests whether two angles fall within the tolerance allowed in LatLngConfig. Ignores NaN and infinite values, returning false in either case.

Parameters:
degree1 - one degree angle.
degree2 - another degree angle.
Returns:
true if they should be considered equal, false otherwise.

getLatitude

public double getLatitude()
Get latitude for this point in degrees.

Returns:
latitude in degrees.

getLatitudeInternal

public long getLatitudeInternal()
Get the internal long representation of this point's latitude in degrees. Intended for library use only.

Returns:
the internal representation of latitude in degrees.

getLongitude

public double getLongitude()
Get longitude for this point in degrees.

Returns:
longitude in degrees.

getLongitudeInternal

public long getLongitudeInternal()
Get the internal long representation of this point's longitude in degrees. Intended for library use only.

Returns:
the internal representation of longitude in degrees.

setLatitudeLongitude

public void setLatitudeLongitude(double latitude,
                                 double longitude)
Sets the latitude and longitude for this point.

Parameters:
latitude - the latitude in degrees.
longitude - the longitude in degrees.

isPolar

public boolean isPolar()
Returns true if this LatLng represents a polar coordinate (+/- 90 degrees latitude).


equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2010-2013. All Rights Reserved.