<html style="direction: ltr;">
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
    <style>body p { margin-bottom: 0cm; margin-top: 0pt; } </style>
  </head>
  <body style="direction: ltr;"
    bidimailui-detected-decoding-type="latin-charset" bgcolor="#FFFFFF"
    text="#000000">
    On 02/09/2012 07:19 PM, uk52rob wrote:
    <blockquote cite="mid:013401cce74f$00806970$01813c50$@co.uk"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=ISO-8859-1">
      <meta name="Generator" content="Microsoft Word 12 (filtered
        medium)">
      <style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
        {mso-style-priority:99;
        mso-style-link:"Plain Text Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.5pt;
        font-family:Consolas;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";}
span.PlainTextChar
        {mso-style-name:"Plain Text Char";
        mso-style-priority:99;
        mso-style-link:"Plain Text";
        font-family:Consolas;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif][if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
      <div class="WordSection1">
        <p class="MsoPlainText">Thanks Andreas, I will give that a go.<o:p></o:p></p>
        <p class="MsoPlainText"><o:p> </o:p></p>
      </div>
    </blockquote>
    <p><br>
    </p>
    <p>To expand on Andreas' suggestion here's a PostGIS trigger
      function I use to automatically update columns for Lon/Lat and the
      X-Y coords for each insert of a new point:</p>
    <p><br>
    </p>
    <p>-- Function: update_lonlat_coords()<br>
      -- DROP FUNCTION update_lonlat_coords();<br>
      <br>
      CREATE OR REPLACE FUNCTION update_lonlat_coords()<br>
        RETURNS trigger AS<br>
      $BODY$<br>
      DECLARE g integer;<br>
      BEGIN<br>
          g:=NEW.gauge_id;<br>
          UPDATE rain_gauges <br>
              SET x_coord=ST_X(the_geom), y_coord=ST_Y(the_geom)    <br>
              WHERE gauge_id=g;<br>
          UPDATE rain_gauges <br>
              SET lon=ST_X(ST_TRANSFORM(the_geom,4326)),
      lat=ST_Y(ST_TRANSFORM(the_geom,4326))    <br>
              WHERE gauge_id=g;<br>
          RETURN NULL;<br>
      END;<br>
      $BODY$<br>
        LANGUAGE plpgsql VOLATILE<br>
        COST 100;<br>
      ALTER FUNCTION update_lonlat_coords() OWNER TO flood_dba;</p>
    <p><br>
    </p>
    <p>If you apply this trigger function ON INSERT, then each new point
      will automatically have lon/lat and the projected X-Y in those
      fields. <br>
    </p>
    <p>Regards,</p>
    <p>Micha <br>
    </p>
    <blockquote cite="mid:013401cce74f$00806970$01813c50$@co.uk"
      type="cite">
      <div class="WordSection1">
        <p class="MsoPlainText"><o:p> </o:p></p>
        <p class="MsoPlainText">Date: Thu, 09 Feb 2012 17:21:15 +0100<o:p></o:p></p>
        <p class="MsoPlainText">From: Andreas Neumann <<a
            moz-do-not-send="true" href="mailto:a.neumann@carto.net">a.neumann@carto.net</a>><o:p></o:p></p>
        <p class="MsoPlainText">Subject: Re: [Qgis-user] postgis / PHP<o:p></o:p></p>
        <p class="MsoPlainText">To: <<a moz-do-not-send="true"
            href="mailto:qgis-user@lists.osgeo.org">qgis-user@lists.osgeo.org</a>><o:p></o:p></p>
        <p class="MsoPlainText">Message-ID: <<a
            moz-do-not-send="true"
            href="mailto:c45ab8cba3c98432ac7ed27f2108961b@carto.net">c45ab8cba3c98432ac7ed27f2108961b@carto.net</a>><o:p></o:p></p>
        <p class="MsoPlainText">Content-Type: text/plain; charset=UTF-8;
          format=flowed<o:p></o:p></p>
        <p class="MsoPlainText"><o:p> </o:p></p>
        <p class="MsoPlainText"> Hi,<o:p></o:p></p>
        <p class="MsoPlainText"><o:p> </o:p></p>
        <p class="MsoPlainText"> You can use the Postgis commands
          "ST_AsText()" and "ST_GeomFromText()" <o:p></o:p></p>
        <p class="MsoPlainText"> for this purpose. If you want to
          extract x/y you can use<o:p></o:p></p>
        <p class="MsoPlainText"> ST_AsText(ST_X(the_geom)) AS x.<o:p></o:p></p>
        <p class="MsoPlainText"><o:p> </o:p></p>
        <p class="MsoPlainText"> Hope this helps? It is really easy -
          not complicated at all.<o:p></o:p></p>
        <p class="MsoPlainText"><o:p> </o:p></p>
        <p class="MsoPlainText"> Andreas<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
      </div>
      <br>
      <br>
      This mail was received via Mail-SeCure System.<br>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Qgis-user mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Qgis-user@lists.osgeo.org">Qgis-user@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/qgis-user">http://lists.osgeo.org/mailman/listinfo/qgis-user</a>

This mail was received via Mail-SeCure System.


</pre>
    </blockquote>
    <p><br>
    </p>
    <br>
    <pre class="moz-signature" cols="72">-- 
Micha Silver
GIS Consultant, Arava Development Co.
<a class="moz-txt-link-freetext" href="http://www.surfaces.co.il">http://www.surfaces.co.il</a></pre>
  </body>
</html>