Java SDK for 2D
 All Classes Namespaces Functions Variables Pages
ApiNavigation Class Reference

Static Public Member Functions

static GpsPosition getActualGpsPosition (boolean satInfo, int maxTime) throws GpsException
 Returns informations about actual GPS position. More...
 
static RouteInfo getRouteInfo (boolean extended, int maxTime) throws GeneralException
 Returns informations about computed route. More...
 
static void startNavigation (WayPoint location, int flags, boolean searchAddress, int maxTime) throws NavigationException
 Starts navigation to a given location. More...
 
static void startNavigation (WayPoint location, int flags, boolean searchAddress, RouteComputeSettings rcs, int maxTime) throws NavigationException
 Starts navigation to a given location. More...
 
static void stopNavigation (int maxTime) throws GeneralException
 Stops navigation and the current route is canceled. More...
 
static void navigateToAddress (String strAddress, boolean postal, int flags, int maxTime) throws NavigationException
 Computes route from actual GPS position to taken target and starts navigate to taken address. More...
 
static void loadComputedRoute (String routePath, int maxTime) throws GeneralException
 Loads a pre-computed route from a file and starts navigation following that route. More...
 
static void loadComputedRoute (String routePath, int startWpId, int maxTime) throws GeneralException
 Loads a pre-computed route from a file and starts navigation following that route. More...
 
static void saveComputedRoute (String routePath, int maxTime) throws GeneralException
 Saves the current route in navigation to a file. More...
 
static void loadOFGRoute (String routePath, int startFromIndex, int flags, int maxTime) throws GeneralException
 Loads an offroad guided route (OFG) and starts navigation following that route. More...
 
static String getOFGRouteStatus (int maxTime) throws GeneralException
 Gets the status of currently loaded guided (OFG) route in JSON format. More...
 
static void saveOFGRoute (String fileName, int fromIndex, Position fromPos, int toIndex, Position toPos, int maxTime) throws GeneralException
 Saves sub-route of currently loaded guided (OFG) route. More...
 

Static Public Attributes

static final int ASK_DELETE_ROUTE = 0x00000002
 NpAskDeleteRoute commands Navigation to ask user to delete computed route. More...
 
static final int MESSAGE_AVOID_MOTORWAYS_ENABLE = 0x00000004
 NpMessageAvoidMotorwaysUnable commands Navigation to notice user that not all motorways can be avoided. More...
 
static final int MESSAGE_AVOID_TOLL_ROADS_ENABLE = 0x00000008
 NpMessageAvoidTollRoadsUnable commands Navigation to notice user that not all toll roads can be avoided. More...
 
static final int MESSAGE_AVOID_FERRIES_ENABLE = 0x00000010
 NpMessageAvoidFerriesUnable commands Navigation to notice user that not all ferries can be avoided. More...
 
static final int MESSAGE_ROUTE_ENABLE = 0x00000020
 NpMessageRouteUnable commands Navigation to notice user that route can not be computed. More...
 
static final int MESSAGE_WAYPOINTS_DISTANT = 0x00000040
 NpMessageWaypointsDistant commands Navigation to notice user that route can not be computed because of too big distance between start and destination points. More...
 
static final int FLAG_OFG_DEFAULT = 0x00000000
 commands navigation to load OFG route and switch to offroad mode. More...
 
static final int FLAG_OFG_SHOW_ONLY = 0x00000001
 commands navigation to show OFG route on map, but it will not switch to offroad mode and progress of guided route will not be computed. More...
 

Member Function Documentation

static GpsPosition getActualGpsPosition ( boolean  satInfo,
int  maxTime 
) throws GpsException
static

Returns informations about actual GPS position.

Parameters
satInfoFlag determining whether function should return satellites information.
maxTimeMaximum of time (in milliseconds) function can take. If maxTime=0 function execution is not time limited.
Returns
model.GpsPosition instance which contains informations about GPS position.
Remarks
The function getActualGpsPosition needs Navigation to have valid GPS position. If valid GPS position is not present, function returns null.
Exceptions
GpsExceptionthe gps exception

References Api.getInstance(), Api.getService(), and GpsPosition.readBundle().

static String getOFGRouteStatus ( int  maxTime) throws GeneralException
static

Gets the status of currently loaded guided (OFG) route in JSON format.

Parameters
maxTimeMaximum of time (in milliseconds) function can take. If maxTime=0 function execution is not time limited.
Returns
status of currently loaded guided (OFG) route in JSON format
Exceptions
GeneralExceptionGeneralException#getCode()

References Api.getInstance(), and Api.getService().

static RouteInfo getRouteInfo ( boolean  extended,
int  maxTime 
) throws GeneralException
static

Returns informations about computed route.

Parameters
extendeddescribes whether to return time and distance to each of the waypoints on the route
maxTimeMaximum of time (in milliseconds) function can take. If maxTime=0 function execution is not time limited.
Returns
the model.RouteInfo instance that contains the route information
Remarks
GetRouteInfo fills in RouteInfo members.
Status member of RouteInfo determines status of the route. Possible values are:
  • 0x0001 - Computing
  • 0x0002 - Computed
  • 0x0010 - EnumeratingJunctions
  • 0x0020 - ReconstructRoute
