wiki:GSoC/CAPI_PrecisionModel

To expose PrecisionModel? through C-API

  • Create a function GEOSPrecisionModel in geos_c.cpp which calls GEOSPrecisionModel_r in geos_ts_c.cpp to make it thread safe.
  • GEOSPrecisionModel_r creates a new precision model with arguments (double newScale, double newOffsetX, double newOffsetY) with fixed precision(the arguments that need to be passed are to be finalized).
  • Create a new geometry factory by passing this precision model to it.
  • Create a function GEOSContext_setPrecisionModel which sets the geometry factory and precision model to be used in that context.
  • Write test cases.

Requirements for Shapely

Shapely (https://github.com/Toblerity/Shapely) is one of the major Python users of GEOS. I want to let programmers select and use a precision model like this:

from shapely.geometry import Point, factory
from shapely.precision import fixed_model

# make a geometry factory using a fixed-precision model.
fixed = factory(fixed_model(scale=1.0, offset=(0.0, 0.0)))

# make a point snapped to a fixed-precision grid.
p = Point(0, 0, factory=fixed)

# make a float-precision point.
q = Point(0, 0)

The above is a bit of a reversal from what I've previously written about my precision model requirements. A Python API like the one above is going to be very reliable and doesn't leave any geometry objects twisting in the wind when their precision model goes away: they have references to the model which keep it "alive". So, my main requirements for the precision model in the C API are now:

No global state

There shouldn't be a precision model in the global context. Or if there is, it shouldn't preclude precision models outside the global context.

As many precision models as I want

I expect any particular Shapely program to be using only 1-2 at a time, but let's not do anything to arbitrarily limit the number.

Last modified 4 years ago Last modified on Mar 17, 2014 9:57:46 AM