[geos-devel] Exposing PrecisionModel, GeometryPrecisionReducer in the C API
Sandro Mani
manisandro at gmail.com
Tue Dec 23 05:23:29 PST 2014
Hi,
Following the initial discussion in ticket #713 [1], I'd like to discuss
the exposing of PrecisionModel and GeometryPrecisionReducer methods in
the C API.
Personally I'm interested in having access to the
GeometryPrecisionReducer::reduce method, as noted in the ticket there is
also the desire [2] to expose the GeometryFactory in the C API and allow
creating geometries with a specified GeometryFactory. Below is an
initial proposal.
-------------------------------------------------------------------------------
/** Precision Model **/
typedef struct GEOSPrecisionModel_t GEOSPrecisionModel;
enum GEOSPrecisionModelType {
GEOS_PRECISION_FIXED,
GEOS_PRECISION_FLOATING,
GEOS_PRECISION_FLOATING_SINGLE
};
extern GEOSPrecisionModel* GEOSPrecisionModel_create(int type);
extern GEOSPrecisionModel* GEOSPrecisionModel_createFixed(double scale);
extern void GEOSPrecisionModel_destroy(GEOSPrecisionModel* model);
/** Geometry Factory **/
typedef struct GEOSGeometryFactory_t GEOSGeometryFactory;
/* pm copied, NULL for default. */
extern GEOSGeometryFactory*
GEOSGeometryFactory_create(GEOSPrecisionModel* pm, int SRID);
extern void GEOSGeometryFactory_destroy(GEOSGeometryFactory* factory);
/** New geometry constructors **/
/* Factory needs to stay valid */
extern GEOSGeometry GEOS_DLL
*GEOSGeometryFactory_createPoint(GEOSGeometryFactory* factory,
GEOSCoordSequence* s);
extern GEOSGeometry GEOS_DLL
*GEOSGeometryFactory_createEmptyPoint(GEOSGeometryFactory* factory);
extern GEOSGeometry GEOS_DLL
*GEOSGeometryFactory_createLinearRing(GEOSGeometryFactory* factory,
GEOSCoordSequence* s);
extern GEOSGeometry GEOS_DLL
*GEOSGeometryFactory_createLineString(GEOSGeometryFactory* factory,
GEOSCoordSequence* s);
extern GEOSGeometry GEOS_DLL
*GEOSGeometryFactory_createEmptyLineString(GEOSGeometryFactory* factory);
extern GEOSGeometry GEOS_DLL
*GEOSGeometryFactory_createEmptyPolygon(GEOSGeometryFactory* factory);
extern GEOSGeometry GEOS_DLL
*GEOSGeometryFactory_createPolygon(GEOSGeometryFactory* factory,
GEOSGeometry* shell, GEOSGeometry** holes, unsigned int nholes);
extern GEOSGeometry GEOS_DLL
*GEOSGeometryFactory_createCollection(GEOSGeometryFactory* factory, int
type, GEOSGeometry* *geoms, unsigned int ngeoms);
extern GEOSGeometry GEOS_DLL
*GEOSGeometryFactory_createEmptyCollection(GEOSGeometryFactory* factory,
int type);
/** Retreive factory from geometry **/
extern GEOSGeometryFactory GEOSGeom_getGeometryFactory(GEOSGeometry* geom);
/** Precision Reducer **/
typedef struct GEOSGeometryPrecisionReducer_t GEOSGeometryPrecisionReducer;
/* Factory needs to stay valid */
extern GEOSGeometryPrecisionReducer*
GEOSGeometryPrecisionReducer_create_factory(GEOSGeometryFactory* factory);
extern GEOSGeometry*
GEOSGeometryPrecisionReducer_reduce(GEOSGeometryPrecisionReducer*
reducer, GEOSGeometry* geometry);
extern void
GEOSGeometryPrecisionReducer_destroy(GEOSGeometryPrecisionReducer* reducer);
-------------------------------------------------------------------------------
Remarks:
- GEOSGeometryFactory_createXXX is closer to the C++ API, an alternative
would be something like GEOSGeom_createXXX_factory which is closer to
what is described in [2].
- Possibly the CoordinateSequenceFactory needs to be exposed also?
Comments appreciated. Thanks,
Sandro
[1] http://trac.osgeo.org/geos/ticket/713
[2] http://trac.osgeo.org/geos/wiki/GSoC/CAPI_PrecisionModel
More information about the geos-devel
mailing list