Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | Related Pages

geos_c.h

00001 /************************************************************************
00002  *
00003  * $Id: geos_c.h.in,v 1.11.2.1 2005/11/29 17:51:15 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 1
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.1"
00046 #define GEOS_JTS_PORT "1.4.1"
00047 
00048 #define GEOS_CAPI_VERSION_MAJOR 1
00049 #define GEOS_CAPI_VERSION_MINOR 0
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.1-CAPI-1.0.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 GEOSIntersection(const GEOSGeom g1, const GEOSGeom g2);
00215 extern GEOSGeom GEOS_DLL GEOSBuffer(const GEOSGeom g1,
00216         double width, int quadsegs);
00217 extern GEOSGeom GEOS_DLL GEOSConvexHull(const GEOSGeom g1);
00218 extern GEOSGeom GEOS_DLL GEOSDifference(const GEOSGeom g1, const GEOSGeom g2);
00219 extern GEOSGeom GEOS_DLL GEOSSymDifference(const GEOSGeom g1,
00220         const GEOSGeom g2);
00221 extern GEOSGeom GEOS_DLL GEOSBoundary(const GEOSGeom g1);
00222 extern GEOSGeom GEOS_DLL GEOSUnion(const GEOSGeom g1, const GEOSGeom g2);
00223 extern GEOSGeom GEOS_DLL GEOSPointOnSurface(const GEOSGeom g1);
00224 extern GEOSGeom GEOS_DLL GEOSGetCentroid(const GEOSGeom g);
00225 extern char GEOS_DLL *GEOSRelate(const GEOSGeom g1, const GEOSGeom g2);
00226 extern GEOSGeom GEOS_DLL GEOSPolygonize(const GEOSGeom geoms[],
00227         unsigned int ngeoms);
00228 extern GEOSGeom GEOS_DLL GEOSLineMerge(const GEOSGeom g);
00229 
00230 /************************************************************************
00231  *
00232  *  Binary predicates - return 2 on exception, 1 on true, 0 on false
00233  *
00234  ***********************************************************************/
00235 
00236 extern char GEOS_DLL GEOSRelatePattern(const GEOSGeom g1, const GEOSGeom g2,
00237         const char *pat);
00238 extern char GEOS_DLL GEOSDisjoint(const GEOSGeom g1, const GEOSGeom g2);
00239 extern char GEOS_DLL GEOSTouches(const GEOSGeom g1, const GEOSGeom g2);
00240 extern char GEOS_DLL GEOSIntersects(const GEOSGeom g1, const GEOSGeom g2);
00241 extern char GEOS_DLL GEOSCrosses(const GEOSGeom g1, const GEOSGeom g2);
00242 extern char GEOS_DLL GEOSWithin(const GEOSGeom g1, const GEOSGeom g2);
00243 extern char GEOS_DLL GEOSContains(const GEOSGeom g1, const GEOSGeom g2);
00244 extern char GEOS_DLL GEOSOverlaps(const GEOSGeom g1, const GEOSGeom g2);
00245 extern char GEOS_DLL GEOSEquals(const GEOSGeom g1, const GEOSGeom g2);
00246 
00247 
00248 /************************************************************************
00249  *
00250  *  Unary predicate - return 2 on exception, 1 on true, 0 on false
00251  *
00252  ***********************************************************************/
00253 
00254 extern char GEOS_DLL GEOSisEmpty(const GEOSGeom g1);
00255 extern char GEOS_DLL GEOSisValid(const GEOSGeom g1);
00256 extern char GEOS_DLL GEOSisSimple(const GEOSGeom g1);
00257 extern char GEOS_DLL GEOSisRing(const GEOSGeom g1);
00258 extern char GEOS_DLL GEOSHasZ(const GEOSGeom g1);
00259 
00260 
00261 /************************************************************************
00262  *
00263  *  Geometry info
00264  *
00265  ***********************************************************************/
00266 
00267 /* Return -1 on exception */
00268 extern int GEOS_DLL GEOSGeomTypeId(const GEOSGeom g1);
00269 
00270 /* Return 0 on exception */
00271 extern int GEOS_DLL GEOSGetSRID(const GEOSGeom g1);
00272 
00273 extern void GEOS_DLL GEOSSetSRID(GEOSGeom g, int SRID);
00274 
00275 /* Return -1 on exception */
00276 extern int GEOS_DLL GEOSGetNumGeometries(const GEOSGeom g1);
00277 
00278 /*
00279  * Return NULL on exception, Geometry must be a Collection.
00280  * Returned object is a pointer to internal storage:
00281  * it must NOT be destroyed directly.
00282  */
00283 extern const GEOSGeom GEOS_DLL GEOSGetGeometryN(const GEOSGeom g, int n);
00284 
00285 /* Return -1 on exception */
00286 extern int GEOS_DLL GEOSGetNumInteriorRings(const GEOSGeom g1);
00287 
00288 /*
00289  * Return NULL on exception, Geometry must be a Polygon.
00290  * Returned object is a pointer to internal storage:
00291  * it must NOT be destroyed directly.
00292  */
00293 extern const GEOSGeom GEOS_DLL GEOSGetInteriorRingN(const GEOSGeom g, int n);
00294 
00295 /*
00296  * Return NULL on exception, Geometry must be a Polygon.
00297  * Returned object is a pointer to internal storage:
00298  * it must NOT be destroyed directly.
00299  */
00300 extern const GEOSGeom GEOS_DLL GEOSGetExteriorRing(const GEOSGeom g);
00301 
00302 /* Return -1 on exception */
00303 extern int GEOS_DLL GEOSGetNumCoordinates(const GEOSGeom g1);
00304 
00305 /*
00306  * Return NULL on exception.
00307  * Geometry must be a LineString, LinearRing or Point.
00308  */
00309 extern const GEOSCoordSeq GEOS_DLL GEOSGeom_getCoordSeq(const GEOSGeom g);
00310 
00311 /*
00312  * Return 0 on exception (or empty geometry)
00313  */
00314 extern int GEOS_DLL GEOSGeom_getDimensions(const GEOSGeom g);
00315 
00316 /************************************************************************
00317  *
00318  *  Misc functions 
00319  *
00320  ***********************************************************************/
00321 
00322 /* Return 0 on exception, 1 otherwise */
00323 extern int GEOS_DLL GEOSDistance(const GEOSGeom g1, const GEOSGeom g2,
00324         double *dist);
00325 
00326 #ifdef __cplusplus
00327 } // extern "C"
00328 #endif

Generated on Tue Jan 10 01:37:53 2006 for GEOS by  doxygen 1.4.4