gps.log.out
Class GPSFile

java.lang.Object
  extended by gps.log.out.GPSFile
All Implemented Interfaces:
GPSFileConverterInterface, GPSFileConfInterface, GPSFileInterface
Direct Known Subclasses:
GPSArray, GPSCompoGPSTrkFile, GPSCSVFile, GPSGmapsHTMLEncodedFile, GPSGmapsHTMLFile, GPSGoogleStaticMapUrl, GPSGPXFile, GPSKMLFile, GPSNMEAFile, GPSPLTFile, GPSPostGISFile, GPSSqlFile

public abstract class GPSFile
extends java.lang.Object
implements GPSFileInterface

Author:
Mario De Weerd This abstract class defines the 'interface' with the BT747LogConvert class. Derived classes will be able to write the desired output in the formats they implement. Refactoring / Discussion: Either each implementation of this abstract class is a Strategy Design Pattern. Or this abstract class could be a concrete class and be a Strategy itself. The concrete classes currently deriving from this class would be Builders. This will be given some thought. It is not urgent to make the change.

Field Summary
static int FILE_SPLIT_NONE
           
static int FILE_SPLIT_ONE_FILE_PER_DAY
           
static int FILE_SPLIT_ONE_FILE_PER_TRACK
           
 
Constructor Summary
GPSFile()
           
 
Method Summary
 void addLogRecord(GPSRecord r)
          A record is added from the input log.
 boolean cachedRecordIsNeeded(GPSRecord r)
           
 void finaliseFile()
          Method called when all parsing is finished and the last file has to be closed.
 java.lang.String getBadTrackColor()
           
 java.lang.String getErrorInfo()
           
 BT747HashSet getFilesCreated()
           
 java.lang.String getGoodTrackColor()
           
 int getMaxDiff()
           
 int getNbrFilesCreated()
           
 GPSConversionParameters getParamObject()
           
 GPSRecord[] getUserWayPointList()
           
 void initialiseFile(BT747Path baseName, java.lang.String extension, int fileSeparationFreq)
          This function has to be called at some time to initialize the file conversion.
 boolean isAddLogConditionInfo()
           
 boolean isOverridePreviousTag()
           
 boolean isRecordNbrInLogs()
           
 boolean needPassToFindFieldsActivatedInLog()
           
 boolean nextPass()
          Called when the input file has been parsed.
 void setActiveFileFields(GPSRecord activeFileFieldsFormat)
          Called to set the fields that are active in the current input.
 void setAddLogConditionInfo(boolean addLogConditionInfo)
           
 void setBadTrackColor(java.lang.String badTrackColor)
           
 void setFilenameBuilder(BT747FileName filenameBuilder)
           
 void setFilters(GPSFilter[] ourFilters)
          Set the track point and way point filters.
 void setGoodTrackColor(java.lang.String goodTrackColor)
           
 void setImperial(boolean useImperial)
          Indicate whether Imperial units (miles, knots, mph) should be used.
 void setIncludeTrkComment(boolean isTrkComment)
           
 void setIncludeTrkName(boolean isIncludeTrkName)
           
 void setMaxDiff(int maxDiff)
           
 void setOutputFields(GPSRecord selectedOutputFields)
          Set the fields that should be written to the output.
 void setOverridePreviousTag(boolean overridePreviousTag)
           
 void setParamObject(GPSConversionParameters paramObject)
           
 void setRecordNbrInLogs(boolean recordNbrInLogs)
           
 void setTimeOffset(int offset)
          The time offset to apply to the output records in seconds.
 void setTrackSepTime(int time)
          Set the track separation time.
 void setUserWayPointList(GPSRecord[] list)
          Entry must be an ordered list (UTC time).
 void setWayPointTimeCorrection(int seconds)
           
 void writeLogFmtHeader(GPSRecord f)
          Called every time the log format changes so that the appropriate header information can be written to the output files.
 void writeRecord(GPSRecord r)
          Called for any new position.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILE_SPLIT_NONE

public static final int FILE_SPLIT_NONE
See Also:
Constant Field Values

FILE_SPLIT_ONE_FILE_PER_DAY

