com.sony.csl.j2me.locationapitools.tracking
Class KMLTrackWriter

java.lang.Object
  extended by com.sony.csl.j2me.locationapitools.tracking.TrackWriter
      extended by com.sony.csl.j2me.locationapitools.tracking.KMLTrackWriter
All Implemented Interfaces:
LocationProxyListener

public class KMLTrackWriter
extends TrackWriter

A TrackWriter subclass that stores a location track as a KML file for use with Google Earth or Google Maps

Author:
mstevens (Sony CSL Paris / Vrije Universiteit Brussel)

Field Summary
private  java.util.Vector coordinateStrings
           
static java.lang.String DEFAULT_CHARACTER_ENCODING
           
protected  KMLStyle kmlStyle
           
 
Fields inherited from class com.sony.csl.j2me.locationapitools.tracking.TrackWriter
characterEncoding, coveredDistance, firstLocation, firstLocationReceivalTime, firstValidLocation, lastLocation, lastLocationReceivalTime, lastValidLocation, locationProxy, maxAltitude, maxLatitude, maxLongitude, minAltitude, minLatitude, minLongitude, numberOfLocations, numberOfValidLocations, trackFileFolderPath, trackFilePath, trackName, tracksInvalids, trackStartTime
 
Constructor Summary
KMLTrackWriter(LocationProxy locationProxy, java.lang.String trackFileFolderPath, java.lang.String trackName)
           
KMLTrackWriter(LocationProxy locationProxy, java.lang.String trackFileFolderPath, java.lang.String trackName, boolean tracksInvalids)
           
KMLTrackWriter(LocationProxy locationProxy, java.lang.String trackFileFolderPath, java.lang.String trackName, boolean tracksInvalids, KMLStyle kmlStyle)
           
KMLTrackWriter(LocationProxy locationProxy, java.lang.String trackFileFolderPath, java.lang.String trackName, boolean tracksInvalids, KMLStyle kmlStyle, java.lang.String characterEncoding)
           
 
Method Summary
protected  java.lang.String coordinatesTuple(Coordinates coords)
           
protected  java.lang.String getAdditionalTrackContents(int tabs)
           
private  java.lang.String getBoundingBoxPlacemark()
           
protected  java.lang.String getFileExtension()
          Gets the file extension (e.g.: "txt") that is used on the files the TrackWriter creates
 KMLStyle getKmlStyle()
           
private  java.lang.String getTrackDescription()
           
private  java.lang.String getTrackLinePlacemark()
           
protected  void initializeBeforeStart()
          Allows subclasses to add initializations that should take place before tracking starts.
private  java.lang.String kmlTimeSpan(long beginTime, long endTime, int tabs)
           
 void setKmlStyle(KMLStyle kmlStyle)
           
protected  void writeFooter()
          Writes the footer of the file.
protected  void writeHeader()
          Writes the header of the file.
protected  void writeLocation(Location location)
          Writes a new location to the file.
protected  void writePaused(java.lang.String reason)
           
protected  void writeProviderStateChanged(LocationProvider provider, int newState)
           
protected  void writeResumed()
           
 
Methods inherited from class com.sony.csl.j2me.locationapitools.tracking.TrackWriter
firstLocationFound, getCharacterEncoding, getCoveredDistance, getFirstLocation, getFirstLocationReceivalTime, getFirstValidLocation, getLastLocation, getLastLocationReceivalTime, getLastValidLocation, getLocationProxy, getMaxAltitude, getMaxLatitude, getMaxLongitude, getMinAltitude, getMinLatitude, getMinLongitude, getNumberOfLocations, getNumberOfValidLocations, getTrackFilePath, getTrackName, isPaused, isTracking, isTracksInvalids, locationProviderStateChanged, locationUpdated, pauseTracking, pauseTracking, proxyConnected, proxyDisconnected, receivesInvalidLocations, reset, resumeTracking, setCharacterEncoding, startTracking, stopTracking, writeToFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CHARACTER_ENCODING

public static final java.lang.String DEFAULT_CHARACTER_ENCODING
See Also:
Constant Field Values

