[geos-devel] Exposing PrecisionModel, GeometryPrecisionReducer in the C API
Sandro Santilli
strk at keybit.net
Wed Jan 7 03:00:28 PST 2015
On Wed, Jan 07, 2015 at 09:54:32AM +0100, Sandro Mani wrote:
> GeometryFactory does make a copy of the PrecisionModel passed by the
> user, so it is not necessary to keep the copy around.
Great
> By this you mean not exposting the PrecisionModel at all, and
> instead doing something like this?:
>
> /** Geometry Factory **/
> typedef struct GEOSGeometryFactory_t GEOSGeometryFactory;
>
> extern GEOSGeometryFactory* GEOSGeometryFactory_create(int SRID);
> extern GEOSGeometryFactory*
> GEOSGeometryFactory_create_doublePrecision(int SRID);
> extern GEOSGeometryFactory*
> GEOSGeometryFactory_create_singlePrecision(int SRID);
> extern GEOSGeometryFactory*
> GEOSGeometryFactory_create_fixedPrecision(int SRID, double scale);
> extern void GEOSGeometryFactory_destroy(GEOSGeometryFactory* factory);
>
> I'm ok with that, it is actually cleaner.
Yes. I'm not sure it's worth having support for single-precision,
and I'd avoid having two different signatures to create a double-precision.
extern GEOSGeometryFactory*
GEOSGeometryFactory_createDoublePrecision(int SRID);
extern GEOSGeometryFactory*
GEOSGeometryFactory_createFixedPrecision(int SRID, double scale);
Further thinking about it, I wonder if there's a chance to also hide
the GeometryFactory object completely. I guess the main reason to expose
it is to give caller a way to manage it's lifetime, otherwise it could
be set into the Context before creating any geometry. Could lifetime
be taken care of by the C-API with reference counting ? Aren't Geometry
objects (the sole referers to GeometryFactory objects) solely constructable
and destroyable via C-API methods ? In that case such methods could
increase/decrease refcounts and delete no-more-needed ones.
Refcounting hiding would further simplify the interface because you would
not need to add new constructors signatures for making actual use of
the reduced precision.
--strk;
() Free GIS & Flash consultant/developer
/\ http://strk.keybit.net/services.html
More information about the geos-devel
mailing list