Changeset 20124


Ignore:
Timestamp:
Jul 22, 2010 10:34:10 PM (6 years ago)
Author:
chaitanya
Message:

Remove unupdated indices of a shapefile layer. (#2798)

Location:
branches/1.6/gdal/ogr/ogrsf_frmts/shape
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/1.6/gdal/ogr/ogrsf_frmts/shape/ogrshape.h

    r15583 r20124  
    7979
    8080    int                 CheckForQIX();
     81
     82    int                 bSbnSbxDeleted;
    8183
    8284  public:
  • branches/1.6/gdal/ogr/ogrsf_frmts/shape/ogrshapelayer.cpp

    r18900 r20124  
    7070    fpQIX = NULL;
    7171
     72    bSbnSbxDeleted = FALSE;
     73   
    7274    bHeaderDirty = FALSE;
    7375
     
    386388{
    387389    bHeaderDirty = TRUE;
     390    if( CheckForQIX() )
     391        DropSpatialIndex();
    388392
    389393    return SHPWriteOGRFeature( hSHP, hDBF, poFeatureDefn, poFeature );
     
    428432
    429433    bHeaderDirty = TRUE;
     434    if( CheckForQIX() )
     435        DropSpatialIndex();
    430436
    431437    return OGRERR_NONE;
     
    442448
    443449    bHeaderDirty = TRUE;
     450    if( CheckForQIX() )
     451        DropSpatialIndex();
    444452
    445453    poFeature->SetFID( OGRNullFID );
     
    873881        return OGRERR_FAILURE;
    874882    }
    875     else
    876         return OGRERR_NONE;
     883
     884    if( !bSbnSbxDeleted )
     885    {
     886        const char *pszIndexFilename;
     887        const char papszExt[2][4] = { "sbn", "sbx" };
     888        int i;
     889        for( i = 0; i < 2; i++ )
     890        {
     891            pszIndexFilename = CPLResetExtension( pszFullName, papszExt[i] );
     892            CPLDebug( "SHAPE", "Trying to unlink index file %s", pszIndexFilename );
     893
     894            if( VSIUnlink( pszIndexFilename ) != 0 )
     895            {
     896                CPLDebug( "SHAPE",
     897                          "Failed to delete file %s.\n%s",
     898                          pszIndexFilename, VSIStrerror( errno ) );
     899            }
     900        }
     901    }
     902    bSbnSbxDeleted = TRUE;
     903
     904    return OGRERR_NONE;
    877905}
    878906
Note: See TracChangeset for help on using the changeset viewer.