Skip to content
Permalink
Browse files

allow setting geometry empty in postgres and spatialite provider (app…

…lies PR#1343)
  • Loading branch information
jef-n committed May 9, 2014
1 parent 59e6abc commit 38e694713a742baa85577c6454934d0ca43a7f66
Showing with 27 additions and 39 deletions.
  1. +2 −8 src/providers/postgres/qgspostgresprovider.cpp
  2. +25 −31 src/providers/spatialite/qgsspatialiteprovider.cpp
@@ -2171,18 +2171,12 @@ bool QgsPostgresProvider::changeGeometryValues( QgsGeometryMap & geometry_map )
throw PGException( result );
}

QgsDebugMsg( "iterating over the map of changed geometries..." );

for ( QgsGeometryMap::iterator iter = geometry_map.begin();
iter != geometry_map.end();
++iter )
{
QgsDebugMsg( "iterating over the map of changed geometries..." );

if ( !iter->asWkb() )
{
QgsDebugMsg( "empty geometry" );
continue;
}

QgsDebugMsg( "iterating over feature id " + FID_TO_STRING( iter.key() ) );

// Save the id of the current topogeometry
@@ -3981,39 +3981,33 @@ bool QgsSpatiaLiteProvider::changeGeometryValues( QgsGeometryMap & geometry_map

for ( QgsGeometryMap::iterator iter = geometry_map.begin(); iter != geometry_map.end(); ++iter )
{
// looping on each feature to change
if ( iter->asWkb() )
{

// resetting Prepared Statement and bindings
sqlite3_reset( stmt );
sqlite3_clear_bindings( stmt );

// binding GEOMETRY to Prepared Statement
unsigned char *wkb = NULL;
size_t wkb_size;
convertFromGeosWKB( iter->asWkb(), iter->wkbSize(), &wkb, &wkb_size,
nDims );
if ( !wkb )
sqlite3_bind_null( stmt, 1 );
else
sqlite3_bind_blob( stmt, 1, wkb, wkb_size, free );
sqlite3_bind_int64( stmt, 2, FID_TO_NUMBER( iter.key() ) );
// resetting Prepared Statement and bindings
sqlite3_reset( stmt );
sqlite3_clear_bindings( stmt );

// performing actual row update
ret = sqlite3_step( stmt );
if ( ret == SQLITE_DONE || ret == SQLITE_ROW )
;
else
{
// some unexpected error occurred
const char *err = sqlite3_errmsg( sqliteHandle );
int len = strlen( err );
errMsg = ( char * ) sqlite3_malloc( len + 1 );
strcpy( errMsg, err );
goto abort;
}
// binding GEOMETRY to Prepared Statement
unsigned char *wkb = NULL;
size_t wkb_size;
convertFromGeosWKB( iter->asWkb(), iter->wkbSize(), &wkb, &wkb_size,
nDims );
if ( !wkb )
sqlite3_bind_null( stmt, 1 );
else
sqlite3_bind_blob( stmt, 1, wkb, wkb_size, free );
sqlite3_bind_int64( stmt, 2, FID_TO_NUMBER( iter.key() ) );

// performing actual row update
ret = sqlite3_step( stmt );
if ( ret == SQLITE_DONE || ret == SQLITE_ROW )
;
else
{
// some unexpected error occurred
const char *err = sqlite3_errmsg( sqliteHandle );
int len = strlen( err );
errMsg = ( char * ) sqlite3_malloc( len + 1 );
strcpy( errMsg, err );
goto abort;
}
}
sqlite3_finalize( stmt );

0 comments on commit 38e6947

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