Rogue Wave Views Maps Reader Framework > Feature Iterators > Overview of IlvMapFeatureIterator
 
Overview of IlvMapFeatureIterator
A map feature iterator has three main methods:
*The IlvMapFeatureIterator::getNextFeature method allows you to iterate a stream of cartographic objects read from a file or queried from a database or a map server. It returns a null pointer when the last map feature has been read. The Rogue Wave Views predefined readers, which implement the IlvMapFeatureIterator abstract class, always return the same instance of IlvMapFeature. This means that each time the getNextFeature method is called, the newly read map feature overwrites the previous one, which is permanently lost along with its geometry and attributes. As a consequence, you must be sure to use this map feature before invoking the getNextFeature method again, or make a copy of the map feature if you wish to keep it. This is what we did in the example given in Attaching Attributes to Graphic Objects.
The reason why map features have been made volatile is to avoid the situation where memory is allocated each time a new feature is read, thus resulting in a loss of performance. It is more efficient to allocate memory for storing a map feature when it is read for the first time and then update it only when necessary.
*The getDefaultFeatureRenderer method returns a renderer that is appropriate for each of the map features read. See Renderers.
*The getProjection method returns a non null IlvProjection if the data source is georeferenced and a null projection otherwise. A data source is said to be georeferenced if it describes the projection system used for its data. For information about projections, see the section Selecting a Target Projection and Map Projections. See also the section Loading Nongeoreferenced Files.
The following code example loads all the map features read by an iterator and puts them into a manager.
IlvFeatureRenderer* renderer =
featureIterator->getDefaultFeatureRenderer(display);
 
for (const IlvMapFeature* feature = featureIterator->getNextFeature(status);
feature;
feature = featureIterator->getNextFeature(status)) {
 
if (status != IlvMaps::NoError()) {
IlvPrint(IlvMaps::GetErrorMessage(status, display));
return;
}
 
IlvGraphic* graphic = renderer->makeGraphic(feature,
mapinfo,
status);
if(graphic)
manager->addObject(graphic, IlvFalse, layerIndex);
else if(status != IlvMaps::NoError())
IlvPrint(IlvMaps::GetErrorMessage(status, display));
}
 

Version 5.7
Copyright © 2013, Rogue Wave Software, Inc. All Rights Reserved.