<html>
<head>
<meta name="generator" content="Windows Mail 17.5.9600.20689">
<style data-externalstyle="true"><!--
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph {
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
margin-bottom:.0001pt;
}
p.MsoNormal, li.MsoNormal, div.MsoNormal {
margin:0in;
margin-bottom:.0001pt;
}
p.MsoListParagraphCxSpFirst, li.MsoListParagraphCxSpFirst, div.MsoListParagraphCxSpFirst,
p.MsoListParagraphCxSpMiddle, li.MsoListParagraphCxSpMiddle, div.MsoListParagraphCxSpMiddle,
p.MsoListParagraphCxSpLast, li.MsoListParagraphCxSpLast, div.MsoListParagraphCxSpLast {
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
margin-bottom:.0001pt;
line-height:115%;
}
--></style></head>
<body dir="ltr">
<div data-externalstyle="false" dir="ltr" style="font-family: 'Calibri', 'Segoe UI', 'Meiryo', 'Microsoft YaHei UI', 'Microsoft JhengHei UI', 'Malgun Gothic', 'sans-serif';font-size:12pt;"><div>Obrigado a Todos</div><div><br></div><div>Já esta a funcionar.</div><div><br></div><div>Abraço</div><div>Nuno Cortês<br></div><div data-signatureblock="true"><div><br></div><div>Enviado de Correio do Windows</div><div><br></div></div><div style="padding-top: 5px; border-top-color: rgb(229, 229, 229); border-top-width: 1px; border-top-style: solid;"><div><font face=" 'Calibri', 'Segoe UI', 'Meiryo', 'Microsoft YaHei UI', 'Microsoft JhengHei UI', 'Malgun Gothic', 'sans-serif'" style='line-height: 15pt; letter-spacing: 0.02em; font-family: "Calibri", "Segoe UI", "Meiryo", "Microsoft YaHei UI", "Microsoft JhengHei UI", "Malgun Gothic", "sans-serif"; font-size: 12pt;'><b>De:</b> <a href="mailto:andre.s.mano@gmail.com" target="_parent">Andre Mano</a><br><b>Enviada:</b> quinta-feira, 2 de abril de 2015 09:58<br><b>Para:</b> <a href="mailto:portugal@lists.osgeo.org" target="_parent">portugal@lists.osgeo.org</a></font></div></div><div><br></div><div dir=""><div dir="ltr"><div><div>Ola Marco,<br><br></div>Para fazeres isso tens de implementar um trigger na tua base de dados. Estes comandos deverao funcionar, apenas tens de mudar o nome dos campos:<br><font><br>
</font><p style="text-align: left; margin-top: 0pt; margin-bottom: 0pt; vertical-align: baseline; direction: ltr;"><font><span style="color: rgb(0, 176, 80); font-family: Arial;">-- Cr</span><span style="color: rgb(0, 176, 80); font-family: Arial;">iar o trigger<br></span></font></p><font>
</font><p style="text-align: left; margin-top: 0pt; margin-bottom: 0pt; vertical-align: baseline; direction: ltr;"><font><span style="color: blue; font-family: Arial;">CREATE </span><span style="color: blue; font-family: Arial;">OR REPLACE FUNCTION </span><span style="color: black; font-family: Arial;">computing_area</span><span style="color: black; font-family: Arial;">()<span>
</span></span><span style="color: black; font-family: Arial;"><span> </span></span></font></p><font>
</font><p style="text-align: left; margin-top: 0pt; margin-bottom: 0pt; vertical-align: baseline; direction: ltr;"><font><span style="color: blue; font-family: Arial;"><span> </span>RETURNS
</span><span style="color: blue; font-family: Arial;">TRIGGER </span><span style="color: blue; font-family: Arial;">AS</span></font></p><font>
</font><p style="text-align: left; margin-top: 0pt; margin-bottom: 0pt; vertical-align: baseline; direction: ltr;"><font><span style="color: black; font-family: Arial;"><span>
</span>$</span><span style="color: blue; font-family: Arial;">BODY</span><span style="color: black; font-family: Arial;">$</span><span style="color: blue; font-family: Arial;"><span>
</span></span></font></p><font>
</font><p style="text-align: left; margin-top: 0pt; margin-bottom: 0pt; vertical-align: baseline; direction: ltr;"><font><span style="color: blue; font-family: Arial;"><span> </span></span><span style="color: blue; font-family: Arial;">BEGIN<span> </span></span></font></p><font>
</font><p style="text-align: left; margin-top: 0pt; margin-bottom: 0pt; vertical-align: baseline; direction: ltr;"><font><span style="color: blue; font-family: Arial;"><span> </span><span> </span></span><span style="color: blue; font-family: Arial;"><span> </span></span><span style="color: blue; font-family: Arial;">NEW.area</span><span style="color: blue; font-family: Arial;"> </span><span style="color: blue; font-family: Arial;">:=
ROUND((</span><span style="color: blue; font-family: Arial;">st_area</span><span style="color: blue; font-family: Arial;">(</span><span style="color: blue; font-family: Arial;">NEW.geom</span><span style="color: blue; font-family: Arial;">))::numeric,2);<span> </span><span> </span></span><span style="color: blue; font-family: Arial;"><span> </span>RETURN </span><span style="color: blue; font-family: Arial;">NEW;<span> </span></span></font></p><font>
</font><p style="text-align: left; margin-top: 0pt; margin-bottom: 0pt; vertical-align: baseline; direction: ltr;"><font><span style="color: blue; font-family: Arial;"><span> </span></span><span style="color: blue; font-family: Arial;">END;</span></font></p><font>
</font><p style="text-align: left; margin-top: 0pt; margin-bottom: 0pt; vertical-align: baseline; direction: ltr;"><font><span style="color: black; font-family: Arial;"><span>
</span>$</span><span style="color: blue; font-family: Arial;">BODY</span><span style="color: black; font-family: Arial;">$</span><span style="color: blue; font-family: Arial;"><span>
</span></span></font></p><font>
</font><p style="text-align: left; margin-top: 0pt; margin-bottom: 0pt; vertical-align: baseline; direction: ltr;"><font><span style="color: blue; font-family: Arial;">LANGUAGE </span><span style="color: black; font-family: Arial;">'</span><span style="color: black; font-family: Arial;">plpgsql</span><span style="color: black; font-family: Arial;">'</span></font></p><p style="text-align: left; margin-top: 0pt; margin-bottom: 0pt; vertical-align: baseline; direction: ltr;"><font><span style="color: black; font-family: Arial;"><br></span></font></p><font>
</font><p style="text-align: left; margin-top: 0pt; margin-bottom: 0pt; vertical-align: baseline; direction: ltr;"><font><span style="color: rgb(0, 176, 80); font-family: Arial;">-- </span><span style="color: rgb(0, 176, 80); font-family: Arial;">implementar o trigger<br></span></font></p><font>
</font><p style="text-align: left; margin-top: 0pt; margin-bottom: 0pt; vertical-align: baseline; direction: ltr;"><font><span style="color: blue; font-family: Arial;">CREATE TRIGGER</span><span style="color: black; font-family: Arial;"> </span><span style="color: black; font-family: Arial;">calculate_area</span><span style="color: black; font-family: Arial;"> </span></font></p><font>
</font><p style="text-align: left; margin-top: 0pt; margin-bottom: 0pt; vertical-align: baseline; direction: ltr;"><font><span style="color: blue; font-family: Arial;"><span> </span>BEFORE</span><span style="color: black; font-family: Arial;"> </span><span style="color: blue; font-family: Arial;">INSERT</span><span style="color: black; font-family: Arial;"> </span><span style="color: blue; font-family: Arial;">OR</span><span style="color: black; font-family: Arial;"> </span><span style="color: blue; font-family: Arial;">UPDATE<span> </span></span></font></p><font>
</font><p style="text-align: left; margin-top: 0pt; margin-bottom: 0pt; vertical-align: baseline; direction: ltr;"><font><span style="color: blue; font-family: Arial;"><span> </span>ON</span><span style="color: black; font-family: Arial;"> </span><span style="color: black; font-family: Arial;">landplot</span><span style="color: black; font-family: Arial;"><span> </span></span></font></p><font>
</font><p style="text-align: left; margin-top: 0pt; margin-bottom: 0pt; vertical-align: baseline; direction: ltr;"><font><span style="color: blue; font-family: Arial;"><span> </span>FOR</span><span style="color: black; font-family: Arial;"> </span><span style="color: blue; font-family: Arial;">EACH</span><span style="color: black; font-family: Arial;"> </span><span style="color: blue; font-family: Arial;">ROW<span> </span></span></font></p><font>
</font><p style="text-align: left; margin-top: 0pt; margin-bottom: 0pt; vertical-align: baseline; direction: ltr;"><font><span style="color: blue; font-family: Arial;"><span> </span>EXECUTE</span><span style="color: black; font-family: Arial;"> </span><span style="color: blue; font-family: Arial;">PROCEDURE</span><span style="color: black; font-family: Arial;"> </span><span style="color: black; font-family: Arial;">computing_area</span><span style="color: black; font-family: Arial;">();</span></font></p>
<br></div><br></div><div class="gmail_extra"><br><div class="gmail_quote">2015-04-02 10:47 GMT+02:00 <span dir="ltr"><<a href="mailto:nmrcortes@gmail.com" target="_parent">nmrcortes@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid;">
<div dir="ltr">
<div style='font-family: "Calibri","Segoe UI","Meiryo","Microsoft YaHei UI","Microsoft JhengHei UI","Malgun Gothic","sans-serif"; font-size: 12pt;' dir="ltr"><div><br></div><div><div>Quero criar uma coluna numa tabela (polígono) no PostGIS que calcule a área automaticamente e que a mantenha actualizada sempre que se altere a geometria do polígono no Qgis.</div><div><br></div><div>Com o seguinte SQL:<br>UPDATE "Parcela" SET AreaHectares=ST_AREA(geom)/10000; <br>FROM<br> "Parcela"</div><div><br></div><div>Faz a actualização da área mas tenho que fazer o Update sempre que altero a geometria.<br>Há alguma forma de fazer isto automaticamente?</div><div><br></div><div>Obrigado<br>Nuno Cortês<br></div><div><br></div><div><br></div></div></div>
</div>
<br>_______________________________________________<br>
Portugal mailing list<br>
<a href="mailto:Portugal@lists.osgeo.org" target="_parent">Portugal@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/portugal" target="_parent">http://lists.osgeo.org/mailman/listinfo/portugal</a><br></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature">..................................<br>André Mano<br><a style="color: rgb(0, 0, 153);" href="http://opussig.blogspot.com/" target="_parent"><font size="1">http://opussig.blogspot.com/</font></a><br></div>
</div>
</div></div>
</body>
</html>