<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
    <title></title>
  </head>
  <body bgcolor="#ffffff" text="#000000">
    Hi Javier,<br>
    <br>
    you could add the missing end point (and then try again with
    ST_BuildArea() etc.). Here a more or less suiting example of the
    PostGIS manual for ST_AddPoint():<br>
    <pre class="programlisting">UPDATE sometable
SET the_geom = ST_AddPoint(the_geom, ST_StartPoint(the_geom))
FROM sometable
WHERE ST_IsClosed(the_geom) = false;

</pre>
    With a MultiLineString, this might be a bit more complicated because
    you have to find out first, is your multilinestring resulting in a
    polygon or a multipolygon? If all linestrings form one polygon, you
    have to select the start point of the first linestring as end point
    of the last linestring. If the result is a multipolygon, you have to
    find out which of the rings is not closed, first. As I see from your
    first e-mail, you are expecting the geometry to become a
    multipolygon, so (assuming every linestring is representing a
    polygon within the multipolygon, otherwise it might be a solution to
    union the linestrings first) maybe the sql code could look like
    this:<br>
    <pre class="programlisting">UPDATE sometable a
SET the_geom = sel.geom FROM 
(SELECT b1.gid, ST_Collect(b1.geom) AS geom --put together all linestrings to one multilinestring again
FROM 
(SELECT b.gid, ST_AddPoint(b.geom, ST_StartPoint(b.geom)) --add an end point on the position of the start point for each non-closed linestring
FROM 
(SELECT gid, (st_dump(the_geom)).geom AS geom --separate the linestrings and select the not closed ones
FROM sometable
WHERE ST_IsClosed(the_geom)=false) b
WHERE ST_IsClosed(b.geom) = false
UNION ALL
SELECT b.gid, b.geom
FROM
(SELECT gid, (st_dump(the_geom)).geom AS geom --separate the linestrings and select the closed ones
FROM sometable
WHERE ST_IsClosed(the_geom)=false) b
WHERE ST_IsClosed(b.geom) = true) b1
GROUP BY b1.gid) sel
WHERE ST_IsClosed(a.the_geom)=false AND a.gid=sel.gid;</pre>
    I did not test the code, but I hope you get the idea...<br>
    <br>
    Regards,<br>
    <br>
    Birgit.<br>
    <br>
    <br>
    On 28.03.2011 18:47, Javier Perez wrote:
    <blockquote
      cite="mid:AANLkTikFun3_hGUozzrpneaiRPwZVvusMwe6KY=vLykm@mail.gmail.com"
      type="cite">Hi,
      <div><br>
      </div>
      <div>I tried  <span class="Apple-style-span" style="color: rgb(46,
          46, 46); font-family: 'Lucida
          Grande',Verdana,Geneva,Arial,Helvetica,sans-serif; font-size:
          13px;"><code class="funcdef"><b class="fsfunc" style="color:
              rgb(33, 55, 128);">ST_BuildArea</b>(</code>geometry <var
            class="pdparam">A</var><code>)</code>;  and </span><span
          class="Apple-style-span" style="color: rgb(46, 46, 46);
          font-family: 'Lucida
          Grande',Verdana,Geneva,Arial,Helvetica,sans-serif; font-size:
          13px;"><code class="funcdef"><b class="fsfunc" style="color:
              rgb(33, 55, 128);">ST_BdMPolyFromText</b>(</code>text <var
            class="pdparam">WKT</var>, integer <var class="pdparam">srid</var><code>)</code>;</span></div>
      <div><font class="Apple-style-span" color="#2e2e2e" face="'Lucida
          Grande', Verdana, Geneva, Arial, Helvetica, sans-serif"><br>
        </font></div>
      <div><font class="Apple-style-span" face="'Lucida Grande',
          Verdana, Geneva, Arial, Helvetica, sans-serif">but the output
          is empty. I think it's becouse this functions may need the
          MULTILINESTRING to be closed and it's not.</font></div>
      <div><font class="Apple-style-span" face="'Lucida Grande',
          Verdana, Geneva, Arial, Helvetica, sans-serif"><br>
        </font></div>
      <div><font class="Apple-style-span" face="'Lucida Grande',
          Verdana, Geneva, Arial, Helvetica, sans-serif">Any suggestion?<br>
        </font><br>
        <div class="gmail_quote">2011/3/25 Javier Perez <span dir="ltr"><<a
              moz-do-not-send="true"
              href="mailto:javi.peisaco@gmail.com">javi.peisaco@gmail.com</a>></span><br>
          <blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
            0.8ex; border-left: 1px solid rgb(204, 204, 204);
            padding-left: 1ex;">
            Hi Marc-Andre!
            <div><br>
            </div>
            <div>I think this usefull.</div>
            <div><br>
            </div>
            <div>Thanks a lot!</div>
            <div><br>
            </div>
            <div>Regards<br>
              <br>
              <div class="gmail_quote">2011/3/25 Morin, Marc-André <span
                  dir="ltr"><<a moz-do-not-send="true"
                    href="mailto:Marc-Andre.Morin@dfo-mpo.gc.ca"
                    target="_blank">Marc-Andre.Morin@dfo-mpo.gc.ca</a>></span><br>
                <blockquote class="gmail_quote" style="margin: 0pt 0pt
                  0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204);
                  padding-left: 1ex;">
                  <div>
                    <div class="h5">
                      <div>
                        <div dir="ltr" align="left"><font face="Tahoma"
                            size="2"><span><strong>Hi,</strong></span></font></div>
                        <div dir="ltr" align="left"><font face="Tahoma"
                            size="2"><span><strong></strong></span></font> </div>
                        <div dir="ltr" align="left"><font face="Tahoma"
                            size="2"><span><strong>This is the recipe I
                                found in the past to get it done:</strong></span></font></div>
                        <div dir="ltr" align="left"><font face="Tahoma"
                            size="2"><span><strong></strong></span></font> </div>
                        <div dir="ltr" align="left"><font face="Tahoma"
                            size="2"><span><a moz-do-not-send="true"