public static final int FILE_SPLIT_ONE_FILE_PER_DAY
See Also:
Constant Field Values

FILE_SPLIT_ONE_FILE_PER_TRACK

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

GPSFile

public GPSFile()
Method Detail

initialiseFile

public void initialiseFile(BT747Path baseName,
                           java.lang.String extension,
                           int fileSeparationFreq)
This function has to be called at some time to initialize the file conversion. Other parameters can be set through other methods.

Specified by:
initialiseFile in interface GPSFileConfInterface
Parameters:
baseName - Base name of the output file. This value will be provided to the filename builder.
extension - Extension of the output file. This value will be provided to the filename builder.
fileSeparationFreq - Indicates how the file must be separated.
See Also:
AppSettings.SPLIT_ONE_FILE, AppSettings.SPLIT_ONE_FILE_PER_DAY, AppSettings.SPLIT_ONE_FILE_PER_TRACK

setTrackSepTime

public final void setTrackSepTime(int time)
Description copied from interface: GPSFileConfInterface
Set the track separation time.

Specified by:
setTrackSepTime in interface GPSFileConfInterface
Parameters:
time - Seconds of unavailable positions require before deciding to hava a new track.

setActiveFileFields

public final void setActiveFileFields(GPSRecord activeFileFieldsFormat)
Description copied from interface: GPSFileConfInterface
Called to set the fields that are active in the current input. This is set by the internal algorithm that analyses the input file.

Specified by:
setActiveFileFields in interface GPSFileConverterInterface
Specified by:
setActiveFileFields in interface GPSFileConfInterface

setOutputFields

public final void setOutputFields(GPSRecord selectedOutputFields)
Description copied from interface: GPSFileConfInterface
Set the fields that should be written to the output. This can be a superset of the active file fields, but only the fields that are both active and selected for output will be available in the output files. This is to be configured from the application.

Specified by:
setOutputFields in interface GPSFileConfInterface

writeLogFmtHeader

public void writeLogFmtHeader(GPSRecord f)
Called every time the log format changes so that the appropriate header information can be written to the output files. Updates the activeFields so 'super()' should be called by the extending class that must add a hook to this method to write the intermediate header (if needed for the output format).

Specified by:
writeLogFmtHeader in interface GPSFileConverterInterface
Parameters:
f -

setFilters

public final void setFilters(GPSFilter[] ourFilters)
Description copied from interface: GPSFileConfInterface
Set the track point and way point filters. To be called from the application.

Specified by:
setFilters in interface GPSFileConfInterface
Parameters:
ourFilters - Track point and way point filters.

setImperial

public final void setImperial(boolean useImperial)
Description copied from interface: GPSFileConfInterface
Indicate whether Imperial units (miles, knots, mph) should be used.

Specified by:
setImperial in interface GPSFileConfInterface
Parameters:
useImperial - when true, use imperial units.

cachedRecordIsNeeded

public final boolean cachedRecordIsNeeded(GPSRecord r)

setUserWayPointList

public void setUserWayPointList(GPSRecord[] list)
Description copied from interface: GPSFileConfInterface
Entry must be an ordered list (UTC time).

Specified by:
setUserWayPointList in interface GPSFileConfInterface

getUserWayPointList

public GPSRecord[] getUserWayPointList()

setWayPointTimeCorrection

public void setWayPointTimeCorrection(int seconds)
Specified by:
setWayPointTimeCorrection in interface GPSFileConfInterface

addLogRecord

public void addLogRecord(GPSRecord r)
A record is added from the input log. User way points are geotagged here and inserted at the right spot.

This is not to be extended.

The provided record should no longer be referenced in the caller.
It is supposed to be unique.

Specified by:
addLogRecord in interface GPSFileConverterInterface
Parameters:
r -

writeRecord

public void writeRecord(GPSRecord r)
Called for any new position. This method is called by the input analysis class and should be extended for the output format. The extension must call super(). That will make sure that the appropriate files are opened, and the t property set.

Parameters:
r - information regarding the position.

finaliseFile

