<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Hola Luis,<br>
      <br>
      Gracias! Funciona perfectamente.<br>
      <br>
      Mikel<br>
      <br>
      2015/02/24 14:01(e)an, Luis Franco Vázquez igorleak idatzi zuen:<br>
    </div>
    <blockquote
cite="mid:CAAtnAdURDrc=TjtBwfGFdT0n19iJuy4zwth0tPqPR_v88NJVsA@mail.gmail.com"
      type="cite">
      <div dir="ltr">Pues es muy simple. Suponiendo que tus nuevos
        campos x e y se llaman x_25830 e y_25830 (adáptalos a tu gusto),
        solo tienes que añadir dos líneas y reemplazar la función
        ejecutando lo que sigue:
        <div><span style="color:rgb(0,0,0);font-size:12.8000001907349px">CREATE
            OR REPLACE FUNCTION errepide_intz()</span><br
            style="color:rgb(0,0,0);font-size:12.8000001907349px">
          <span style="color:rgb(0,0,0);font-size:12.8000001907349px"> 
            RETURNS trigger AS</span><br
            style="color:rgb(0,0,0);font-size:12.8000001907349px">
          <span style="color:rgb(0,0,0);font-size:12.8000001907349px">$BODY$</span><br
            style="color:rgb(0,0,0);font-size:12.8000001907349px">
          <span style="color:rgb(0,0,0);font-size:12.8000001907349px">   
            DECLARE</span><br
            style="color:rgb(0,0,0);font-size:12.8000001907349px">
          <span style="color:rgb(0,0,0);font-size:12.8000001907349px">   
            BEGIN</span><br
            style="color:rgb(0,0,0);font-size:12.8000001907349px">
          <span style="color:rgb(0,0,0);font-size:12.8000001907349px">NEW.geom:=ST_transform(ST_</span><span
            style="color:rgb(0,0,0);font-size:12.8000001907349px">SetSRID(ST_MakePoint(NEW.lon,</span><span
            style="color:rgb(0,0,0);font-size:12.8000001907349px">NEW.lat),4326),25830);</span></div>
        <div>NEW.x_25830 := ST_X(NEW.geom);</div>
        <div>NEW.y_25830 := ST_Y(NEW.geom);<br>
          <span style="color:rgb(0,0,0);font-size:12.8000001907349px">   
            RETURN NEW;</span><br
            style="color:rgb(0,0,0);font-size:12.8000001907349px">
          <span style="color:rgb(0,0,0);font-size:12.8000001907349px">   
            END;</span><br
            style="color:rgb(0,0,0);font-size:12.8000001907349px">
          <span style="color:rgb(0,0,0);font-size:12.8000001907349px">$BODY$</span><br
            style="color:rgb(0,0,0);font-size:12.8000001907349px">
          <span style="color:rgb(0,0,0);font-size:12.8000001907349px"> 
            LANGUAGE plpgsql VOLATILE</span><br
            style="color:rgb(0,0,0);font-size:12.8000001907349px">
          <span style="color:rgb(0,0,0);font-size:12.8000001907349px"> 
            COST 100;</span><br>
        </div>
        <div><br>
        </div>
        <div>Prueba y cuentas. Deberías echarle un vistazo al manual de
          postgresql.</div>
        <div>Si quieres actualizar los registros que ya tienes haces:</div>
        <div>UPDATE tu_tabla SET x_25830 = ST_X(geom), y_25830 =
          ST_Y(geom);</div>
        <div><br>
        </div>
        <div>Muy simple, la verdad.</div>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">El 24 de febrero de 2015, 13:47, Mikel
          <span dir="ltr"><<a moz-do-not-send="true"
              href="mailto:m.ayesta@gislan.com" target="_blank">m.ayesta@gislan.com</a>></span>
          escribió:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div bgcolor="#FFFFFF" text="#000000">
              <div>Hola Luis,<br>
                <br>
                Aquí te pego la función.<br>
                <br>
                CREATE OR REPLACE FUNCTION errepide_intz()<br>
                  RETURNS trigger AS<br>
                $BODY$<br>
                    DECLARE<br>
                    BEGIN<br>
