org.iu.gps
Class GPSLog

java.lang.Object
  |
  +--org.iu.gps.GPSLog
All Implemented Interfaces:
java.io.Serializable

public class GPSLog
extends java.lang.Object
implements java.io.Serializable

This class represents a device-independent GPS log. Further, it is capable of converting raw GPS log files from GPS devices into our internal representation on the fly.

See Also:
Serialized Form

Field Summary
protected  int duration
          Specifies the duration of the log in seconds.
protected  java.util.Vector gpslog
          Specifies the GPSInfo elements of the log, one for each second of logged data.
protected  java.util.Date start
          Specifies the start time of the log.
 
Constructor Summary
GPSLog()
          Creates an empty GPSLog.
GPSLog(java.util.Date _start)
          Creates an empty GPSLog with given time/date.
 
Method Summary
 int getDuration()
          Returns the duration of the log in seconds.
 GPSInfo getInfoAt(int t)
          Gets the GPSInfo from the log at a certain point of time, where t>=0 and t smaller than duration.
static GPSLog load(java.io.InputStream _is)
          Loads a GPSLog from a given stream, uses device-independent file format.
static GPSLog loadRaw(java.io.InputStream is)
          Loads GPSLog from a raw GPS driver log file.
static void main(java.lang.String[] arg)
          Test method.
 void save(java.io.OutputStream os)
          Saves the log in the given output stream.
 void setInfoAt(int t, GPSInfo gi)
          Sets GPSInfo in the log for a specific time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

start

protected java.util.Date start
Specifies the start time of the log.

duration

protected int duration
Specifies the duration of the log in seconds.

gpslog

protected java.util.Vector gpslog
Specifies the GPSInfo elements of the log, one for each second of logged data.
Constructor Detail

GPSLog

public GPSLog()
Creates an empty GPSLog.

GPSLog

public GPSLog(java.util.Date _start)
Creates an empty GPSLog with given time/date.
Parameters:
_start - Creation date of the log.
Method Detail

loadRaw

public static GPSLog loadRaw(java.io.InputStream is)
                      throws java.io.IOException
Loads GPSLog from a raw GPS driver log file.
Parameters:
is - Input stream.
Returns:
Returns a new GPSLog object representing the given stream's log data.
Throws:
java.io.IOException - In case of I/O Error.

load

public static GPSLog load(java.io.InputStream _is)
Loads a GPSLog from a given stream, uses device-independent file format. Falls back and tries to load raw GPS log if the given input stream is not in the device-independent format.
Parameters:
_is - Input stream.
Returns:
Returns new GPSLog object representing the log from the given stream.

main

public static void main(java.lang.String[] arg)
                 throws java.lang.Exception
Test method. Converts old log file into new log file format.
Parameters:
arg -  
Throws:
java.lang.Exception -  

setInfoAt

public void setInfoAt(int t,
                      GPSInfo gi)
Sets GPSInfo in the log for a specific time.
Parameters:
t - time in seconds.
gi - GPSInfo to set.

getDuration

public int getDuration()
Returns the duration of the log in seconds.
Returns:
Duration in seconds.

getInfoAt

public GPSInfo getInfoAt(int t)
Gets the GPSInfo from the log at a certain point of time, where t>=0 and t smaller than duration.
Parameters:
t - time in seconds (>=0 and smaller duration)
Returns:
GPSInfo at specified time, or null if not available.

save

public void save(java.io.OutputStream os)
          throws java.io.IOException
Saves the log in the given output stream.
Parameters:
os - Output stream to use for saving.
Throws:
java.io.IOException - In case of I/O error.