Skip to content
Permalink
Browse files

Add initial support for editing TopoGeometry objects

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
Sandro Santilli committed Oct 31, 2012
1 parent bd8237f commit bbecffdb659ce3b5d33d11fa93290f7c04b9cbff
Showing with 22 additions and 5 deletions.
  1. +22 −5 src/providers/postgres/qgspostgresprovider.cpp
@@ -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 );

0 comments on commit bbecffd

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