<DIV> </DIV>
<DIV>Hi,</DIV>
<DIV> i try to delete features from a set of shape file, sometimes get error. I use this version of ogrshapelayer.cpp : <A href="http://trac.osgeo.org/gdal/changeset/10969">http://trac.osgeo.org/gdal/changeset/10969</A> . Delete feature in two ways would get different result:</DIV>
<DIV>(1) for(iFeat=0;iFeat<nFeat;iFeat++)<BR> {<BR> int cplE = pLayer->DeleteFeature(0);<BR> if(cplE==CE_None)<BR> { <BR> OGRShapeLayer* pShpLayer = (OGRShapeLayer*)pLayer;<BR> cplE = pShpLayer->Repack();</DIV>
<DIV> if(cplE!=CE_None)<BR> {<BR> printf("delete feature failed ŁĄ\n");<BR> return false;<BR> }<BR> }<BR> }</DIV>
<DIV> int nFeatRest = pLayer->GetFeatureCount();</DIV>
<DIV> </DIV>
<DIV> These codes could delete each feature with returned value CE_None, and at the end nFeatRest=0. But when ran to pShpLayer->Repack() second, the error occurs: "Failure writing DBF record 0", it jumped untill all features were deleted.</DIV>
<DIV> </DIV>
<DIV>(2) for(iFeat=nFeat-1;iFeat>=0;iFeat--)<BR> {<BR> int cplE = pLayer->DeleteFeature(iFeat);</DIV>
<DIV> if(cplE==CE_None)<BR> { <BR> OGRShapeLayer* pShpLayer = (OGRShapeLayer*)pLayer;<BR> cplE = pShpLayer->Repack();<BR> if(cplE!=CE_None)<BR> {<BR> printf("delete feature failed ŁĄ\n");<BR> return false;<BR> }<BR> }<BR> }</DIV>
<DIV> int nFeatRest = pLayer->GetFeatureCount();</DIV>
<DIV> </DIV>
<DIV> These codes could delete each feature with returned value CE_None, but at the end nFeatRest>0 and nFeatRest<nFeat, some features were NOT deleted yet! Same as (1), when ran to pShpLayer->Repack() second, the error occurs: "Failure writing DBF record iFeat", it jumped untill all features were deleted.</DIV>
<DIV> Trace the error "Failure writing DBF record ..." into Repack():</DIV>
<DIV> /* -------------------------------------------------------------------- */<BR> /* Build a list of records to be dropped. */<BR> /* -------------------------------------------------------------------- */<BR> ...</DIV>
<DIV> for( iShape = 0; iShape < nTotalShapeCount; iShape++ )<BR> {<BR> if( DBFIsRecordDeleted( hDBF, iShape ) )//------------ERROR jumped ---------<BR> panRecordsToDelete[nDeleteCount++] = iShape;<BR> }<BR> Why did this phenomena occurs? </DIV>
<DIV> Thank you.</DIV>
<DIV> </DIV>
<DIV style="FONT-SIZE: 12px; COLOR: #909090; FONT-FAMILY: Arial Narrow">------------------</DIV>
<DIV>
<DIV>To the world you're little, but to a person you're the world.</DIV>
<DIV> Chen Xuexia</DIV></DIV>