I am trying to see how to use the CDB API to retrieve the FTL model from CDB Tile zip file. If for example, we have the following code that read the file from the zip. How do you convert the buffer to the T3dFile object correctly? or is there another class or method I have not seen?
CntrFolder* aFolder = wFile->getFolder();
for (unsigned int i = 0; i < aFolder->getFileCount(); ++i)
CntrFile* aFile = aFolder->getFile(i);
unsigned int iSize = aFile->getSize();
char* oBuffer = new char[iSize];
unsigned int iOffset = 0;
// now we read the file from the zip
int result= aFile->read ( oBuffer, iOffset, iSize );
// Now how do you convert the buffer to a T3dFile object?
I did not find this information in the samples and the documentation.
The cdbDump sample shows you how to access a FLT file and decode it. You do not need to access the zip, you can simply do a createFile on the file name. Typically, using the GSFeature shapefile, you get the filename and can pass it to CreateFile.
If you want to iterate inside the container, the CDBDump sample has that as well - extract each file from the name.
Let me know if this is not what you are trying to do.
Maybe I am missing something but if you provide "/CDB/Tiles/N33/W118/300_GSModelGeometry/LC/U0/N33W118_D300_S001_T001_LC01_U0_R0.zip" to the cdbDump it just iterates on the name of the FLT file inside the zip (like I was initially saying). It does not read the FTL into a T3dFile ?
It all works with a CDBparam to call a createFile(). You do this directly on the FLT file. You build a CDBParam from the info in the vector and CDB API will access it inside the zip, making the zip transparent. CDB API knows that GS models are stored in a zip.
The only time you want to access the container would be for pre-paging of the complete tile.
If this is not detailed enough, I will try to build a small code sample to read a GSFeature shapefile and access the models pointed by it.
An example would be nice. I must be missing something, the .creatFile() with the parameter works but when I call .decode() it return eInvalidParameters but when I look in my CDBParam it look ok !
I will work on a sample.
My statement that CDB API will access the ZIP directly where referring the zip was not correct. The key is to do a CreateFile on the zip and from the returned CDBFile, call a CreateFile with the CDBParam of the OpenFlight.
It will look like this:
CdbFile *theZip = wCdb->createFile(theZipParams, eRead);
T3dFile *theFlt = theZip->createFile(theFltParams, eRead);
This should be enough to get you going but I will still work on a proper sample.
That was the missing piece I did not find in the example (or documentation). The example is not exactly like you describe but here is a code section that work:
CdbFile *wZipFile = wCdb.createFile(wZipParam, eSharedRead);
CdbFile *wFltFile = wZipFile->createFile(wParam, eSharedRead);
if (wZipFile != 0 && wFltFile !=0)
if (wFltFile->getType() == CdbFile::e3D)
T3dFile* model = wFltFile->get3DFile();