@@ -1182,6 +1182,49 @@ cannot change attribute");
11821182 return true ;
11831183}
11841184
1185+ bool QgsOgrProvider::changeGeometryValues (std::map<int , QgsGeometry> & geometry_map)
1186+ {
1187+ OGRFeature* theOGRFeature = 0 ;
1188+ OGRGeometry* theNewGeometry = 0 ;
1189+
1190+ for (std::map<int , QgsGeometry>::iterator it = geometry_map.begin (); it != geometry_map.end (); ++it)
1191+ {
1192+ theOGRFeature = ogrLayer->GetFeature (it->first );
1193+ if (!theOGRFeature)
1194+ {
1195+ QgsLogger::warning (" QgsOgrProvider::changeGeometryValues, cannot find feature" );
1196+ continue ;
1197+ }
1198+
1199+ // create an OGRGeometry
1200+ if (OGRGeometryFactory::createFromWkb (it->second .wkbBuffer (), ogrLayer->GetSpatialRef (), &theNewGeometry, it->second .wkbSize ()) != OGRERR_NONE)
1201+ {
1202+ QgsLogger::warning (" QgsOgrProvider::changeGeometryValues, error while creating new OGRGeometry" );
1203+ delete theNewGeometry;
1204+ theNewGeometry = 0 ;
1205+ continue ;
1206+ }
1207+
1208+ if (!theNewGeometry)
1209+ {
1210+ QgsLogger::warning (" QgsOgrProvider::changeGeometryValues, new geometry is NULL" );
1211+ continue ;
1212+ }
1213+
1214+ // set the new geometry
1215+ if (theOGRFeature->SetGeometryDirectly (theNewGeometry) != OGRERR_NONE)
1216+ {
1217+ QgsLogger::warning (" QgsOgrProvider::changeGeometryValues, error while replacing geometry" );
1218+ delete theNewGeometry;
1219+ theNewGeometry = 0 ;
1220+ continue ;
1221+ }
1222+ ogrLayer->SetFeature (theOGRFeature);
1223+ }
1224+ ogrLayer->SyncToDisk ();
1225+ return true ;
1226+ }
1227+
11851228bool QgsOgrProvider::createSpatialIndex ()
11861229{
11871230 QString filename=getDataSourceUri ().section (' /' ,-1 ,-1 );// find out the filename from the uri
@@ -1272,8 +1315,7 @@ int QgsOgrProvider::capabilities() const
12721315 // TODO And test appropriately.
12731316
12741317 ability |= ChangeAttributeValues;
1275- // This provider can't change geometries yet anyway (cf. Postgres provider)
1276- // ability |= QgsVectorDataProvider::ChangeGeometries;
1318+ ability |= QgsVectorDataProvider::ChangeGeometries;
12771319 }
12781320
12791321 if (ogrLayer->TestCapability (" FastSpatialFilter" ))
0 commit comments