Hi, Strk, Markus Schaber wrote:
Here's another patch, it includes the last one, and also reverts the four places of "unsigned int" changes that break source compatibility between geos 2 and geos 3. HTH, Markus -- Markus Schaber | Logical Tracking&Tracing International AG Dipl. Inf. | Software Development GIS Fight against software patents in Europe! www.ffii.org www.nosoftwarepatents.org
Index: source/algorithm/InteriorPointLine.cpp =================================================================== --- source/algorithm/InteriorPointLine.cpp (revision 1879) +++ source/algorithm/InteriorPointLine.cpp (working copy) @@ -36,7 +36,7 @@ namespace geos { namespace algorithm { // geos.algorithm -InteriorPointLine::InteriorPointLine(Geometry *g) +InteriorPointLine::InteriorPointLine(const Geometry *g) { minDistance=DoubleInfinity; hasInterior=false; Index: source/geom/Geometry.cpp =================================================================== --- source/geom/Geometry.cpp (revision 1879) +++ source/geom/Geometry.cpp (working copy) @@ -240,7 +240,7 @@ } Point* -Geometry::getInteriorPoint() +Geometry::getInteriorPoint() const { Coordinate interiorPt; int dim=getDimension(); Index: source/operation/polygonize/Polygonizer.cpp =================================================================== --- source/operation/polygonize/Polygonizer.cpp (revision 1879) +++ source/operation/polygonize/Polygonizer.cpp (working copy) @@ -40,9 +40,9 @@ } void -Polygonizer::LineStringAdder::filter_rw(Geometry *g) +Polygonizer::LineStringAdder::filter_ro(const Geometry *g) { - LineString *ls = dynamic_cast<LineString *>(g); + const LineString *ls = dynamic_cast<const LineString *>(g); if ( ls ) pol->add(ls); } @@ -99,12 +99,30 @@ { for(unsigned int i=0, n=geomList->size(); i<n; ++i) { - Geometry *geometry=(*geomList)[i]; + const Geometry *geometry=(*geomList)[i]; add(geometry); } } /* + * Add a collection of geometries to be polygonized. + * May be called multiple times. + * Any dimension of Geometry may be added; + * the constituent linework will be extracted and used + * + * @param geomList a list of [EMAIL PROTECTED] Geometry}s with linework to be polygonized + */ +void +Polygonizer::add(vector<const Geometry*> *geomList) +{ + for(unsigned int i=0, n=geomList->size(); i<n; ++i) + { + const Geometry *geometry=(*geomList)[i]; + add(geometry); + } +} + +/* * Add a geometry to the linework to be polygonized. * May be called multiple times. * Any dimension of Geometry may be added; @@ -115,16 +133,30 @@ void Polygonizer::add(Geometry *g) { - g->apply_rw(lineStringAdder); + g->apply_ro(lineStringAdder); } /* + * Add a geometry to the linework to be polygonized. + * May be called multiple times. + * Any dimension of Geometry may be added; + * the constituent linework will be extracted and used + * + * @param g a Geometry with linework to be polygonized + */ +void +Polygonizer::add(const Geometry *g) +{ + g->apply_ro(lineStringAdder); +} + +/* * Add a linestring to the graph of polygon edges. * * @param line the LineString to add */ void -Polygonizer::add(LineString *line) +Polygonizer::add(const LineString *line) { // create a new graph using the factory from the input Geometry if (graph==NULL) Index: source/headers/geos/algorithm/InteriorPointLine.h =================================================================== --- source/headers/geos/algorithm/InteriorPointLine.h (revision 1879) +++ source/headers/geos/algorithm/InteriorPointLine.h (working copy) @@ -45,7 +45,7 @@ class InteriorPointLine { public: - InteriorPointLine(geom::Geometry *g); + InteriorPointLine(const geom::Geometry *g); ~InteriorPointLine(); Index: source/headers/geos/geom/Geometry.h =================================================================== --- source/headers/geos/geom/Geometry.h (revision 1879) +++ source/headers/geos/geom/Geometry.h (working copy) @@ -642,7 +642,7 @@ * @return a Point which is in the interior of this Geometry, or * null if the geometry doesn't have an interior (empty) */ - virtual Point* getInteriorPoint(); + virtual Point* getInteriorPoint() const; /* * \brief Index: source/headers/geos/operation/polygonize/Polygonizer.h =================================================================== --- source/headers/geos/operation/polygonize/Polygonizer.h (revision 1879) +++ source/headers/geos/operation/polygonize/Polygonizer.h (working copy) @@ -70,8 +70,8 @@ public: Polygonizer *pol; LineStringAdder(Polygonizer *p); - void filter_rw(geom::Geometry *g); - //void filter_ro(const geom::Geometry * /*g*/){}; + //void filter_rw(geom::Geometry *g); + void filter_ro(const geom::Geometry * g); }; // default factory @@ -82,7 +82,7 @@ * * @param line the [EMAIL PROTECTED] LineString} to add */ - void add(geom::LineString *line); + void add(const geom::LineString *line); /** * Perform the polygonization, if it has not already been carried out. @@ -134,6 +134,16 @@ */ void add(std::vector<geom::Geometry*> *geomList); + /** \brief + * Add a collection of geometries to be polygonized. + * May be called multiple times. + * Any dimension of Geometry may be added; + * the constituent linework will be extracted and used + * + * @param geomList a list of Geometry with linework to be polygonized + */ + void add(std::vector<const geom::Geometry*> *geomList); + /** * Add a geometry to the linework to be polygonized. * May be called multiple times. @@ -144,6 +154,16 @@ */ void add(geom::Geometry *g); + /** + * Add a geometry to the linework to be polygonized. + * May be called multiple times. + * Any dimension of Geometry may be added; + * the constituent linework will be extracted and used + * + * @param g a Geometry with linework to be polygonized + */ + void add(const geom::Geometry *g); + /** \brief * Gets the list of polygons formed by the polygonization. * Index: capi/geos_c.cpp =================================================================== --- capi/geos_c.cpp (revision 1879) +++ capi/geos_c.cpp (working copy) @@ -50,6 +50,12 @@ #include <string> #include <memory> +// Some extra magic to make type declarations in geos_c.h work - for cross-checking of types in header. +#define GEOSGeom geos::geom::Geometry* +#define GEOSCoordSeq geos::geom::CoordinateSequence* +#define GEOSGeomTypes geos::geom::GeometryTypeId +#include "geos_c.h" + /// Define this if you want operations triggering Exceptions to /// be printed (will use the NOTIFY channel - only implemented for GEOSUnion so far) /// @@ -78,119 +84,9 @@ //## PROTOTYPES ############################################# -/* Initialize GEOS library */ -extern "C" void GEOS_DLL initGEOS(GEOSMessageHandler notice, GEOSMessageHandler err); - -/* Release GEOS resources */ -extern "C" void GEOS_DLL finishGEOS(); - -/* Input and Output functions, return NULL on exception. */ -extern "C" Geometry GEOS_DLL *GEOSGeomFromWKT(const char *wkt); -extern "C" Geometry GEOS_DLL *GEOSGeomFromWKB_buf(const char *wkb, size_t size); -extern "C" Geometry GEOS_DLL *GEOSGeomFromHEX_buf(const char *hex, size_t size); -extern "C" char GEOS_DLL *GEOSGeomToWKT(const Geometry *g); -extern "C" char GEOS_DLL *GEOSGeomToWKB_buf(const Geometry *g, size_t *size); -extern "C" char GEOS_DLL *GEOSGeomToHEX_buf(const Geometry *g, size_t *size); -extern "C" int GEOS_DLL GEOS_getWKBOutputDims(); -extern "C" int GEOS_DLL GEOS_setWKBOutputDims(int newdims); -extern "C" int GEOS_DLL GEOS_getWKBByteOrder(); -extern "C" int GEOS_DLL GEOS_setWKBByteOrder(int byteOrder); - -extern "C" void GEOS_DLL GEOSSetSRID(Geometry *g, int SRID); - -extern "C" char GEOS_DLL *GEOSRelate(const Geometry *g1, const Geometry *g2); -extern "C" char GEOS_DLL GEOSRelatePattern(const Geometry *g1, const Geometry *g2, const char *pat); -extern "C" char GEOS_DLL GEOSDisjoint(const Geometry *g1, const Geometry *g2); -extern "C" char GEOS_DLL GEOSTouches(const Geometry *g1, const Geometry *g2); -extern "C" char GEOS_DLL GEOSIntersects(const Geometry *g1, const Geometry *g2); -extern "C" char GEOS_DLL GEOSCrosses(const Geometry *g1, const Geometry *g2); -extern "C" char GEOS_DLL GEOSWithin(const Geometry *g1, const Geometry *g2); -extern "C" char GEOS_DLL GEOSContains(const Geometry *g1, const Geometry *g2); -extern "C" char GEOS_DLL GEOSOverlaps(const Geometry *g1, const Geometry *g2); - -extern "C" Geometry GEOS_DLL *GEOSpolygonize(Geometry **geoms, unsigned int ngeoms); -extern "C" char GEOS_DLL GEOSisValid(const Geometry *g1); -extern "C" char GEOS_DLL GEOSisEmpty(const Geometry *g1); -extern "C" Geometry GEOS_DLL *GEOSEnvelope(Geometry *g1); -extern "C" Geometry GEOS_DLL *GEOSIntersection(Geometry *g1,Geometry *g2); -extern "C" Geometry GEOS_DLL *GEOSBuffer(Geometry *g1,double width,int quadsegs); -extern "C" Geometry GEOS_DLL *GEOSConvexHull(Geometry *g1); -extern "C" Geometry GEOS_DLL *GEOSDifference(Geometry *g1,Geometry *g2); -extern "C" Geometry GEOS_DLL *GEOSBoundary(Geometry *g1); -extern "C" Geometry GEOS_DLL *GEOSSymDifference(Geometry *g1,Geometry *g2); -extern "C" Geometry GEOS_DLL *GEOSUnion(Geometry *g1,Geometry *g2); -extern "C" const Geometry GEOS_DLL *GEOSGetGeometryN(Geometry *g1, int n); -extern "C" const Geometry GEOS_DLL *GEOSGetExteriorRing(Geometry *g1); -extern "C" const Geometry GEOS_DLL *GEOSGetInteriorRingN(Geometry *g1, int n); -extern "C" int GEOS_DLL GEOSNormalize(Geometry *g1); -extern "C" int GEOS_DLL GEOSGetNumInteriorRings(Geometry *g1); -extern "C" int GEOS_DLL GEOSGetSRID(Geometry *g1); -extern "C" int GEOS_DLL GEOSGetNumGeometries(Geometry *g1); -extern "C" char GEOS_DLL GEOSisSimple(Geometry *g1); -extern "C" char GEOS_DLL GEOSEquals(const Geometry *g1, const Geometry*g2); -extern "C" char GEOS_DLL GEOSEqualsExact(const Geometry *g1, const Geometry *g2, double tolerance); -extern "C" char GEOS_DLL GEOSisRing(Geometry *g1); -extern "C" Geometry GEOS_DLL *GEOSPointOnSurface(Geometry *g1); -extern "C" Geometry GEOS_DLL *GEOSGetCentroid(Geometry *g); -extern "C" CoordinateSequence GEOS_DLL *GEOSGeom_getCoordSeq(Geometry *g1); - -extern "C" int GEOS_DLL GEOSArea(const Geometry *g1, double *area); -extern "C" int GEOS_DLL GEOSLength(const Geometry *g1, double *length); -extern "C" int GEOS_DLL GEOSDistance(const Geometry *g1, const Geometry *g2, - double *dist); - -extern "C" Geometry GEOS_DLL *GEOSSimplify(Geometry *g1, double tolerance); -extern "C" Geometry GEOS_DLL *GEOSTopologyPreserveSimplify(Geometry *g1, double tolerance); - -extern "C" const char GEOS_DLL *GEOSversion(); extern "C" const char GEOS_DLL *GEOSjtsport(); extern "C" char GEOS_DLL *GEOSasText(Geometry *g1); -extern "C" char GEOS_DLL *GEOSGeomType(Geometry *g1); -extern "C" int GEOS_DLL GEOSGeomTypeId(Geometry *g1); -//extern "C" void GEOSdeleteChar(char *a); -extern "C" void GEOS_DLL GEOSGeom_destroy(Geometry *a); -extern "C" bool GEOS_DLL GEOSHasZ(Geometry *g1); - -extern "C" Geometry GEOS_DLL *GEOSPolygonize(Geometry **, unsigned int); -extern "C" Geometry GEOS_DLL *GEOSLineMerge(Geometry *); - -extern "C" int GEOS_DLL GEOSGeom_getDimensions(const Geometry *); -extern "C" int GEOS_DLL GEOSGetNumCoordinates(const Geometry *); - -/************************************************************************* - * - * Coordinate Sequences - * - *************************************************************************/ - -extern "C" CoordinateSequence GEOS_DLL *GEOSCoordSeq_create(unsigned int, unsigned int); -extern "C" int GEOS_DLL GEOSCoordSeq_getSize(CoordinateSequence *, unsigned int *size); -extern "C" int GEOS_DLL GEOSCoordSeq_getDimensions(CoordinateSequence *, unsigned int *dims); -extern "C" int GEOS_DLL GEOSCoordSeq_setX(CoordinateSequence *, unsigned int, double); -extern "C" int GEOS_DLL GEOSCoordSeq_setY(CoordinateSequence *, unsigned int, double); -extern "C" int GEOS_DLL GEOSCoordSeq_setZ(CoordinateSequence *, unsigned int, double); -extern "C" int GEOS_DLL GEOSCoordSeq_setOrdinate(CoordinateSequence *, unsigned int, unsigned int, double); -extern "C" int GEOS_DLL GEOSCoordSeq_getX(CoordinateSequence *, unsigned int, double *); -extern "C" int GEOS_DLL GEOSCoordSeq_getY(CoordinateSequence *, unsigned int, double *); -extern "C" int GEOS_DLL GEOSCoordSeq_getZ(CoordinateSequence *, unsigned int, double *); -extern "C" int GEOS_DLL GEOSCoordSeq_getOrdinate(CoordinateSequence *, unsigned int, unsigned int, double *); -extern "C" CoordinateSequence GEOS_DLL *GEOSCoordSeq_clone(CoordinateSequence *); -extern "C" void GEOS_DLL GEOSCoordSeq_destroy(CoordinateSequence *); - -/************************************************************************* - * - * Geometry constructors - * - *************************************************************************/ - -extern "C" Geometry GEOS_DLL *GEOSGeom_createPoint(CoordinateSequence *); -extern "C" Geometry GEOS_DLL *GEOSGeom_createLinearRing(CoordinateSequence *); -extern "C" Geometry GEOS_DLL *GEOSGeom_createLineString(CoordinateSequence *); -extern "C" Geometry GEOS_DLL *GEOSGeom_createPolygon(Geometry *, Geometry **, unsigned int); -extern "C" Geometry GEOS_DLL *GEOSGeom_createCollection(int type, Geometry **, unsigned int); -extern "C" Geometry GEOS_DLL *GEOSGeom_clone(Geometry *); - //## GLOBALS ################################################ // NOTE: SRID will have to be changed after geometry creation @@ -202,6 +98,8 @@ static int WKBOutputDims = 2; static int WKBByteOrder = getMachineByteOrder(); +extern "C" { + void initGEOS (GEOSMessageHandler nf, GEOSMessageHandler ef) { @@ -640,7 +538,7 @@ } // Remember to free the result! -char * +unsigned char * GEOSGeomToWKB_buf(const Geometry *g, size_t *size) { try @@ -656,7 +554,7 @@ result = (char*) std::malloc(len); memcpy(result, wkbstring.c_str(), len); *size = len; - return result; + return (unsigned char*) result; } catch (const std::exception &e) { @@ -672,11 +570,11 @@ } Geometry * -GEOSGeomFromWKB_buf(const char *wkb, size_t size) +GEOSGeomFromWKB_buf(const unsigned char *wkb, size_t size) { try { - std::string wkbstring = std::string(wkb, size); // make it binary ! + std::string wkbstring = std::string((const char*)wkb, size); // make it binary ! io::WKBReader r(*geomFactory); std::istringstream s(std::ios_base::binary); s.str(wkbstring); @@ -700,7 +598,7 @@ /* Read/write wkb hex values. Returned geometries are owned by the caller.*/ -char * +unsigned char * GEOSGeomToHEX_buf(const Geometry *g, size_t *size) { try @@ -716,7 +614,7 @@ result = (char*) std::malloc(len); memcpy(result, hexstring.c_str(), len); *size = len; - return result; + return (unsigned char*) result; } catch (const std::exception &e) { @@ -732,11 +630,11 @@ } Geometry * -GEOSGeomFromHEX_buf(const char *hex, size_t size) +GEOSGeomFromHEX_buf(const unsigned char *hex, size_t size) { try { - std::string hexstring = std::string(hex, size); + std::string hexstring = std::string((const char*)hex, size); io::WKBReader r(*geomFactory); std::istringstream s(std::ios_base::binary); s.str(hexstring); @@ -779,7 +677,7 @@ } char -GEOSisSimple(Geometry *g1) +GEOSisSimple(const Geometry *g1) { try { @@ -799,11 +697,11 @@ } char -GEOSisRing(Geometry *g) +GEOSisRing(const Geometry *g) { try { - LineString *ls = dynamic_cast<LineString *>(g); + const LineString *ls = dynamic_cast<const LineString *>(g); if ( ls ) { return (ls->isRing()); } else { @@ -827,7 +725,7 @@ //free the result of this char * -GEOSGeomType(Geometry *g1) +GEOSGeomType(const Geometry *g1) { try { @@ -853,7 +751,7 @@ // Return postgis geometry type index int -GEOSGeomTypeId(Geometry *g1) +GEOSGeomTypeId(const Geometry *g1) { try { @@ -880,7 +778,7 @@ //------------------------------------------------------------------- Geometry * -GEOSEnvelope(Geometry *g1) +GEOSEnvelope(const Geometry *g1) { try { @@ -901,7 +799,7 @@ } Geometry * -GEOSIntersection(Geometry *g1, Geometry *g2) +GEOSIntersection(const Geometry *g1, const Geometry *g2) { try { @@ -924,7 +822,7 @@ } Geometry * -GEOSBuffer(Geometry *g1, double width, int quadrantsegments) +GEOSBuffer(const Geometry *g1, double width, int quadrantsegments) { try { @@ -945,7 +843,7 @@ } Geometry * -GEOSConvexHull(Geometry *g1) +GEOSConvexHull(const Geometry *g1) { try { @@ -966,7 +864,7 @@ } Geometry * -GEOSDifference(Geometry *g1, Geometry *g2) +GEOSDifference(const Geometry *g1, const Geometry *g2) { try { @@ -989,7 +887,7 @@ } Geometry * -GEOSBoundary(Geometry *g1) +GEOSBoundary(const Geometry *g1) { try { @@ -1010,7 +908,7 @@ } Geometry * -GEOSSymDifference(Geometry *g1, Geometry *g2) +GEOSSymDifference(const Geometry *g1, const Geometry *g2) { try { @@ -1033,7 +931,7 @@ } Geometry * -GEOSUnion(Geometry *g1, Geometry *g2) +GEOSUnion(const Geometry *g1, const Geometry *g2) { try { @@ -1064,7 +962,7 @@ Geometry * -GEOSPointOnSurface(Geometry *g1) +GEOSPointOnSurface(const Geometry *g1) { try { @@ -1181,7 +1079,7 @@ } int -GEOSGetNumInteriorRings(Geometry *g1) +GEOSGetNumInteriorRings(const Geometry *g1) { try{ Polygon *p = (Polygon *) g1; @@ -1203,7 +1101,7 @@ //only call on GCs (or multi*) int -GEOSGetNumGeometries(Geometry *g1) +GEOSGetNumGeometries(const Geometry *g1) { try{ GeometryCollection *gc = (GeometryCollection *) g1; @@ -1228,10 +1126,10 @@ * Return a pointer to the internal Geometry. */ const Geometry * -GEOSGetGeometryN(Geometry *g1, int n) +GEOSGetGeometryN(const Geometry *g1, int n) { try{ - const GeometryCollection *gc = dynamic_cast<GeometryCollection *>(g1); + const GeometryCollection *gc = dynamic_cast<const GeometryCollection *>(g1); if ( ! gc ) { ERROR_MESSAGE("Argument is not a GeometryCollection"); @@ -1258,10 +1156,10 @@ * Return a copy of the internal Geometry. */ const Geometry * -GEOSGetExteriorRing(Geometry *g1) +GEOSGetExteriorRing(const Geometry *g1) { try{ - Polygon *p = dynamic_cast<Polygon *>(g1); + const Polygon *p = dynamic_cast<const Polygon *>(g1); if ( ! p ) { ERROR_MESSAGE("Invalid argument (must be a Polygon)"); @@ -1287,10 +1185,10 @@ * Return a pointer to internal storage, do not destroy it. */ const Geometry * -GEOSGetInteriorRingN(Geometry *g1, int n) +GEOSGetInteriorRingN(const Geometry *g1, int n) { try{ - Polygon *p = dynamic_cast<Polygon *>(g1); + const Polygon *p = dynamic_cast<const Polygon *>(g1); if ( ! p ) { ERROR_MESSAGE("Invalid argument (must be a Polygon)"); @@ -1312,7 +1210,7 @@ } Geometry * -GEOSGetCentroid(Geometry *g) +GEOSGetCentroid(const Geometry *g) { try{ Geometry *ret = g->getCentroid(); @@ -1383,13 +1281,13 @@ } Geometry * -GEOSPolygonize(Geometry **g, unsigned int ngeoms) +GEOSPolygonize(const Geometry **g, unsigned int ngeoms) { unsigned int i; Geometry *out = NULL; // construct vector - std::vector<Geometry *> *geoms = new std::vector<Geometry *>(ngeoms); + std::vector<const Geometry *> *geoms = new std::vector<const Geometry *>(ngeoms); for (i=0; i<ngeoms; i++) (*geoms)[i] = g[i]; #if GEOS_DEBUG @@ -1415,11 +1313,11 @@ #if GEOS_DEBUG ERROR_MESSAGE("geometry vector deleted"); #endif - - geoms = new std::vector<Geometry *>(polys->size()); - for (i=0; i<polys->size(); i++) (*geoms)[i] = (*polys)[i]; + std::vector<Geometry*> *polyvec = new std::vector<Geometry *>(polys->size()); + for (i=0; i<polys->size(); i++) (*polyvec)[i] = (*polys)[i]; delete polys; - out = geomFactory->createGeometryCollection(geoms); + out = geomFactory->createGeometryCollection(polyvec); + delete polyvec; } catch (const std::exception &e) { @@ -1437,7 +1335,7 @@ } Geometry * -GEOSLineMerge(Geometry *g) +GEOSLineMerge(const Geometry *g) { unsigned int i; Geometry *out = NULL; @@ -1476,7 +1374,7 @@ } int -GEOSGetSRID(Geometry *g1) +GEOSGetSRID(const Geometry *g1) { try{ return g1->getSRID(); @@ -1511,8 +1409,8 @@ } -bool -GEOSHasZ(Geometry *g) +char +GEOSHasZ(const Geometry *g) { if ( g->isEmpty() ) return false; double az = g->getCoordinate()->z; @@ -1612,7 +1510,7 @@ } CoordinateSequence * -GEOSCoordSeq_clone(CoordinateSequence *s) +GEOSCoordSeq_clone(const CoordinateSequence *s) { try { return s->clone(); } catch (const std::exception &e) @@ -1629,7 +1527,7 @@ } int -GEOSCoordSeq_getOrdinate(CoordinateSequence *s, unsigned int idx, +GEOSCoordSeq_getOrdinate(const CoordinateSequence *s, unsigned int idx, unsigned int dim, double *val) { try { @@ -1652,25 +1550,25 @@ } int -GEOSCoordSeq_getX(CoordinateSequence *s, unsigned int idx, double *val) +GEOSCoordSeq_getX(const CoordinateSequence *s, unsigned int idx, double *val) { return GEOSCoordSeq_getOrdinate(s, idx, 0, val); } int -GEOSCoordSeq_getY(CoordinateSequence *s, unsigned int idx, double *val) +GEOSCoordSeq_getY(const CoordinateSequence *s, unsigned int idx, double *val) { return GEOSCoordSeq_getOrdinate(s, idx, 1, val); } int -GEOSCoordSeq_getZ(CoordinateSequence *s, unsigned int idx, double *val) +GEOSCoordSeq_getZ(const CoordinateSequence *s, unsigned int idx, double *val) { return GEOSCoordSeq_getOrdinate(s, idx, 2, val); } int -GEOSCoordSeq_getSize(CoordinateSequence *s, unsigned int *size) +GEOSCoordSeq_getSize(const CoordinateSequence *s, unsigned int *size) { try { int sz = s->getSize(); @@ -1691,7 +1589,7 @@ } int -GEOSCoordSeq_getDimensions(CoordinateSequence *s, unsigned int *dims) +GEOSCoordSeq_getDimensions(const CoordinateSequence *s, unsigned int *dims) { try { unsigned int dm = s->getDimension(); @@ -1729,17 +1627,17 @@ } } -CoordinateSequence * -GEOSGeom_getCoordSeq(Geometry *g) +const CoordinateSequence * +GEOSGeom_getCoordSeq(const Geometry *g) { try { - LineString *ls = dynamic_cast<LineString *>(g); + const LineString *ls = dynamic_cast<const LineString *>(g); if ( ls ) { return const_cast<CoordinateSequence *>(ls->getCoordinatesRO()); } - Point *p = dynamic_cast<Point *>(g); + const Point *p = dynamic_cast<const Point *>(g); if ( p ) { return const_cast<CoordinateSequence *>(p->getCoordinatesRO()); @@ -1840,7 +1738,7 @@ } Geometry * -GEOSGeom_clone(Geometry *g) +GEOSGeom_clone(const Geometry *g) { try { return g->clone(); } catch (const std::exception &e) @@ -1904,7 +1802,7 @@ } Geometry * -GEOSSimplify(Geometry *g1, double tolerance) +GEOSSimplify(const Geometry *g1, double tolerance) { using namespace geos::simplify; @@ -1928,7 +1826,7 @@ } Geometry * -GEOSTopologyPreserveSimplify(Geometry *g1, double tolerance) +GEOSTopologyPreserveSimplify(const Geometry *g1, double tolerance) { using namespace geos::simplify; @@ -1950,3 +1848,5 @@ return NULL; } } + +} //extern "C" Index: capi/geos_c.h.in =================================================================== --- capi/geos_c.h.in (revision 1879) +++ capi/geos_c.h.in (working copy) @@ -65,10 +65,14 @@ ***********************************************************************/ typedef void (*GEOSMessageHandler)(const char *fmt, ...); + +#ifndef GEOSGeom typedef struct GEOSGeom_t *GEOSGeom; typedef struct GEOSCoordSeq_t *GEOSCoordSeq; +#endif -/* Supported geometry types */ +/* Supported geometry types - may be defined when included by geos_c.cpp*/ +#ifndef GEOSGeomTypes enum GEOSGeomTypes { GEOS_POINT, GEOS_LINESTRING, @@ -79,6 +83,7 @@ GEOS_MULTIPOLYGON, GEOS_GEOMETRYCOLLECTION }; +#endif /* Byte oders exposed via the c api */ enum GEOSByteOrders { @@ -303,14 +308,14 @@ extern void GEOS_DLL GEOSSetSRID(GEOSGeom g, int SRID); /* Return -1 on exception */ -extern unsigned int GEOS_DLL GEOSGetNumGeometries(const GEOSGeom g1); +extern int GEOS_DLL GEOSGetNumGeometries(const GEOSGeom g1); /* * Return NULL on exception, Geometry must be a Collection. * Returned object is a pointer to internal storage: * it must NOT be destroyed directly. */ -extern const GEOSGeom GEOS_DLL GEOSGetGeometryN(const GEOSGeom g, unsigned int n); +extern const GEOSGeom GEOS_DLL GEOSGetGeometryN(const GEOSGeom g, int n); /* Return -1 on exception */ extern int GEOS_DLL GEOSNormalize(GEOSGeom g1); @@ -323,7 +328,7 @@ * Returned object is a pointer to internal storage: * it must NOT be destroyed directly. */ -extern const GEOSGeom GEOS_DLL GEOSGetInteriorRingN(const GEOSGeom g, unsigned int n); +extern const GEOSGeom GEOS_DLL GEOSGetInteriorRingN(const GEOSGeom g, int n); /* * Return NULL on exception, Geometry must be a Polygon. @@ -344,7 +349,7 @@ /* * Return 0 on exception (or empty geometry) */ -extern unsigned int GEOS_DLL GEOSGeom_getDimensions(const GEOSGeom g); +extern int GEOS_DLL GEOSGeom_getDimensions(const GEOSGeom g); /************************************************************************ *
signature.asc
Description: OpenPGP digital signature
_______________________________________________ geos-devel mailing list geos-devel@geos.refractions.net http://geos.refractions.net/mailman/listinfo/geos-devel