[gdal-dev] OGRErr OGRLayer::CreateField // cant create fields
Even Rouault
even.rouault at mines-paris.org
Mon Jul 22 14:09:38 PDT 2013
Le lundi 22 juillet 2013 22:58:39, Mauro Pisano a écrit :
> Hi guys!
>
> Im having a problem by using the OGRLayter::CreateField method, it isnt
> creating the field as the description saids :).
>
> Maybe you can see the error or have an idea to go out of this hole.
>
> Here are the lines of code:
>
> *...*
> *...*
> * OGRLayer* player = pvector->GetLayer(0);*
>
> * if (player->GetLayerDefn()->GetFieldIndex(SUR_HOTLINK_FIELD) < 0) {*
> // If the field doesnt exist, I create it.
> * OGRFieldDefn field(SUR_HOTLINK_FIELD, OFTString);*
> // Try to insert it to the table.
> * if ( player->CreateField(&field, TRUE) == OGRERR_NONE )*
> * SHOW_ERROR("D:Error trying to create field);*
> * }*
> *...*
> *...*
>
> *NOTES:*
> the first line returns me without problems the Working Layer ( I just
> using just 1 layer to avoid confusions )
> the first IF returns that there arent any SUR_HOTLINK_FIELD in the table (
> that its OK! )
>
> and de last IF returns that the CreateField gives distinct as OGRERR_NONE.
Mauro,
You didn't really give a lot of context. But several possible causes :
- the datasource is not opened in update mode
- the driver does not support field creation at all
Even
--
Geospatial professional services
http://even.rouault.free.fr/services.html
More information about the gdal-dev
mailing list