Dennis Laumen We who cut mere stones must always be envisioning cathedrals

Debugging JSR-179 using OpenLAPI

Global Positioning System

Developing a J2ME application using the Location API can be pretty annoying. It's quite difficult debugging *an application which uses a GPS device as a form of input. You usually *can't get a GPS fix in a building (which is where most people do their developing) and even then you would have to continually get up and walk around to see if your new bit of code functions properly.OpenLAPI to the rescue! OpenLAPI is an open source implementation of JSR-179 (J2ME's Location API). It contains the complete JSR-179 API and then some... One of the extra features solves the aforementioned debugging problem. We'll come back to those features later on in this post.In a previous blog post you read how to create an instance of the LocationProvider. The LocationProvider is basically an abstract factory and instances are built on a set of criteria. As a developer you don't have any direct control over what type of LocationProvider you receive. You just tell the API which demands you have and the API gives you the implementation closest to your demands.

LocationProvider provider = LocationProvider.getInstance(new Criteria());

OpenLAPI however gives developers some extra flexibility when creating a LocationProvider. You can choose to use either a GPS device, an NMEA log file, a KML file, a LandmarkStore or your own specific implementation of the LocationProvider class. All you have to do is add a configuration file called OpenLAPI-mode.txt to the root of your MIDlet. In this file you place GPS, NMEA, KML, LMS (for the LandmarkStore) or the full class name (including packages) of your own LocationProvider implementation. Now all we need to do is add one of the log files in the same directory as the configuration file and we are done (more details can be found here).Using the feature mentioned in the paragraph above we can now debug our application with ease. We can use NMEA logs from GPS devices or create a route in Google Earth and export it to KML. Doing this really makes GPS development a lot quicker and more reliable.