Skip to content
Permalink
Browse files

Added possibility to delete features for OGR layers.

However then I've found out that nearly no OGR drivers support it :-)


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5062 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder
wonder committed Mar 19, 2006
1 parent 7955a13 commit b1995af7b1ec1f811a5bd53228ad3b0bb7aa526a
Showing with 33 additions and 2 deletions.
  1. +28 −2 src/providers/ogr/qgsogrprovider.cpp
  2. +5 −0 src/providers/ogr/qgsogrprovider.h
@@ -1159,6 +1159,25 @@ bool QgsOgrProvider::createSpatialIndex()
}
}

bool QgsOgrProvider::deleteFeatures(std::list<int> const & id)
{
bool returnvalue=true;
for(std::list<int>::const_iterator it=id.begin();it!=id.end();++it)
{
if(!deleteFeature(*it))
{
returnvalue=false;
}
}
return returnvalue;
}

bool QgsOgrProvider::deleteFeature(int id)
{
OGRErr res = ogrLayer->DeleteFeature(id);
return (res == OGRERR_NONE);
}

int QgsOgrProvider::capabilities() const
{
int ability = NoCapabilities;
@@ -1185,6 +1204,12 @@ int QgsOgrProvider::capabilities() const
ability |= QgsVectorDataProvider::AddFeatures;
}

if (ogrLayer->TestCapability("DeleteFeature"))
// TRUE if this layer can delete its features
{
ability |= DeleteFeatures;
}

if (ogrLayer->TestCapability("RandomWrite"))
// TRUE if the SetFeature() method is operational on this layer.
{
@@ -1232,9 +1257,10 @@ int QgsOgrProvider::capabilities() const
{
// No use required for this QGIS release.
}

#ifdef QGISDEBUG
std::cout << "QgsOgrProvider::capabilities: GDAL Version Num is 'GDAL_VERSION_NUM'." << std::endl;
std::cout << "QgsOgrProvider::capabilities: GDAL Version Num is '" <<
GDAL_VERSION_NUM << "'." << std::endl;
#endif

if (1)
@@ -147,6 +147,9 @@ class QgsOgrProvider:public QgsVectorDataProvider
/**Writes a list of features to the file*/
bool addFeatures(std::list<QgsFeature*> const flist);

/**Deletes a feature*/
bool deleteFeatures(std::list<int> const & id);

/**Adds new attributess. Unfortunately not supported for layers with features in it*/
bool addAttributes(std::map<QString,QString> const & name);

@@ -260,6 +263,8 @@ class QgsOgrProvider:public QgsVectorDataProvider
OGRPolygon * mSelectionRectangle;
/**Adds one feature*/
bool addFeature(QgsFeature* f);
/**Deletes one feature*/
bool deleteFeature(int id);
//! The geometry factory
geos::GeometryFactory *geometryFactory;
//! The well known text reader

0 comments on commit b1995af

Please sign in to comment.
You can’t perform that action at this time.