GEOS: geos_c.h Source File

- Main Page
- Namespaces
- Classes
- Files
- Related Pages

# geos_c.h

    00001 /************************************************************************
    00002  *
    00003  * $Id: geos_c.h.in,v 1.11.2.3 2006/03/27 09:05:19 strk Exp $
    00004  *
    00005  * C-Wrapper for GEOS library
    00006  *
    00007  * Copyright (C) 2005 Refractions Research Inc.
    00008  *
    00009  * This is free software; you can redistribute and/or modify it under
    00010  * the terms of the GNU Lesser General Public Licence as published
    00011  * by the Free Software Foundation.
    00012  * See the COPYING file for more information.
    00013  *
    00014  * Author: Sandro Santilli <strk@refractions.net>
    00015  *
    00016  ***********************************************************************
    00017  *
    00018  * GENERAL NOTES:
    00019  *
    00020  *      - Remember to call initGEOS() before any use of this library's
    00021  *        functions, and call finishGEOS() when done.
    00022  *
    00023  *      - Currently you have to explicitly GEOSGeom_destroy() all
    00024  *        GEOSGeom objects to avoid memory leaks, and to free()
    00025  *        all returned char * (unless const). This might change
    00026  *        before first release to ensure greater API stability.
    00027  *
    00028  ***********************************************************************/
    00029
    00030 #ifdef __cplusplus
    00031 extern "C" {
    00032 #endif
    00033
    00034 /************************************************************************
    00035  *
    00036  * Version
    00037  *
    00038  ***********************************************************************/
    00039
    00040 #define GEOS_VERSION_MAJOR 2
    00041 #define GEOS_VERSION_MINOR 2
    00042 #define GEOS_VERSION_PATCH 3
    00043 #define GEOS_FIRST_INTERFACE GEOS_VERSION_MAJOR
    00044 #define GEOS_LAST_INTERFACE (GEOS_VERSION_MAJOR+GEOS_VERSION_MINOR)
    00045 #define GEOS_VERSION "2.2.3"
    00046 #define GEOS_JTS_PORT "1.4.1"
    00047
    00048 #define GEOS_CAPI_VERSION_MAJOR 1
    00049 #define GEOS_CAPI_VERSION_MINOR 1
    00050 #define GEOS_CAPI_VERSION_PATCH 1
    00051 #define GEOS_CAPI_FIRST_INTERFACE GEOS_CAPI_VERSION_MAJOR
    00052 #define GEOS_CAPI_LAST_INTERFACE (GEOS_CAPI_VERSION_MAJOR+GEOS_CAPI_VERSION_MINOR)
    00053 #define GEOS_CAPI_VERSION "2.2.3-CAPI-1.1.1"
    00054
    00055
    00056 /************************************************************************
    00057  *
    00058  * (Abstract) type definitions
    00059  *
    00060  ***********************************************************************/
    00061
    00062 typedef void (*GEOSMessageHandler)(const char *fmt, ...);
    00063 typedef struct GEOSGeom_t *GEOSGeom;
    00064 typedef struct GEOSCoordSeq_t *GEOSCoordSeq;
    00065
    00066 /* Supported geometry types */
    00067 enum GEOSGeomTypeId {
    00068         GEOS_POINT,
    00069         GEOS_LINESTRING,
    00070         GEOS_LINEARRING,
    00071         GEOS_POLYGON,
    00072         GEOS_MULTIPOINT,
    00073         GEOS_MULTILINESTRING,
    00074         GEOS_MULTIPOLYGON,
    00075         GEOS_GEOMETRYCOLLECTION
    00076 };
    00077
    00078
    00079 /************************************************************************
    00080  *
    00081  * Initialization, cleanup, version
    00082  *
    00083  ***********************************************************************/
    00084
    00085 #if defined(_MSC_VER)
    00086 #  define GEOS_DLL     __declspec(dllexport)
    00087 #else
    00088 #  define GEOS_DLL
    00089 #endif
    00090
    00091 extern void GEOS_DLL initGEOS(GEOSMessageHandler notice_function,
    00092         GEOSMessageHandler error_function);
    00093 extern void GEOS_DLL finishGEOS(void);
    00094 extern const char GEOS_DLL *GEOSversion();
    00095
    00096
    00097 /************************************************************************
    00098  *
    00099  * Geometry Input and Output functions, return NULL on exception.
    00100  *
    00101  ***********************************************************************/
    00102
    00103 extern GEOSGeom GEOS_DLL GEOSGeomFromWKT(const char *wkt);
    00104 extern char GEOS_DLL *GEOSGeomToWKT(const GEOSGeom g);
    00105
    00106 /*
    00107  * Specify whether output WKB should be 2d or 3d.
    00108  * Return previously set number of dimensions.
    00109  */
    00110 extern int GEOS_DLL GEOS_setWKBOutputDims(int newDims);
    00111
    00112 extern GEOSGeom GEOS_DLL GEOSGeomFromWKB_buf(const unsigned char *wkb, size_t size);
    00113 extern unsigned char GEOS_DLL *GEOSGeomToWKB_buf(const GEOSGeom g, size_t *size);
    00114
    00115 /************************************************************************
    00116  *
    00117  * Coordinate Sequence functions
    00118  *
    00119  ***********************************************************************/
    00120
    00121 /*
    00122  * Create a Coordinate sequence with ``size'' coordinates
    00123  * of ``dims'' dimensions.
    00124  * Return NULL on exception.
    00125  */
    00126 extern GEOSCoordSeq GEOS_DLL GEOSCoordSeq_create(unsigned int size, unsigned int dims);
    00127
    00128 /*
    00129  * Clone a Coordinate Sequence.
    00130  * Return NULL on exception.
    00131  */
    00132 extern GEOSCoordSeq GEOS_DLL GEOSCoordSeq_clone(GEOSCoordSeq s);
    00133
    00134 /*
    00135  * Destroy a Coordinate Sequence.
    00136  */
    00137 extern void GEOS_DLL GEOSCoordSeq_destroy(GEOSCoordSeq s);
    00138
    00139 /*
    00140  * Set ordinate values in a Coordinate Sequence.
    00141  * Return 0 on exception.
    00142  */
    00143 extern int GEOS_DLL GEOSCoordSeq_setX(GEOSCoordSeq s,
    00144         unsigned int idx, double val);
    00145 extern int GEOS_DLL GEOSCoordSeq_setY(GEOSCoordSeq s,
    00146         unsigned int idx, double val);
    00147 extern int GEOS_DLL GEOSCoordSeq_setZ(GEOSCoordSeq s,
    00148         unsigned int idx, double val);
    00149 extern int GEOS_DLL GEOSCoordSeq_setOrdinate(GEOSCoordSeq s,
    00150         unsigned int idx, unsigned int dim, double val);
    00151
    00152 /*
    00153  * Get ordinate values from a Coordinate Sequence.
    00154  * Return 0 on exception.
    00155  */
    00156 extern int GEOS_DLL GEOSCoordSeq_getX(const GEOSCoordSeq s,
    00157         unsigned int idx, double *val);
    00158 extern int GEOS_DLL GEOSCoordSeq_getY(const GEOSCoordSeq s,
    00159         unsigned int idx, double *val);
    00160 extern int GEOS_DLL GEOSCoordSeq_getZ(const GEOSCoordSeq s,
    00161         unsigned int idx, double *val);
    00162 extern int GEOS_DLL GEOSCoordSeq_getOrdinate(const GEOSCoordSeq s,
    00163         unsigned int idx, unsigned int dim, double *val);
    00164
    00165 /*
    00166  * Get size and dimensions info from a Coordinate Sequence.
    00167  * Return 0 on exception.
    00168  */
    00169 extern int GEOS_DLL GEOSCoordSeq_getSize(const GEOSCoordSeq s,
    00170         unsigned int *size);
    00171 extern int GEOS_DLL GEOSCoordSeq_getDimensions(const GEOSCoordSeq s,
    00172         unsigned int *dims);
    00173
    00174
    00175 /************************************************************************
    00176  *
    00177  * Geometry Constructors.
    00178  * GEOSCoordSeq arguments will become ownership of the returned object.
    00179  * All functions return NULL on exception.
    00180  *
    00181  ***********************************************************************/
    00182
    00183 extern GEOSGeom GEOS_DLL GEOSGeom_createPoint(GEOSCoordSeq s);
    00184 extern GEOSGeom GEOS_DLL GEOSGeom_createLinearRing(GEOSCoordSeq s);
    00185 extern GEOSGeom GEOS_DLL GEOSGeom_createLineString(GEOSCoordSeq s);
    00186
    00187 /*
    00188  * Second argument is an array of GEOSGeom objects.
    00189  * The caller remains owner of the array, but pointed-to
    00190  * objects become ownership of the returned GEOSGeom.
    00191  */
    00192 extern GEOSGeom GEOS_DLL GEOSGeom_createPolygon(GEOSGeom shell,
    00193         GEOSGeom *holes, unsigned int nholes);
    00194 extern GEOSGeom GEOS_DLL GEOSGeom_createCollection(int type,
    00195         GEOSGeom *geoms, unsigned int ngeoms);
    00196
    00197 extern GEOSGeom GEOS_DLL GEOSGeom_clone(const GEOSGeom g);
    00198
    00199 /************************************************************************
    00200  *
    00201  * Memory management
    00202  *
    00203  ***********************************************************************/
    00204
    00205 extern void GEOS_DLL GEOSGeom_destroy(GEOSGeom g);
    00206
    00207
    00208 /************************************************************************
    00209  *
    00210  * Topology operations - return NULL on exception.
    00211  *
    00212  ***********************************************************************/
    00213
    00214 extern GEOSGeom GEOS_DLL GEOSEnvelope(const GEOSGeom g1);
    00215 extern GEOSGeom GEOS_DLL GEOSIntersection(const GEOSGeom g1, const GEOSGeom g2);
    00216 extern GEOSGeom GEOS_DLL GEOSBuffer(const GEOSGeom g1,
    00217         double width, int quadsegs);
    00218 extern GEOSGeom GEOS_DLL GEOSConvexHull(const GEOSGeom g1);
    00219 extern GEOSGeom GEOS_DLL GEOSDifference(const GEOSGeom g1, const GEOSGeom g2);
    00220 extern GEOSGeom GEOS_DLL GEOSSymDifference(const GEOSGeom g1,
    00221         const GEOSGeom g2);
    00222 extern GEOSGeom GEOS_DLL GEOSBoundary(const GEOSGeom g1);
    00223 extern GEOSGeom GEOS_DLL GEOSUnion(const GEOSGeom g1, const GEOSGeom g2);
    00224 extern GEOSGeom GEOS_DLL GEOSPointOnSurface(const GEOSGeom g1);
    00225 extern GEOSGeom GEOS_DLL GEOSGetCentroid(const GEOSGeom g);
    00226 extern char GEOS_DLL *GEOSRelate(const GEOSGeom g1, const GEOSGeom g2);
    00227 extern GEOSGeom GEOS_DLL GEOSPolygonize(const GEOSGeom geoms[],
    00228         unsigned int ngeoms);
    00229 extern GEOSGeom GEOS_DLL GEOSLineMerge(const GEOSGeom g);
    00230
    00231 /************************************************************************
    00232  *
    00233  *  Binary predicates - return 2 on exception, 1 on true, 0 on false
    00234  *
    00235  ***********************************************************************/
    00236
    00237 extern char GEOS_DLL GEOSRelatePattern(const GEOSGeom g1, const GEOSGeom g2,
    00238         const char *pat);
    00239 extern char GEOS_DLL GEOSDisjoint(const GEOSGeom g1, const GEOSGeom g2);
    00240 extern char GEOS_DLL GEOSTouches(const GEOSGeom g1, const GEOSGeom g2);
    00241 extern char GEOS_DLL GEOSIntersects(const GEOSGeom g1, const GEOSGeom g2);
    00242 extern char GEOS_DLL GEOSCrosses(const GEOSGeom g1, const GEOSGeom g2);
    00243 extern char GEOS_DLL GEOSWithin(const GEOSGeom g1, const GEOSGeom g2);
    00244 extern char GEOS_DLL GEOSContains(const GEOSGeom g1, const GEOSGeom g2);
    00245 extern char GEOS_DLL GEOSOverlaps(const GEOSGeom g1, const GEOSGeom g2);
    00246 extern char GEOS_DLL GEOSEquals(const GEOSGeom g1, const GEOSGeom g2);
    00247
    00248
    00249 /************************************************************************
    00250  *
    00251  *  Unary predicate - return 2 on exception, 1 on true, 0 on false
    00252  *
    00253  ***********************************************************************/
    00254
    00255 extern char GEOS_DLL GEOSisEmpty(const GEOSGeom g1);
    00256 extern char GEOS_DLL GEOSisValid(const GEOSGeom g1);
    00257 extern char GEOS_DLL GEOSisSimple(const GEOSGeom g1);
    00258 extern char GEOS_DLL GEOSisRing(const GEOSGeom g1);
    00259 extern char GEOS_DLL GEOSHasZ(const GEOSGeom g1);
    00260
    00261
    00262 /************************************************************************
    00263  *
    00264  *  Geometry info
    00265  *
    00266  ***********************************************************************/
    00267
    00268 /* Return NULL on exception. Return must be freed by caller. */
    00269 extern char GEOS_DLL *GEOSGeomType(const GEOSGeom g1);
    00270
    00271 /* Return -1 on exception */
    00272 extern int GEOS_DLL GEOSGeomTypeId(const GEOSGeom g1);
    00273
    00274 /* Return 0 on exception */
    00275 extern int GEOS_DLL GEOSGetSRID(const GEOSGeom g1);
    00276
    00277 extern void GEOS_DLL GEOSSetSRID(GEOSGeom g, int SRID);
    00278
    00279 /* Return -1 on exception */
    00280 extern int GEOS_DLL GEOSGetNumGeometries(const GEOSGeom g1);
    00281
    00282 /*
    00283  * Return NULL on exception, Geometry must be a Collection.
    00284  * Returned object is a pointer to internal storage:
    00285  * it must NOT be destroyed directly.
    00286  */
    00287 extern const GEOSGeom GEOS_DLL GEOSGetGeometryN(const GEOSGeom g, int n);
    00288
    00289 /* Return -1 on exception */
    00290 extern int GEOS_DLL GEOSGetNumInteriorRings(const GEOSGeom g1);
    00291
    00292 /*
    00293  * Return NULL on exception, Geometry must be a Polygon.
    00294  * Returned object is a pointer to internal storage:
    00295  * it must NOT be destroyed directly.
    00296  */
    00297 extern const GEOSGeom GEOS_DLL GEOSGetInteriorRingN(const GEOSGeom g, int n);
    00298
    00299 /*
    00300  * Return NULL on exception, Geometry must be a Polygon.
    00301  * Returned object is a pointer to internal storage:
    00302  * it must NOT be destroyed directly.
    00303  */
    00304 extern const GEOSGeom GEOS_DLL GEOSGetExteriorRing(const GEOSGeom g);
    00305
    00306 /* Return -1 on exception */
    00307 extern int GEOS_DLL GEOSGetNumCoordinates(const GEOSGeom g1);
    00308
    00309 /*
    00310  * Return NULL on exception.
    00311  * Geometry must be a LineString, LinearRing or Point.
    00312  */
    00313 extern const GEOSCoordSeq GEOS_DLL GEOSGeom_getCoordSeq(const GEOSGeom g);
    00314
    00315 /*
    00316  * Return 0 on exception (or empty geometry)
    00317  */
    00318 extern int GEOS_DLL GEOSGeom_getDimensions(const GEOSGeom g);
    00319
    00320 /************************************************************************
    00321  *
    00322  *  Misc functions
    00323  *
    00324  ***********************************************************************/
    00325
    00326 /* Return 0 on exception, 1 otherwise */
    00327 extern int GEOS_DLL GEOSArea(const GEOSGeom g1, double *area);
    00328 extern int GEOS_DLL GEOSLength(const GEOSGeom g1, double *length);
    00329 extern int GEOS_DLL GEOSDistance(const GEOSGeom g1, const GEOSGeom g2,
    00330         double *dist);
    00331
    00332 #ifdef __cplusplus
    00333 } // extern "C"
    00334 #endif