NEW.geom:=ST_transform(ST_SetSRID(ST_MakePoint(NEW.lon,NEW.lat),4326),25830);<br>
                    RETURN NEW;<br>
                    END;<br>
                $BODY$<br>
                  LANGUAGE plpgsql VOLATILE<br>
                  COST 100;<br>
                ALTER FUNCTION errepide_intz()<br>
                  OWNER TO postgres;<br>
                <br>
                Gracias de antemano,<br>
                <br>
                Mikel<br>
                <div><br>
                  <p> </p>
                  <br>
                </div>
                2015/02/24 13:44(e)an, Luis Franco Vázquez igorleak
                idatzi zuen:<br>
              </div>
              <div>
                <div class="h5">
                  <blockquote type="cite">
                    <div dir="ltr">Vale. Ahora lo he entendido.
                      <div>Si me pegas aquí la función disparadora que
                        ya tienes te digo como hacerlo. </div>
                      <div><br>
                      </div>
                      <div><br>
                      </div>
                    </div>
                    <div class="gmail_extra"><br>
                      <div class="gmail_quote">El 24 de febrero de 2015,
                        13:19, Mikel <span dir="ltr"><<a
                            moz-do-not-send="true"
                            href="mailto:m.ayesta@gislan.com"
                            target="_blank">m.ayesta@gislan.com</a>></span>
                        escribió:<br>
                        <blockquote class="gmail_quote" style="margin:0
                          0 0 .8ex;border-left:1px #ccc
                          solid;padding-left:1ex">
                          <div bgcolor="#FFFFFF" text="#000000">
                            <div><br>
                              <div>Hola Luis,<br>
                                El disparador lo que hace es crear el
                                punto en el sistema de referencia 25830
                                partiendo de las coordenadas geográficas
                                que introduzco en el sistema 4326. Lo
                                que necesito es que me rellene los
                                campos X e Y en el sistema 25830 de
                                manera automática.<br>
                                <br>
                                He intentando poner por defecto en el
                                campo X el valor ST_X (geom) pero me da
                                error...<br>
                                <br>
                                Gracias.<br>
                                <p> </p>
                                <br>
                              </div>
                              2015/02/24 12:29(e)an, Luis Franco Vázquez
                              igorleak idatzi zuen:<br>
                            </div>
                            <div>
                              <div>
                                <blockquote type="cite">
                                  <div dir="ltr">Disculpa, no te he
                                    entendido. ¿Ya tienes un disparador
                                    que crea el punto y quieres obtener
                                    las coordenadas que tú mismo estás
                                    introduciendo?. Tengo que haberlo
                                    entendido muy mal. ¿O es que estás
                                    introduciendo coordenadas en un
                                    sistema de referencia distinto al
                                    25830 (por ejemplo epsg 4326) y lo
                                    que hace tu disparador es rellenar
                                    un atributo de tipo punto con srid
                                    25830 a partir de un par x, y en
                                    otro sistema de referencias?. Si me
                                    das más datos puedo concretar algo.
                                    <div>En general: postgis no tiene
                                      disparadores. Quien los tiene es
                                      postgresql. Postgis es una
                                      extensión espacial de postgresql,
                                      por lo tanto debes consultar la
                                      documentación de postgresql.</div>
                                    <div>Y sobre como obtener
                                      coordenadas x e y, mira <a
                                        moz-do-not-send="true"
                                        href="http://postgis.net/docs/manual-2.1/ST_X.html"
                                        target="_blank">http://postgis.net/docs/manual-2.1/ST_X.html</a>
                                      y  <a moz-do-not-send="true"
                                        href="http://postgis.net/docs/manual-2.1/ST_Y.html"
                                        target="_blank">http://postgis.net/docs/manual-2.1/ST_Y.html</a></div>
                                  </div>
                                  <div class="gmail_extra"><br>
                                    <div class="gmail_quote">El 24 de
                                      febrero de 2015, 11:56, Mikel <span
                                        dir="ltr"><<a
                                          moz-do-not-send="true"
                                          href="mailto:m.ayesta@gislan.com"
                                          target="_blank">m.ayesta@gislan.com</a>></span>
                                      escribió:<br>
                                      <blockquote class="gmail_quote"
                                        style="margin:0 0 0
                                        .8ex;border-left:1px #ccc
                                        solid;padding-left:1ex">
                                        <div bgcolor="#FFFFFF"
                                          text="#000000">
                                          <div>Hola a tod@s,<br>
                                            <br>
                                            Tengo una duda con PostGIS.
                                            ¿Hay alguna manera de que se
                                            rellenen automáticamente dos
                                            campos de la tabla con las
                                            coordenadas del elemento
                                            introducido?<br>
                                            <br>
                                            Me explico. Tengo una tabla
                                            en la que introduzco los
                                            puntos con coordenadas
                                            geográficas y mediante un
                                            disparador, me situa el
                                            punto en las coordenadas
                                            introducidas. El sistema de
                                            referencia es EPSG: 25830,
                                            por lo que en el disparador
                                            realizo la transformación de
                                            coordenadas. La cuestión es
                                            que necesito que se me
                                            rellenen los campos X e Y de
                                            forma automática. ¿Hay algún
                                            valor por defecto que se
                                            puede introducir (como en el
                                            caso de la fecha, now()), o
                                            por el contrario hay que
                                            programar algún disparador?
                                            y si es la segunda opción,
                                            ¿cómo?<br>
                                            <br>
                                            Gracias de antemano.<br>
                                            <br>
                                            Un cordial saludo, <br>
                                            <div>
                                              <table>
                                                <tbody>
                                                  <tr>
                                                    <td><a
                                                        moz-do-not-send="true"
