net.landspurg.map
Class Track

java.lang.Object
  extended by net.landspurg.map.Track
All Implemented Interfaces:
NotifyLoadURL

public class Track
extends java.lang.Object
implements NotifyLoadURL

A Track represnt a combination of Waypoints (oneLoc) and and a list of points.
Tracks are saved and loaded through RMS or through external input stream...
Do not use directly constructor, use the factory calls instead: Track.getTrack()


Field Summary
 float[] alts
           
 int[] coordSeg
          The track itself in pixel ccordinates.
 float[] courses
           
static int currRecord
           
 boolean isInit
           
 java.util.Vector listPlaces
          The list of "Waypoints" of this track.
 boolean m_autoDisplay
           
static int m_curRate
          current sampling rate, in seconds...
static OneLoc m_defaultLocType
           
 OneLoc m_locType
           
 java.lang.String m_name
          The name of this Track.
 int m_refreshType
           
static int REFRESH_MODE_NONE
          True if the track need to be notified when visible area change (onyl called if track is displayed
static int REFRESH_MODE_ON_CHANGE
           
static int REFRESH_MODE_ON_INTERVAL
           
 byte[] savedTrack
           
static int sizeElem
          The internal header size used when writing with RMS.
static int sizeHeader
           
 float[] speeds
           
 long[] times
          If altitude datas are present, this is not null
static java.util.Vector tracks
          List of tracks.
static int TYPE_EXPORT_GPX
          Used for exporting tracks, define an export in GPX format.
static int TYPE_EXPORT_KML
          Used for exporting tracks, define an export in GoogleEarth/KML format.
 
Constructor Summary
protected Track(javax.microedition.lcdui.Display d, javax.microedition.lcdui.Displayable reference, java.io.InputStream is, java.lang.String inInfo)
           
protected Track(javax.microedition.lcdui.Display d, int inRmsId)
           
protected Track(javax.microedition.lcdui.Display d, java.lang.String name)
           
protected Track(javax.microedition.lcdui.Display d, java.lang.String inUrl, java.lang.String inInfo, MapCanvas inCanvas)
           
 
Method Summary
 void addLoc(OneLoc newLoc)
          Add one location to display in the track
 void addRecord(oneGPSPos newLoc)
           
static void addTrack(Track t)
          Add an existing track to the list of Track.
 void clear()
          Clear all content of track...
 void delete()
          Delete this track.
 void error(int inErrorCode)
           
 void export(java.io.OutputStream os, int typeExport)
          Export the Track to an output stream.
 boolean fireOpened(OneLoc theLoc)
           
 void fireSelected(OneLoc theLoc)
           
 int getNbWayPoints()
           
 int getSizeTrack()
           
 long getTimeStamp()
           
 int[] getTrack()
           
static Track getTrack(javax.microedition.lcdui.Display d, javax.microedition.lcdui.Displayable reference, java.io.InputStream is, java.lang.String inInfo)
           
static Track getTrack(javax.microedition.lcdui.Display d, java.lang.String name)
          Create and get an empty track.
static Track getTrack(javax.microedition.lcdui.Display d, java.lang.String inUrl, java.lang.String inInfo, MapCanvas inMap)
          Create and get a track to be loaded from a specific URL
 java.util.Vector getWaypoints()
           
static void initTracks()
          Init thr track list: open the RMS, read the saved track and add them into the global list of tracks.
 boolean inputStream(java.io.InputStream is)
          implemented for notifyLoadURL
 boolean lineRead(URLFetcher f, java.lang.String inLine)
           
 void loaded(URLFetcher f)
           
protected  void loadHeader()
          Load the header (from RMS) of the track.
 void loadTrack()
           
 float parseFloat(java.lang.String inString)
           
protected  long readLong(byte[] b, int off, int length)
           
 void refreshTrack(MapCanvas m_map)
           
static void removeTrack(Track t)
          Delete and remove a track from the list of tracks...
 void saveTrack()
           
protected  void sendGPX(java.io.OutputStream os)
           
protected  void sendKML(java.io.OutputStream os)
           
 java.lang.String sendTrack(java.lang.String theUrl)
          Post track to an url
static void setGlobalNotifier(TrackNotifier tn)
          Set the global notifier
 void setName(java.lang.String inName)
           
 void setNotifier(TrackNotifier tn)
          Set the notifier to this track only
 void setTrackListener(TrackListener inListener)
           
 void setUrl(java.lang.String inUrl, MapCanvas inMap)
           
protected static void writeLong(byte[] b, int off, int length, long data)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

isInit

public boolean isInit

coordSeg

public int[] coordSeg
The track itself in pixel ccordinates. Can be null if no points is defined


times

public long[] times
If altitude datas are present, this is not null


alts

public float[] alts

courses

public float[] courses

speeds

public float[] speeds

m_defaultLocType

public static OneLoc m_defaultLocType

m_locType

public OneLoc m_locType

m_name

public java.lang.String m_name
The name of this Track. Default is "noname"


listPlaces

public java.util.Vector listPlaces
The list of "Waypoints" of this track. Can be empy if noWaypoint are defined


savedTrack

public byte[] savedTrack

m_autoDisplay

public boolean m_autoDisplay

sizeElem

public static final int sizeElem
The internal header size used when writing with RMS. Should not be used

See Also:
Constant Field Values

sizeHeader

public static final int sizeHeader
See Also:
Constant Field Values

currRecord

public static int currRecord

m_curRate

public static int m_curRate
current sampling rate, in seconds...


tracks

public static java.util.Vector tracks
List of tracks. Do not modify this list directly, instead use init, get Track() and remove methods.


TYPE_EXPORT_KML

public static final int TYPE_EXPORT_KML
Used for exporting tracks, define an export in GoogleEarth/KML format.

See Also:
Constant Field Values

TYPE_EXPORT_GPX

public static final int TYPE_EXPORT_GPX
Used for exporting tracks, define an export in GPX format.

See Also:
Constant Field Values

REFRESH_MODE_NONE

public static final int REFRESH_MODE_NONE
True if the track need to be notified when visible area change (onyl called if track is displayed

See Also:
Constant Field Values

REFRESH_MODE_ON_CHANGE

public static final int REFRESH_MODE_ON_CHANGE
See Also:
Constant Field Values

REFRESH_MODE_ON_INTERVAL

public static final int REFRESH_MODE_ON_INTERVAL
See Also:
Constant Field Values

m_refreshType

public int m_refreshType
Constructor Detail

Track

protected Track(javax.microedition.lcdui.Display d,
                java.lang.String inUrl,
                java.lang.String inInfo,
                MapCanvas inCanvas)
Parameters:
d -
inUrl -
inInfo -

Track

protected Track(javax.microedition.lcdui.Display d,
                java.lang.String name)

Track

protected Track(javax.microedition.lcdui.Display d,
                int inRmsId)

Track

protected Track(javax.microedition.lcdui.Display d,
                javax.microedition.lcdui.Displayable reference,
                java.io.InputStream is,
                java.lang.String inInfo)
Method Detail

getTrack

public static Track getTrack(javax.microedition.lcdui.Display d,
                             java.lang.String name)
Create and get an empty track.

Parameters:
d - the current display
name - the new name of the track
Returns:

getTrack

public static Track getTrack(javax.microedition.lcdui.Display d,
                             java.lang.String inUrl,
                             java.lang.String inInfo,
                             MapCanvas inMap)
Create and get a track to be loaded from a specific URL

Parameters:
d - the current display
inUrl - the URL to load the track from
inInfo - the information to be displayed to the user...
inMap - : a referance to the canvas to display the URL. Used to "localize" the URL with the current area if needed
Returns:

getTrack

public static Track getTrack(javax.microedition.lcdui.Display d,
                             javax.microedition.lcdui.Displayable reference,
                             java.io.InputStream is,
                             java.lang.String inInfo)

addTrack

public static void addTrack(Track t)
Add an existing track to the list of Track. Only needed if the track as not been created through "getTrack" factory method. This method will add the track to the global list of track and calls if needed the notifier.

Parameters:
t: - the track to be added.

readLong

protected long readLong(byte[] b,
                        int off,
                        int length)

writeLong

protected static void writeLong(byte[] b,
                                int off,
                                int length,
                                long data)

setUrl

public void setUrl(java.lang.String inUrl,
                   MapCanvas inMap)

export

public void export(java.io.OutputStream os,
                   int typeExport)
Export the Track to an output stream.

Parameters:
os - the output streal to export the track
typeExport - the type of the export ( TYPE_EXPORT_GPX or TYPE_EXPORT_KML )

initTracks

public static void initTracks()
Init thr track list: open the RMS, read the saved track and add them into the global list of tracks.
Each track is not effectively loaded, only the informations on the track are loaded.


loadHeader

protected void loadHeader()
Load the header (from RMS) of the track. Usefull if you need information


clear

public void clear()
Clear all content of track...


parseFloat

public float parseFloat(java.lang.String inString)

inputStream

public boolean inputStream(java.io.InputStream is)
implemented for notifyLoadURL

Specified by:
inputStream in interface NotifyLoadURL
Returns:
false if loading must stop from here

error

public void error(int inErrorCode)
Specified by:
error in interface NotifyLoadURL

loaded

public void loaded(URLFetcher f)
Specified by:
loaded in interface NotifyLoadURL

lineRead

public boolean lineRead(URLFetcher f,
                        java.lang.String inLine)
Specified by:
lineRead in interface NotifyLoadURL
Returns:

setGlobalNotifier

public static void setGlobalNotifier(TrackNotifier tn)
Set the global notifier

Parameters:
tn -

setNotifier

public void setNotifier(TrackNotifier tn)
Set the notifier to this track only

Parameters:
tn -

sendTrack

public java.lang.String sendTrack(java.lang.String theUrl)
Post track to an url


loadTrack

public void loadTrack()

getTrack

public int[] getTrack()

getWaypoints

public java.util.Vector getWaypoints()

sendKML

protected void sendKML(java.io.OutputStream os)

sendGPX

protected void sendGPX(java.io.OutputStream os)

saveTrack

public void saveTrack()

addLoc

public void addLoc(OneLoc newLoc)
Add one location to display in the track


addRecord

public void addRecord(oneGPSPos newLoc)

delete

public void delete()
Delete this track. If track was loaded from RMS, this will also delete the RMS part...


setName

public void setName(java.lang.String inName)

getSizeTrack

public int getSizeTrack()

getNbWayPoints

public int getNbWayPoints()

getTimeStamp

public long getTimeStamp()

removeTrack

public static void removeTrack(Track t)
Delete and remove a track from the list of tracks...

Parameters:
t -

refreshTrack

public void refreshTrack(MapCanvas m_map)

setTrackListener

public void setTrackListener(TrackListener inListener)

fireSelected

public void fireSelected(OneLoc theLoc)

fireOpened

public boolean fireOpened(OneLoc theLoc)