<HTML dir=ltr><HEAD><TITLE>Re: [postgis-devel] ST_MakePolygon returns null geometry when passedNULL or empty array</TITLE>
<META http-equiv=Content-Type content="text/html; charset=unicode">
<META content="MSHTML 6.00.2900.3354" name=GENERATOR></HEAD>
<BODY>
<DIV id=idOWAReplyText53838 dir=ltr>
<DIV dir=ltr><FONT face=Arial color=#000000 size=2>Okay this is puzzling me.  I wasn't getting errors, just getting NULL back.</FONT></DIV>
<DIV dir=ltr><FONT face=Arial color=#000000 size=2></FONT> </DIV>
<DIV dir=ltr><FONT face=Arial color=#000000 size=2>What do you get if you run this</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2></FONT> </DIV>
<DIV dir=ltr>SELECT ST_IsValid(the_geom), ST_AsText(the_geom)<BR>FROM (<BR>   SELECT ST_MakePolygon(<BR>     'LINESTRING(0 0, 0 8, 8 8, 8 0, 0 0)'::geometry,<BR>     ARRAY(SELECT 'LINESTRING(1 1, 0 8, 8 8, 8 0, 1 1)'::geometry WHERE false)) AS the_geom<BR>   ) AS foo;</DIV>
<DIV dir=ltr> </DIV>
<DIV dir=ltr>The test I ran should have been the same as this, but this actually works the way I would expect it to returning a geometry when given an empty geometry array.  Although I just ran on 1.3.2  and I think earlier I was testing on 1.3.3 and it was slightly more complicated than the above so I'll need to retry my example to make sure I was mistaken and its not just a version difference.</DIV>
<DIV dir=ltr> </DIV>
<DIV dir=ltr>Just plain null - doesn't give me an error as an ARRAY[NULL] but returns NULL</DIV>
<DIV dir=ltr> </DIV>
<DIV dir=ltr>SELECT ST_IsValid(the_geom), ST_AsText(the_geom)<BR>FROM (<BR>   SELECT ST_MakePolygon(<BR>     'LINESTRING(0 0, 0 8, 8 8, 8 0, 0 0)'::geometry,<BR>     NULL) AS the_geom<BR>   ) AS foo;<BR></DIV>
<DIV dir=ltr>Thanks,</DIV>
<DIV dir=ltr>Regina</DIV>
<DIV dir=ltr> </DIV></DIV>
<DIV dir=ltr><BR>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> Obe, Regina<BR><B>Sent:</B> Tue 7/8/2008 1:06 PM<BR><B>To:</B> PostGIS Development Discussion; PostGIS Development Discussion<BR><B>Subject:</B> RE: [postgis-devel] ST_MakePolygon returns null geometry when passedNULL or empty array<BR></FONT><BR></DIV>
<DIV dir=ltr>
<DIV id=idOWAReplyText17923 dir=ltr>
<DIV dir=ltr><FONT face=Arial color=#000000 size=2>Well I did put a note in my example of using ST_Accum (with a left join that sometimes results in a null passed to the second)  and Array() which sometimes results in an empty array.</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2></FONT> </DIV>
<DIV dir=ltr><FONT face=Arial size=2>I suppose I could put the comment at the top too in the first paragraph.</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2></FONT> </DIV>
<DIV dir=ltr><FONT face=Arial size=2>Thanks,</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2>Regina</FONT></DIV></DIV>
<DIV dir=ltr><BR>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> postgis-devel-bounces@postgis.refractions.net on behalf of Kevin Neufeld<BR><B>Sent:</B> Tue 7/8/2008 11:42 AM<BR><B>To:</B> PostGIS Development Discussion<BR><B>Subject:</B> Re: [postgis-devel] ST_MakePolygon returns null geometry when passedNULL or empty array<BR></FONT><BR></DIV>
<DIV>
<P><FONT size=2>I think the current assumption is that if you choose to supply a set of<BR>interior rings that make up the polygon, they should form simple linear<BR>rings.  Hence the "input geometries must be closed LINESTRINGs" phrase<BR>in the docs.<BR><BR>You're right, this doesn't work:<BR>postgis=# SELECT ST_IsValid(the_geom), ST_AsText(the_geom)<BR>FROM (<BR>   SELECT ST_MakePolygon(<BR>     'LINESTRING(0 0, 0 8, 8 8, 8 0, 0 0)'::geometry,<BR>     ARRAY[NULL]) AS the_geom<BR>   ) AS foo;<BR>ERROR:  Hole 0 is not a line<BR><BR>I suppose we could add "make this function more robust" to the TODO list.<BR><BR>In any case, the docs definitely should be clarified.<BR><BR>Cheers,<BR>-- Kevin<BR><BR>Obe, Regina wrote:<BR>> I'm not sure if this expected behavior or not, but it surprised me.<BR>><BR>> In formulating ST_MakePolygon examples for the docs, I noticed if I<BR>> passed in NULL or an empty array<BR>> for the ST_MakePolygon second arg, I get back a null geometry.<BR>><BR>> Shouldn't it just return a polygon formed from the first argument?<BR>><BR>> Thanks,<BR>> Regina<BR>> -----------------------------------------<BR>> The substance of this message, including any attachments, may be<BR>> confidential, legally privileged and/or exempt from disclosure<BR>> pursuant to Massachusetts law. It is intended<BR>> solely for the addressee. If you received this in error, please<BR>> contact the sender and delete the material from any computer.<BR>><BR>> _______________________________________________<BR>> postgis-devel mailing list<BR>> postgis-devel@postgis.refractions.net<BR>> <A href="http://postgis.refractions.net/mailman/listinfo/postgis-devel">http://postgis.refractions.net/mailman/listinfo/postgis-devel</A><BR>_______________________________________________<BR>postgis-devel mailing list<BR>postgis-devel@postgis.refractions.net<BR><A href="http://postgis.refractions.net/mailman/listinfo/postgis-devel">http://postgis.refractions.net/mailman/listinfo/postgis-devel</A><BR></FONT></P></DIV></DIV></BODY></HTML>