Tip: Wayfinding is demonstrated in complete runnable Wayfinding code example


Wayfinding is done on a graph created by the IA wayfinding graph editor (see Wayfinding graph).


To use the IndoorAtlas Wayfinding in your project, you need to first setup the positioning SDK. After this, you need to add the dependencies to IndoorAtlas Wayfinding:


dependencies {
    compile 'com.indooratlas.android:indooratlas-android-wayfinding:2.8.0@aar'
}



Using the wayfinder


To begin, first initialize the IndoorAtlas positioning SDK with valid credentials


// Initialize the IALocationManger
IALocationManager mLocationManager =
        IALocationManager.create(context, extras);



Then initialize the IndoorAtlas wayfinder (IAWayfinder) using the wayfinding graph together with the application context:


// Load the JSON file to String graphJSON
IAWayfinder wayfinder = IAWayfinder.create(context, graphJson);


To start routing an user to a given destination, first set the destination in the wayfinder:


// Set the latitude, longitude and floor number
wayfinder.setDestination(60.1684003, 24.9306895, 1);


The route from the current location to destination is obtained by first setting the user’s location and then calling getRoute:


// Set the latitude, longitude and floor number
wayfinder.setLocation(60.1696597, 24.932497, 1);
IARoutingLeg[] route = wayfinder.getRoute();
// empty if route could not be found, otherwise list of legs




Example route in Kamppi center



Route is a list of legs where each leg is a straight line segment. The legs also contain pointers to the original nodes and edges of the wayfinding graph, to allow linking to possibly relevant meta data, but using that information is often not mandatory. One leg (IARoutingLeg) in the route list contains the following variables:


IARoutingPoint begin;
IARoutingPoint end;
double length;
double direction;
java.lang.Integer edgeIndex;


where the IARoutingPoints contain the following variables:


double latitude;
double longitude;
int floor;
java.lang.Integer nodeIndex;


The variables edgeIndex and nodeIndex point to edges and nodes in the original graph. Note that the index variables can be null for the first and last legs of the route, that present the final connections between the graph and arbitrary off-graph locations.


The begin node of the first leg is always the starting location and the end node of the last leg is the destination. The returned route can also be empty if no possible route was found. This can happen if the given destination or start location floor number does not exist in the wayfinding graph (e.g., if one would do something like wayfinder.setLocation(60.2, 24.9, 1000);).