IlvMapsError IlvMapTileLoader::load(IlvTile* tile) { // Get the feature iterator. IlvMapFeatureIterator* iterator = getFeatureIterator(tile); ... // Check if the iterator implements IlvLookAheadFeatureIterator. ... // Parameters for rendering. ... IlvFeatureRenderer* renderer = getFeatureRenderer(tile->getDisplay()); ... do { // Case of look ahead feature iterator. // Check if the next feature ID corresponds to an object // already in the manager (skip the next feature in this // case and continue). ... // Process the feature itself. ... feature = iterator->getNextFeature(); ... // Ask the renderer to make the IlvGraphic. ... // Attach the attributes to the graphic if necessary // and add the graphic to the tile. } while (feature); ... } |
class MyTileLoader:public IlvMapTileLoader { IlvDisplay* _display; const char* _filename; // The filename that corresponds to the image // its format should be known by Rogue Wave Views. IlvProjection* _projection; IlvMapInfo* _info; IlvDim _imageWidth; IlvDim _imageHeight; public: MyTileLoader(IlvDisplay* display, const char* filename) _display(display), _filename(IlvMapDataPathManager::ResolvePath(filename)), _projection(new IlvGeographicProjection()), _info(0), _imageWidth(0), _imageHeight(0) { //Creation of the IlvBitmap corresponding to the given filename. IlvBitmap* bitmap = display->readBitmap(IlvMapDataPathManager::ResolvePath(filename)); if(bitmap) { _imageWidth = bitmap->width(); _imageHeight = bitmap->height(); } } ~MyTileLoader() { if(_info) delete _info; } IlBoolean isPersistent() const { return IlFalse; } IlvMapFeatureIterator* getFeatureIterator(IlvTile* tile) { IlvRect rect; tile->boundingBox(rect); IlvMapInfo* info = getMapInfo(); IlvCoordinate ul; IlvCoordinate lr; IlvPoint p1(rect.x(), rect.y()); IlvPoint p2(rect.x() + rect.w(), rect.y() - rect.h()); ul = info->getAdapter()->fromViews(p1); lr = info->getAdapter()->fromViews(p2); return new IlvImageReader(_display, _filename, ul, lr); } |
IlvFeatureRenderer* getDefaultFeatureRenderer(IlvDisplay* display) { return new IlvDefaultFeatureRenderer(display); } IlvMapInfo* getMapInfo() { if (!_info) _info = new IlvMapInfo(_projection); return _info; } IlvRect getTileOrigin() { return IlvRect(0, 0, _imageWidth, _imageHeight); } }; |
IlvDefaultDataPathResolver* resolver = new IlvDefaultDataPathResolver(“c:\\data”); IlvMapDataPathManager::AddDataPathResolver(resolver); |