[postgis-devel] isvalid(geom), but st_ashexewkb(geom, 'NDR')::geometry fails

Kevin Neufeld kneufeld at refractions.net
Fri Oct 24 08:51:44 PDT 2008


I was going to say that it looks like a bug in the WKB parser, but then 
I noticed that this is fixed in newer PostGIS versions.

In my 1.1.6 version, I can produce the same thing - it's clearly not 
symmetric.

postgis=# select 
astext('0106000020C90E00000100000001030000000100000000000000'::geometry);
          astext
------------------------
  MULTIPOLYGON(( EMPTY))
(1 row)

postgis=# select astext('MULTIPOLYGON(( EMPTY))');
ERROR:  parse error - invalid geometry

-- Kevin

David Fuhry wrote:
> Regina,
> 
>    Yeah, I agree that the WKT is not valid.  The real question is, is 
> the WKB valid?  If not, isvalid() should return false.  If so, the 
> parser should parse it without error.
> 
>    ST_GeomFromText('MULTIPOLYGON EMPTY') returns a different geometry 
> from mine.  Adding the srid makes it a little closer, but not the same. 
>  Both of these are correctly identified as st_isempty(), although mine 
> is not.
> 
> db=> select st_geomfromtext('MULTIPOLYGON EMPTY');
>   st_geomfromtext
> --------------------
>  010700000000000000
> (1 row)
> 
> db=> select setsrid(st_geomfromtext('MULTIPOLYGON EMPTY'), 3785);
>           setsrid
> ----------------------------
>  0107000020C90E000000000000
> (1 row)
> 
> 
> Thanks,
> 
> Dave
> 
> 
> Obe, Regina wrote:
>> David,
>>
>> I don't think that is valid WKT syntax for an EMPTY multipolygon. If I 
>> try to stuff that in via ST_GeomFromText it returns invalid geometry. 
>> Not sure how you got that in there.
>>
>> It should be
>>
>>  SELECT ST_GeomFromText('MULTIPOLYGON EMPTY');
>>
>>
>> On 1.3.3 and 1.3.4SVN - when I do this - I get the below which is also 
>> kind of odd.  I would have expected it to maintain the empty polygon.
>>
>>  SELECT ST_IsValid(the_geom), ST_AsText(the_geom), 
>> ST_IsEmpty(the_geom), ST_AsEWKT(the_geom)  FROM (SELECT 
>> ST_GeomFromText('MULTIPOLYGON EMPTY') As the_geom) As foo ;
>>  st_isvalid |        st_astext         | st_isempty |        
>> st_asewkt        
>> ------------+--------------------------+------------+-------------------------- 
>>
>>  t          | GEOMETRYCOLLECTION EMPTY | t          | 
>> GEOMETRYCOLLECTION EMPTY
>> (1 row)
>>
>> Hope that helps,
>> Regina
>> -----Original Message-----
>> From: postgis-devel-bounces at postgis.refractions.net on behalf of David 
>> Fuhry
>> Sent: Thu 10/23/2008 11:28 PM
>> To: PostGIS Development Discussion
>> Subject: [postgis-devel] isvalid(geom), but 
>> st_ashexewkb(geom,'NDR')::geometry fails
>>
>> I have an empty multipolygon which isvalid(), but which the parser
>> throws "ERROR:  geometry requires more points" on.  Is this a bug in
>> isvalid(), or in the parser?  Interestingly, st_isempty() returns false.
>>
>> db=> select geom from tt;
>>                           geom
>> ------------------------------------------------------
>>   0106000020C90E00000100000001030000000100000000000000
>> (1 row)
>>
>> db=> select st_astext(geom) from tt;
>>         st_astext
>> ------------------------
>>   MULTIPOLYGON(( EMPTY))
>> (1 row)
>>
>> db=> select isvalid(geom) from tt;
>>   isvalid
>> ---------
>>   t
>> (1 row)
>>
>> db=> select st_ashexewkb(geom,'NDR')::geometry from tt;
>> ERROR:  geometry requires more points
>>
>> db=> select st_isempty(geom) from tt;
>>   st_isempty
>> ------------
>>   f
>> (1 row)
>>
>> db=> select version(), postgis_version();
>>                                          version
>>                   |            postgis_version
>> -----------------------------------------------------------------------
>> -----------------+---------------------------------------
>>   PostgreSQL 8.3.1 on i486-pc-linux-gnu, compiled by GCC cc (GCC) 4.2.3
>> (Debian 4.2.3-4) | 1.3 USE_GEOS=1 USE_PROJ=1 USE_STATS=1
>> (1 row)
>>
>> Thanks,
>>
>> Dave
>> _______________________________________________
>> postgis-devel mailing list
>> postgis-devel at postgis.refractions.net
>> http://postgis.refractions.net/mailman/listinfo/postgis-devel
>>
>>
>> ------------------------------------------------------------------------
>>
>> * The substance of this message, including any attachments, may be 
>> confidential, legally privileged and/or exempt from disclosure 
>> pursuant to Massachusetts law. It is intended solely for the 
>> addressee. If you received this in error, please contact the sender 
>> and delete the material from any computer. *
>>
>> ------------------------------------------------------------------------
>>
>> * Help make the earth a greener place. If at all possible resist 
>> printing this email and join us in saving paper. *
>>
>> * *
>>
>> * *
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> postgis-devel mailing list
>> postgis-devel at postgis.refractions.net
>> http://postgis.refractions.net/mailman/listinfo/postgis-devel
> _______________________________________________
> postgis-devel mailing list
> postgis-devel at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-devel



More information about the postgis-devel mailing list