This is an old revision of the document!
{ te::da::DataSource* ds_pols = te::da::DataSourceFactory::make("OGR"); ds_pols->open(ogrInfo); // get a transactor to interact to the data source te::da::DataSourceTransactor* transactor = ds_pols->getTransactor(); // from transactor, take a catalog loader to find out the datasets stored in the data source te::da::DataSourceCatalogLoader* cloader = transactor->getCatalogLoader(); // now retrieve the name of the datasets std::vector<std::string*> datasets; cloader->getDataSets(datasets); for(std::vector<std::string*>::const_iterator it = datasets.begin(); it < datasets.end(); ++it) { const std::string* datasetName = *it; // retrieve the dataset by its name te::da::DataSet* dataset = transactor->getDataSet(*datasetName); te::gm::Envelope* envelope = dataset->getExtent(); int srid = 29183; int zerox = (int) envelope->getLowerLeftX(); int zeroy = (int) envelope->getLowerLeftY(); // Loading Raster // describes the raster that you want std::string raster_name = "raster.tif"; te::da::RasterProperty* rstp = new te::da::RasterProperty(raster_name, srid, envelope, (int)envelope->getWidth(), (int)envelope->getHeight(), 1); te::da::RasterBand* bd = new te::da::RasterBand(0,TE_UCHAR_DT); rstp->setRasterBand(bd,0); te::da::DataSetType* dstp = new te::da::DataSetType(raster_name); dstp->add(rstp); // access a datasource to persist it std::map<std::string, std::string> connInfoRaster; connInfoRaster["source"] = ""TE_DATA_EXAMPLE_LOCALE"\\data\\rasters" ; te::da::DataSource* ds = te::da::DataSourceFactory::make("GDAL"); ds->open(connInfoRaster); te::da::DataSourceTransactor* tr = ds->getTransactor(); te::da::DataSetTypePersistence* pers = tr->getDataSetTypePersistence(); // manipulate it using data set type persistence; pers->create(dstp); // access the data set te::da::DataSet* dset = tr->getDataSet(raster_name,te::common::FORWARDONLY, te::common::RWAccess); te::da::Raster* rst = dset->getRaster(); // Fill Raster with PolygonSet information double polygon_id = 0; while(dataset->moveNext()) { te::gm::Geometry *geometry = dataset->getGeometry(); te::gm::Coord2D ll = geometry->getMBR()->getLowerLeft(); te::gm::Coord2D ur = geometry->getMBR()->getUpperRight(); // access the raster for (unsigned int b=0; b<rst->getNBands(); ++b) { for (unsigned int l=MAX(0,(ll.y-zeroy)); l<MIN(rst->getNLines(),(ur.y-zeroy)); ++l) { for (unsigned int c=MAX(0,(ll.x-zerox)); c<MIN(rst->getNColumns(),(ur.x-zerox)); ++c) { te::gm::Point* possible_pixel = new te::gm::Point(c+zerox, l+zeroy); if (possible_pixel->intersects(geometry)) rst->setValue(c,l,polygon_id,b); } } } } polygon_id++; } delete pers; delete tr; delete ds; delete rst; delete dset; }