org.placelab.core
Class GPSMeasurement

java.lang.Object
  extended byorg.placelab.core.Measurement
      extended byorg.placelab.core.GPSMeasurement
All Implemented Interfaces:
Observable, PositionMeasurement

public class GPSMeasurement
extends Measurement
implements PositionMeasurement

A Measurement based on a reading from a GPS unit. GPSMeasurements are different from most Measurements in that they have a Coordinate included with them that is read from the GPS.


Field Summary
static int DONT_HAVE_A_LOCK
           
static java.lang.String[] gpsTypes
           
static int HAVE_A_LOCK
           
static int NO_INFO_RE_A_LOCK
           
 
Constructor Summary
GPSMeasurement(long timestampInMillis, Coordinate loc)
           
GPSMeasurement(long timestampInMillis, Coordinate loc, java.util.Hashtable fields)
           
GPSMeasurement(long time, java.io.DataInputStream dis)
           
 
Method Summary
 java.lang.String getField(java.lang.String fieldName)
           
 Coordinate getPosition()
           
 java.lang.String getType()
           
 int haveALock()
          Roughly the same as isValid, but also returns whether there was no info about a lock (which can be assumed to be no lock)
 boolean isLikelyAccurate()
          Uses a heuristic based on number of satellites and satellite angles to predict if reading is likely to be accurate.
 boolean isValid()
          Gets whether or not the fix data is valid for this GPSMeasurement.
 byte[] toCompressedBytes()
          For storage on impoverished devices
 java.lang.String toLogString()
          Converts the Measurement to a form which is convenient for writing to a log file.
 java.lang.String toShortString()
          A short string based representation for debugging purposes
 
Methods inherited from class org.placelab.core.Measurement
fromCompressedBytes, getTimestamp, setTimestamp
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.placelab.core.PositionMeasurement
getTimestamp
 

Field Detail

gpsTypes

public static final java.lang.String[] gpsTypes

HAVE_A_LOCK

public static final int HAVE_A_LOCK
See Also:
Constant Field Values

DONT_HAVE_A_LOCK

public static final int DONT_HAVE_A_LOCK
See Also:
Constant Field Values

NO_INFO_RE_A_LOCK

public static final int NO_INFO_RE_A_LOCK
See Also:
Constant Field Values
Constructor Detail

GPSMeasurement

public GPSMeasurement(long timestampInMillis,
                      Coordinate loc,
                      java.util.Hashtable fields)

GPSMeasurement

public GPSMeasurement(long timestampInMillis,
                      Coordinate loc)

GPSMeasurement

public GPSMeasurement(long time,
                      java.io.DataInputStream dis)
               throws java.io.IOException
Method Detail

getPosition

public Coordinate getPosition()
Specified by:
getPosition in interface PositionMeasurement

isValid

public boolean isValid()
Gets whether or not the fix data is valid for this GPSMeasurement. GPSMeasurements without valid fix data should not be relied upon for positioning.


isLikelyAccurate

public boolean isLikelyAccurate()
Uses a heuristic based on number of satellites and satellite angles to predict if reading is likely to be accurate.


getField

public java.lang.String getField(java.lang.String fieldName)
Parameters:
fieldName - GPS field names from NMEASentence
Returns:
the field value

getType

public java.lang.String getType()
Specified by:
getType in interface PositionMeasurement

toLogString

public java.lang.String toLogString()
Description copied from class: Measurement
Converts the Measurement to a form which is convenient for writing to a log file. The convention is to have the following form:
 TYPE=type|TIME=timestamp|OTHERFIELD=value ...
 
All necessary fields should be stored in that pipe separated format, and all values should be percentEscaped with StringUtil.percentEscape(String)

Such a format is easily converted into a HashMap form, and a Measurement should (but is not required to) provide a constructor to build itself from a HashMap created from its log string form.

Overrides:
toLogString in class Measurement

toShortString

public java.lang.String toShortString()
Description copied from class: Measurement
A short string based representation for debugging purposes

Overrides:
toShortString in class Measurement

toCompressedBytes

public byte[] toCompressedBytes()
Description copied from class: Measurement
For storage on impoverished devices

Overrides:
toCompressedBytes in class Measurement
Returns:
a compressed form of the Measurement suitable for storing on small devices such as phones

haveALock

public int haveALock()
Roughly the same as isValid, but also returns whether there was no info about a lock (which can be assumed to be no lock)

See Also:
HAVE_A_LOCK, DONT_HAVE_A_LOCK, NO_INFO_RE_A_LOCK