<html style="direction: ltr;">
<head>
<meta content="text/html; charset=windows-1255"
http-equiv="Content-Type">
<style type="text/css">body p { margin-bottom: 0cm; margin-top: 0pt; } </style>
</head>
<body style="direction: ltr;"
bidimailui-detected-decoding-type="preferred-charset"
bgcolor="#FFFFFF" text="#660000">
<div class="moz-cite-prefix">On 12/11/2012 00:14, Bernd Vogelgesang
wrote:<br>
</div>
<blockquote cite="mid:op.wnmqqot8l2i25i@bernd-aspire-5741g"
type="cite">Hi,
<br>
i'm searching for a solution for updating field values easily
while
<br>
editing the layer.
<br>
<br>
I have a layer consisting of polygons which represent areas with a
certain
<br>
base value.
<br>
Those values multiplied with the polygons area give a result value
for the
<br>
area which is interesting for us.
<br>
<br>
We have to "remodel" the polygons (topological editing) to reach
<br>
approximately some certain result values.
<br>
It would be very nice to be able to have the polygon values be
<br>
recalculated on each save action, so we can easily see the results
without
<br>
having to go to the attribute table, open field calculator, select
all
<br>
polygons, recalculate the result values from the $area and the
base value
<br>
manually. This is quite time consuming and really boring after a
while.
<br>
<br>
I thought that there might be a way through the actions tab, but
<br>
unfortunately i have really no clue what to do there and basic
<br>
informations are really rare or only towards presenting html stuff
or
<br>
sending values to other programs but not about editing fields in a
layer
<br>
(at least i didn't find any).
<br>
<br>
I also know, that in spatialite, there is a possibility to have
triggers
<br>
to do such things, but those introductions are even more
unexisting and
<br>
mysterious.
<br>
<br>
I would prefer (not personally) a way for shape files, cause the
people
<br>
i'm doing this for possibly think spatialite and such things are
<br>
witchcraft or worse.
<br>
</blockquote>
<br>
Here's some "witchcraft"<br>
<br>
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:<br>
<br>
CREATE TRIGGER update_result_trig<br>
AFTER UPDATE ON "fields"<br>
BEGIN<br>
UPDATE fields <br>
SET result_val=(val*ST_Area(geometry))<br>
WHERE ROWID=NEW.ROWID;<br>
END<br>
<br>
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.<br>
<br>
HTH<br>
Micha<br>
<br>
<blockquote cite="mid:op.wnmqqot8l2i25i@bernd-aspire-5741g"
type="cite">
<br>
So, has anyone an idea for an action (if possible at all), or an
easy
<br>
explanation for some trigger stuff?
<br>
<br>
Thanx
<br>
bernd
<br>
<br>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
Micha Silver
GIS Consulting
052-3665918
<a class="moz-txt-link-freetext" href="http://www.surfaces.co.il">http://www.surfaces.co.il</a>
</pre>
</body>
</html>