Skip to content

Commit

Permalink
Add initial support for editing TopoGeometry objects
Browse files Browse the repository at this point in the history
This is pretty hackish in that it basically creates a new TopoGeometry
on every edit, leaving loads of orphaned ones around.
  • Loading branch information
Sandro Santilli committed Oct 31, 2012
1 parent bd8237f commit bbecffd
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions src/providers/postgres/qgspostgresprovider.cpp
Expand Up @@ -2412,11 +2412,28 @@ bool QgsPostgresProvider::changeGeometryValues( QgsGeometryMap & geometry_map )
// Start the PostGIS transaction
mConnectionRW->PQexecNR( "BEGIN" );

QString update = QString( "UPDATE %1 SET %2=%3 WHERE %4" )
.arg( mQuery )
.arg( quotedIdentifier( mGeometryColumn ) )
.arg( geomParam( 1 ) )
.arg( pkParamWhereClause( 2 ) );
QString update;

if ( mSpatialColType == sctTopoGeometry ) {
// NOTE: We are creating a new TopoGeometry objects with the new shape.
// TODO: _replace_ the initial TopoGeometry instead, so that it keeps
// the same identifier and thus still partecipates in any
// hierarchical definition. Also creating a new object results
// in orphaned topogeometries!
update = QString( "UPDATE %1 SET %2=toTopoGeom(%3,t.name,layer_id(%2))"
" FROM topology.topology t WHERE t.id = topology_id(%2)"
" AND %4" )
.arg( mQuery )
.arg( quotedIdentifier( mGeometryColumn ) )
.arg( geomParam( 1 ) )
.arg( pkParamWhereClause( 2 ) );
} else {
update = QString( "UPDATE %1 SET %2=%3 WHERE %4" )
.arg( mQuery )
.arg( quotedIdentifier( mGeometryColumn ) )
.arg( geomParam( 1 ) )
.arg( pkParamWhereClause( 2 ) );
}

QgsDebugMsg( "updating: " + update );

Expand Down

0 comments on commit bbecffd

Please sign in to comment.