[Gdal-dev] VRT SimpleSource problem

Matt Hanson mhanson at photon.com
Thu Jan 11 18:25:11 EST 2007


I'm having problems getting bands correct when creating a VRT file.  In the code below I have an XML stringstream and loop through each band that I am copying.   For each band I create the <SimpleSource> XML with the correct band number and regions of interest.    However in the resulting VRT file for all the bands the <SourceBand> tag is the exact same band number for all bands.   The band metadata is copying over correctly, it is just as if when I set the source_0 MetadataItem it is setting it for all bands, or using the first band for all bands.    
 
Might this be a bug or am I doing something incorrectly?
 
 
********************************************************************

for (iIndex=Indexes.begin(); iIndex!=Indexes.end(); iIndex++) {

XML << "<SimpleSource><SourceFilename relativeToVRT=\"1\">" << ImageSet.Filename() << "</SourceFilename>"

<< "<SourceBand>" << (*iIndex)+1 << "</SourceBand>"

<< "<SrcRect xOff=\"" << ROI.x0() << "\" yOff=\"" << ROI.y0() << "\" xSize=\"" << ROI.width() << "\" ySize=\"" << ROI.height() << "\"/>"

<< "<DstRect xOff=\"0\" yOff=\"0\" xSize=\"" << ROI.width() << "\" ySize=\"" << ROI.height() << "\"/>"

<< "</SimpleSource>";

// Copy band metadata from source band

NewImage[iNewIndex].GetGDALRasterBand()->SetMetadataItem("source_0",XML.str().c_str(),"new_vrt_sources");

NewImage[iNewIndex++].GetGDALRasterBand()->SetMetadata( ImageSet[*iIndex].GetGDALRasterBand()->GetMetadata() );

}

NewImage.GetGDALDataset()->FlushCache();





More information about the Gdal-dev mailing list