Skip to content

Commit

Permalink
[OGR] Followup: Add orig_ogc_fid as last field to avoid changing fiel…
Browse files Browse the repository at this point in the history
…d order
  • Loading branch information
manisandro committed Sep 25, 2017
1 parent 386d52d commit cf23d56
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/providers/ogr/qgsogrfeatureiterator.cpp
Expand Up @@ -346,7 +346,12 @@ bool QgsOgrFeatureIterator::readFeature( OGRFeatureH fet, QgsFeature &feature )
{
if ( mOrigFidAdded )
{
feature.setId( OGR_F_GetFieldAsInteger64( fet, 0 ) );
OGRFeatureDefnH fdef = OGR_L_GetLayerDefn( ogrLayer );
int lastField = OGR_FD_GetFieldCount( fdef ) - 1;
if ( lastField >= 0 )
feature.setId( OGR_F_GetFieldAsInteger64( fet, lastField ) );
else
feature.setId( OGR_F_GetFID( fet ) );
}
else
{
Expand Down

0 comments on commit cf23d56

Please sign in to comment.