com.bbn.openmap.proj.coords
Class DMSLatLonPoint

java.lang.Object
  extended by com.bbn.openmap.proj.coords.DMSLatLonPoint
All Implemented Interfaces:
java.lang.Cloneable

public class DMSLatLonPoint
extends java.lang.Object
implements java.lang.Cloneable

Encapsulates a latitude and longitude coordinate in degrees, minutes and seconds as well as the sign.

Original code contributed by Colin Mummery (colin_mummery@yahoo.com)


Field Summary
 int lat_degrees
          The number of degrees in the latitude.
 boolean lat_isnegative
          Indicates if the latitude is negative, the actual int values are always positive.
 int lat_minutes
          The number of minutes in the latitude.
 double lat_seconds
          The number of seconds in the latitude.
 int lon_degrees
          The number of degrees in the longitude.
 boolean lon_isnegative
          Indicates if the longitude is negative, the actual int values are always positive.
 int lon_minutes
          The number of minutes in the longitude.
 double lon_seconds
          The number of seconds in the longitude.
 
Constructor Summary
DMSLatLonPoint()
          Construct a default LatLonPoint with zero values.
DMSLatLonPoint(boolean lat_isnegative, int lat_degrees, int lat_minutes, double lat_seconds, boolean lon_isnegative, int lon_degrees, int lon_minutes, double lon_seconds)
          Construct a DMSLatLonPoint from raw int lat/lon.
DMSLatLonPoint(int lat_degrees, double lat_minutesDotSeconds, int lon_degrees, double lon_minutesDotSeconds)
          Create DMSLatLonPoint from different notation
DMSLatLonPoint(int lat_degrees, int lat_minutes, double lat_seconds, int lon_degrees, int lon_minutes, double lon_seconds)
          Create DMSLatLonPoint where lat_degrees and lon_degrees are signed, negative for South and West.
DMSLatLonPoint(LatLonPoint llp)
          Constructs a new DMSLatLonPoint given a LatLonPoint instance
 
Method Summary
 java.lang.Object clone()
          Clone the DMSLatLonPoint.
 boolean equals(java.lang.Object obj)
          Determines whether two DMSLatLonPoints are exactly equal.
 double getDecimalLatitude()
          Returns the latitude as decimal degrees.
 double getDecimalLongitude()
          Returns the longitude as decimal degrees.
 LatLonPoint getLatLonPoint()
          Return a LatLonPoint from this DMSLatLonPoint.
 LatLonPoint getLatLonPoint(LatLonPoint llp)
          Return a LatLonPoint from this DMSLatLonPoint.
 int hashCode()
          Generate a hash value for the point.
static double normalize_value(double val)
          Sets the minutes and seconds to something sane.
static int normalize_value(int val)
          Sets the minutes and seconds to something sane.
 void setDMSLatLon(DMSLatLonPoint llpt)
          Set DMSLatLonPoint.
 java.lang.String toString()
          Returns a string representation of the object.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

lat_isnegative

public boolean lat_isnegative
Indicates if the latitude is negative, the actual int values are always positive.


lat_degrees

public int lat_degrees
The number of degrees in the latitude.


lat_minutes

public int lat_minutes
The number of minutes in the latitude.


lat_seconds

public double lat_seconds
The number of seconds in the latitude.


lon_isnegative

public boolean lon_isnegative
Indicates if the longitude is negative, the actual int values are always positive.


lon_degrees

public int lon_degrees
The number of degrees in the longitude.


lon_minutes

public int lon_minutes
The number of minutes in the longitude.


lon_seconds

public double lon_seconds
The number of seconds in the longitude.

Constructor Detail

DMSLatLonPoint

public DMSLatLonPoint()
Construct a default LatLonPoint with zero values.


DMSLatLonPoint

public DMSLatLonPoint(int lat_degrees,
                      int lat_minutes,
                      double lat_seconds,
                      int lon_degrees,
                      int lon_minutes,
                      double lon_seconds)
