|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.monarchy.guideme.data.PersonalLocation
public class PersonalLocation
PersonalLocation is the main service of the program, providing information about position and orientation of the mobile device. After binding to this class, any other component can be notified about changes in position, orientation and routing via handlers. PersonalLocation therefore provides two lists. MovementHandlers are getting updates about orientation and position changes, respectively indicated by the constants POSITION_CHANGED and ORIENTATION_CHANGED as described below. RoutingHandlers receive information when routing calls succeed or fail. Those, too, are indicated by constants ROUTING_FAILED and ROUTING_DONE. POSITION_CHANGED will provide a GeoCoordinate as m.obj. ORIENTATION_CHANGED provides a float[] as m.obj as described in SensorEvent. ROUTING_DONE delivers a RoutingPoint[] as m.obj. ROUTING_FAILED is only a notice and does not carry any additional data. Every given data should not be manipulated directly. If a Handler needs to do so, it should build a deep copy of the object to avoid side effects.
Field Summary | |
---|---|
static int |
CALCULATE_ROUTE_FROM_TO
status asking for routing service from a given point |
static int |
CALCULATE_ROUTE_TO
status asking for routing service from actual position |
Context |
context
context, needed for service connections |
Handler |
handler
handler for message queue |
static int |
KILL_COMMAND
kills the thread |
static int |
ORIENTATION_CHANGED
status telling that the orientation of the device changed |
static int |
POSITION_CHANGED
status telling that the position of the device changed |
static java.lang.String |
preferred_language
variable expressing the user's preferred language for pois |
static int |
ROUTING_DONE
status telling that a new route was calculated |
static int |
ROUTING_FAILED
status telling that a routing call was unsuccessful |
Constructor Summary | |
---|---|
PersonalLocation(Context c)
Creates a new data provider. |
Method Summary | |
---|---|
boolean |
addMovementHandler(Handler m)
Adds a Handler to this service, so external objects can retain information about the position of the device. |
boolean |
addRoutingHandler(Handler m)
Adds a Handler to this service, so external objects can retain information about changing routing information. |
void |
calculateRoute(GeoCoordinate to)
Convenience method for finding a route between the actual position and the given destination point. |
void |
calculateRoute(GeoCoordinate from,
GeoCoordinate to)
Calculates a route between the given points. |
void |
clearRoute()
Removes the calculated route. |
float[] |
getOrientation()
Returns the orientation of the device in an float array. |
POI[] |
getPOIs()
Returns an array of all known POIs. |
GeoCoordinate |
getPosition()
Returns the current position of the device as an GeoCoordinate. |
RoutePoint[] |
getRoute()
Returns the last route calculated by the service. |
void |
onError(int code)
This method is called if an error occured while calculating the route. |
void |
onRouteCalculated(RoutePoint[] points)
Delivers a route to the Listener. |
void |
onStart()
Registers the position listener at system services so the thread is able to maintain information. |
void |
onStop()
Cuts the location service off the system services, so that it will no longer get informations about position or orientation updates. |
void |
registerPositionListener()
Registers the service's listener to the best location service available. |
boolean |
removeMovementHandler(Handler m)
Removes a handler from this service. |
boolean |
removeRoutingHandler(Handler m)
Removes a handler from this service. |
void |
run()
|
void |
setOrientation(float[] orientation)
Sets the orientation of the device. |
void |
setPosition(GeoCoordinate position)
Sets the position of the device. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int KILL_COMMAND
public static final int ORIENTATION_CHANGED
public static final int POSITION_CHANGED
public static final int ROUTING_DONE
public static final int ROUTING_FAILED
public static final int CALCULATE_ROUTE_TO
public static final int CALCULATE_ROUTE_FROM_TO
public static java.lang.String preferred_language
public Context context
public Handler handler
Constructor Detail |
---|
public PersonalLocation(Context c)
c
- context the object is living inMethod Detail |
---|
public float[] getOrientation()
public void setOrientation(float[] orientation)
orientation
- new orientation as described in SensorEventpublic RoutePoint[] getRoute()
public void clearRoute()
public GeoCoordinate getPosition()
public void setPosition(GeoCoordinate position)
position
- new position of the devicepublic void calculateRoute(GeoCoordinate from, GeoCoordinate to)
from
- starting pointto
- destination pointpublic void calculateRoute(GeoCoordinate to)
to
- destination point.public boolean addMovementHandler(Handler m)
m
- new handler
public boolean removeMovementHandler(Handler m)
m
- handler to be removed
public boolean addRoutingHandler(Handler m)
m
- new handler
public boolean removeRoutingHandler(Handler m)
m
- handler to be removed
public void registerPositionListener()
public void onError(int code)
RoutingListener
onError
in interface RoutingListener
code
- a constant value from RoutingComponent indicating the type of
errorpublic void onRouteCalculated(RoutePoint[] points)
RoutingListener
onRouteCalculated
in interface RoutingListener
points
- RoutePoint[] with turning pointspublic POI[] getPOIs()
public void run()
run
in interface java.lang.Runnable
public void onStop()
public void onStart()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |