OGRFeature *OGRAVCBinLayer::GetFeature( GIntBig nFID ) { if( !CPL_INT64_FITS_ON_INT32(nFID) ) return NULL; /* -------------------------------------------------------------------- */ /* If we haven't started yet, open the file now. */ /* -------------------------------------------------------------------- */ if( hFile == NULL ) { AVCE00ReadPtr psInfo = ((OGRAVCBinDataSource *) poDS)->GetInfo(); hFile = AVCBinReadOpen(psInfo->pszCoverPath, psSection->pszFilename, psInfo->eCoverType, psSection->eType, psInfo->psDBCSInfo); } /* -------------------------------------------------------------------- */ /* Read the raw feature - the -3 fid is a special flag */ /* indicating serial access. */ /* -------------------------------------------------------------------- */ void *pFeature; if( nFID == -3 ) { while( (pFeature = AVCBinReadNextObject( hFile )) != NULL && !MatchesSpatialFilter( pFeature ) ) { nNextFID++; } } else { bNeedReset = TRUE; pFeature = AVCBinReadObject( hFile, (int)nFID ); } if( pFeature == NULL ) return NULL; /* -------------------------------------------------------------------- */ /* Translate the feature. */ /* -------------------------------------------------------------------- */ OGRFeature *poFeature; poFeature = TranslateFeature( pFeature ); if( poFeature == NULL ) return NULL; /* -------------------------------------------------------------------- */ /* LAB's we have to assign the FID to directly, since it */ /* doesn't seem to be stored in the file structure. */ /* -------------------------------------------------------------------- */ if( psSection->eType == AVCFileLAB ) { if( nFID == -3 ) poFeature->SetFID( nNextFID++ ); else poFeature->SetFID( nFID ); } /* -------------------------------------------------------------------- */ /* If this is a polygon layer, try to assemble the arcs to form */ /* the whole polygon geometry. */ /* -------------------------------------------------------------------- */ if( psSection->eType == AVCFilePAL || psSection->eType == AVCFileRPL ) FormPolygonGeometry( poFeature, (AVCPal *) pFeature ); /* -------------------------------------------------------------------- */ /* If we have an attribute table, append the attributes now. */ /* -------------------------------------------------------------------- */ AppendTableFields( poFeature ); return poFeature; }
OGRFeature *OGRAVCE00Layer::GetFeature( GIntBig nFID ) { /* -------------------------------------------------------------------- */ /* If we haven't started yet, open the file now. */ /* -------------------------------------------------------------------- */ if( psRead == NULL ) { psRead = AVCE00ReadOpenE00(psSection->pszFilename); if (psRead == NULL) return NULL; /* advance to the specified line number */ if (AVCE00ReadGotoSectionE00(psRead, psSection, 0) != 0) return NULL; nNextFID = 1; } /* -------------------------------------------------------------------- */ /* Read the raw feature - the -3 fid is a special flag */ /* indicating serial access. */ /* -------------------------------------------------------------------- */ void *pFeature; if( nFID == -3 ) { while( (pFeature = AVCE00ReadNextObjectE00(psRead)) != NULL && psRead->hParseInfo->eFileType != AVCFileUnknown && !MatchesSpatialFilter( pFeature ) ) { nNextFID++; } } else { bNeedReset = TRUE; if (nNextFID > nFID) { /* advance to the specified line number */ if (AVCE00ReadGotoSectionE00(psRead, psSection, 0) != 0) return NULL; } do { pFeature = AVCE00ReadNextObjectE00(psRead); ++nNextFID; } while (NULL != pFeature && nNextFID <= nFID); } if( pFeature == NULL ) return NULL; /* -------------------------------------------------------------------- */ /* Translate the feature. */ /* -------------------------------------------------------------------- */ OGRFeature *poFeature; poFeature = TranslateFeature( pFeature ); if( poFeature == NULL ) return NULL; /* -------------------------------------------------------------------- */ /* LAB's we have to assign the FID to directly, since it */ /* doesn't seem to be stored in the file structure. */ /* -------------------------------------------------------------------- */ if( psSection->eType == AVCFileLAB ) { if( nFID == -3 ) poFeature->SetFID( nNextFID++ ); else poFeature->SetFID( nFID ); } /* -------------------------------------------------------------------- */ /* If this is a polygon layer, try to assemble the arcs to form */ /* the whole polygon geometry. */ /* -------------------------------------------------------------------- */ if( psSection->eType == AVCFilePAL || psSection->eType == AVCFileRPL ) { FormPolygonGeometry( poFeature, (AVCPal *) pFeature ); } /* -------------------------------------------------------------------- */ /* If we have an attribute table, append the attributes now. */ /* -------------------------------------------------------------------- */ AppendTableFields( poFeature ); return poFeature; }