<DIV> Hi, Frank,thank you for reply. </DIV>
<DIV> I have posted the ticket with little experience here:</DIV>
<DIV> <A href="http://trac.osgeo.org/gdal/ticket/2531">http://trac.osgeo.org/gdal/ticket/2531</A>.</DIV>
<DIV> Attachment of this mail is the example project. Thank you for more help.</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>
<DIV> </DIV>
<DIV> </DIV>
<DIV style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 12px; PADDING-BOTTOM: 2px; PADDING-TOP: 2px; FONT-FAMILY: Arial Narrow">------------------ Original ------------------</DIV>
<DIV style="FONT-SIZE: 12px">
<DIV id=menu_sender><B>From: </B> "Frank Warmerdam"<warmerdam@pobox.com>;</DIV>
<DIV><B>Date: </B> Fri, Aug 15, 2008 10:06 AM</DIV>
<DIV><B>To: </B> "wow"<27949218@qq.com>; </DIV>
<DIV><B>Cc: </B> "gdal-dev"<gdal-dev@lists.osgeo.org>; </DIV>
<DIV><B>Subject: </B> Re: [gdal-dev] deleting feature exceptions</DIV></DIV>
<DIV> </DIV>
<DIV style="FONT-WEIGHT: normal">Chen,<BR><BR>I'm surprised both approaches don't work smoothly. I'd suggest you boil<BR>down a minimum example of the problem, and file a bug ticket on it<BR>including the input data.<BR><BR>Best regards,<BR>FrankW<BR><BR>2008/8/14 wow <27949218@qq.com>:<BR>><BR>> Hi,<BR>> i try to delete features from a set of shape file, sometimes get error. I<BR>> use this version of ogrshapelayer.cpp :<BR>> http://trac.osgeo.org/gdal/changeset/10969 . Delete feature in two ways<BR>> would get different result:<BR>> (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();<BR>> if(cplE!=CE_None)<BR>> {<BR>> printf("delete feature failed !\n");<BR>> return false;<BR>> }<BR>> }<BR>> }<BR>> int nFeatRest = pLayer->GetFeatureCount();<BR>><BR>> These codes could delete each feature with returned value CE_None, and<BR>> at the end nFeatRest=0. But when ran to pShpLayer->Repack() second, the<BR>> error occurs: "Failure writing DBF record 0", it jumped untill all features<BR>> were deleted.<BR>><BR>> (2) for(iFeat=nFeat-1;iFeat>=0;iFeat--)<BR>> {<BR>> int cplE = pLayer->DeleteFeature(iFeat);<BR>> 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>> }<BR>> int nFeatRest = pLayer->GetFeatureCount();<BR>><BR>> These codes could delete each feature with returned value CE_None, but<BR>> at the end nFeatRest>0 and nFeatRest<nFeat, some features were NOT deleted<BR>> yet! Same as (1), when ran to pShpLayer->Repack() second, the error<BR>> occurs: "Failure writing DBF record iFeat", it jumped untill all features<BR>> were deleted.<BR>> Trace the error "Failure writing DBF record ..." into Repack():<BR>> /* --------------------------------------------------------------------<BR>> */<BR>> /* Build a list of records to be dropped.<BR>> */<BR>> /* --------------------------------------------------------------------<BR>> */<BR>> ...<BR>> for( iShape = 0; iShape < nTotalShapeCount; iShape++ )<BR>> {<BR>> if( DBFIsRecordDeleted( hDBF, iShape ) )//------------ERROR jumped<BR>> ---------<BR>> panRecordsToDelete[nDeleteCount++] = iShape;<BR>> }<BR>> Why did this phenomena occurs?<BR>> Thank you.<BR>><BR>> ------------------<BR>> To the world you're little, but to a person you're the world.<BR>> Chen Xuexia<BR>> _______________________________________________<BR>> gdal-dev mailing list<BR>> gdal-dev@lists.osgeo.org<BR>> http://lists.osgeo.org/mailman/listinfo/gdal-dev<BR>><BR><BR><BR><BR>-- <BR>---------------------------------------+--------------------------------------<BR>I set the clouds in motion - turn up | Frank Warmerdam, warmerdam@pobox.com<BR>light and sound - activate the windows | http://pobox.com/~warmerdam<BR>and watch the world go round - Rush | Geospatial Programmer for Rent<BR></DIV><div id=QQMailBigAttach style='font-size:12px;padding-top:60px;text-align:left;'><hr style='width:75%;color:#909090;' size='1px' align=left><span style='color:#909090;font-size:12px;display:block;'>以下文件通过QQ邮箱的中转站发给您。保存时间有限制,请及时提取。</span><span style='margin:5px 0 0 0;font-size:12px;display:block;'><span class='qqmailbgattach' style='font-weight:bold;' expiretime='1219389244' downloadlink='http://mail.qq.com/cgi-bin/exs_download?uin=27949218&svrid=240&fid=0005cdc7f9832359f9e4eb3efc621a7a0b6aed38b0648f15&temp=74cb36d4&k=87991e35a04ec67fda159d7b32331b39613965348d6133658e603632216137615d0b584c15165c523401180016145047&code=74cb36d4&s=email'>min-projV1.4.rar<SPAN style="FONT-WEIGHT: normal"> (2.92M)</SPAN> <WBR><WBR></span>[<a href='http://mail.qq.com/cgi-bin/exs_download?uin=27949218&svrid=240&fid=0005cdc7f9832359f9e4eb3efc621a7a0b6aed38b0648f15&temp=74cb36d4&k=87991e35a04ec67fda159d7b32331b39613965348d6133658e603632216137615d0b584c15165c523401180016145047&code=74cb36d4&s=email' target=_blank>下载</a>] <span style='color:#909090'>(有效时间到: 2008年8月22日 15:14)</span></span></div>