[postgis-devel] Re: [postgis-users] how to identify the_geom that
cause : RelateOperation called withLWGEOMCOLLECTION type
Kevin Neufeld
kneufeld at refractions.net
Mon Dec 8 10:47:18 PST 2008
Ghislain Geniaux wrote:
> otm=# create table info_nonvoue1 as
> otm-# select b.id_parc, z.niv from bd_dispo_finalc as b, ZS2c as z
> otm-# where z.niv=1 and intersects(centroid(b.the_geom),z.the_geom) and
> b.the_geom && z.the_geom and isvalid(b.the_geom) and isvalid(z.the_geom);
> ERROR: Relate Operation called with a LWGEOMCOLLECTION type. This is
> unsupported
> otm=#
>
Mark,
Is it fairly trivial to change the elog in lwgeom_geos.c to your fancy errhint so that when the error is thrown the user
has an idea where the problem occurs?
The attached patch seems to work, but I got lost when trying to limit the output of the LWGEOMCOLLECTION to the first
say 128 characters of the WKT representation.
Cheers,
Kevin
-------------- next part --------------
Index: lwgeom_geos.c
===================================================================
--- lwgeom_geos.c (revision 3371)
+++ lwgeom_geos.c (working copy)
@@ -1025,9 +1025,24 @@
{
int t1 = lwgeom_getType(g1->type);
int t2 = lwgeom_getType(g2->type);
+
+ LWGEOM_UNPARSER_RESULT lwg_unparser_result;
+ int result;
- if ( (t1 == COLLECTIONTYPE) || (t2 == COLLECTIONTYPE) )
- elog(ERROR,"Relate Operation called with a LWGEOMCOLLECTION type. This is unsupported");
+ if ( t1 == COLLECTIONTYPE) {
+ result = serialized_lwgeom_to_ewkt(&lwg_unparser_result, SERIALIZED_FORM(g1), PARSER_CHECK_ALL);
+ ereport(ERROR,
+ (errmsg("Relate Operation called with a LWGEOMCOLLECTION type. This is unsupported"),
+ errhint("Argument 1: '%s'", lwg_unparser_result.wkoutput))
+ );
+ }
+ else if (t2 == COLLECTIONTYPE) {
+ result = serialized_lwgeom_to_ewkt(&lwg_unparser_result, SERIALIZED_FORM(g2), PARSER_CHECK_ALL);
+ ereport(ERROR,
+ (errmsg("Relate Operation called with a LWGEOMCOLLECTION type. This is unsupported"),
+ errhint("Argument 2: '%s'", lwg_unparser_result.wkoutput))
+ );
+ }
}
PG_FUNCTION_INFO_V1(isvalid);