Opened 15 years ago

Last modified 15 years ago

#356 closed defect (invalid)

OGR_L_GetFeature (OGRLayerH, i) i>=1 with MapInfo files ?

Reported by: pierocavalieri@… Owned by: warmerdam
Priority: high Milestone:
Component: OGR_SF Version: unspecified
Severity: normal Keywords:


Maybe I'm wrong, but It seems that with

OGR_L_GetFeature (OGRLayerH, iFeature)

with a MapInfo file (.dat, .id, .map, .tab)
the iFeature must start by 1 (and ends at nFeatures+1, if nFeatures is respect
to 0)   

i.e. if I convert a shapefile with ogr2ogr to a MapInfo file, I have
the same output from my functions if I have 

for (iFeature = 0; iFeature < nFeatures; iFeature++) {
  hFeature = OGR_L_GetFeature (hLayer, iFeature)
with the shapefile

for (iFeature = 0; iFeature < nFeatures; iFeature++) {
  hFeature = OGR_L_GetFeature (hLayer, iFeature +1 )
with the MapInfo file.

I have to start by 1, also with other (not converted) MapInfo files.

Change History (1)

comment:1 Changed 15 years ago by warmerdam


I understand your point but it is not considered to be a bug.  The 
feature ids for features from a layer in different drivers are required
to be non-negative integers and unique within a layer, but no other
requirements exist for order or consecutiveness.  The Shapefile and 
MapInfo drivers happen to use consecutive integers starting at 0 and 1 but 
other drivers use sparse values with internal meaning. 

Your looping construct is not considered an appropriate way of reading from
OGR datasources in general.  The correct way to read all the features in a layer
is to call OGR_L_ResetReading() and then call OGR_L_GetNextFeature() untill it
returns a NULL.

Note: See TracTickets for help on using tickets.