[Gdal-dev] Problem writing to MapInfo files

Frank Warmerdam warmerdam at pobox.com
Wed Jul 7 16:50:26 EDT 2004

Woon Wei Lee wrote:
> Hi all
> I have been trying to put together a little program to re-write data from an existing *.TAB file to a new layer but with different colours for the features (I am working on an app to process traffic data then return a colour-coded congestion map) but the ogr library refuses to transfer the stylestring info over to the new layer. 
> I noticed from a previous posting that this is a known bug ( http://xserve.flids.com/pipermail/gdal-dev/2004-July/006558.html ) so I thought I could have a short at debugging it but I can't seem to find the relevant part of the ogr source. 
> My program uses the function OGR_L_CreateFeature() from the c api which is a wrapper for OGRLayer::CreateFeature() but the closest I can find is this bit of code from ogrlayer.cpp:
> OGRErr OGRLayer::CreateFeature( OGRFeature * )
> {
> }
> which presumably is a stub for some driver specific version which is contained in another file.. however I just can't find where the "real" function is. Could anyone help me out please??

Wei Lee,

The MITAB driver overrides the CreateFeature in the IMapInfoFile class found
in gdal/ogr/ogrsf_frmts/mitab/mitab_imapinfofile.cpp.  Looking at this method,
I see it makes no effort to transfer the style string to the internal feature.
I am suspecting this is responsible for the problems generating proper styling
results.  Try adding something like this down just before the SetFeature() call
to apply the passed in style string to the real MapInfo feature object used for
writing and see if that helps.

     if( poFeature->GetStyleString() != NULL )
         poTABFeature->SetStyleString( poFeature->GetStyleString() );

Best regards,

I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent

More information about the Gdal-dev mailing list