[gdal-dev] misssing field width information when getting OGRLayer form filegdb

Even Rouault even.rouault at spatialys.com
Thu Jan 8 05:03:46 PST 2015


Le jeudi 08 janvier 2015 08:04:00, Rebecca a écrit :
> I get ogrlayer from fielgdb , when I try to get the field information such
> as field name, field width, field type, I found the field name and field
> type is right , but field width is zero when the field type is OFTString.
> Does the filegdb lost the field width information in gdal-filegdb?
> 
> OGRDataSource *pOGRDS...
> OGRLayer *pLayer=pOGRDS->GetLayerByName(filename.c_str());
> for(int i=0;i<pLayer->GetLayerDefn()->GetFieldCount();i++)
> {
> 	OGRFieldDefn *pDef=pLayer->GetLayerDefn()->GetFieldDefn(i);
> 	std::string name=pDef->GetNameRef();
> 	int width=pDef->GetWidth(); //width =0
> 
> }

Digging a bit, the code in the driver that should set the width is commented. 
It appears those lines are mine. Not sure why I let it commented. I somehow 
remember this was due to oddities with integer fields where the width is 
probably reported in terms of number of bytes for the binary representation 
rather than in terms of the width for the decimal representation. But for 
strings it could probably be reported. Perhaps worth a ticket in Trac.

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list