[geos-devel] Exposing PrecisionModel, GeometryPrecisionReducer in the C API

Sandro Mani manisandro at gmail.com
Wed Jan 7 07:48:24 PST 2015

On 07.01.2015 15:25, Sandro Santilli wrote:
> On Wed, Jan 07, 2015 at 02:05:59PM +0100, Sandro Mani wrote:
>> Okay. So back to your point about hiding the GeometryFactory, I'd
>> say no since otherwise one is limited to one precision model per
>> context?
> Yes, but there's no limit on the number of contexts you can hold in
> a thread. Also nobody would prevent you from switching precision model
> of the current context. The only problem would be, again, management
> of GeometryFactory objects that are no more used.

So this would mean an API like:

/** Create context handle **/
extern GEOSContextHandle_t GEOS_DLL initGEOS_r(GEOSMessageHandler 
notice_function, GEOSMessageHandler error_function);
extern GEOSContextHandle_t GEOS_DLL 
initGEOS_r_fixedPrecision(GEOSMessageHandler notice_function, 
GEOSMessageHandler error_function, double scale);
/** GEOSContextHandle_t internally keeps a reference count, set to 1 on 
  * - *All* methods producing a GEOSGeom increase the reference count
  * - GEOSGeom_destroy decreses the GeometryFactory reference count, if 
0, it destroys the context
  * - finishGEOS_r decreses the reference count, if 0, it destroys the 

/** Set context handle precision model **/
void GEOSContextHandle_t 
GEOSContext_setPrecisionDouble(GEOSContextHandle_t* handle);
void GEOSContextHandle_t 
GEOSContext_setPrecisionFixed(GEOSContextHandle_t* handle, double scale);

/** Precision reducer **/
extern GEOSGeometryPrecisionReducer* GEOSGeometryPrecisionReducer_create();
extern GEOSGeometry* 
reducer, GEOSGeometry* geometry);
extern void 
GEOSGeometryPrecisionReducer_destroy(GEOSGeometryPrecisionReducer* reducer);

The changes needed for reference counting are somewhat invasive IMO.

More information about the geos-devel mailing list