Ejemplo n.º 1
0
int OGRPCIDSKDataSource::Open( const char * pszFilename, int bUpdateIn )

{
    if( !EQUAL(CPLGetExtension(pszFilename),"pix") )
        return FALSE;

    osName = pszFilename;
    if( bUpdateIn )
        bUpdate = true;
    else
        bUpdate = false;

/* -------------------------------------------------------------------- */
/*      Open the file, and create layer for each vector segment.        */
/* -------------------------------------------------------------------- */
    try 
    {
        PCIDSK::PCIDSKSegment *segobj;
        const char *pszAccess = "r";

        if( bUpdateIn )
            pszAccess = "r+";

        poFile = PCIDSK::Open( pszFilename, pszAccess,
                               PCIDSK2GetInterfaces() );

        for( segobj = poFile->GetSegment( PCIDSK::SEG_VEC, "" );
             segobj != NULL;
             segobj = poFile->GetSegment( PCIDSK::SEG_VEC, "",
                                          segobj->GetSegmentNumber() ) )
        {
            apoLayers.push_back( new OGRPCIDSKLayer( segobj, bUpdate ) );
        }

        /* Check if this is a raster-only PCIDSK file */
        if ( !bUpdate && apoLayers.size() == 0 && poFile->GetChannels() != 0 )
            return FALSE;
    }

/* -------------------------------------------------------------------- */
/*      Trap exceptions and report as CPL errors.                       */
/* -------------------------------------------------------------------- */
    catch( PCIDSK::PCIDSKException ex )
    {
        CPLError( CE_Failure, CPLE_AppDefined, 
                  "%s", ex.what() );
        return FALSE;
    }
    catch(...)
    {
        CPLError( CE_Failure, CPLE_AppDefined, 
                  "Non-PCIDSK exception trapped." );
        return FALSE;
    }

    return TRUE;
}
int OGRPCIDSKDataSource::Open( const char * pszFilename, int bUpdateIn )

{
    if( !EQUAL(CPLGetExtension(pszFilename),"pix") )
        return FALSE;

    osName = pszFilename;
    bUpdate = bUpdateIn;

/* -------------------------------------------------------------------- */
/*      Open the file, and create layer for each vector segment.        */
/* -------------------------------------------------------------------- */
    try 
    {
        PCIDSK::PCIDSKSegment *segobj;
        const char *pszAccess = "r";

        if( bUpdateIn )
            pszAccess = "r+";

        poFile = PCIDSK::Open( pszFilename, pszAccess, NULL );

        for( segobj = poFile->GetSegment( PCIDSK::SEG_VEC, "" );
             segobj != NULL;
             segobj = poFile->GetSegment( PCIDSK::SEG_VEC, "",
                                          segobj->GetSegmentNumber() ) )
        {
            apoLayers.push_back( new OGRPCIDSKLayer( segobj, bUpdate ) );
        }
    }

/* -------------------------------------------------------------------- */
/*      Trap exceptions and report as CPL errors.                       */
/* -------------------------------------------------------------------- */
    catch( PCIDSK::PCIDSKException ex )
    {
        CPLError( CE_Failure, CPLE_AppDefined, 
                  "%s", ex.what() );
        return FALSE;
    }
    catch(...)
    {
        CPLError( CE_Failure, CPLE_AppDefined, 
                  "Non-PCIDSK exception trapped." );
        return FALSE;
    }

/* -------------------------------------------------------------------- */
/*      We presume that this is indeed intended to be a PCIDSK          */
/*      datasource if over half the files were .csv files.              */
/* -------------------------------------------------------------------- */
    return TRUE;
}