href="http://www.gislan.com" target="_blank"><img
                                                          src="cid:part6.02030403.00070504@gislan.com"></a></td>
                                                    <td><a
                                                        moz-do-not-send="true"
href="http://www.gislan.com/node/107" target="_blank"><img
                                                          src="cid:part8.03070807.06030800@gislan.com"></a></td>
                                                  </tr>
                                                  <tr>
                                                    <td colspan="2"><b><font
                                                          color="blue">Mikel
                                                          Ayestaran
                                                          Olano</font></b><br>
                                                      GISLAN GEOGRAPHIC
                                                      APPLICATIONS S.L<br>
                                                      <font color="blue"><a
moz-do-not-send="true" href="mailto:m.ayesta@gislan.com" target="_blank">m.ayesta@gislan.com</a></font><br>
                                                      Tel.: 0034 943 304
                                                      255<br>
                                                      <a
                                                        moz-do-not-send="true"
href="http://www.gislan.com" target="_blank">www.gislan.com</a><br>
                                                    </td>
                                                  </tr>
                                                </tbody>
                                              </table>
                                              <p> </p>
                                              <table border="1">
                                                <tbody>
                                                  <tr>
                                                    <td><font size="1"><strong>Lege

                                                          oharra:</strong>
                                                        Mezu elektroniko
                                                        honetan, eta,
                                                        hala badagokio,
                                                        bere fitxategi
                                                        erantsietan,
                                                        hartzaileari
                                                        soilik
                                                        zuzendutako
                                                        isilpeko
                                                        informazioa
                                                        dago. Debekatuta
                                                        dago informazio
                                                        hori zabaldu,
                                                        kopiatu eta
                                                        beste pertsonen
                                                        artean banatzea,
                                                        Gaindegiaren
                                                        baimen idatzirik
                                                        gabe. Akatsen
                                                        batengatik mezu
                                                        hau jaso baduzu,
                                                        jakinarazi
                                                        mesedez, mezua
                                                        igorlearen
                                                        helbidera
                                                        birbidaliz.
                                                        DBLOn
                                                        ezarritakoaren
                                                        arabera,
                                                        Gaindegiak datu
                                                        pertsonalen
                                                        isilpeko
                                                        tratamendua
                                                        bermatzeko
                                                        beharrezko
                                                        neurriak hartzen
                                                        ditu. Halaber,
                                                        zure datuak
                                                        fitxategi batean
                                                        daudela
                                                        jakinarazi nahi
                                                        dizugu, zure
                                                        harremana
                                                        mantentzeko.
                                                        Eskubidea
                                                        daukazu datuok
                                                        begiratu,
                                                        zuzendu, ezabatu
                                                        eta aurka
                                                        egiteko, helbide
                                                        honetan: Martin
                                                        Ugalde Kultur
                                                        Parkea, 20140
                                                        Andoain.</font>
                                                    </td>
                                                  </tr>
                                                  <tr>
                                                    <td><font size="1"><strong>Nota:</strong>
                                                        "Este correo
                                                        electrónico y,
                                                        en su caso,
                                                        cualquier
                                                        fichero anexo al
                                                        mismo, contiene
                                                        información de
                                                        carácter
                                                        confidencial
                                                        exclusivamente
                                                        dirigida a su
                                                        destinatario.
                                                        Queda prohibida
                                                        su divulgación,
                                                        copia o
                                                        distribución a
                                                        terceros sin la
                                                        previa
                                                        autorización
                                                        escrita de
                                                        Gaindegia. En el
                                                        caso de haber
                                                        recibido este
                                                        correo
                                                        electrónico por
                                                        error, se ruega
                                                        notifíquese
                                                        inmediatamente
                                                        esta
                                                        circunstancia
                                                        mediante reenvío
                                                        a la dirección
                                                        electrónica del
                                                        remitente. De
                                                        conformidad con
                                                        lo establecido
                                                        en la LOPD
                                                        Gaindegia
                                                        garantiza la
                                                        adopción de las
                                                        medidas
                                                        necesarias para
                                                        asegurar el
                                                        tratamiento
                                                        confidencial de
                                                        los datos de
                                                        carácter
                                                        personal. Así
                                                        mismo le
                                                        informamos de
                                                        inclusión de sus
                                                        datos en un
                                                        fichero con la
                                                        finalidad de
                                                        mantener su
                                                        relación con
                                                        Gaindegia y de
                                                        la posibilidad
                                                        de ejercer los
                                                        derechos de
                                                        acceso,
                                                        rectificación,
                                                        cancelación y
                                                        oposición en la
                                                        siguiente
                                                        dirección:
                                                        Martin Ugalde
                                                        Kultur Parkea,
                                                        20140 Andoain.”</font>
                                                    </td>
                                                  </tr>
                                                </tbody>
                                              </table>
                                            </div>
                                            <br>
                                          </div>
                                        </div>
                                        <br>
