IlvMapLoader* loader = new IlvMapLoader(&manager); IlvMapsError status = IlvMaps::NoError(); loader->load(filename, status); if(status != IlvMaps::NoError()) IlvWarning(IlvMaps::GetErrorMessage(status, display)); |
メモ: 同じマネージャーで、投影図法が不明な形状ファイル形式の複数のソース・ファイルをロードする場合、データが同じ座標系で表現されていればオブジェクトは適切に配置されます。ただし、マネージャーで他の形式のデータをインポートすると、異なるソース形式から派生するオブジェクトの相対位置が不正確になります。 |
// Initialize the manager for the mercator projection. IlvProjection* projection = new IlvMercatorProjection(); IlvMapInfo* mapinfo = new IlvMapInfo(projection, 0, IlvFalse); mapinfo->attach(manager); // Create a map loader. IlvMapLoader mapLoader = new IlvMapLoader(manager); // Load other data. .... // Load a shape file that is in the geographic projection. IlvProjection* geographic = new IlvGeographicProjection(); mapLoader->setDefaultSourceProjection(geographic); mapLoader->load("myShapeFile.shp"); |
IlvMapLoader* loader = new IlvMapLoader(&manager); IlvMapsError status = IlvMaps::NoError(); IlvMapFeatureIterator* iterator = loader->makeFeatureIterator(filename); IlvDefaultCurveRenderer* renderer = new IlvDefaultCurveRenderer(display); IlvMapLineRenderingStyle* style = new IlvMapLineRenderingStyle(display); style->setForeground(display->getColor("green")); renderer->setLineRenderingStyle(style); loader->load(iterator, renderer, status); if(status != IlvMaps::NoError()) IlvWarning(IlvMaps::GetErrorMessage(status, display)); |
#include <strings.h> #include <ilviews/maps/format/maploader.h> #include "polread.h" class MyMapLoader :public IlvMapLoader { public: MyMapLoader(IlvDisplay* display, IlvManager* manager); /** * Overrides the makeFeatureIterator method from super class. */ virtual IlvMapFeatureIterator* makeFeatureIterator(const char* fileName); private: IlvDisplay* _display; }; MyMapLoader::MyMapLoader(IlvDisplay* display, IlvManager* manager) :IlvMapLoader(manager), _display(display) { } IlvMapFeatureIterator* MyMapLoader::makeFeatureIterator(const char* fileName) { // Does superclass know the format of provided file? IlvMapFeatureIterator* result = IlvMapLoader::makeFeatureIterator(fileName); // If not, try with the polygon reader. if (!result) { // test extension int length = strlen(fileName); // .pol are polylines files. if (length > 4) { char* ptr = strrchr(fileName, ’.’); if(ptr) if(strcasecmp(ptr, ".pol") == 0) return new SimplePolylineReader(_display, fileName); } } return result; } |