On 12/11/2012 00:14, Bernd Vogelgesang wrote:
Hi,
i'm searching for a solution for updating field values easily while
editing the layer.

I have a layer consisting of polygons which represent areas with a certain
base value.
Those values multiplied with the polygons area give a result value for the
area which is interesting for us.

We have to "remodel" the polygons (topological editing) to reach
approximately some certain result values.
It would be very nice to be able to have the polygon values be
recalculated on each save action, so we can easily see the results without
having to go to the attribute table, open field calculator, select all
polygons, recalculate the result values from the $area and the base value
manually. This is quite time consuming and really boring after a while.

I thought that there might be a way through the actions tab, but
unfortunately i have really no clue what to do there and basic
informations are really rare or only towards presenting html stuff or
sending values to other programs but not about editing fields in a layer
(at least i didn't find any).

I also know, that in spatialite, there is a possibility to have triggers
to do such things, but those introductions are even more unexisting and
mysterious.

I would prefer (not personally) a way for shape files, cause the people
i'm doing this for possibly think spatialite and such things are
witchcraft or worse.

Here's some "witchcraft"

In a spatialite DB, I have a polygon table "fields". I Added an integer column "val" and a column "result_val" of type real. Then I set up this trigger:

CREATE TRIGGER update_result_trig
AFTER UPDATE ON "fields"
BEGIN
    UPDATE fields
    SET result_val=(val*ST_Area(geometry))
    WHERE ROWID=NEW.ROWID;
END

I loaded the spatialite polygon layer into QGIS and set the "result_val" attribute as a label for each polygon. Now I started editing. At each click of the save button the label, representing the result_val, changes. Seems to work nicely.

HTH
Micha


So, has anyone an idea for an action (if possible at all), or an easy
explanation for some trigger stuff?

Thanx
bernd



-- 
Micha Silver
GIS Consulting
052-3665918
http://www.surfaces.co.il

_______________________________________________
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user

Reply via email to