Create DMSLatLonPoint where lat_degrees and lon_degrees are signed, negative for South and West.

Parameters:
lat_degrees -
lat_minutes -
lat_seconds -
lon_degrees -
lon_minutes -
lon_seconds -

DMSLatLonPoint

public DMSLatLonPoint(boolean lat_isnegative,
                      int lat_degrees,
                      int lat_minutes,
                      double lat_seconds,
                      boolean lon_isnegative,
                      int lon_degrees,
                      int lon_minutes,
                      double lon_seconds)
Construct a DMSLatLonPoint from raw int lat/lon. All parameters are checked for their validity.

Parameters:
lat_isnegative - boolean value indicating the sign of the latitude
lat_degrees - integer number of degrees in latitude
lat_minutes - integer number of minutes in latitude
lat_seconds - float number of seconds in latitude
lon_isnegative - boolean value indicating the sign of the longitude
lon_degrees - integer number of degrees in longitude
lon_minutes - integer number of minutes in longitude
lon_seconds - float number of seconds in longitude

DMSLatLonPoint

public DMSLatLonPoint(int lat_degrees,
                      double lat_minutesDotSeconds,
                      int lon_degrees,
                      double lon_minutesDotSeconds)
Create DMSLatLonPoint from different notation

Parameters:
lat_degrees - integer degrees for lat, signed negative for South
lat_minutesDotSeconds - positive decimal minutes.seconds fraction
lon_degrees - integer degrees for lon, signed negative for West
lon_minutesDotSeconds - positive decimal minutes.seconds fraction

DMSLatLonPoint

public DMSLatLonPoint(LatLonPoint llp)
Constructs a new DMSLatLonPoint given a LatLonPoint instance

Parameters:
llp - A LatLonPoint instance
Method Detail

getLatLonPoint

public LatLonPoint getLatLonPoint()
Return a LatLonPoint from this DMSLatLonPoint. The LatLonPoint is allocated here.

Returns:
LatLonPoint, full of decimal degrees.

getLatLonPoint

public LatLonPoint getLatLonPoint(LatLonPoint llp)
Return a LatLonPoint from this DMSLatLonPoint. The LatLonPoint is allocated here if the llp is null. If it's not null, then the llp is loaded with the proper values.

Parameters:
llp - the LatLonPoint to load up.
Returns:
LatLonPoint, full of decimal degrees.

getDecimalLatitude

public double getDecimalLatitude()
Returns the latitude as decimal degrees.

Returns:
A float value for the latitude

getDecimalLongitude

public double getDecimalLongitude()
Returns the longitude as decimal degrees.

Returns:
A float value for the longitude

toString

public java.lang.String toString()
Returns a string representation of the object.

Overrides:
toString in class java.lang.Object
Returns:
String representation

setDMSLatLon

public void setDMSLatLon(DMSLatLonPoint llpt)
Set DMSLatLonPoint. Sets the current instance values to be the same as another DMSLatLonPoint instance.

Parameters:
llpt - DMSLatLonPoint

clone

public java.lang.Object clone()
Clone the DMSLatLonPoint.

Overrides:
clone in class java.lang.Object
Returns:
clone

equals

public boolean equals(java.lang.Object obj)
Determines whether two DMSLatLonPoints are exactly equal.

Overrides:
equals in class java.lang.Object
Parameters:
obj - Object
Returns:
boolean

normalize_value

public static final int normalize_value(int val)
Sets the minutes and seconds to something sane.

Parameters:
val - an int value for the minutes or seconds
Returns:
int value normalized

normalize_value

public static final double normalize_value(double val)
Sets the minutes and seconds to something sane.

Parameters:
val - an double value for the minutes or seconds
Returns:
float value normalized

hashCode

public int hashCode()
Generate a hash value for the point. Hash by spreading the values across a 32 bit int, ignoring the sign allow 8 bits (max 255) for degrees, 7 bits (max 127) for (minutes + seconds) so the total is 30 bits.

Overrides:
hashCode in class java.lang.Object
Returns:
An int hash value representing the point.


Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details