skip to main content
Programmer's documentation > Programming with JViews Maps for Defense > Readers and writers > The VMAP Reader
 
The VMAP Reader
Describes the VMAP readers provided.
*Overview
*Provides general information on the VMAP reader.
*The IlvVMAPReader class
*Describes the IlvVMAPReader class.
*Using the IlvVMAPReader class to create images
*Explains how to create a VMAP reader, limit the features to be read and create a default renderer.
*The IlvVMAPDataSource class
*Describes the IlvVMAPDataSource class.
*Using the IlvVMAPDataSource class to create vector data
*Explains how to create a VMAP data source, limit the features to be read and read the data.
Overview
VMAP (see VMAP format) is a comprehensive vector base map of the world. It consists of cartographic, attribute, and textual data, usually stored on CD-ROM in a specified file and folder structure. The data is tiled and spatially indexed for rapid access. The precision levels for VMAP data for JViews Maps for Defense are: level 0 (1:1,000,000 scale), level 1 (1:250,000 scale), and level 2 (1:100,000 and 1:50,000 scale). VMAP data is in geographic projection and coordinates are expressed in degrees.
There are two ways of reading VMAP data:
*Use an IlvVMAPReader instance directly. In this case, you must write all of the code required to render the VMAP map features into graphic objects, and to add them to the manager.
*Use an IlvVMAPDataSource. This is a convenient way of performing all of the above operations at once and is more integrated with the data model of the map.
The source code for the Map Builder demonstration, which contains all of the code described in this section, can be found at <installdir> /jviews-maps/samples/mapbuilder/index.html.
The IlvVMAPReader class
This class reads VMAP features from a specified VMAP database. It implements” the IlvMapFeatureIterator interface to iterate over the read features.
Using the IlvVMAPReader class to create images
To read VMAP features using the IlvVMAPReader object:
1. Create an IlvVMAPReader instance from the path of the VMAP database (the directory containing DHT and LAT files, parent of the libraries):
 
String databasePath = "C:/VMAP/vmaplv0/";
IlvVMAPReader VMAPReader = new IlvVMAPReader(databasePath);
2. You must also specify the library to read. The libraries available in a database correspond to the sub-directories of the database directory. Here we assume that the database directory is vmaplv0 and that there is a subdirectory vmaplv0/eurnasia :
 
VMAPReader.setLibraryName("eurnasia"); // this is Europe and Northern Asia
library
3. Optionally, you can specify the region of interest (in degrees). Only features of this area are read:
 
VMAPReader.setRegionOfInterest(0,30,15,45);
4. You can also limit what is read to features specified by particular FACC codes (for further information about FACC codes, refer to the VMAP format specification). For instance, to read only roads, you can use:
 
VMAPReader.setFaccFilter(new String[]{"AP030"});
5. Finally, iterate over the features, render them with an appropriate IlvFeatureRenderer, and assign them to a manager:
 
IlvMapFeature feature = VMAPReader.getNextFeature();
IlvManager manager = view.getManager();
 
// Create default renderer
IlvFeatureRenderer renderer = new IlvDefaultFeatureRenderer();
 
while(feature != null) {
 
  // Render map feature into graphic object
  IlvGraphic graphic = renderer.makeGraphic(feature,null);
 
  // Add this object on the first layer of the manager
  manager.addObject(graphic, 0, false);
 
  feature = VMAPReader.getNextFeature();
}
The IlvVMAPDataSource class
The IlvVMAPDataSource class provides a convenient way of creating a layer containing VMAP data in a manager. You can also use the load-on-demand mechanism as VMAP data sets can be quite big.
Using the IlvVMAPDataSource class to create vector data
To read VMAP features using the IlvVMAPDataSource: object:
1. Create an IlvVMAPDataSource. Note that the path of the VMAP library, not the path of the database, must be passed to the constructor:
 
String libraryPath = ":/VMAP/vmaplv0/eurnasia";
IlvVMAPDataSource VMAPSource = new IlvVMAPDataSource(libraryPath);
 
// connect this data source with the manager of the view
VMAPSource.setManager(getView().getManager());
2. Select the map features you want to read by specifying the FACC codes for those features (for further information about FACC codes, refer to the VMAP format specification). For instance, to read only roads, you can use:
 
VMAPSource.setFaccCodeList(new String[]{"AP030"});
3. Specify the area of interest (in degrees). Only features in this area are read:
 
VMAPSource.setAreaOfinterest(Math.toRadians(0),Math.toRadians(30),
  Math.toRadians(15),Math.toRadians(45));
4. Choose whether to use load-on-demand. This is useful when you specify a large area of interest but want to display only a small part of it:
 
boolean useTiling = true;
int rowCount = 5;
int columnCount = 5;
VMAPSource.setTilingParameters(useTiling, rowCount, columnCount);
5. Finally, start the VMAP data source:
 
VMAPSource.start();
For further information, see:
*Vector data sources, for defense-specific data sources.
*Introducing the main classes and Creating a map application using the API for non defense-specific data sources, properties, tiling, and pixel-on-demand.

Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.