[geos-devel] Design of exception-trapping wrapper
David Blasby
dblasby at refractions.net
Fri Apr 11 20:33:20 EDT 2003
Martin Davis wrote:
>Does anyone have time and ideas to prototype the design of this wrapper? I'm not sure I understand the problem quite well enough yet to propose a design. A small mockup might help to clarify the situation.
>
Something like the function included below.
NOTE: this is an *added* interface, not the ONLY interface. C++ and
simple C programs could use the system exactly the way it is now.
We'd have to come up with name so we dont have any redundant symbols.
>>This seems like a pretty substantial change to GEOS.
No - I think it would be pretty easy. We could add another class to
GEOS. It wouldnt even have to be compiled unless you're using postgis...
Unfortunately, there could be a lot of these little functions. But, if
we stick to just wrapping the Geometry interface, we should be okay. I
dont think postgis requires more than this.
// call g1->contains(g2)
// returns 0 = false
// 1 = true
// 2 = error was trapped
char GEOSrelateContains(Geometry *g1, Geometry*g2)
{
try {
bool result;
result = g1->contains(g2);
if (result)
return 1;
else
return 0;
}
catch (...)
{
return 2;
}
}
The postgis_wrapper.cpp would be very simple:
char relate(Geometry *g1, Geometry *g2)
{
return GEOSrelateContains(g1,g2);
}
More information about the geos-devel
mailing list