Ejemplo 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;
}
Ejemplo n.º 2
0
int OGRAVCE00Layer::CheckSetupTable(AVCE00Section *psTblSectionIn)
{
    if (psTableRead)
        return FALSE;

    const char *pszTableType = NULL;
    switch (eSectionType)
    {
    case AVCFileARC:
        pszTableType = ".AAT";
        break;

    case AVCFilePAL:
    case AVCFileLAB:
        pszTableType = ".PAT";
        break;

    default:
        break;
    }

/* -------------------------------------------------------------------- */
/*      Is the table type found anywhere in the section pszName?  Do    */
/*      a case insensitive check.                                       */
/* -------------------------------------------------------------------- */
    if( pszTableType == NULL )
        return FALSE;
    
    int iCheckOff;
    for( iCheckOff = 0; 
         psTblSectionIn->pszName[iCheckOff] != '\0'; 
         iCheckOff++ )
    {
        if( EQUALN(psTblSectionIn->pszName + iCheckOff, 
                   pszTableType, strlen(pszTableType) ) )
            break;
    }

    if( psTblSectionIn->pszName[iCheckOff] == '\0' )
        return FALSE;

    psTableSection = psTblSectionIn;

/* -------------------------------------------------------------------- */
/*      Try opening the table.                                          */
/* -------------------------------------------------------------------- */
    psTableRead = AVCE00ReadOpenE00(psTblSectionIn->pszFilename);
    if (psTableRead == NULL)
        return FALSE;

    /* advance to the specified line number */
    if (AVCE00ReadGotoSectionE00(psTableRead, psTableSection, 0) != 0)
    {
        AVCE00ReadCloseE00(psTableRead);
        psTableRead = NULL;
        return FALSE;
    }
    
    AVCE00ReadNextObjectE00(psTableRead);
    bNeedReset = 1;

    pszTableFilename = CPLStrdup(psTblSectionIn->pszFilename);
    nTableBaseField = poFeatureDefn->GetFieldCount();

	if (eSectionType == AVCFileLAB)
	{
        AVCE00ReadE00Ptr psInfo = ((OGRAVCE00DataSource *) poDS)->GetInfo();
        for( int iSection = 0; iSection < psInfo->numSections; iSection++ )
        {
            if( psInfo->pasSections[iSection].eType == AVCFilePAL )
                nTableAttrIndex = poFeatureDefn->GetFieldIndex( "PolyId" );
        }
	}

/* -------------------------------------------------------------------- */
/*      Setup attributes.                                               */
/* -------------------------------------------------------------------- */
    AppendTableDefinition( psTableRead->hParseInfo->hdr.psTableDef );

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

    return TRUE;
}
Ejemplo n.º 3
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;
}