int TigerPolygon::SetModule( const char * pszModule ) { if( !OpenFile( pszModule, "A" ) ) return FALSE; EstablishFeatureCount(); /* -------------------------------------------------------------------- */ /* Open the RTS file */ /* -------------------------------------------------------------------- */ if( bUsingRTS ) { if( fpRTS != NULL ) { VSIFCloseL( fpRTS ); fpRTS = NULL; } if( pszModule ) { char *pszFilename; pszFilename = poDS->BuildFilename( pszModule, "S" ); fpRTS = VSIFOpenL( pszFilename, "rb" ); CPLFree( pszFilename ); nRTSRecLen = EstablishRecordLength( fpRTS ); } } return TRUE; }
void TigerFileBase::EstablishFeatureCount() { if( fpPrimary == NULL ) return; nRecordLength = EstablishRecordLength( fpPrimary ); if( nRecordLength == -1 ) { nRecordLength = 1; nFeatures = 0; return; } /* -------------------------------------------------------------------- */ /* Now we think we know the fixed record length for the file */ /* (including line terminators). Get the total file size, and */ /* divide by this length to get the presumed number of records. */ /* -------------------------------------------------------------------- */ long nFileSize; VSIFSeek( fpPrimary, 0, SEEK_END ); nFileSize = VSIFTell( fpPrimary ); if( (nFileSize % nRecordLength) != 0 ) { CPLError( CE_Warning, CPLE_FileIO, "TigerFileBase::EstablishFeatureCount(): " "File length %d doesn't divide by record length %d.\n", (int) nFileSize, (int) nRecordLength ); } nFeatures = nFileSize / nRecordLength; }