org.placelab.core
Class FixedTwoDCoordinate

java.lang.Object
  extended byorg.placelab.core.FixedTwoDCoordinate
All Implemented Interfaces:
Coordinate

public class FixedTwoDCoordinate
extends java.lang.Object
implements Coordinate

The Coordinate class used on systems that do not support floating point math. If you write an application that only runs on fixed point hardware (some phones) you can cast any Coordinate into a FixedTwoDCoordinate.


Constructor Summary
FixedTwoDCoordinate()
          Create a null FixedTwoDCoordinate
FixedTwoDCoordinate(FixedTwoDCoordinate c)
           
FixedTwoDCoordinate(long flongLat, long flongLon)
           
FixedTwoDCoordinate(java.lang.String lat, java.lang.String lon)
           
FixedTwoDCoordinate(java.lang.String latNMEA, java.lang.String latHem, java.lang.String lonNMEA, java.lang.String lonHem)
           
 
Method Summary
 void constructFromMap(java.util.Hashtable map)
          Constructs from a Hashtable.
 void constructFromNMEA(java.lang.String latNMEA, java.lang.String latHem, java.lang.String lonNMEA, java.lang.String lonHem)
          Constructs a Coordinate from the NMEA specification for Coordinates which is a hemisphere and a lat and lon in hhmm.sssss format.
 void constructFromStrings(java.lang.String lat, java.lang.String lon)
          Constructs a Coordinate from String representations of lat and lon as doubles in hh.ddddd format
 Coordinate createClone()
           
 java.lang.String distanceFromAsString(Coordinate c2)
           
 long distanceFromFlong(FixedTwoDCoordinate c2)
          Returns the distance between points in meters
 int distanceFromInMeters(Coordinate c2)
           
 boolean equals(java.lang.Object o)
           
 java.lang.String getLatitudeAsString()
           
 long getLatitudeFlong()
           
 java.lang.String getLatitudeHemisphereNMEA()
           
 java.lang.String getLatitudeNMEA()
           
 java.lang.String getLongitudeAsString()
           
 long getLongitudeFlong()
           
 java.lang.String getLongitudeHemisphereNMEA()
           
 java.lang.String getLongitudeNMEA()
           
 boolean isNull()
          The Null coordinate is a Coordinate which does not map to anywhere at all.
 java.lang.String toString()
           
 Coordinate translate(int north, int east)
          Provides a new Coordinate at a position translated from an existing one
 FixedTwoDCoordinate translateFixed(long northFlong, long eastFlong)
           
 boolean within(Coordinate coord1, Coordinate coord2)
          c1 and c2 define opposing corners of a rectangular region.
 long xDistanceFrom(FixedTwoDCoordinate c2)
           
 long yDistanceFrom(FixedTwoDCoordinate c2)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FixedTwoDCoordinate

public FixedTwoDCoordinate()
Create a null FixedTwoDCoordinate


FixedTwoDCoordinate

public FixedTwoDCoordinate(java.lang.String lat,
                           java.lang.String lon)

FixedTwoDCoordinate

public FixedTwoDCoordinate(java.lang.String latNMEA,
                           java.lang.String latHem,
                           java.lang.String lonNMEA,
                           java.lang.String lonHem)

FixedTwoDCoordinate

public FixedTwoDCoordinate(FixedTwoDCoordinate c)

FixedTwoDCoordinate

public FixedTwoDCoordinate(long flongLat,
                           long flongLon)
Method Detail

isNull

public boolean isNull()
Description copied from interface: Coordinate
The Null coordinate is a Coordinate which does not map to anywhere at all. Returns true if this coordinate is the Null coordinate.

Specified by:
isNull in interface Coordinate

createClone

public Coordinate createClone()
Specified by:
createClone in interface Coordinate

constructFromMap

public void constructFromMap(java.util.Hashtable map)
Description copied from interface: Coordinate
Constructs from a Hashtable. The Hashtable should have the following structure:
 Types.LATITUDE=latitude as a String in hh.dddddd format
 Types.LONGITUDE=longitude as a String in hh.ddddd format
 

Specified by:
constructFromMap in interface Coordinate
See Also:
Types#newCoordinate(HashMap)

constructFromStrings

public void constructFromStrings(java.lang.String lat,
                                 java.lang.String lon)
Description copied from interface: Coordinate
Constructs a Coordinate from String representations of lat and lon as doubles in hh.ddddd format

Specified by:
constructFromStrings in interface Coordinate

constructFromNMEA

public void constructFromNMEA(java.lang.String latNMEA,
                              java.lang.String latHem,
                              java.lang.String lonNMEA,
                              java.lang.String lonHem)
Description copied from interface: Coordinate
Constructs a Coordinate from the NMEA specification for Coordinates which is a hemisphere and a lat and lon in hhmm.sssss format.

Specified by:
constructFromNMEA in interface Coordinate

getLatitudeFlong

public long getLatitudeFlong()

getLongitudeFlong

public long getLongitudeFlong()

getLatitudeAsString

public java.lang.String getLatitudeAsString()
Specified by:
getLatitudeAsString in interface Coordinate

getLongitudeAsString

public java.lang.String getLongitudeAsString()
Specified by:
getLongitudeAsString in interface Coordinate

toString

public java.lang.String toString()
Specified by:
toString in interface Coordinate

equals

public boolean equals(java.lang.Object o)

getLatitudeHemisphereNMEA

public java.lang.String getLatitudeHemisphereNMEA()
Specified by:
getLatitudeHemisphereNMEA in interface Coordinate

getLongitudeHemisphereNMEA

public java.lang.String getLongitudeHemisphereNMEA()
Specified by:
getLongitudeHemisphereNMEA in interface Coordinate

getLatitudeNMEA

public java.lang.String getLatitudeNMEA()
Specified by:
getLatitudeNMEA in interface Coordinate

getLongitudeNMEA

public java.lang.String getLongitudeNMEA()
Specified by:
getLongitudeNMEA in interface Coordinate

distanceFromFlong

public long distanceFromFlong(FixedTwoDCoordinate c2)
                       throws FixedPointLongException
Returns the distance between points in meters

Throws:
FixedPointLongException

distanceFromInMeters

public int distanceFromInMeters(Coordinate c2)
Specified by:
distanceFromInMeters in interface Coordinate

distanceFromAsString

public java.lang.String distanceFromAsString(Coordinate c2)
Specified by:
distanceFromAsString in interface Coordinate

within

public boolean within(Coordinate coord1,
                      Coordinate coord2)
Description copied from interface: Coordinate
c1 and c2 define opposing corners of a rectangular region. This method returns true if this Coordinate falls in that region.

Specified by:
within in interface Coordinate

xDistanceFrom

public long xDistanceFrom(FixedTwoDCoordinate c2)
                   throws FixedPointLongException
Throws:
FixedPointLongException

yDistanceFrom

public long yDistanceFrom(FixedTwoDCoordinate c2)
                   throws FixedPointLongException
Throws:
FixedPointLongException

translateFixed

public FixedTwoDCoordinate translateFixed(long northFlong,
                                          long eastFlong)
                                   throws FixedPointLongException
Parameters:
northFlong - the distance in meters to move north
eastFlong - the distance in meters to move east
Returns:
a translated FixedTwoDCoordinate
Throws:
FixedPointLongException

translate

public Coordinate translate(int north,
                            int east)
Description copied from interface: Coordinate
Provides a new Coordinate at a position translated from an existing one

Specified by:
translate in interface Coordinate
Parameters:
north - the distance in meters to move north
east - the distance in meters to move east
Returns:
a translated Coordinate