<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7653.38">
<TITLE>RE: [postgis-devel] FW: [postgis-users] how to identify the_geomthatcause:RelateOperation called withLWGEOMCOLLECTION type</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->
<P><FONT SIZE=2>Weird. What is strange is the ST_AsGeometryFromText version gave me an area of 0 but did return a centroid that looked about right. While the binary one that did return an empty geometry collection - gave an area of 0.00005 e-8 or something like that. I would have thought the ST_AsGeometryFromText version would have had more issues in that case or at least the same issues.<BR>
<BR>
<BR>
<BR>
<BR>
-----Original Message-----<BR>
From: postgis-devel-bounces@postgis.refractions.net on behalf of Martin Davis<BR>
Sent: Wed 12/10/2008 1:06 PM<BR>
To: PostGIS Development Discussion<BR>
Subject: Re: [postgis-devel] FW: [postgis-users] how to identify the_geomthatcause:RelateOperation called withLWGEOMCOLLECTION type<BR>
<BR>
Yup, it's a bug. See my post to the Users list. This is caused by an<BR>
inability to handle zero-area polygons in the current code. It should<BR>
be fixed in GEOS. I'm working on a JTS fix now.<BR>
<BR>
Obe, Regina wrote:<BR>
> Do you guys consider this to be a bug? It is sort of, but not sure if<BR>
> anything can be done about it. I presume it would go under GEOS not<BR>
> PostGIS. Anyrate it seems to me that if a geometry is valid - <BR>
> ST_Centroid should not be returning an empty geometry collection<BR>
> except when given an Empty Geometry Collection. Am I wrong in that<BR>
> assumption?<BR>
> <BR>
> <BR>
><BR>
> ------------------------------------------------------------------------<BR>
> *From:* Obe, Regina<BR>
> *Sent:* Wednesday, December 10, 2008 7:42 AM<BR>
> *To:* 'PostGIS Users Discussion'<BR>
> *Subject:* RE: [postgis-users] how to identify the_geom<BR>
> thatcause:RelateOperation called withLWGEOMCOLLECTION type<BR>
><BR>
> Fred and Ghislain,<BR>
> <BR>
> Thanks - yes that's because of the rounding that happens in<BR>
> ST_GeomFromText -- the ST_GeomFromText is rounding the last couple of<BR>
> digits so the text rep isn't actually what the geometry is so its<BR>
> probably something like<BR>
> <BR>
> 796579.5624334065668 or some such thing. Looking at this in<BR>
> OpenJump, the polygon is practically a line so borders on being almost<BR>
> invalid.<BR>
> <BR>
> So I guess its some sort of rounding issue that before it gets to<BR>
> ST_Centroid its not invalid because the 2 mid points are technically<BR>
> not the same, but once it gets into ST_Centroid some rounding happens<BR>
> that makes it equivalent to an invalid geometry (basically a polygon<BR>
> with 3 points).<BR>
> <BR>
> Well I'm able to recreate this result in "POSTGIS="1.3.5SVN"<BR>
> GEOS="3.1.0-CAPI-1.5.0" PROJ="Rel. 4.6.0, 21 Dec 2007"<BR>
> <BR>
> I suppose the workaround for now would be to ignore anything where the<BR>
> area is close to 0 or centroid is empty or use ST_SnapToGrid to get<BR>
> rid of those extra digits in your geometry.<BR>
> <BR>
> <A HREF="http://postgis.refractions.net/documentation/manual-svn/ST_SnapToGrid.html">http://postgis.refractions.net/documentation/manual-svn/ST_SnapToGrid.html</A><BR>
> <BR>
> None of which is terribly appealing.<BR>
> <BR>
> <BR>
> Thanks,<BR>
> Regina<BR>
> <BR>
><BR>
> ------------------------------------------------------------------------<BR>
> *From:* postgis-users-bounces@postgis.refractions.net<BR>
> [<A HREF="mailto:postgis-users-bounces@postgis.refractions.net">mailto:postgis-users-bounces@postgis.refractions.net</A>] *On Behalf Of<BR>
> *Fred Lehodey<BR>
> *Sent:* Wednesday, December 10, 2008 5:28 AM<BR>
> *To:* PostGIS Users Discussion<BR>
> *Subject:* Re: [postgis-users] how to identify the_geom<BR>
> thatcause:RelateOperation called withLWGEOMCOLLECTION type<BR>
><BR>
> Hi,<BR>
> just a note:<BR>
><BR>
> inserting the same geometry :<BR>
><BR>
> INSERT INTO bug (gid, the_geom) VALUES (<BR>
> 1 ,<BR>
> '0103000020BE6B0000010000000400000081F178483F4F2841D730212506D33C418045F71F474F2841D706623902D33C417E45F71F474F2841D806623902D33C4181F178483F4F2841D730212506D33C41'<BR>
> );<BR>
><BR>
> and<BR>
><BR>
> INSERT INTO bug (gid, the_geom) VALUES (2,st_geomfromtext('POLYGON((<BR>
> 796575.641547725 1889030.1450377,<BR>
> 796579.562433407 1889026.22415202,<BR>
> 796579.562433406 1889026.22415202,<BR>
> 796575.641547725 1889030.1450377))',-1))<BR>
><BR>
> then :<BR>
> SELECT gid, st_area(the_geom), astext(centroid(the_geom)),<BR>
> isvalid(the_geom)<BR>
> FROM bug<BR>
><BR>
> returns:<BR>
><BR>
> 1; 0.0001220703125;"GEOMETRYCOLLECTION EMPTY";t<BR>
> 2; 0.0001220703125;"POINT(796578.255471513 1889027.53111391)";t<BR>
><BR>
> !!<BR>
><BR>
> Fred.<BR>
><BR>
><BR>
><BR>
><BR>
> On Wed, Dec 10, 2008 at 9:06 AM, Ghislain Geniaux<BR>
> <geniaux@avignon.inra.fr <<A HREF="mailto:geniaux@avignon.inra.fr">mailto:geniaux@avignon.inra.fr</A>>> wrote:<BR>
><BR>
> Exact,<BR>
> that's the problem :<BR>
><BR>
> scot3=# SELECT gid, the_geom<BR>
> scot3-# FROM bd_dispo_final<BR>
> scot3-# WHERE isempty(centroid(the_geom));<BR>
> gid | <BR>
> the_geom<BR>
> -------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------<BR>
> 16435 |<BR>
> 0103000020BE6B0000010000000400000081F178483F4F2841D730212506D33C418045F71F474F2841D706623902D33C417E45F71F474F2841D806623902D33C4181F178483F4F2841D730212506D33C41<BR>
> (1 row)<BR>
><BR>
><BR>
> Here, you will find the ouput of pg_dump to study this<BR>
> geometrry. Thanks again.<BR>
><BR>
><BR>
><BR>
> --<BR>
> -- PostgreSQL database dump<BR>
> --<BR>
><BR>
> SET client_encoding = 'SQL_ASCII';<BR>
> SET standard_conforming_strings = off;<BR>
> SET check_function_bodies = false;<BR>
> SET client_min_messages = warning;<BR>
> SET escape_string_warning = off;<BR>
><BR>
> SET search_path = public, pg_catalog;<BR>
><BR>
> SET default_tablespace = '';<BR>
><BR>
> SET default_with_oids = false;<BR>
><BR>
> --<BR>
> -- Name: bug; Type: TABLE; Schema: public; Owner: postgres;<BR>
> Tablespace:--<BR>
><BR>
> CREATE TABLE bug (<BR>
> gid integer,<BR>
> the_geom geometry<BR>
> );<BR>
><BR>
><BR>
> ALTER TABLE public.bug OWNER TO postgres;<BR>
><BR>
> --<BR>
> -- Data for Name: bug; Type: TABLE DATA; Schema: public; Owner:<BR>
> postgres<BR>
> --<BR>
><BR>
> COPY bug (gid, the_geom) FROM stdin;<BR>
> 16435 <BR>
> 0103000020BE6B0000010000000400000081F178483F4F2841D730212506D33C418045F71F474F2841D706623902D33C417E45F71F474F2841D806623902D33C4181F178483F4F2841D730212506D33C41<BR>
> \.<BR>
><BR>
><BR>
> --<BR>
> -- PostgreSQL database dump complete<BR>
> --<BR>
><BR>
><BR>
> Le 9 déc. 08 à 13:04, Obe, Regina a écrit :<BR>
><BR>
><BR>
><BR>
> Ghislain,<BR>
><BR>
> The only time I have seen this kind of behavior is when<BR>
> centroid returns an empty geometry collection. In those cases<BR>
> its because the geometry is invalid.<BR>
><BR>
> Although none of your geometries are invalid, it could be a<BR>
> bug in either the centroid code or isvalid check that may or<BR>
> may not be fixed in 3.0.3+ of GEOS.<BR>
><BR>
><BR>
> Can you do the following<BR>
><BR>
> SELECT gid, the_geom<BR>
> FROM ZS2C<BR>
> WHERE isempty(centroid(the_geom))<BR>
><BR>
><BR>
> and send us as an attatched file with one of those geometries.<BR>
> We can cross check with GEOS 3.0.3 or 3.1 to see if the issue<BR>
> still remains.<BR>
><BR>
> Thanks,<BR>
> Regina<BR>
> -----Original Message-----<BR>
> From: postgis-users-bounces@postgis.refractions.net<BR>
> <<A HREF="mailto:postgis-users-bounces@postgis.refractions.net">mailto:postgis-users-bounces@postgis.refractions.net</A>><BR>
> [<A HREF="mailto:postgis-">mailto:postgis-</A><BR>
> <<A HREF="mailto:postgis-">mailto:postgis-</A>>users-bounces@postgis.refractions.net<BR>
> <<A HREF="mailto:users-bounces@postgis.refractions.net">mailto:users-bounces@postgis.refractions.net</A>>] On Behalf Of<BR>
> Ghislain Geniaux<BR>
> Sent: Monday, December 08, 2008 1:29 PM<BR>
> To: PostGIS Users Discussion<BR>
> Subject: Re: [postgis-users] how to identify the_geom that<BR>
> cause:RelateOperation called withLWGEOMCOLLECTION type<BR>
><BR>
> On Linux :<BR>
><BR>
> POSTGIS="1.3.1" GEOS="3.0.0-CAPI-1.4.1" PROJ="Rel. 4.6.0, 21 Dec<BR>
> 2007" USE_STATS<BR>
> (1 row)<BR>
><BR>
> On Macos<BR>
><BR>
> POSTGIS="1.2.1" GEOS="3.0.0-CAPI-1.4.1" PROJ="Rel. 4.6.0, 21 Dec<BR>
> 2007" USE_STATS<BR>
> (1 row)<BR>
><BR>
> same result with the two platform and postgis version.<BR>
><BR>
> Thanks.<BR>
><BR>
> Le 8 déc. 08 à 17:53, Paragon Corporation a écrit :<BR>
><BR>
> What does<BR>
><BR>
> SELECT postgis_full_version();<BR>
><BR>
> Return<BR>
><BR>
> Thanks,<BR>
> Regina<BR>
> -----Original Message-----<BR>
> From: postgis-users-bounces@postgis.refractions.net<BR>
> <<A HREF="mailto:postgis-users-bounces@postgis.refractions.net">mailto:postgis-users-bounces@postgis.refractions.net</A>><BR>
> [<A HREF="mailto:postgis-users-bounces@postgis.refractions.net">mailto:postgis-users-bounces@postgis.refractions.net</A><BR>
> <<A HREF="mailto:postgis-users-bounces@postgis.refractions.net">mailto:postgis-users-bounces@postgis.refractions.net</A>>] On<BR>
> Behalf Of<BR>
> Ghislain<BR>
> Geniaux<BR>
> Sent: Monday, December 08, 2008 11:03 AM<BR>
> To: PostGIS Users Discussion<BR>
> Subject: Re: [postgis-users] how to identify the_geom that<BR>
> cause<BR>
> :RelateOperation called withLWGEOMCOLLECTION type<BR>
><BR>
> I've no collection. It's looks like a bug.<BR>
><BR>
> Moreover my table is very large wiht more than 500 000<BR>
> geometry and i<BR>
> found no solution to identy the wrong geom.<BR>
><BR>
> Here you can see the query, with the same result on different<BR>
> plateform (LINUX DEBIAN, MACOS, with GEOS 3)<BR>
><BR>
> otm=# select distinct geometrytype(the_geom) from ZS2c;<BR>
> geometrytype<BR>
> --------------<BR>
> MULTIPOLYGON<BR>
> (1 row)<BR>
><BR>
> otm=# select distinct geometrytype(the_geom) from<BR>
> bd_dispo_finalc ;<BR>
> geometrytype<BR>
> --------------<BR>
> MULTIPOLYGON<BR>
> POLYGON<BR>
> (2 rows)<BR>
><BR>
> otm=# create table info_nonvoue1 as<BR>
> otm-# select b.id_parc, z.niv from bd_dispo_finalc as b,<BR>
> ZS2c as z<BR>
> otm-# where z.niv=1 and<BR>
> intersects(centroid(b.the_geom),z.the_geom)<BR>
> and b.the_geom && z.the_geom and isvalid(b.the_geom) and<BR>
> isvalid<BR>
> (z.the_geom);<BR>
> ERROR: Relate Operation called with a LWGEOMCOLLECTION<BR>
> type. This<BR>
> is unsupported<BR>
> otm=#<BR>
><BR>
><BR>
><BR>
> Le 8 déc. 08 à 13:32, Obe, Regina a écrit :<BR>
><BR>
> Many of the GEOS relation functions do not work with<BR>
> collections.<BR>
><BR>
> You must have a geometry collection in there somewhere<BR>
> or its a bug.<BR>
> Also which relation function were you trying?<BR>
><BR>
> To figure out the type of your geometries, run<BR>
><BR>
> SELECT *<BR>
> FROM sometable<BR>
> WHERE GeometryType(the_geom) = 'GEOMETRYCOLLECTION'<BR>
><BR>
><BR>
><BR>
><BR>
> -----Original Message-----<BR>
> From: postgis-users-bounces@postgis.refractions.net<BR>
> <<A HREF="mailto:postgis-users-bounces@postgis.refractions.net">mailto:postgis-users-bounces@postgis.refractions.net</A>><BR>
> [<A HREF="mailto:postgis-users-bounces@postgis.refractions.net">mailto:postgis-users-bounces@postgis.refractions.net</A><BR>
> <<A HREF="mailto:postgis-users-bounces@postgis.refractions.net">mailto:postgis-users-bounces@postgis.refractions.net</A>>]<BR>
> On Behalf Of<BR>
> Nicolas Ribot<BR>
> Sent: Monday, December 08, 2008 6:22 AM<BR>
> To: PostGIS Users Discussion<BR>
> Subject: Re: [postgis-users] how to identify the_geom<BR>
> that cause :<BR>
> RelateOperation called withLWGEOMCOLLECTION type<BR>
><BR>
> I have an error with some geometry that cause :<BR>
> "ERROR Relate<BR>
><BR>
> Operation<BR>
><BR>
> called withLWGEOMCOLLECTION type".<BR>
> All the geometries seem clean (valid, non empty,<BR>
> closed, only<BR>
> POLYGON,<BR>
><BR>
> ..)<BR>
><BR>
> My question : how to get information of which<BR>
> geometry cause the<BR>
><BR>
> problem ?<BR>
><BR>
> Is there a way to have information about the<BR>
> geometry during<BR>
> postgis<BR>
><BR>
> is<BR>
><BR>
> working on a SQL query ?<BR>
> Thanks.<BR>
><BR>
><BR>
> Hi Ghislain,<BR>
><BR>
> What the query that failed looks like ?<BR>
> The message is telling that one geometry has an<BR>
> invalid type.<BR>
> In your query, you could try to ask for<BR>
> ST_GeometryType(geometry) and<BR>
> a geometry identifier to see which geometry has the<BR>
> wrong type.<BR>
> If you perform a spatial operation, it is possible that<BR>
> geometryCollection is produced.<BR>
> You could maybe split your query into smaller block to<BR>
> see where such<BR>
> collections are generated.<BR>
><BR>
> Nicolas<BR>
> _______________________________________________<BR>
> postgis-users mailing list<BR>
> postgis-users@postgis.refractions.net<BR>
> <<A HREF="mailto:postgis-users@postgis.refractions.net">mailto:postgis-users@postgis.refractions.net</A>><BR>
> <A HREF="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</A><BR>
> -----------------------------------------<BR>
> The substance of this message, including any<BR>
> attachments, may be<BR>
> confidential, legally privileged and/or exempt from<BR>
> disclosure<BR>
> pursuant to Massachusetts law. It is intended<BR>
> solely for the addressee. If you received this in<BR>
> error, please<BR>
> contact the sender and delete the material from any<BR>
> computer.<BR>
> _______________________________________________<BR>
> postgis-users mailing list<BR>
> postgis-users@postgis.refractions.net<BR>
> <<A HREF="mailto:postgis-users@postgis.refractions.net">mailto:postgis-users@postgis.refractions.net</A>><BR>
> <A HREF="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</A><BR>
><BR>
><BR>
><BR>
><BR>
> ------------------------------------------<BR>
> Geniaux Ghislain<BR>
> INRA SAD Ecodéveloppement<BR>
> Site Agroparc<BR>
> Domaine St Paul<BR>
> 84914 Avignon Cedex 9<BR>
><BR>
> Tél : 04 32 72 25 64<BR>
> Fax : 04 32 72 25 62<BR>
><BR>
><BR>
> _______________________________________________<BR>
> postgis-users mailing list<BR>
> postgis-users@postgis.refractions.net<BR>
> <<A HREF="mailto:postgis-users@postgis.refractions.net">mailto:postgis-users@postgis.refractions.net</A>><BR>
> <A HREF="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</A><BR>
><BR>
><BR>
><BR>
> _______________________________________________<BR>
> postgis-users mailing list<BR>
> postgis-users@postgis.refractions.net<BR>
> <<A HREF="mailto:postgis-users@postgis.refractions.net">mailto:postgis-users@postgis.refractions.net</A>><BR>
> <A HREF="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</A><BR>
><BR>
><BR>
><BR>
><BR>
> ------------------------------------------<BR>
> Geniaux Ghislain<BR>
> INRA SAD Ecodéveloppement<BR>
> Site Agroparc<BR>
> Domaine St Paul<BR>
> 84914 Avignon Cedex 9<BR>
><BR>
> Tél : 04 32 72 25 64<BR>
> Fax : 04 32 72 25 62<BR>
><BR>
><BR>
> _______________________________________________<BR>
> postgis-users mailing list<BR>
> postgis-users@postgis.refractions.net<BR>
> <<A HREF="mailto:postgis-users@postgis.refractions.net">mailto:postgis-users@postgis.refractions.net</A>><BR>
> <A HREF="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</A><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>
> postgis-users mailing list<BR>
> postgis-users@postgis.refractions.net<BR>
> <<A HREF="mailto:postgis-users@postgis.refractions.net">mailto:postgis-users@postgis.refractions.net</A>><BR>
> <A HREF="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</A><BR>
><BR>
><BR>
><BR>
><BR>
> ------------------------------------------<BR>
> Geniaux Ghislain<BR>
> INRA SAD Ecodéveloppement<BR>
> Site Agroparc<BR>
> Domaine St Paul<BR>
> 84914 Avignon Cedex 9<BR>
><BR>
> Tél : 04 32 72 25 64<BR>
> Fax : 04 32 72 25 62<BR>
><BR>
><BR>
> _______________________________________________<BR>
> postgis-users mailing list<BR>
> postgis-users@postgis.refractions.net<BR>
> <<A HREF="mailto:postgis-users@postgis.refractions.net">mailto:postgis-users@postgis.refractions.net</A>><BR>
> <A HREF="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</A><BR>
><BR>
><BR>
> ------------------------------------------------------------------------<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 solely for the<BR>
> addressee. If you received this in error, please contact the sender<BR>
> and delete the material from any computer. *<BR>
><BR>
> ------------------------------------------------------------------------<BR>
><BR>
> * Help make the earth a greener place. If at all possible resist<BR>
> printing this email and join us in saving paper. *<BR>
><BR>
> * *<BR>
><BR>
> * *<BR>
><BR>
> ------------------------------------------------------------------------<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>
<BR>
--<BR>
Martin Davis<BR>
Senior Technical Architect<BR>
Refractions Research, Inc.<BR>
(250) 383-3022<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>
</FONT>
</P>
</BODY>
</HTML>