Only if Status=0x0002 (Computed) you can be sure than other members of model.RouteInfo are valid.
Destination of route is possible obtain from ApiItinerary#getItineraryList(String, int) method.
Exceptions
GeneralExceptionthe general exception

References Api.getInstance(), Api.getService(), and RouteInfo.readBundle().

static void loadComputedRoute ( String  routePath,
int  maxTime 
) throws GeneralException
static

Loads a pre-computed route from a file and starts navigation following that route.

Parameters
routePathPath and filename of the RSAV file, from which is the saved route loaded.
maxTimeMaximum of time (in milliseconds) function can take. If maxTime=0 function execution is not time limited.
Exceptions
GeneralExceptionthe general exception

References Api.getInstance(), and Api.getService().

static void loadComputedRoute ( String  routePath,
int  startWpId,
int  maxTime 
) throws GeneralException
static

Loads a pre-computed route from a file and starts navigation following that route.

Parameters
routePathPath and filename of the RSAV file, from which is the saved route loaded.
startWpIdthe start waypoint id
maxTimeMaximum of time (in milliseconds) function can take. If maxTime=0 function execution is not time limited.
Exceptions
GeneralExceptionthe general exception

References Api.getInstance(), and Api.getService().

static void loadOFGRoute ( String  routePath,
int  startFromIndex,
int  flags,
int  maxTime 
) throws GeneralException
static

Loads an offroad guided route (OFG) and starts navigation following that route.

Parameters
routePathpath and file name of the OFG file to be loaded
startFromIndexstart index of the route
maxTimeMaximum of time (in milliseconds) function can take. If maxTime=0 function execution is not time limited.
flagsdetermines route loading behavior, see FLAG_OFG_DEFAULT
Exceptions
ref exception.GeneralException::getCode()

References Api.getInstance(), and Api.getService().

static void navigateToAddress ( String  strAddress,
boolean  postal,
int  flags,
int  maxTime 
) throws NavigationException
static

Computes route from actual GPS position to taken target and starts navigate to taken address.

Parameters
strAddressSpecifies address of route target. Address must be in "ISO,city/ZIP, street, house number" format
postalFlag determining whether second address parameter represents city or ZIP code.
  • true - ZIP code
  • false - City
flagsDetermines route computing properties.
maxTimeMaximum of time (in milliseconds) function can take. If maxTime=0 function execution is not time limited.
Remarks
To use this function it is necessary to have valid GPS signal and Location must be situated on loaded map. It is necessary to set Location member of Location.
Parameter flags determines some route computing properties. Possible values are enumerated in ApiNavigation enum. For example, it is possible notify user that not all toll roads can be avoided.
To join more flags together use logical or operator (|).
Address parameter house number is optional. If you do not want to fill it write address like this:
"SVK,Bratislava,Einsteinova,"
Second address parameter can represent city name or ZIP code.
The list of ISO codes can be found at http ://userpage.chemie.fu-berlin.de/diverse/doc/ISO_3166.html.
ISO code of United States of America consists of character "U" plus code of state. E.g New York has ISO code UNY.

Example:

int flags = DriveNavigation.MESSAGE_AVOID_TOLL_ROADS;
boolean searchAddress = true;
boolean postal = false;
String strAddress = "SVK,Bratislava,Einsteinova,1";
int maxTime = 10000;
ApiNavigation.navigateToAddress(strAddress, postal, flags, maxTime);
Exceptions
NavigationExceptionthe navigation exception

References Api.getInstance(), and Api.getService().

static void saveComputedRoute ( String  routePath,
int  maxTime 
) throws GeneralException
static

Saves the current route in navigation to a file.

Parameters
routePathPath and filename of the RSAV file, from which is the saved route loaded.
maxTimeMaximum of time (in milliseconds) function can take. If maxTime=0 function execution is not time limited.
Exceptions
GeneralExceptionthe general exception

References Api.getInstance(), and Api.getService().

static void saveOFGRoute ( String  fileName,
int  fromIndex,
Position  fromPos,
int  toIndex,
Position  toPos,
int  maxTime 
) throws GeneralException
static

Saves sub-route of currently loaded guided (OFG) route.

Parameters
fileNamename of the file where the route will be saved
fromIndexindex of current route that will be first in the new route. If set to -1, it will start from beginning and fromPos will be ignored.
fromPosfirst point of new route
toIndexindex of current route that will be last in the new route. If set to -1, it will go to end and toPos will be ignored.
toPoslast point of new route
maxTimeMaximum of time (in milliseconds) function can take. If maxTime=0 function execution is not time limited.
Exceptions
GeneralExceptionGeneralException#getCode() if no guided route is loaded or it was not possible to save file

References Api.getInstance(), and Api.getService().

static void startNavigation ( WayPoint  location,
int  flags,
boolean  searchAddress,
int  maxTime 
) throws NavigationException
static

Starts navigation to a given location.

