Siva,

In shapefile format, deleted features are just 'marked' as deleted instead
of actually removing them. This makes it faster. However, the statistics
may not be updated. Specifying the the bForce parameter with the
GetFeatureCount() method may be useful.
To actually remove the features, you have to create a new shapefile layer
object and save it.

BTW, you should use GetFeatureCountI() instead of GetFieldCount().

On Wed, Oct 31, 2012 at 4:01 PM, SIVA RAMA KRISHNA
<s.r.kriis...@gmail.com>wrote:

> hai chaitanya,
>
>                         I have fixed it by using point.within(geometry)
>                         But I am having a problem  with  deleting a
> feature
>                         After deleting a feature succesfully from a shape
> file
>                         Next time when i load it is all features  count
> but displying correctly with the undelaeted features
>
>   void myWindow::selectingFeature(QMouseEvent* event)
>
>   {
>     poLayer->ResetReading();
>    while( (poFeature = poLayer->GetNextFeature()) != NULL )
>            {
>                 poGeometry = poFeature->GetGeometryRef();
>                  if(poGeometry !=NULL
>                                       &&
> wkbFlatten(poGeometry->getGeometryType()) == wkbPolygon)
>                                 {
>
>                                     if( p2.Within(poGeometry))
>                                     {
>                                            polyShape  = (OGRPolygon*)
> poGeometry;
>                                            qDebug()<<"Feature Selected";
>                                            qDebug()<<poFeature->GetFID();
>                                            path.addPolygon(polygon);
>                                            featureid=poFeature->GetFID();
>                                      }
>
>
>                                }
>
>                    }
>
>         }
>
>
>
> // this is a slot after deleting  a feature
> void myWindow::DeletingFeature()
> {
>
>      qDebug()<<" deleting feature";
>
>      poLayer->ResetReading();
>      while( (poFeature = poLayer->GetNextFeature()) != NULL )
>              {
>                   poLayer->DeleteFeature(featureid);
>                   qDebug()<<"deleted"<<poFeature->GetFieldCount();
>                   qDebug()<<poFeature->GetFID();
>               }
>
> }
>
> No of features 3
>
> Feature Selected
>
> 1
>
> not
>
> deleting feature
>
> deleted 1
>
> 1
>
> ERROR 1: Attempt to delete shape with feature id (1), but it is marked
> deleted already.
>
> deleted 1
>
> 2
>
> with Regards
>
>


-- 
Best regards,
Chaitanya kumar CH.

+91-9494447584
17.2416N 80.1426E
_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to