Skip to content

Commit bbecffd

Browse files
author
Sandro Santilli
committedOct 31, 2012
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.
1 parent bd8237f commit bbecffd

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed
 

‎src/providers/postgres/qgspostgresprovider.cpp

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2412,11 +2412,28 @@ bool QgsPostgresProvider::changeGeometryValues( QgsGeometryMap & geometry_map )
24122412
// Start the PostGIS transaction
24132413
mConnectionRW->PQexecNR( "BEGIN" );
24142414

2415-
QString update = QString( "UPDATE %1 SET %2=%3 WHERE %4" )
2416-
.arg( mQuery )
2417-
.arg( quotedIdentifier( mGeometryColumn ) )
2418-
.arg( geomParam( 1 ) )
2419-
.arg( pkParamWhereClause( 2 ) );
2415+
QString update;
2416+
2417+
if ( mSpatialColType == sctTopoGeometry ) {
2418+
// NOTE: We are creating a new TopoGeometry objects with the new shape.
2419+
// TODO: _replace_ the initial TopoGeometry instead, so that it keeps
2420+
// the same identifier and thus still partecipates in any
2421+
// hierarchical definition. Also creating a new object results
2422+
// in orphaned topogeometries!
2423+
update = QString( "UPDATE %1 SET %2=toTopoGeom(%3,t.name,layer_id(%2))"
2424+
" FROM topology.topology t WHERE t.id = topology_id(%2)"
2425+
" AND %4" )
2426+
.arg( mQuery )
2427+
.arg( quotedIdentifier( mGeometryColumn ) )
2428+
.arg( geomParam( 1 ) )
2429+
.arg( pkParamWhereClause( 2 ) );
2430+
} else {
2431+
update = QString( "UPDATE %1 SET %2=%3 WHERE %4" )
2432+
.arg( mQuery )
2433+
.arg( quotedIdentifier( mGeometryColumn ) )
2434+
.arg( geomParam( 1 ) )
2435+
.arg( pkParamWhereClause( 2 ) );
2436+
}
24202437

24212438
QgsDebugMsg( "updating: " + update );
24222439

0 commit comments

Comments
 (0)
Please sign in to comment.