Hi Birgit!<div><br></div><div>In the end I made it programaticaly, using a gvsig class: <span class="Apple-style-span" style="font-family: monospace; white-space: pre-wrap; font-size: medium; ">GeometryUtilities.closeLine().</span></div>
<div><font class="Apple-style-span" face="monospace" size="3"><span class="Apple-style-span" style="white-space: pre-wrap;"><br></span></font></div><div><font class="Apple-style-span" face="arial, helvetica, sans-serif"><span class="Apple-style-span" style="white-space: pre-wrap; ">If there was a siple solution aplying only one or two operations, it would be reasonable using postgis. But in my case the geometry was in memory as a multilinestring, and wanted to store it as a multipolygon, and this solution is more elegant and easy, always in my case.</span></font></div>
<div><font class="Apple-style-span" face="arial, helvetica, sans-serif"><span class="Apple-style-span" style="white-space: pre-wrap;"><br></span></font></div><div><font class="Apple-style-span" face="arial, helvetica, sans-serif"><span class="Apple-style-span" style="white-space: pre-wrap;">Anyway I'll keep your code for further needs, and thank you for your attention.</span></font></div>
<div><font class="Apple-style-span" face="arial, helvetica, sans-serif"><span class="Apple-style-span" style="white-space: pre-wrap;"><br></span></font></div><div><font class="Apple-style-span" face="arial, helvetica, sans-serif"><span class="Apple-style-span" style="white-space: pre-wrap;">Regards,</span></font></div>
<div><font class="Apple-style-span" face="arial, helvetica, sans-serif"><span class="Apple-style-span" style="white-space: pre-wrap;"><br></span></font></div><div><font class="Apple-style-span" face="arial, helvetica, sans-serif"><span class="Apple-style-span" style="white-space: pre-wrap;">Javier</span></font></div>
<div><font class="Apple-style-span" face="monospace" size="3"><span class="Apple-style-span" style="white-space: pre-wrap;"><br></span></font><br><div class="gmail_quote">2011/3/30 Birgit Laggner <span dir="ltr"><<a href="mailto:birgit.laggner@vti.bund.de">birgit.laggner@vti.bund.de</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

  
    
    
  
  <div 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>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>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><font color="#888888">
    <br>
    Birgit.</font><div><div></div><div class="h5"><br>
    <br>
    <br>
    On 28.03.2011 18:47, Javier Perez wrote:
    <blockquote type="cite">Hi,
      <div><br>
      </div>
      <div>I tried  <span style="color:rgb(46, 46, 46);font-family:'Lucida Grande',Verdana,Geneva,Arial,Helvetica,sans-serif;font-size:13px"><code><b style="color:rgb(33, 55, 128)">ST_BuildArea</b>(</code>geometry <var>A</var><code>)</code>;  and </span><span style="color:rgb(46, 46, 46);font-family:'Lucida Grande',Verdana,Geneva,Arial,Helvetica,sans-serif;font-size:13px"><code><b style="color:rgb(33, 55, 128)">ST_BdMPolyFromText</b>(</code>text <var>WKT</var>, integer <var>srid</var><code>)</code>;</span></div>

      <div><font color="#2e2e2e" face="'Lucida
          Grande', Verdana, Geneva, Arial, Helvetica, sans-serif"><br>
        </font></div>
      <div><font 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 face="'Lucida Grande',
          Verdana, Geneva, Arial, Helvetica, sans-serif"><br>
        </font></div>
      <div><font 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 href="mailto:javi.peisaco@gmail.com" target="_blank">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 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>
                      <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 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 href="mailto:postgis-users-bounces@postgis.refractions.net" target="_blank">postgis-users-bounces@postgis.refractions.net</a>
                            [mailto:<a 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 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><br>
                    <a href="mailto:postgis-users@postgis.refractions.net" target="_blank">postgis-users@postgis.refractions.net</a><br>
                  </div>
                  <a 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><fieldset></fieldset>
_______________________________________________
postgis-users mailing list
<a href="mailto:postgis-users@postgis.refractions.net" target="_blank">postgis-users@postgis.refractions.net</a>
<a href="http://postgis.refractions.net/mailman/listinfo/postgis-users" target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a>
</pre>
    </blockquote>
  </div></div></div>

<br>_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br>
<a 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>