IndoorWPS Library

The project IndoorWPSLib contains the core logic, such as the calculation algorithms and other platform independent things. However, if you want to create a location-aware application, you need to add some platform-dependent stuff. Currently there is support for the android platform, through the IndoorWPSAndroid project and there is support for Mac OS X, Windows and Linux through project:indoorwpspclib.

Code

Project / Packages

The Code is divided in several projects to avoid special platform dependencies.
There is the core library which calculates the position depending on the visible accesspoints.
The Interface and a dummy scanner are defined in the basic lib project.
The scanning of the accesspoints itself is implemented in the Pc / Android project.

The Pc / Android application which uses the position information uses the classes in the lib project but also provides the specific scanner classes and database adapter to the lib.

Dataflow

If the Pc / Android application would like to be informed if a new position is calculated, or there are some changes in the status of the calculation / scanning classes, they could register listeners.

Build your Application on Mac OS X / Linux / Windows

To Build an application on a PC-System, all you need to do is to add the IndoorWPSLib and the IndoorWPSPc to your classpath. You can either manually check out the code from our SVN-Repository(listed in the section code) and build it(there is an ant task dist, which runs all tests and creates a jar) or use the newest builds from our Hudson Buildserver.

You will also need to have the sqlitejdbc library on your classpath, which you can get here. We are using version v056 at the moment. This is needed because we store our data in a indoorwps.sqlite file. Of course you could change this to your favourite DBMS, as long as it supports JDBC. take a closer look at IndoorWPS.java in the IndoorWPSPc project.

Having the libraries on your classpath, all you have to do is instantiate a IndoorWPS.

wps = new IndoorWPS();

this will automatically choose the appropriate AccessPointScanner, depending on your system. It will also create a sqlite-database at indoorwps.sqlite.
After that, you can register to the IndoorWPS for location-related events. you do this by calling:

wps.getLocator().addLocationListener(new LocationListener() {
    public void onStatusChanged(int newStatus) {
        // ...
    }
    public void onLocationChanged(Location newLocation) {
        // ...
        }
});

You could also query the IndoorWPS for the last location, if you don't want to register a LocationListener

wps.getLocation();

To get some Fingerprints in your database, you could either restore a Backup, containing a whole Database and therefore repalcing the current one, or query the webservice to download the data.
loading a Backup is easy, just call:

Backup.restoreBackup(sourceZip, imagesDirectory);

The sourceZip is the zipfile, created by the Backup-class, which contains the database-file and the georeferenced images. Such a Backup could be created with:

Backup.createBackup(targetZip, imagesDirectory)

The imagesDirectory is a directory on your local machine where you want the georeferenced images to be. This is usually something like ''Applicationroot/data/iamges''. The restoreBackup() method will unzip the images to this directory and update the Map-Objects to reference the image correctly. calling:

geomap.getImage();

will return an Image object, which can be painted on a Canvas or wherever you want.

If you want to get your data from the webservice, you would invoke:

FingerprintWsClient client = new FingerprintWsClient();
client.loadFingerprints(1.0,1.0,1.0E9);  // Load all fingerprints in the world

for Geomaps, you would make a call to:

GeomapWsClient mapClient = new GeomapWsClient(imagesDirectory);
mapClient.loadAllGeomaps();

this will load all availible Geomaps into the imagesDirectory.
if you don't want all maps, you could first call

List<Geomap> availibleMaps = mapClient.loadAllGeomapsForPreview();

which will only download the map data, not the images.
you could now choose from this list and than download your maps by calling:

geomapWsClient.loadGeomap(map.getRemoteId());

where map in from the availibleMaps list.

If you don't want to work with the default webservice, provided at http://geometa.hsr.ch/indoorwps/, you can costumize this url with a call to the static method

WsClient.setWebserviceUrl("The new url");  // make sure the url ends with a '/'!

The classes FingerprintLoader, respectively GeomapLoader are designed to query your local database and offer methods to select the maps or Fingerprints you want to work with.

If you just need to know where your user is and don't really care about geomaps or fingerprint, here is a code-snippet that sets-up a running system, with all Fingerprints and Geomaps availible on the IndoorWPSCommunityServer

wps = new IndoorWPS();
// either
GeomapWsClient mapClient = new GeomapWsClient(new File("data/images"));
mapClient.loadAllGeomaps();
FingerprintWsClient client = new FingerprintWsClient();
client.loadFingerprints(1.0,1.0,1.0E9);  // Load all fingerprints in the world
// or
Backup.restoreBackup(new File("your-prepared-backup-file.zip"), new File("data/images");

wps.getLocator().addLocationListener(new LocationListener() {
    public void onStatusChanged(int newStatus) {
        // this will get if the status of the IndoorWPS changed(user switched of wireless, switched it on, ...)
    }
    public void onLocationChanged(Location newLocation) {
        // this will get called everytime a new location is calculated
        }
});
wps.resumeScanning();

This is it, you now have a running system, and calls to

wps.resumeScanning();

or

wps.stopScanning();

will controll your IndoorWPS-System.

Build your Application on Android

If you would like to start using the IWPS Library in your Android Application following these Steps:
1. Build a jar file with the library and the android specific files.
Check out the code of the IndoorWPSLibrary and IndoorWPSAndroid projects. Build a simple jar with only the files in the src folders.

Or you can download the last build from our Hudson Buildserver

2. Create a new Android project and add this library to the buildpath
3. To start the IndoorWPSLocator set the the correct database driver and signal provider with this code

try {
    Class.forName("com.lemadi.storage.database.sqldroid.SqldroidDriver");
} catch (ClassNotFoundException e) {}

ActiveRecordManager.setDatabase("jdbc:sqldroid:" + getDir("data", 0) + "/indoorwps.sqlite");    
WlanLocator mWlanLocator = new WlanLocator(true);
mWlanLocator.getAccessPointScanner().setWlanProvider(new AndroidWlanSignalProvider(this));

4. To get actual positions you can register a listener or ask the locator for a position.

mWlanLocator.addLocationListener(new LocationListener() {        
    @Override
    public void onStatusChanged(int arg0) { /* your code */ }

    @Override
    public void onLocationChanged(Location arg0) { /* your code */ }
});
or
mWlanLocator.getLocation();

5. To download fingerprints (required to calculate a position) you can use the update methods from the FingeprintWsClient class

FingerprintWsClient client = new FingerprintWsClient();
client.loadFingerprints(1.0,1.0,1.0E9);  // Load all fingerprints in the world

build-jar.png (28.5 KB) Anonymous, 01/20/2011 01:56 PM

overview.png (9.1 KB) Anonymous, 01/20/2011 01:56 PM

StatusListener.png (29.4 KB) Anonymous, 01/20/2011 01:56 PM