com.nutiteq.location.providers
Class CellIdLocationProvider

java.lang.Object
  extended by java.util.TimerTask
      extended by com.nutiteq.location.providers.CellIdLocationProvider
All Implemented Interfaces:
CellIdResponseWaiter, LocationSource, java.lang.Runnable
Direct Known Subclasses:
MotorolaCellIdLocationProvider, SonyEricssonCellIdLocationProvider

public class CellIdLocationProvider
extends java.util.TimerTask
implements CellIdResponseWaiter, LocationSource

Generic cell id location positioning handler. Supports single location query or polling at given interval. Pushes retrieved location in WGS84 to LocationListener. If location could not be determined, then null will be pushed into marker and status changes to LocationSource.STATUS_CANT_LOCATE.


Field Summary
 
Fields inherited from interface com.nutiteq.location.LocationSource
STATUS_CANT_LOCATE, STATUS_CONNECTED, STATUS_CONNECTING, STATUS_CONNECTION_LOST
 
Constructor Summary
CellIdLocationProvider(CellIdDataReader cellIdDataReader, CellIdService cellIdService)
          Create location provider for single query
CellIdLocationProvider(CellIdDataReader dataReader, CellIdService cellIdService, long updateInterval)
          Create location provider that queries for location at given interval
 
Method Summary
 void addLocationListener(LocationListener listener)
          Add listener for location coordinates
 void cantLocate()
           
 WgsPoint getLocation()
           
 LocationMarker getLocationMarker()
          Get location marker used on screen
 java.lang.String getMethod()
          Method of positioning, depending on implementation e.g.
 java.lang.Object getNativeLocation()
          Provides native location object with last info, e.g.
 int getStatus()
          Get status code for location source.
 void locationRetrieved(WgsPoint wgsPoint)
           
 void notifyError()
           
 void quit()
          Quit location polling
 void run()
           
 void setLocationMarker(LocationMarker marker)
          Set location marker where to push location updates
 void start()
          Start location polling
 
Methods inherited from class java.util.TimerTask
cancel, scheduledExecutionTime
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CellIdLocationProvider

public CellIdLocationProvider(CellIdDataReader cellIdDataReader,
                              CellIdService cellIdService)
Create location provider for single query

Parameters:
cellIdDataReader - data reader used for cellid data accessing
cellIdService - service to convert cellid to lat/long

CellIdLocationProvider

public CellIdLocationProvider(CellIdDataReader dataReader,
                              CellIdService cellIdService,
                              long updateInterval)
Create location provider that queries for location at given interval

Parameters:
dataReader - data reader used for cellid data access
updateInterval - update interval for location query
Method Detail

run

public void run()
Specified by:
run in interface java.lang.Runnable
Specified by:
run in class java.util.TimerTask

start

public void start()
Description copied from interface: LocationSource
Start location polling

Specified by:
start in interface LocationSource

getStatus

public int getStatus()
Description copied from interface: LocationSource
Get status code for location source.

Specified by:
getStatus in interface LocationSource
Returns:
status code

notifyError

public void notifyError()
Specified by:
notifyError in interface CellIdResponseWaiter

getLocationMarker

public LocationMarker getLocationMarker()
Description copied from interface: LocationSource
Get location marker used on screen

Specified by:
getLocationMarker in interface LocationSource
Returns:
associated location marker

quit

public void quit()
Description copied from interface: LocationSource
Quit location polling

Specified by:
quit in interface LocationSource

setLocationMarker

public void setLocationMarker(LocationMarker marker)
Description copied from interface: LocationSource
Set location marker where to push location updates

Specified by:
setLocationMarker in interface LocationSource
Parameters:
marker - marker displayed on screen

cantLocate

public void cantLocate()
Specified by:
cantLocate in interface CellIdResponseWaiter

locationRetrieved

public void locationRetrieved(WgsPoint wgsPoint)
Specified by:
locationRetrieved in interface CellIdResponseWaiter

getLocation

public WgsPoint getLocation()
Specified by:
getLocation in interface LocationSource

addLocationListener

public void addLocationListener(LocationListener listener)
Description copied from interface: LocationSource
Add listener for location coordinates

Specified by:
addLocationListener in interface LocationSource
Parameters:
listener - listener to be added

getMethod

public java.lang.String getMethod()
Description copied from interface: LocationSource
Method of positioning, depending on implementation e.g. "GPS", "AGPS" etc Useful for debugging

Specified by:
getMethod in interface LocationSource
Returns:
used location method as string

getNativeLocation

public java.lang.Object getNativeLocation()
Description copied from interface: LocationSource
Provides native location object with last info, e.g. Location in JSR-172

Specified by:
getNativeLocation in interface LocationSource
Returns:
implementation-specific Object holding last location