Handling map features

A map feature is an object that represents cartographic data as it was read from its source file. A map feature holds three main information fields: Its geometry, the coordinate system in which its geometry is expressed, and its attributes. If the map feature is a town, for example, its attributes can be its name and the number of inhabitants. A map feature is completely independent of the way it will be graphically represented in the application. Thus, a point marking the summit of a hill might very well be represented with graphic objects as diverse as a cross, a circle, or an icon.
A map feature carries the following information:

Map Feature Geometry

Each map feature has a geometry. The geometry of a map feature is information relating to its shape and position.
In JViews Maps, map feature geometries are defined by the IlvMapGeometry class in the ilog.views.maps package. The package ilog.views.maps.geometry supplies a number of predefined geometries which are modeled on the “Simple Map Features” geometry specifications defined by the OpenGIS Consortium to ensure interoperability between Geographic Information Systems (GIS). Note, however, that the classes in this package are not strictly equivalent to this model in terms of functionality. They provide simplified features and are mainly drawing oriented. Nevertheless, using these classes greatly facilitates the conversion of data coming from a map server, such as Oracle Spatial, for example.
This package also contains additional geometries for handling images, rasters, and text more easily and can be extended with new geometries.

Map Feature Attributes

Each map feature can also have attributes. If the map feature is a town, its attributes can be its name, or the number of inhabitants. Attributes can be used, for example, for graphical rendering. In the section Creating a colored line renderer, the color of polylines representing contour lines on a map is defined by the elevation attribute.
Attributes belong to the class IlvFeatureAttribute . They are stored in the following two classes of the ilog.views.maps package:
The following code example lists the attributes of an IlvMapFeature object and displays them on the screen:
public void dumpAttributes(IlvMapFeature feature)
 {
   IlvAttributeInfoProperty info = feature.getAttributeInfo();
   IlvFeatureAttributeProperty attributes = feature.getAttributes();
   
   // Attributes are not mandatory in a feature.
   if ((info == null) || (attributes == null)) {
     System.out.println("This feature has no attribute");
     return;
   }
   
   for (int i = 0; i < info.getAttributesCount(); i++) {
     String name = info.getAttributeName(i);
     IlvFeatureAttribute attribute = attributes.getAttribute(i);
     System.out.println("The attribute " + name +
                        " takes the value " + attribute.toString());
   }
 }
The attributes are of different types, according to whether they represent whole numbers, floating-point values, character strings, and so on. The predefined attributes, all of the IlvFeatureAttribute class, are in the ilog.views.maps.attribute package.