Parameters
locationmodel.WayPoint instance which contains information about target.
flagsDetermines route computing properties.
searchAddressFlag determining whether ApiHistory.getHistoryList(boolean, int) searches for address or not.
  • StartNavigation fills address member of each model.HistoryRecord with corresponding address
  • StartNavigation does not search for address
maxTimethe max time
Exceptions
NavigationExceptionthe navigation exception
Remarks
To use this function it is necessary to have valid GPS signal and Location must be situated on loaded map. It is necessary to set Location member of Location.
Parameter flags determines some route computing properties. Possible values are enumerated in ApiNavigation enum. For example, it is possible notify user that not all toll roads can be avoided.
To join more flags together use logical or operator (|).
It is possible to get returned (if address is returned) address by calling WayPoint#getStrAddress() function.

Example:

WayPoint location = new WayPoint();
int flags;
boolean searchAddress;
Position pos = new Position();
String strAddress = "SVK,Bratislava,Einsteinova,1";
int maxTime;
ApiNavigation.locationFromAddress(pos, strAddress, maxTime);
WayPoint wp = new WayPoint(strAddress, pos.getX(), pos.getY());
flags = NavigationParams.NpMessageAvoidTollRoadsUnable;
searchAddress = true;
maxTime = 10000;
ApiNavigation.startNavigation(wp, flags, searchAddress, maxTime);

References Api.getInstance(), Api.getService(), and WayPoint.writeBundle().

static void startNavigation ( WayPoint  location,
int  flags,
boolean  searchAddress,
RouteComputeSettings  rcs,
int  maxTime 
) throws NavigationException
static

Starts navigation to a given location.

Parameters
locationmodel.WayPoint instance which contains information about target.
flagsDetermines route computing properties.
searchAddressFlag determining whether ApiHistory#getHistoryList(boolean, int) searches for address or not.
  • StartNavigation fills address member of each model.HistoryRecord with corresponding address
  • StartNavigation does not search for address
maxTimethe max time
rcsspecial route computing settings
Exceptions
NavigationExceptionthe navigation exception
Remarks
To use this function it is necessary to have valid GPS signal and Location must be situated on loaded map. It is necessary to set Location member of Location.
Parameter flags determines some route computing properties. Possible values are enumerated in ApiNavigation enum. For example, it is possible notify user that not all toll roads can be avoided.
To join more flags together use logical or operator (|).
It is possible to get returned (if address is returned) address by calling WayPoint#getStrAddress() function.

Example:

WayPoint location = new WayPoint();
int flags;
boolean searchAddress;
Position pos = new Position();
String strAddress = "SVK,Bratislava,Einsteinova,1";
int maxTime;
ApiNavigation.locationFromAddress(pos, strAddress, maxTime);
WayPoint wp = new WayPoint(strAddress, pos.getX(), pos.getY());
flags = NavigationParams.NpMessageAvoidTollRoadsUnable;
searchAddress = true;
maxTime = 10000;
ApiNavigation.startNavigation(wp, flags, searchAddress, maxTime);

References Api.getInstance(), Api.getService(), RouteComputeSettings.writeBundle(), and WayPoint.writeBundle().

static void stopNavigation ( int  maxTime) throws GeneralException
static

Stops navigation and the current route is canceled.

Parameters
maxTimeMaximum of time (in milliseconds) function can take. If maxTime=0 function execution is not time limited.
Exceptions
GeneralExceptionthe general exception

References Api.getInstance(), and Api.getService().

Member Data Documentation

final int ASK_DELETE_ROUTE = 0x00000002
static

NpAskDeleteRoute commands Navigation to ask user to delete computed route.

Navigation asks user to delete computed route before computing new route if some route is computed.

final int FLAG_OFG_DEFAULT = 0x00000000
static

commands navigation to load OFG route and switch to offroad mode.

final int FLAG_OFG_SHOW_ONLY = 0x00000001
static

commands navigation to show OFG route on map, but it will not switch to offroad mode and progress of guided route will not be computed.

final int MESSAGE_AVOID_FERRIES_ENABLE = 0x00000010
static

NpMessageAvoidFerriesUnable commands Navigation to notice user that not all ferries can be avoided.

Navigation shows message which notice user that not all ferries can be avoided if user wished to avoid them.

final int MESSAGE_AVOID_MOTORWAYS_ENABLE = 0x00000004
static

NpMessageAvoidMotorwaysUnable commands Navigation to notice user that not all motorways can be avoided.

Navigation shows message which notice user that not all motorways can be avoided if user wished to avoid them.

final int MESSAGE_AVOID_TOLL_ROADS_ENABLE = 0x00000008
static

NpMessageAvoidTollRoadsUnable commands Navigation to notice user that not all toll roads can be avoided.

Navigation shows message which notice user that not all toll roads can be avoided if user wished to avoid them.

final int MESSAGE_ROUTE_ENABLE = 0x00000020
static

NpMessageRouteUnable commands Navigation to notice user that route can not be computed.

For example this could happen if start or destination point of route are out of loaded maps.

final int MESSAGE_WAYPOINTS_DISTANT = 0x00000040
static

NpMessageWaypointsDistant commands Navigation to notice user that route can not be computed because of too big distance between start and destination points.

For example if route is computed for walking.