Core library usage
The main entry point is the ImgFilesBag class. You basically instanciate it and add some IMG files in it:
ImgFilesBag maps=new ImgFilesBag();
File file=new File("/home/patrick/gps/maps/00000002.img");
maps.addFile(file);
Or else, you can add a whole directory in it:
maps.addDirectory(new File("/home/patrick/gps/maps"));
The directory must contain at the same level a set of IMG files and, optionally a PDB file. The presence of the PDB file will speed-up the initial reading since this file contains an index of the IMG files.
Then to read the content of the map, you have to create a listener that will receive the different objects the map is composed of:
public static class TestListener implements MapListener
{
public void addPoint(int type, int subType, int longitude, int latitude,
Label label, boolean indexed)
{
... your code here ...
}
public void addPoly(int type, int[] longitudes, int[] latitudes,
int nbPoints, Label label, boolean line)
{
... your code here ...
}
public void startMap(ImgFileBag file)
{
... your code here ...
}
public void startSubDivision(SubDivision subDivision)
{
... your code here ...
}
public void finishPainting()
{
... your code here ...
}
}
Finally, you call one of the following:
//for having the objects read as fast as possible
map.read(minLon, maxLon, minLat, maxLat, resolution, ObjectKind.ALL, null, listener);
//for having the objects in an order suitable for drawing
maps.readMapForDrawing(minLon, maxLon, minLat, maxLat, resolution, ObjectKind.ALL, listener);
From here, you can do whatever you want with the data. If you want to display it in a Swing application, see this page.