[geos-devel] Adding geometric area() to C API

strk at refractions.net strk at refractions.net
Wed Feb 8 10:43:29 EST 2006


On Wed, Feb 08, 2006 at 08:23:02AM -0700, Sean Gillies wrote:
> strk,
> 
> Can you explain to me how I would go about adding to the C API? I am  
> particularly interested in exposing getArea().

It should be very simple.
Next release will come out of HEAD, so:

* get head 
* cd capi
* edit geos_c.cpp:
	
	extern "C" int GEOS_DLL GEOSArea(const Geometry *g, double *area);
	...
	int
	GEOSArea(const Geometry *g, double *area)
	{
		try  {
			*result = g->getArea();
		} catch (whatever) {
			ERROR_MESSAGE(whatever_msg);
			return 0;
		}
		return 1;
	}	
 
* edit geos_c.h.in:

	/* Return 0 on exception, 1 otherwise */
	extern int GEOS_DLL GEOSArea(const GEOSGeom g1, double *area);

* test
* cvs diff -U2 | mail strk

Mmm.. it seems it's done already, just make sure you catch
both GEOSException* _AND_ std::exception&, as GEOSException
will probably be changed to a std::exception derived.

--strk; 

 +----------------------------------------+
 | Fight against software patents in EU!  |
 | www.ffii.org www.nosoftwarepatents.org |
 +----------------------------------------+




More information about the geos-devel mailing list