href="http://postgis.refractions.net/pipermail/postgis-users/2008-May/019901.html"
                                target="_blank">http://postgis.refractions.net/pipermail/postgis-users/2008-May/019901.html</a></span></font></div>
                        <div dir="ltr" align="left"><font
                            color="#0000ff" face="Arial" size="2"><span></span></font> </div>
                        <div dir="ltr" align="left"><font
                            color="#0000ff" face="Arial" size="2"><span>It
                              worked well for me.</span></font></div>
                        <div dir="ltr" align="left"><font
                            color="#0000ff" face="Arial" size="2"><span></span></font> </div>
                        <div dir="ltr" align="left"><font
                            color="#0000ff" face="Arial" size="2"><span>Regards,</span></font></div>
                        <div dir="ltr" align="left"><font
                            color="#0000ff" face="Arial" size="2"><span></span></font> </div>
                        <div dir="ltr" align="left"><font
                            color="#0000ff" face="Arial" size="2"><span>Marc-André</span></font></div>
                        <div dir="ltr" align="left"><font
                            color="#0000ff" face="Arial" size="2"><span></span></font> </div>
                        <div dir="ltr" align="left"><font
                            color="#0000ff" face="Arial" size="2"><span></span></font> </div>
                        <div dir="ltr" align="left">
                          <hr>
                        </div>
                        <div dir="ltr" align="left"><font face="Tahoma"
                            size="2"><b>De :</b> <a
                              moz-do-not-send="true"
                              href="mailto:postgis-users-bounces@postgis.refractions.net"
                              target="_blank">postgis-users-bounces@postgis.refractions.net</a>
                            [mailto:<a moz-do-not-send="true"
                              href="mailto:postgis-users-bounces@postgis.refractions.net"
                              target="_blank">postgis-users-bounces@postgis.refractions.net</a>]
                            <b>De la part de</b> Javier Perez<br>
                            <b>Envoyé :</b> March 25, 2011 7:35 AM<br>
                            <b>À :</b> <a moz-do-not-send="true"
                              href="mailto:postgis-users@postgis.refractions.net"
                              target="_blank">postgis-users@postgis.refractions.net</a><br>
                            <b>Objet :</b> [postgis-users]
                            MULTILINESTRING to MULTIPOLYGON<br>
                          </font><br>
                        </div>
                        <div>
                          <span style="font-size: 13px; font-family:
                            arial,sans-serif; border-collapse:
                            collapse;">Hi!,
                            <div><br>
                            </div>
                            <div>In my app I get a MULTILINESTRING and
                              want to insert it as MULTIPOLYGON. I think
                              there's an easy way but I did't found, can
                              anyone bring some light?</div>
                            <div><br>
                            </div>
                            <div><br>
                            </div>
                            <div>Thanks in advance</div>
                          </span>
                          <div class="gmail_quote">
                          </div>
                          <br>
                        </div>
                      </div>
                      <br>
                    </div>
                  </div>
                  _______________________________________________<br>
                  postgis-users mailing list
                  <div class="im"><br>
                    <a moz-do-not-send="true"
                      href="mailto:postgis-users@postgis.refractions.net"
                      target="_blank">postgis-users@postgis.refractions.net</a><br>
                  </div>
                  <a moz-do-not-send="true"
                    href="http://postgis.refractions.net/mailman/listinfo/postgis-users"
                    target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br>
                  <br>
                </blockquote>
              </div>
              <br>
            </div>
          </blockquote>
        </div>
        <br>
      </div>
      <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
postgis-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a>
<a class="moz-txt-link-freetext" href="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</a>
</pre>
    </blockquote>
  </body>
</html>