Le mercredi 01 mai 2013 01:29:30, Peter Bunting a écrit : > Hi All, > > Sam and I have prepared an RFC for our proposal for improving raster > attribute table (RAT) support and put it on the trac. > > http://trac.osgeo.org/gdal/wiki/rfc40_enhanced_rat_support > > We'd be keen to here feedback on our proposal. >
Peter, Here are my observations and questions : * Is the boolean data type really necessary ? There will be a difficulty with the associated C bindings since 'bool' isn't a C type, but a C++ one. * I'm not sure about what you meant with "The CSLString type will be used for reading and writing strings". You probably meant the CPLString C++ class right ? I'm not sure how this would fly with ValuesIO(GDALRWFlag eRWFlag, int iField, int iStartRow, int iLength, char **papszStrList). This is probably just an implementation detail. Related to that, when eRWFlag == GF_Read, you will probably need to document that only the papszStrList array must be allocated with a size of iLength * sizeof(char*) bytes, and that the papszStrList[i] values that will be set in it will be allocated with the CPL allocation routines. So users will be responsible to clear the values with CPLFree(). * For the HFA specialized implementation, I guess you would override almost all methods of GDALRasterAttributeTable, and that you wouldn't use the "std::vector<GDALRasterAttributeField> aoFields" member variable for example since you don't want the size of anValues/adfValues/aosValues arrays of GDALRasterAttributeField to go out of control. So perhaps a better design would be to completely remove the private members of GDALRasterAttributeTable to make it an abstract class. The current implementation, with the private member variables, would go to a GDALDefaultRasterAttributeTable that would extend GDALRasterAttributeTable (like HFARasterAttributeTable would do). This would have of course some backward compatibility implications, especially for C++ users, since GDALRasterAttributeTable would be no longer instanciable (GDALDefaultRasterAttributeTable would), but I don't believe this would cause much churn in existing user code bases, and would have only some limited implication in GDAL code base. The C function GDALCreateRasterAttributeTable() could be preserved and return an instance of GDALDefaultRasterAttributeTable. * If your purpose is to address huge RATs, I'm not sure about what we can do with the Serialize() method, which is for example used by the PAM mechanism when translating datasets to formats that don't support natively RATs. Perhaps in the case the RAT is detected to be large to be reasonably serialized (for example 10 MB ?), this method could just return NULL (some check should be done in the existing GDAL code base to see if we are robust to NULL being returned. I can see at least that CPLAddXMLChild( psTree, psPam->poDefaultRAT- >Serialize() ) at line 209 of gdalpamrasterband.cpp would need some care) * In a similar situation (huge RAT), I'm not sure what the Clone() method would do. GDALPamRasterBand::SetDefaultRAT() uses Clone() on that passed RAT object.http://trac.osgeo.org/gdal/attachment/ticket/4903/4903.4.diff would do the same on VRTRasterBand::SetDefaultRAT(). IdrisiRasterBand::SetDefaultRAT() does that too. Perhaps that HFARasterAttributeTable::Clone() could return a self-contained immutable copy of itself (i.e. it could survive the destruction of the HFADataset object of the source RAT). Perhaps only in the huge RAT case. In other cases, it could return a GDALDefaultRasterAttributeTable object with all columns and rows in memory, that could be potentially modified by calling code. Hum, that seems to be complicated... In the SetDefaultRAT() use case, the use of Clone() is not meant at getting a free-standing copy of the source object that can be altered, but rather to be independant from the life cycle of the passed object. Would be probably better addressed with some shared pointer mechanism, but the implication would be really too huge and go well beyond changes in RAT management... * Not linked with your proposal, but I noticed that gdal_rat.h exposes methods that are not implemented, like GetRowMin(), GetRowMax(), GetColorOfValue(). Your work could be the opportunity to clean that by removing them. * Just a detail: In the current state of your proposal, "The proposed additions will have an impact on C binary compatibility because they change the API" would be better rephrased as "The proposed additions will extend the C API" (there's no compatibility problem since it is backward compatible). * I'd like to see a mention of extending the Python autotest suite to test the new API, both for their default implementation and specialized implementation in the HFA driver. Best regards, Even _______________________________________________ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev