Maps > Rogue Wave Views Maps Reader Framework > Renderers > Overview of Renderers
 
Overview of Renderers
A renderer is an object that is used to transform a map feature into a graphic object of the class IlvGraphic or one of its subclasses.
A renderer must implement the IlvFeatureRenderer abstract class. To transform a given map feature into a graphic object, you use its makeGraphic method:
IlvGraphic* makeGraphic(const IlvMapFeature& feature,
const IlvMapInfo& targetMapInfo,
IlvMapsError& status);
The second argument, targetMapInfo, allows you to specify a target projection and an adapter. An adapter is a converter that provides facilities to convert geographic coordinates (that are generally expressed with floating point values in a coordinate system where the vertical axis is oriented upwards) into the points used by an IlvManager which are expressed with integer values in a coordinate system where the vertical axis is oriented downwards.
If the projection of the IlvMapInfo is set to 0 or is an instance of IlvUnknownProjection, the target projection is considered to be the same as the source projection of the IlvMapFeature. In this case, no projection conversion is performed.
For information about projections and adapters, see Selecting a Target Projection and Map Projections.
Rogue Wave® Views Maps includes a set of default renderers for each of the geometry types available in the library. These renderers can be found in the package rendering. The IlvDefaultPointRenderer, for example, transforms a map feature whose geometry is a point into an object of the type IlvMarker. The library also provides a global default renderer of the type IlvDefaultFeatureRenderer, which you can use to translate any map feature whose geometry is one of the predefined geometries. You can customize some attributes of the renderers by providing a rendering style. For example, the IlvMapLineRenderingStyle is used to customize line width, color or line style.
The following code sample shows how to transform a map feature whose geometry is of the type IlvMapCurve into a green curve. These polylines could be, for example, the segments of a country’s border.
IlvFeatureRenderer* renderer = new IlvDefaultCurveRenderer(_display);
IlvMapLineRenderingStyle *lrs = new IlvMapLineRenderingStyle(_display);
lrs->setForeground("green");
lrs->setLineWidth(2);
renderer->setLineRenderingStyle(lrs);
IlvGraphic* graphic = renderer->makeGraphic(feature, mapInfo, status);
if(graphic) {
_manager->addObject(graphic);
} else {
IlvWarning("This renderer can’t translate the map feature");
if(status != IlvMaps::NoError())
IlvWarning(IlvMaps::GetErrorMessage(status, _display));
}
 

Version 6.1
Copyright © 2016, Rogue Wave Software, Inc. All Rights Reserved.