[EMAIL PROTECTED] wrote:
On Mon, Nov 27, 2006 at 05:29:54PM +0000, Olivier Bedel wrote:
Hi all members of the list,
I try to handle exception with the CAPI. I use the GEOSGeomFromWKT
function and I want to avoid segmentation fault when a wrong wkt string
is given as a parameter. Reading the comments in geos_c.h, I expected
this function return a NULL pointer when an exception was raised, but
strangely, it seems that he seg fault happens in the function call. So I
get no return values and I can't handle exceptions.
Here is a simple example of what I want to do:
/****************************/
GEOSGeometry *g;
g = GEOSGeomFromWKT("POLYGON(0.0 0.0, 1.0 1.0, 2.0 2.0, 0.0 0.0))");
if (g==NULL)
fprintf(stderr,"g is not a valid geometry\n");
/****************************/
Do I miss something ?
Have you initialised GEOS using the initGEOS function? If not, when
geos tries to return an error (as in the above code), it will segfault
as it tries to access a pointer to an error reporting function but
finds NULL instead. This error reporting function is set using
initGEOS. Have a look in capi/geostest.c for an example of how to go
about it.
Kind regards,
Homme
Thanks Homme,
You were right. By initialising GEOS with initGEOS, it solves the problem.
Best regards,
Olivier.
_______________________________________________
geos-devel mailing list
geos-devel@geos.refractions.net
http://geos.refractions.net/mailman/listinfo/geos-devel