kmlStyle

protected KMLStyle kmlStyle

coordinateStrings

private java.util.Vector coordinateStrings
Constructor Detail

KMLTrackWriter

public KMLTrackWriter(LocationProxy locationProxy,
                      java.lang.String trackFileFolderPath,
                      java.lang.String trackName)
               throws java.lang.Exception
Throws:
java.lang.Exception

KMLTrackWriter

public KMLTrackWriter(LocationProxy locationProxy,
                      java.lang.String trackFileFolderPath,
                      java.lang.String trackName,
                      boolean tracksInvalids)
               throws java.lang.Exception
Throws:
java.lang.Exception

KMLTrackWriter

public KMLTrackWriter(LocationProxy locationProxy,
                      java.lang.String trackFileFolderPath,
                      java.lang.String trackName,
                      boolean tracksInvalids,
                      KMLStyle kmlStyle)
               throws java.lang.Exception
Throws:
java.lang.Exception

KMLTrackWriter

public KMLTrackWriter(LocationProxy locationProxy,
                      java.lang.String trackFileFolderPath,
                      java.lang.String trackName,
                      boolean tracksInvalids,
                      KMLStyle kmlStyle,
                      java.lang.String characterEncoding)
               throws java.lang.Exception
Throws:
java.lang.Exception
Method Detail

getKmlStyle

public KMLStyle getKmlStyle()
Returns:
the kmlStyle

setKmlStyle

public void setKmlStyle(KMLStyle kmlStyle)
                 throws java.lang.Exception
Parameters:
kmlStyle - the kmlStyle to set
Throws:
java.lang.Exception

initializeBeforeStart

protected void initializeBeforeStart()
Description copied from class: TrackWriter
Allows subclasses to add initializations that should take place before tracking starts.

Specified by:
initializeBeforeStart in class TrackWriter
See Also:
TrackWriter.initializeBeforeStart()

getFileExtension

protected java.lang.String getFileExtension()
Description copied from class: TrackWriter
Gets the file extension (e.g.: "txt") that is used on the files the TrackWriter creates

Specified by:
getFileExtension in class TrackWriter
Returns:
a String containing the file extension (without the '.')
See Also:
TrackWriter.getFileExtension()

writeHeader

protected void writeHeader()
Description copied from class: TrackWriter
Writes the header of the file.

Specified by:
writeHeader in class TrackWriter
See Also:
TrackWriter.writeHeader()

writeLocation

protected void writeLocation(Location location)
Description copied from class: TrackWriter
Writes a new location to the file.

Specified by:
writeLocation in class TrackWriter
See Also:
TrackWriter.writeLocation(javax.microedition.location.Location)

writePaused

protected void writePaused(java.lang.String reason)
Specified by:
writePaused in class TrackWriter
See Also:
TrackWriter.writePaused(java.lang.String)

writeResumed

protected void writeResumed()
Specified by:
writeResumed in class TrackWriter
See Also:
TrackWriter.writeResumed()

writeProviderStateChanged

protected void writeProviderStateChanged(LocationProvider provider,
                                         int newState)
Specified by:
writeProviderStateChanged in class TrackWriter
See Also:
TrackWriter.writeProviderStateChanged(javax.microedition.location.LocationProvider, int)

writeFooter

protected void writeFooter()
Description copied from class: TrackWriter
Writes the footer of the file.

Specified by:
writeFooter in class TrackWriter
See Also:
TrackWriter.writeFooter()

getAdditionalTrackContents

protected java.lang.String getAdditionalTrackContents(int tabs)

getTrackLinePlacemark

private java.lang.String getTrackLinePlacemark()

getBoundingBoxPlacemark

private java.lang.String getBoundingBoxPlacemark()

getTrackDescription

private java.lang.String getTrackDescription()

coordinatesTuple

protected java.lang.String coordinatesTuple(Coordinates coords)

kmlTimeSpan

private java.lang.String kmlTimeSpan(long beginTime,
                                     long endTime,
                                     int tabs)