_______________________________________________<br>
                                        Spanish mailing list<br>
                                        <a moz-do-not-send="true"
                                          href="http://lists.osgeo.org/mailman/listinfo/spanish"
                                          target="_blank">http://lists.osgeo.org/mailman/listinfo/spanish</a><br>
                                        <a moz-do-not-send="true"
                                          href="http://es.osgeo.org"
                                          target="_blank">http://es.osgeo.org</a><br>
                                        <a moz-do-not-send="true"
                                          href="http://twitter.com/osgeoes"
                                          target="_blank">http://twitter.com/osgeoes</a><br>
                                      </blockquote>
                                    </div>
                                    <br>
                                  </div>
                                  <br>
                                  <fieldset></fieldset>
                                  <br>
                                  <pre>_______________________________________________
Spanish mailing list
<a moz-do-not-send="true" href="http://lists.osgeo.org/mailman/listinfo/spanish" target="_blank">http://lists.osgeo.org/mailman/listinfo/spanish</a>
<a moz-do-not-send="true" href="http://es.osgeo.org" target="_blank">http://es.osgeo.org</a>
<a moz-do-not-send="true" href="http://twitter.com/osgeoes" target="_blank">http://twitter.com/osgeoes</a></pre>
                                </blockquote>
                                <br>
                              </div>
                            </div>
                          </div>
                          <br>
_______________________________________________<br>
                          Spanish mailing list<br>
                          <a moz-do-not-send="true"
                            href="http://lists.osgeo.org/mailman/listinfo/spanish"
                            target="_blank">http://lists.osgeo.org/mailman/listinfo/spanish</a><br>
                          <a moz-do-not-send="true"
                            href="http://es.osgeo.org" target="_blank">http://es.osgeo.org</a><br>
                          <a moz-do-not-send="true"
                            href="http://twitter.com/osgeoes"
                            target="_blank">http://twitter.com/osgeoes</a><br>
                        </blockquote>
                      </div>
                      <br>
                    </div>
                    <br>
                    <fieldset></fieldset>
                    <br>
                    <pre>_______________________________________________
Spanish mailing list
<a moz-do-not-send="true" href="http://lists.osgeo.org/mailman/listinfo/spanish" target="_blank">http://lists.osgeo.org/mailman/listinfo/spanish</a>
<a moz-do-not-send="true" href="http://es.osgeo.org" target="_blank">http://es.osgeo.org</a>
<a moz-do-not-send="true" href="http://twitter.com/osgeoes" target="_blank">http://twitter.com/osgeoes</a></pre>
                  </blockquote>
                  <br>
                </div>
              </div>
            </div>
            <br>
            _______________________________________________<br>
            Spanish mailing list<br>
            <a moz-do-not-send="true"
              href="http://lists.osgeo.org/mailman/listinfo/spanish"
              target="_blank">http://lists.osgeo.org/mailman/listinfo/spanish</a><br>
            <a moz-do-not-send="true" href="http://es.osgeo.org"
              target="_blank">http://es.osgeo.org</a><br>
            <a moz-do-not-send="true" href="http://twitter.com/osgeoes"
              target="_blank">http://twitter.com/osgeoes</a><br>
          </blockquote>
        </div>
        <br>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Spanish mailing list
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/spanish">http://lists.osgeo.org/mailman/listinfo/spanish</a>
<a class="moz-txt-link-freetext" href="http://es.osgeo.org">http://es.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://twitter.com/osgeoes">http://twitter.com/osgeoes</a></pre>
    </blockquote>
    <br>
  </body>
</html>