public void finaliseFile()
Method called when all parsing is finished and the last file has to be closed.
This method can be extended. It closes the output file by default, so super() should be called once other handling is finished.

Specified by:
finaliseFile in interface GPSFileConverterInterface

nextPass

public boolean nextPass()
Called when the input file has been parsed. This method checks if other passes are needed and performs some closing operations if that is not the case.
This method must be extended, call super.nextPass() and then update nbrOfPassesToGo.

Specified by:
nextPass in interface GPSFileConverterInterface
Returns:
true if analysis must go on.

needPassToFindFieldsActivatedInLog

public boolean needPassToFindFieldsActivatedInLog()
Specified by:
needPassToFindFieldsActivatedInLog in interface GPSFileConverterInterface

getBadTrackColor

public final java.lang.String getBadTrackColor()
Returns:
Returns the badTrackColor.

setBadTrackColor

public final void setBadTrackColor(java.lang.String badTrackColor)
Specified by:
setBadTrackColor in interface GPSFileConfInterface
Parameters:
badTrackColor - The badTrackColor to set.

getGoodTrackColor

public final java.lang.String getGoodTrackColor()
Returns:
Returns the goodTrackColor.

setGoodTrackColor

public final void setGoodTrackColor(java.lang.String goodTrackColor)
Specified by:
setGoodTrackColor in interface GPSFileConfInterface
Parameters:
goodTrackColor - The goodTrackColor to set.

getNbrFilesCreated

public final int getNbrFilesCreated()
Specified by:
getNbrFilesCreated in interface GPSFileConverterInterface
Returns:
Returns the filesCreated.

getFilesCreated

public final BT747HashSet getFilesCreated()
Specified by:
getFilesCreated in interface GPSFileConverterInterface
Returns:
Returns the filesCreated.

isRecordNbrInLogs

public final boolean isRecordNbrInLogs()
Returns:
Returns the recordNbrInLogs.

setRecordNbrInLogs

public final void setRecordNbrInLogs(boolean recordNbrInLogs)
Specified by:
setRecordNbrInLogs in interface GPSFileConfInterface
Parameters:
recordNbrInLogs - The recordNbrInLogs to set.

isAddLogConditionInfo

public final boolean isAddLogConditionInfo()

setAddLogConditionInfo

public final void setAddLogConditionInfo(boolean addLogConditionInfo)
Specified by:
setAddLogConditionInfo in interface GPSFileConfInterface

getErrorInfo

public final java.lang.String getErrorInfo()

setIncludeTrkComment

public final void setIncludeTrkComment(boolean isTrkComment)
Specified by:
setIncludeTrkComment in interface GPSFileConfInterface

setIncludeTrkName

public final void setIncludeTrkName(boolean isIncludeTrkName)
Specified by:
setIncludeTrkName in interface GPSFileConfInterface

setFilenameBuilder

public final void setFilenameBuilder(BT747FileName filenameBuilder)
Specified by:
setFilenameBuilder in interface GPSFileConfInterface

setTimeOffset

public final void setTimeOffset(int offset)
Description copied from interface: GPSFileConfInterface
The time offset to apply to the output records in seconds.

Specified by:
setTimeOffset in interface GPSFileConfInterface
Parameters:
offset - The time offset in seconds.

getMaxDiff

public final int getMaxDiff()
Returns:
the maxDiff

setMaxDiff

public final void setMaxDiff(int maxDiff)
Specified by:
setMaxDiff in interface GPSFileConfInterface
Parameters:
maxDiff - the maxDiff to set

isOverridePreviousTag

public final boolean isOverridePreviousTag()
Returns:
the overridePreviousTag

setOverridePreviousTag

public final void setOverridePreviousTag(boolean overridePreviousTag)
Specified by:
setOverridePreviousTag in interface GPSFileConfInterface
Parameters:
overridePreviousTag - the overridePreviousTag to set

getParamObject

public final GPSConversionParameters getParamObject()
Specified by:
getParamObject in interface GPSFileConfInterface

setParamObject

public final void setParamObject(GPSConversionParameters paramObject)
Specified by:
setParamObject in interface GPSFileConfInterface