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

Sandro Santilli strk at keybit.net
Wed Jan 14 01:38:23 PST 2015


On Tue, Jan 13, 2015 at 11:21:34AM +0100, Sandro Mani wrote:
> 
> On 08.01.2015 13:08, Sandro Mani wrote:
> >So to wrap up, things currently look as follows (which I actually
> >think is quite neat!):
> >
> >
> >/** GEOSContextHandle_t internally keeps a reference count, set to
> >1 on creation
> > * - *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 context
> > */
> >
> >/** GEOSGeom_clone() clones the geometry and applies
> >PrecisionReducer::reduce
> > *  if the PrecisionModel of the current context is different than
> >the that of
> > *  the passed geometry
> > */
> >
> >/** Set context handle precision model **/
> >void GEOSContextHandle_t
> >GEOSContext_setPrecisionDouble(GEOSContextHandle_t* handle);
> >void GEOSContextHandle_t
> >GEOSContext_setPrecisionFixed(GEOSContextHandle_t* handle, double
> >scale);
>
> So, what do you think? Worth pursuing this approach?

Sorry I'm not having much time to dedicate to this.
I'm not very sure about the approach, to be honest.
There are indeed 2 possible things one would want to do with PM:

 1. "advertise" the PM of a geometry, w/out rounding coords

 2. "set" the PM of a geometry, rounding coords

I'm not sure we ever want to allow for 1, to avoid wrong advertisement.
The signature in the current proposal makes 2 clear for the cloning
of a geometry, but we're still missing clear documentation about what
happens from the constructors. Would/should they round ?

Example, what should happen here:

  GEOSContextHandle_t h = initGEOS_r(...);
  GEOSCoordSequence *s = GEOSCoordSeq_create_r(h,2,2);
  GEOSContext_setPrecisionDouble(h);
  GEOSCoordSeq_setX_r(h, s, 0, 0);
  GEOSCoordSeq_setY_r(h, s, 0, 0);
  GEOSContext_setPrecisionFixed(h, 1);
  GEOSCoordSeq_setX_r(h, s, 1, 0.2);
  GEOSCoordSeq_setY_r(h, s, 1, 0.2);

Should the coordinate sequence contain 2 equal points after the above ?
And what about WKB/WKT parsing ?

It would help to gather more comments from others.
I've added Oliver and Sean in Cc as they took part of a precedent
discussion about this:
http://lists.osgeo.org/pipermail/geos-devel/2014-February/006780.html

--strk;

  ()   Free GIS & Flash consultant/developer
  /\   http://strk.keybit.net/services.html


More information about the geos-devel mailing list