Exemplo n.º 1
0
int OGRAVCBinLayer::CheckSetupTable()

{
    if( szTableName[0] == '\0' )
        return FALSE;

/* -------------------------------------------------------------------- */
/*      Scan for the indicated section.                                 */
/* -------------------------------------------------------------------- */
    AVCE00ReadPtr psInfo = ((OGRAVCBinDataSource *) poDS)->GetInfo();
    int           iSection;
    AVCE00Section *psSection = NULL;
    char	  szPaddedName[65];
    
    sprintf( szPaddedName, "%s%32s", szTableName, " " );
    szPaddedName[32] = '\0';

    for( iSection = 0; iSection < psInfo->numSections; iSection++ )
    {
        if( EQUAL(szPaddedName,psInfo->pasSections[iSection].pszName) 
            && psInfo->pasSections[iSection].eType == AVCFileTABLE )
            psSection = psInfo->pasSections + iSection;
    }

    if( psSection == NULL )
    {
        szTableName[0] = '\0';
        return FALSE;
    }

/* -------------------------------------------------------------------- */
/*      Try opening the table.                                          */
/* -------------------------------------------------------------------- */
    hTable = AVCBinReadOpen( psInfo->pszInfoPath,  szTableName,
                             psInfo->eCoverType, AVCFileTABLE,
                             psInfo->psDBCSInfo);
    
    if( hTable == NULL )
    {
        szTableName[0] = '\0';
        return FALSE;
    }
    
/* -------------------------------------------------------------------- */
/*      Setup attributes.                                               */
/* -------------------------------------------------------------------- */
    nTableBaseField = poFeatureDefn->GetFieldCount();
    
    AppendTableDefinition( hTable->hdr.psTableDef );

/* -------------------------------------------------------------------- */
/*      Close table so we don't have to many files open at once.        */
/* -------------------------------------------------------------------- */
    AVCBinReadClose( hTable );

    hTable = NULL;

    return TRUE;
}
Exemplo n.º 2
0
void OGRAVCBinLayer::ResetReading()

{
    if( hFile != NULL )
    {
        AVCBinReadClose( hFile );
        hFile = NULL;
    }

    bNeedReset = FALSE;
    nNextFID = 1;

    if( hTable != NULL )
    {
        AVCBinReadClose( hTable );
        hTable = NULL;
    }
}
Exemplo n.º 3
0
int OGRAVCBinDataSource::Open( const char * pszNewName, int bTestOpen )

{
/* -------------------------------------------------------------------- */
/*      Open the source file.  Supress error reporting if we are in     */
/*      TestOpen mode.                                                  */
/* -------------------------------------------------------------------- */
    if( bTestOpen )
        CPLPushErrorHandler( CPLQuietErrorHandler );

    psAVC = AVCE00ReadOpen( pszNewName );

    if( bTestOpen )
    {
        CPLPopErrorHandler();
        CPLErrorReset();
    }

    if( psAVC == NULL )
        return FALSE;

    pszName = CPLStrdup( pszNewName );
    pszCoverageName = CPLStrdup( psAVC->pszCoverName );

/* -------------------------------------------------------------------- */
/*      Create layers for the "interesting" sections of the coverage.   */
/* -------------------------------------------------------------------- */
    int		iSection;

    papoLayers = (OGRLayer **)
        CPLCalloc( sizeof(OGRLayer *), psAVC->numSections );
    nLayers = 0;

    for( iSection = 0; iSection < psAVC->numSections; iSection++ )
    {
        AVCE00Section *psSec = psAVC->pasSections + iSection;

        switch( psSec->eType )
        {
          case AVCFileARC:
          case AVCFilePAL:
          case AVCFileCNT:
          case AVCFileLAB:
          case AVCFileRPL:
          case AVCFileTXT:
          case AVCFileTX6:
            papoLayers[nLayers++] = new OGRAVCBinLayer( this, psSec );
            break;

          case AVCFilePRJ:
          {
              char 	**papszPRJ;
              AVCBinFile *hFile;
              
              hFile = AVCBinReadOpen(psAVC->pszCoverPath, 
                                     psSec->pszFilename, 
                                     psAVC->eCoverType, 
                                     psSec->eType,
                                     psAVC->psDBCSInfo);
              if( hFile && poSRS == NULL )
              {
                  papszPRJ = AVCBinReadNextPrj( hFile );

                  poSRS = new OGRSpatialReference();
                  if( poSRS->importFromESRI( papszPRJ ) != OGRERR_NONE )
                  {
                      CPLError( CE_Warning, CPLE_AppDefined, 
                                "Failed to parse PRJ section, ignoring." );
                      delete poSRS;
                      poSRS = NULL;
                  }
                  AVCBinReadClose( hFile );
              }
          }
          break;

          default:
            ;
        }
    }
    
    return nLayers > 0;
}
Exemplo n.º 4
0
bool OGRAVCBinLayer::CheckSetupTable()

{
    if( szTableName[0] == '\0' )
        return false;

/* -------------------------------------------------------------------- */
/*      Scan for the indicated section.                                 */
/* -------------------------------------------------------------------- */
    AVCE00ReadPtr psInfo
        = static_cast<OGRAVCBinDataSource *>( poDS )->GetInfo();
    const size_t BUFSIZE = 32;
    char szPaddedName[BUFSIZE+1] = { 0 };

    // Fill szPaddedName with szTableName up to 32 chars and fill the remaining
    // ones with ' '
    strncpy( szPaddedName, szTableName, BUFSIZE );
    if( strlen(szTableName) < BUFSIZE )
    {
        memset( szPaddedName + strlen(szTableName), ' ',
                BUFSIZE - strlen(szTableName) );
    }

    AVCE00Section *l_psSection = NULL;
    for( int iSection = 0; iSection < psInfo->numSections; iSection++ )
    {
        if( EQUAL(szPaddedName,psInfo->pasSections[iSection].pszName)
            && psInfo->pasSections[iSection].eType == AVCFileTABLE )
            l_psSection = psInfo->pasSections + iSection;
    }

    if( l_psSection == NULL )
    {
        szTableName[0] = '\0';
        return false;
    }

/* -------------------------------------------------------------------- */
/*      Try opening the table.                                          */
/* -------------------------------------------------------------------- */
    hTable = AVCBinReadOpen( psInfo->pszInfoPath,  szTableName,
                             psInfo->eCoverType, AVCFileTABLE,
                             psInfo->psDBCSInfo);

    if( hTable == NULL )
    {
        szTableName[0] = '\0';
        return false;
    }

/* -------------------------------------------------------------------- */
/*      Setup attributes.                                               */
/* -------------------------------------------------------------------- */
    nTableBaseField = poFeatureDefn->GetFieldCount();

    AppendTableDefinition( hTable->hdr.psTableDef );

/* -------------------------------------------------------------------- */
/*      Close table so we don't have to many files open at once.        */
/* -------------------------------------------------------------------- */
    AVCBinReadClose( hTable );

    hTable = NULL;

    return true;
}