[gdal-dev] Delete Feature
Even Rouault
even.rouault at spatialys.com
Mon Feb 16 01:17:28 PST 2015
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
More information about the gdal-dev
mailing list