[Qgis-user] How to get a new 'the_geom' into the 'Init function' of an 'Edit UI'?
Knut Sübert
knut.suebert at ewetel.net
Fri Dec 3 11:45:15 PST 2010
Hello,
using a PostGIS-layer, I thought about adding informations to the
table. 'Edit UI' and 'Init function' are working well for updating
existent geometries. Minimal example:
def onDialogAcceptClicked(self):
if self.id: # existing polygon
query = ("update tablename set "
"comment = 'EDIT' " # just an example
"where id = %s ") % (self.id)
self.query.exec_(query)
else: # new polygon
query = ("insert into tablename (comment) "
"values ('NEW') ") # another example
self.query.exec_(query)
self.dialog.close()
return
Database works as expected. A new row with comment 'NEW' is inserted
after creating a new polygon.
But the column 'the_geom' is empty and the new created polygon
disappears from the map.
Question: How to get the data to set 'the_geom' in case of a new
polygon?
As the 'init function' gets the string 'layerid', which contains the
database connection and the name of the geometry column, maybe there's
a 'magic' function, which has to be be called?
I searched the sources to get the default 'init function', but I
didn't found it.
Regards
Knut
More information about the Qgis-user
mailing list