all, If i want to update every time the layer every time how can it be done? I want to do undo redo operations on adding and deleting features .
thanks, hema On Mon, Feb 16, 2015 at 2:47 PM, Even Rouault <[email protected]> wrote: > Le lundi 16 février 2015 10:07:35, Hema Yeedunuri a écrit : > > hi all, > > > > I am trying to delete feature from shape layer using feature id.the > feature > > id is deleted when deleted in order descending order.When trying to > delete > > randomly it is giving error message > > Hema, > > REPACK will remove destroyed features, so it will modify the feature ids of > the features after the deleted one(s). This might explain that you get > failures if you REPACK after each deletion (wich will be inefficient, you > should > do it just after having deleted all features) if you've determined the > feature > ids before. > Note: the below code is more complicated than necessary: you just need to > call > DeleteFeature(actualIndex), no need to NULLify its geometry before. > > Even > > > > if i delete fid = 1, the below error is shown. > > > > ERROR 1: Attempt to read shape with feature id (2) out of available > range. > > > > this is what i am doing > > > > OGRFeature *delFeatur = poLayer->GetFeature(actualIndex); > > > > delFeatur->SetGeometryDirectly(NULL); > > poLayer->SetFeature(delFeatur); > > poLayer->DeleteFeature(actualIndex); > > > > OGRFeature::DestroyFeature( delFeatur ); > > > > QString sql = QString( "REPACK %1" ).arg( poLayer->GetName() ); > > reader->ExecuteSQL(sql.toLatin1().data(),NULL,NULL); > > > > poLayer->SyncToDisk(); > > > > reader->SyncToDisk(); > > > > > > > > thanks, > > > > hema > > -- > Spatialys - Geospatial professional services > http://www.spatialys.com >
_______________________________________________ gdal-dev mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/gdal-dev
