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 2556 2009-06-06 22:22:28Z strk $
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 GEOSFree()
00025  *        all returned char * (unless const). 
00026  *
00027  ***********************************************************************/
00028 
00029 #ifndef GEOS_C_H_INCLUDED
00030 #define GEOS_C_H_INCLUDED
00031 
00032 #ifndef __cplusplus
00033 # include <stddef.h> /* for size_t definition */
00034 #else
00035 # include <cstddef>
00036 using std::size_t;
00037 #endif
00038 
00039 #ifdef __cplusplus
00040 extern "C" {
00041 #endif
00042 
00043 /************************************************************************
00044  *
00045  * Version
00046  *
00047  ***********************************************************************/
00048 
00049 /*
00050  *  * Following 'ifdef' hack fixes problem with generating geos_c.h on Windows,
00051  *   * when building with Visual C++ compiler.
00052  *    */
00053 #if defined(_MSC_VER)
00054 #include <geos/version.h>
00055 #define GEOS_CAPI_VERSION_MAJOR 1
00056 #define GEOS_CAPI_VERSION_MINOR 5
00057 #define GEOS_CAPI_VERSION_PATCH 0
00058 #define GEOS_CAPI_VERSION "3.1.0-CAPI-1.5.0"
00059 #else
00060 #ifndef GEOS_VERSION_MAJOR
00061 #define GEOS_VERSION_MAJOR 3
00062 #endif
00063 #ifndef GEOS_VERSION_MINOR
00064 #define GEOS_VERSION_MINOR 1
00065 #endif
00066 #ifndef GEOS_VERSION_PATCH
00067 #define GEOS_VERSION_PATCH 0
00068 #endif
00069 #ifndef GEOS_VERSION
00070 #define GEOS_VERSION "3.1.0"
00071 #endif
00072 #ifndef GEOS_JTS_PORT
00073 #define GEOS_JTS_PORT "1.7.1"
00074 #endif
00075 
00076 #define GEOS_CAPI_VERSION_MAJOR 1
00077 #define GEOS_CAPI_VERSION_MINOR 5
00078 #define GEOS_CAPI_VERSION_PATCH 0
00079 #define GEOS_CAPI_VERSION "3.1.0-CAPI-1.5.0"
00080 #endif
00081 
00082 #define GEOS_CAPI_FIRST_INTERFACE GEOS_CAPI_VERSION_MAJOR 
00083 #define GEOS_CAPI_LAST_INTERFACE (GEOS_CAPI_VERSION_MAJOR+GEOS_CAPI_VERSION_MINOR)
00084 
00085 /************************************************************************
00086  *
00087  * (Abstract) type definitions
00088  *
00089  ************************************************************************/
00090 
00091 typedef void (*GEOSMessageHandler)(const char *fmt, ...);
00092 
00093 /* When we're included by geos_c.cpp, those are #defined to the original
00094  * JTS definitions via preprocessor. We don't touch them to allow the
00095  * compiler to cross-check the declarations. However, for all "normal" 
00096  * C-API users, we need to define them as "opaque" struct pointers, as 
00097  * those clients don't have access to the original C++ headers, by design.
00098  */
00099 #ifndef GEOSGeometry
00100 typedef struct GEOSGeom_t GEOSGeometry;
00101 typedef struct GEOSPrepGeom_t GEOSPreparedGeometry;
00102 typedef struct GEOSCoordSeq_t GEOSCoordSequence;
00103 #endif
00104 
00105 /* Those are compatibility definitions for source compatibility
00106  * with GEOS 2.X clients relying on that type.
00107  */
00108 typedef GEOSGeometry* GEOSGeom;
00109 typedef GEOSCoordSequence* GEOSCoordSeq;
00110 
00111 /* Supported geometry types
00112  * This was renamed from GEOSGeomTypeId in GEOS 2.2.X, which might
00113  * break compatibility, this issue is still under investigation.
00114  */
00115 
00116 enum GEOSGeomTypes {
00117     GEOS_POINT,
00118     GEOS_LINESTRING,
00119     GEOS_LINEARRING,
00120     GEOS_POLYGON,
00121     GEOS_MULTIPOINT,
00122     GEOS_MULTILINESTRING,
00123     GEOS_MULTIPOLYGON,
00124     GEOS_GEOMETRYCOLLECTION
00125 };
00126 
00127 /* Byte oders exposed via the c api */
00128 enum GEOSByteOrders {
00129     GEOS_WKB_XDR = 0, /* Big Endian */
00130     GEOS_WKB_NDR = 1 /* Little Endian */
00131 };
00132 
00133 typedef struct GEOSContextHandle_HS *GEOSContextHandle_t;
00134 
00135 /************************************************************************
00136  *
00137  * Initialization, cleanup, version
00138  *
00139  ***********************************************************************/
00140 
00141 #include <geos/export.h>
00142 
00143 extern void GEOS_DLL initGEOS(GEOSMessageHandler notice_function,
00144         GEOSMessageHandler error_function);
00145 extern void GEOS_DLL finishGEOS(void);
00146 
00147 extern GEOSContextHandle_t GEOS_DLL initGEOS_r(
00148                                     GEOSMessageHandler notice_function,
00149                                     GEOSMessageHandler error_function);
00150 extern void GEOS_DLL finishGEOS_r(GEOSContextHandle_t handle);
00151 
00152 extern const char GEOS_DLL *GEOSversion();
00153 
00154 
00155 /************************************************************************
00156  *
00157  * NOTE - These functions are DEPRECATED.  Please use the new Reader and
00158  * writer APIS!
00159  *
00160  ***********************************************************************/
00161 
00162 extern GEOSGeometry GEOS_DLL *GEOSGeomFromWKT(const char *wkt);
00163 extern char GEOS_DLL *GEOSGeomToWKT(const GEOSGeometry* g);
00164 
00165 extern GEOSGeometry GEOS_DLL *GEOSGeomFromWKT_r(GEOSContextHandle_t handle,
00166                                                 const char *wkt);
00167 extern char GEOS_DLL *GEOSGeomToWKT_r(GEOSContextHandle_t handle,
00168                                       const GEOSGeometry* g);
00169 
00170 /*
00171  * Specify whether output WKB should be 2d or 3d.
00172  * Return previously set number of dimensions.
00173  */
00174 extern int GEOS_DLL GEOS_getWKBOutputDims();
00175 extern int GEOS_DLL GEOS_setWKBOutputDims(int newDims);
00176 
00177 extern int GEOS_DLL GEOS_getWKBOutputDims_r(GEOSContextHandle_t handle);
00178 extern int GEOS_DLL GEOS_setWKBOutputDims_r(GEOSContextHandle_t handle,
00179                                             int newDims);
00180 
00181 /*
00182  * Specify whether the WKB byte order is big or little endian. 
00183  * The return value is the previous byte order.
00184  */
00185 extern int GEOS_DLL GEOS_getWKBByteOrder();
00186 extern int GEOS_DLL GEOS_setWKBByteOrder(int byteOrder);
00187 
00188 extern GEOSGeometry GEOS_DLL *GEOSGeomFromWKB_buf(const unsigned char *wkb, size_t size);
00189 extern unsigned char GEOS_DLL *GEOSGeomToWKB_buf(const GEOSGeometry* g, size_t *size);
00190 
00191 extern GEOSGeometry GEOS_DLL *GEOSGeomFromHEX_buf(const unsigned char *hex, size_t size);
00192 extern unsigned char GEOS_DLL *GEOSGeomToHEX_buf(const GEOSGeometry* g, size_t *size);
00193 
00194 extern int GEOS_DLL GEOS_getWKBByteOrder_r(GEOSContextHandle_t handle);
00195 extern int GEOS_DLL GEOS_setWKBByteOrder_r(GEOSContextHandle_t handle,
00196                                            int byteOrder);
00197 
00198 extern GEOSGeometry GEOS_DLL *GEOSGeomFromWKB_buf_r(GEOSContextHandle_t handle,
00199                                                     const unsigned char *wkb,
00200                                                     size_t size);
00201 extern unsigned char GEOS_DLL *GEOSGeomToWKB_buf_r(GEOSContextHandle_t handle,
00202                                                    const GEOSGeometry* g,
00203                                                    size_t *size);
00204 
00205 extern GEOSGeometry GEOS_DLL *GEOSGeomFromHEX_buf_r(GEOSContextHandle_t handle,
00206                                                     const unsigned char *hex,
00207                                                     size_t size);
00208 extern unsigned char GEOS_DLL *GEOSGeomToHEX_buf_r(GEOSContextHandle_t handle,
00209                                                    const GEOSGeometry* g,
00210                                                    size_t *size);
00211 
00212 /************************************************************************
00213  *
00214  * Coordinate Sequence functions
00215  *
00216  ***********************************************************************/
00217 
00218 /*
00219  * Create a Coordinate sequence with ``size'' coordinates
00220  * of ``dims'' dimensions.
00221  * Return NULL on exception.
00222  */
00223 extern GEOSCoordSequence GEOS_DLL *GEOSCoordSeq_create(unsigned int size, unsigned int dims);
00224 
00225 extern GEOSCoordSequence GEOS_DLL *GEOSCoordSeq_create_r(
00226                                                 GEOSContextHandle_t handle,
00227                                                 unsigned int size,
00228                                                 unsigned int dims);
00229 
00230 /*
00231  * Clone a Coordinate Sequence.
00232  * Return NULL on exception.
00233  */
00234 extern GEOSCoordSequence GEOS_DLL *GEOSCoordSeq_clone(const GEOSCoordSequence* s);
00235 
00236 extern GEOSCoordSequence GEOS_DLL *GEOSCoordSeq_clone_r(
00237                                                 GEOSContextHandle_t handle,
00238                                                 const GEOSCoordSequence* s);
00239 
00240 /*
00241  * Destroy a Coordinate Sequence.
00242  */
00243 extern void GEOS_DLL GEOSCoordSeq_destroy(GEOSCoordSequence* s);
00244 
00245 extern void GEOS_DLL GEOSCoordSeq_destroy_r(GEOSContextHandle_t handle,
00246                                             GEOSCoordSequence* s);
00247 
00248 /*
00249  * Set ordinate values in a Coordinate Sequence.
00250  * Return 0 on exception.
00251  */
00252 extern int GEOS_DLL GEOSCoordSeq_setX(GEOSCoordSequence* s,
00253         unsigned int idx, double val);
00254 extern int GEOS_DLL GEOSCoordSeq_setY(GEOSCoordSequence* s,
00255         unsigned int idx, double val);
00256 extern int GEOS_DLL GEOSCoordSeq_setZ(GEOSCoordSequence* s,
00257         unsigned int idx, double val);
00258 extern int GEOS_DLL GEOSCoordSeq_setOrdinate(GEOSCoordSequence* s,
00259         unsigned int idx, unsigned int dim, double val);
00260 
00261 extern int GEOS_DLL GEOSCoordSeq_setX_r(GEOSContextHandle_t handle,
00262                                         GEOSCoordSequence* s, unsigned int idx,
00263                                         double val);
00264 extern int GEOS_DLL GEOSCoordSeq_setY_r(GEOSContextHandle_t handle,
00265                                         GEOSCoordSequence* s, unsigned int idx,
00266                                         double val);
00267 extern int GEOS_DLL GEOSCoordSeq_setZ_r(GEOSContextHandle_t handle,
00268                                         GEOSCoordSequence* s, unsigned int idx,
00269                                         double val);
00270 extern int GEOS_DLL GEOSCoordSeq_setOrdinate_r(GEOSContextHandle_t handle,
00271                                                GEOSCoordSequence* s,
00272                                                unsigned int idx,
00273                                                unsigned int dim, double val);
00274 
00275 /*
00276  * Get ordinate values from a Coordinate Sequence.
00277  * Return 0 on exception.
00278  */
00279 extern int GEOS_DLL GEOSCoordSeq_getX(const GEOSCoordSequence* s,
00280         unsigned int idx, double *val);
00281 extern int GEOS_DLL GEOSCoordSeq_getY(const GEOSCoordSequence* s,
00282         unsigned int idx, double *val);
00283 extern int GEOS_DLL GEOSCoordSeq_getZ(const GEOSCoordSequence* s,
00284         unsigned int idx, double *val);
00285 extern int GEOS_DLL GEOSCoordSeq_getOrdinate(const GEOSCoordSequence* s,
00286         unsigned int idx, unsigned int dim, double *val);
00287 
00288 extern int GEOS_DLL GEOSCoordSeq_getX_r(GEOSContextHandle_t handle,
00289                                         const GEOSCoordSequence* s,
00290                                         unsigned int idx, double *val);
00291 extern int GEOS_DLL GEOSCoordSeq_getY_r(GEOSContextHandle_t handle,
00292                                         const GEOSCoordSequence* s,
00293                                         unsigned int idx, double *val);
00294 extern int GEOS_DLL GEOSCoordSeq_getZ_r(GEOSContextHandle_t handle,
00295                                         const GEOSCoordSequence* s,
00296                                         unsigned int idx, double *val);
00297 extern int GEOS_DLL GEOSCoordSeq_getOrdinate_r(GEOSContextHandle_t handle,
00298                                                const GEOSCoordSequence* s,
00299                                                unsigned int idx,
00300                                                unsigned int dim, double *val);
00301 /*
00302  * Get size and dimensions info from a Coordinate Sequence.
00303  * Return 0 on exception.
00304  */
00305 extern int GEOS_DLL GEOSCoordSeq_getSize(const GEOSCoordSequence* s,
00306         unsigned int *size);
00307 extern int GEOS_DLL GEOSCoordSeq_getDimensions(const GEOSCoordSequence* s,
00308         unsigned int *dims);
00309 
00310 extern int GEOS_DLL GEOSCoordSeq_getSize_r(GEOSContextHandle_t handle,
00311                                            const GEOSCoordSequence* s,
00312                                            unsigned int *size);
00313 extern int GEOS_DLL GEOSCoordSeq_getDimensions_r(GEOSContextHandle_t handle,
00314                                                  const GEOSCoordSequence* s,
00315                                                  unsigned int *dims);
00316 
00317 /************************************************************************
00318  *
00319  * Geometry Constructors.
00320  * GEOSCoordSequence* arguments will become ownership of the returned object.
00321  * All functions return NULL on exception.
00322  *
00323  ***********************************************************************/
00324 
00325 extern GEOSGeometry GEOS_DLL *GEOSGeom_createPoint(GEOSCoordSequence* s);
00326 extern GEOSGeometry GEOS_DLL *GEOSGeom_createLinearRing(GEOSCoordSequence* s);
00327 extern GEOSGeometry GEOS_DLL *GEOSGeom_createLineString(GEOSCoordSequence* s);
00328 
00329 extern GEOSGeometry GEOS_DLL *GEOSGeom_createPoint_r(
00330                                        GEOSContextHandle_t handle,
00331                                        GEOSCoordSequence* s);
00332 extern GEOSGeometry GEOS_DLL *GEOSGeom_createLinearRing_r(
00333                                        GEOSContextHandle_t handle,
00334                                        GEOSCoordSequence* s);
00335 extern GEOSGeometry GEOS_DLL *GEOSGeom_createLineString_r(
00336                                        GEOSContextHandle_t handle,
00337                                        GEOSCoordSequence* s);
00338 
00339 /*
00340  * Second argument is an array of GEOSGeometry* objects.
00341  * The caller remains owner of the array, but pointed-to
00342  * objects become ownership of the returned GEOSGeometry.
00343  */
00344 extern GEOSGeometry GEOS_DLL *GEOSGeom_createPolygon(GEOSGeometry* shell,
00345         GEOSGeometry** holes, unsigned int nholes);
00346 extern GEOSGeometry GEOS_DLL *GEOSGeom_createCollection(int type,
00347         GEOSGeometry* *geoms, unsigned int ngeoms);
00348 
00349 extern GEOSGeometry GEOS_DLL *GEOSGeom_createPolygon_r(
00350                                        GEOSContextHandle_t handle,
00351                                        GEOSGeometry* shell,
00352                                        GEOSGeometry** holes,
00353                                        unsigned int nholes);
00354 extern GEOSGeometry GEOS_DLL *GEOSGeom_createCollection_r(
00355                                        GEOSContextHandle_t handle, int type,
00356                                        GEOSGeometry* *geoms,
00357                                        unsigned int ngeoms);
00358 
00359 extern GEOSGeometry GEOS_DLL *GEOSGeom_clone(const GEOSGeometry* g);
00360 
00361 extern GEOSGeometry GEOS_DLL *GEOSGeom_clone_r(GEOSContextHandle_t handle,
00362                                                const GEOSGeometry* g);
00363 
00364 /************************************************************************
00365  *
00366  * Memory management
00367  *
00368  ***********************************************************************/
00369 
00370 extern void GEOS_DLL GEOSGeom_destroy(GEOSGeometry* g);
00371 
00372 extern void GEOS_DLL GEOSGeom_destroy_r(GEOSContextHandle_t handle,
00373                                         GEOSGeometry* g);
00374 
00375 /************************************************************************
00376  *
00377  * Topology operations - return NULL on exception.
00378  *
00379  ***********************************************************************/
00380 
00381 extern GEOSGeometry GEOS_DLL *GEOSEnvelope(const GEOSGeometry* g1);
00382 extern GEOSGeometry GEOS_DLL *GEOSIntersection(const GEOSGeometry* g1, const GEOSGeometry* g2);
00383 extern GEOSGeometry GEOS_DLL *GEOSBuffer(const GEOSGeometry* g1,
00384         double width, int quadsegs);
00385 extern GEOSGeometry GEOS_DLL *GEOSConvexHull(const GEOSGeometry* g1);
00386 extern GEOSGeometry GEOS_DLL *GEOSDifference(const GEOSGeometry* g1, const GEOSGeometry* g2);
00387 extern GEOSGeometry GEOS_DLL *GEOSSymDifference(const GEOSGeometry* g1,
00388         const GEOSGeometry* g2);
00389 extern GEOSGeometry GEOS_DLL *GEOSBoundary(const GEOSGeometry* g1);
00390 extern GEOSGeometry GEOS_DLL *GEOSUnion(const GEOSGeometry* g1, const GEOSGeometry* g2);
00391 extern GEOSGeometry GEOS_DLL *GEOSUnionCascaded(const GEOSGeometry* g1);
00392 
00393 extern GEOSGeometry GEOS_DLL *GEOSPointOnSurface(const GEOSGeometry* g1);
00394 extern GEOSGeometry GEOS_DLL *GEOSGetCentroid(const GEOSGeometry* g);
00395 extern char GEOS_DLL *GEOSRelate(const GEOSGeometry* g1, const GEOSGeometry* g2);
00396 
00397 extern GEOSGeometry GEOS_DLL *GEOSEnvelope_r(GEOSContextHandle_t handle,
00398                                              const GEOSGeometry* g1);
00399 extern GEOSGeometry GEOS_DLL *GEOSIntersection_r(GEOSContextHandle_t handle,
00400                                                  const GEOSGeometry* g1,
00401                                                  const GEOSGeometry* g2);
00402 extern GEOSGeometry GEOS_DLL *GEOSBuffer_r(GEOSContextHandle_t handle,
00403                                            const GEOSGeometry* g1,
00404                                            double width, int quadsegs);
00405 extern GEOSGeometry GEOS_DLL *GEOSConvexHull_r(GEOSContextHandle_t handle,
00406                                                const GEOSGeometry* g1);
00407 extern GEOSGeometry GEOS_DLL *GEOSDifference_r(GEOSContextHandle_t handle,
00408                                                const GEOSGeometry* g1,
00409                                                const GEOSGeometry* g2);
00410 extern GEOSGeometry GEOS_DLL *GEOSSymDifference_r(GEOSContextHandle_t handle,
00411                                                   const GEOSGeometry* g1,
00412                                                   const GEOSGeometry* g2);
00413 extern GEOSGeometry GEOS_DLL *GEOSBoundary_r(GEOSContextHandle_t handle,
00414                                              const GEOSGeometry* g1);
00415 extern GEOSGeometry GEOS_DLL *GEOSUnion_r(GEOSContextHandle_t handle,
00416                                           const GEOSGeometry* g1,
00417                                           const GEOSGeometry* g2);
00418 extern GEOSGeometry GEOS_DLL *GEOSUnionCascaded_r(GEOSContextHandle_t handle, const GEOSGeometry* g1);
00419 extern GEOSGeometry GEOS_DLL *GEOSPointOnSurface_r(GEOSContextHandle_t handle,
00420                                                    const GEOSGeometry* g1);
00421 extern GEOSGeometry GEOS_DLL *GEOSGetCentroid_r(GEOSContextHandle_t handle,
00422                                                 const GEOSGeometry* g);
00423 extern char GEOS_DLL *GEOSRelate_r(GEOSContextHandle_t handle,
00424                                    const GEOSGeometry* g1,
00425                                    const GEOSGeometry* g2);
00426 
00427 /*
00428  * all arguments remain ownership of the caller
00429  * (both Geometries and pointers)
00430  */
00431 extern GEOSGeometry GEOS_DLL *GEOSPolygonize(const GEOSGeometry * const geoms[], unsigned int ngeoms);
00432 extern GEOSGeometry GEOS_DLL *GEOSPolygonizer_getCutEdges(const GEOSGeometry * const geoms[], unsigned int ngeoms);
00433 
00434 extern GEOSGeometry GEOS_DLL *GEOSLineMerge(const GEOSGeometry* g);
00435 extern GEOSGeometry GEOS_DLL *GEOSSimplify(const GEOSGeometry* g1, double tolerance);
00436 extern GEOSGeometry GEOS_DLL *GEOSTopologyPreserveSimplify(const GEOSGeometry* g1,
00437         double tolerance);
00438 
00439 extern GEOSGeometry GEOS_DLL *GEOSPolygonize_r(GEOSContextHandle_t handle,
00440                               const GEOSGeometry *const geoms[],
00441                               unsigned int ngeoms);
00442 extern GEOSGeometry GEOS_DLL *GEOSPolygonizer_getCutEdges_r(
00443                               GEOSContextHandle_t handle,
00444                               const GEOSGeometry * const geoms[],
00445                               unsigned int ngeoms);
00446 
00447 extern GEOSGeometry GEOS_DLL *GEOSLineMerge_r(GEOSContextHandle_t handle,
00448                                               const GEOSGeometry* g);
00449 extern GEOSGeometry GEOS_DLL *GEOSSimplify_r(GEOSContextHandle_t handle,
00450                                              const GEOSGeometry* g1,
00451                                              double tolerance);
00452 extern GEOSGeometry GEOS_DLL *GEOSTopologyPreserveSimplify_r(
00453                               GEOSContextHandle_t handle,
00454                               const GEOSGeometry* g1, double tolerance);
00455 
00456 /************************************************************************
00457  *
00458  *  Binary predicates - return 2 on exception, 1 on true, 0 on false
00459  *
00460  ***********************************************************************/
00461 
00462 extern char GEOS_DLL GEOSRelatePattern(const GEOSGeometry* g1, const GEOSGeometry* g2,
00463         const char *pat);
00464 extern char GEOS_DLL GEOSDisjoint(const GEOSGeometry* g1, const GEOSGeometry* g2);
00465 extern char GEOS_DLL GEOSTouches(const GEOSGeometry* g1, const GEOSGeometry* g2);
00466 extern char GEOS_DLL GEOSIntersects(const GEOSGeometry* g1, const GEOSGeometry* g2);
00467 extern char GEOS_DLL GEOSCrosses(const GEOSGeometry* g1, const GEOSGeometry* g2);
00468 extern char GEOS_DLL GEOSWithin(const GEOSGeometry* g1, const GEOSGeometry* g2);
00469 extern char GEOS_DLL GEOSContains(const GEOSGeometry* g1, const GEOSGeometry* g2);
00470 extern char GEOS_DLL GEOSOverlaps(const GEOSGeometry* g1, const GEOSGeometry* g2);
00471 extern char GEOS_DLL GEOSEquals(const GEOSGeometry* g1, const GEOSGeometry* g2);
00472 extern char GEOS_DLL GEOSEqualsExact(const GEOSGeometry* g1, const GEOSGeometry* g2, double tolerance);
00473 
00474 extern char GEOS_DLL GEOSRelatePattern_r(GEOSContextHandle_t handle,
00475                                          const GEOSGeometry* g1,
00476                                          const GEOSGeometry* g2,
00477                                          const char *pat);
00478 extern char GEOS_DLL GEOSDisjoint_r(GEOSContextHandle_t handle,
00479                                     const GEOSGeometry* g1,
00480                                     const GEOSGeometry* g2);
00481 extern char GEOS_DLL GEOSTouches_r(GEOSContextHandle_t handle,
00482                                    const GEOSGeometry* g1,
00483                                    const GEOSGeometry* g2);
00484 extern char GEOS_DLL GEOSIntersects_r(GEOSContextHandle_t handle,
00485                                       const GEOSGeometry* g1,
00486                                       const GEOSGeometry* g2);
00487 extern char GEOS_DLL GEOSCrosses_r(GEOSContextHandle_t handle,
00488                                    const GEOSGeometry* g1,
00489                                    const GEOSGeometry* g2);
00490 extern char GEOS_DLL GEOSWithin_r(GEOSContextHandle_t handle,
00491                                   const GEOSGeometry* g1,
00492                                   const GEOSGeometry* g2);
00493 extern char GEOS_DLL GEOSContains_r(GEOSContextHandle_t handle,
00494                                     const GEOSGeometry* g1,
00495                                     const GEOSGeometry* g2);
00496 extern char GEOS_DLL GEOSOverlaps_r(GEOSContextHandle_t handle,
00497                                     const GEOSGeometry* g1,
00498                                     const GEOSGeometry* g2);
00499 extern char GEOS_DLL GEOSEquals_r(GEOSContextHandle_t handle,
00500                                   const GEOSGeometry* g1,
00501                                   const GEOSGeometry* g2);
00502 extern char GEOS_DLL GEOSEqualsExact_r(GEOSContextHandle_t handle,
00503                                        const GEOSGeometry* g1,
00504                                        const GEOSGeometry* g2,
00505                                        double tolerance);
00506 
00507 /************************************************************************
00508  *
00509  *  Prepared Geometry Binary predicates - return 2 on exception, 1 on true, 0 on false
00510  *
00511  ***********************************************************************/
00512 
00513 /* 
00514  * GEOSGeometry ownership is retained by caller
00515  */
00516 extern const GEOSPreparedGeometry GEOS_DLL *GEOSPrepare(const GEOSGeometry* g);
00517 
00518 extern void GEOS_DLL GEOSPreparedGeom_destroy(const GEOSPreparedGeometry* g);
00519 
00520 extern char GEOS_DLL GEOSPreparedContains(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
00521 extern char GEOS_DLL GEOSPreparedContainsProperly(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
00522 extern char GEOS_DLL GEOSPreparedCovers(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
00523 extern char GEOS_DLL GEOSPreparedIntersects(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
00524 
00525 /* 
00526  * GEOSGeometry ownership is retained by caller
00527  */
00528 extern const GEOSPreparedGeometry GEOS_DLL *GEOSPrepare_r(
00529                                             GEOSContextHandle_t handle,
00530                                             const GEOSGeometry* g);
00531 
00532 extern void GEOS_DLL GEOSPreparedGeom_destroy_r(GEOSContextHandle_t handle,
00533                                                 const GEOSPreparedGeometry* g);
00534 
00535 extern char GEOS_DLL GEOSPreparedContains_r(GEOSContextHandle_t handle,
00536                                             const GEOSPreparedGeometry* pg1,
00537                                             const GEOSGeometry* g2);
00538 extern char GEOS_DLL GEOSPreparedContainsProperly_r(GEOSContextHandle_t handle,
00539                                          const GEOSPreparedGeometry* pg1,
00540                                          const GEOSGeometry* g2);
00541 extern char GEOS_DLL GEOSPreparedCovers_r(GEOSContextHandle_t handle,
00542                                           const GEOSPreparedGeometry* pg1,
00543                                           const GEOSGeometry* g2);
00544 extern char GEOS_DLL GEOSPreparedIntersects_r(GEOSContextHandle_t handle,
00545                                               const GEOSPreparedGeometry* pg1,
00546                                               const GEOSGeometry* g2);
00547 
00548 /************************************************************************
00549  *
00550  *  Unary predicate - return 2 on exception, 1 on true, 0 on false
00551  *
00552  ***********************************************************************/
00553 
00554 extern char GEOS_DLL GEOSisEmpty(const GEOSGeometry* g1);
00555 extern char GEOS_DLL GEOSisValid(const GEOSGeometry* g1);
00556 extern char GEOS_DLL *GEOSisValidReason(const GEOSGeometry *g1);
00557 extern char GEOS_DLL GEOSisSimple(const GEOSGeometry* g1);
00558 extern char GEOS_DLL GEOSisRing(const GEOSGeometry* g1);
00559 extern char GEOS_DLL GEOSHasZ(const GEOSGeometry* g1);
00560 
00561 extern char GEOS_DLL GEOSisEmpty_r(GEOSContextHandle_t handle,
00562                                    const GEOSGeometry* g1);
00563 extern char GEOS_DLL GEOSisValid_r(GEOSContextHandle_t handle,
00564                                    const GEOSGeometry* g1);
00565 extern char GEOS_DLL *GEOSisValidReason_r(GEOSContextHandle_t handle,
00566                                          const GEOSGeometry* g1);
00567 extern char GEOS_DLL GEOSisSimple_r(GEOSContextHandle_t handle,
00568                                     const GEOSGeometry* g1);
00569 extern char GEOS_DLL GEOSisRing_r(GEOSContextHandle_t handle,
00570                                   const GEOSGeometry* g1);
00571 extern char GEOS_DLL GEOSHasZ_r(GEOSContextHandle_t handle,
00572                                 const GEOSGeometry* g1);
00573 
00574 /************************************************************************
00575  *
00576  *  Geometry info
00577  *
00578  ***********************************************************************/
00579 
00580 /* Return NULL on exception, result must be freed by caller. */
00581 extern char GEOS_DLL *GEOSGeomType(const GEOSGeometry* g1);
00582 
00583 extern char GEOS_DLL *GEOSGeomType_r(GEOSContextHandle_t handle,
00584                                      const GEOSGeometry* g1);
00585 
00586 /* Return -1 on exception */
00587 extern int GEOS_DLL GEOSGeomTypeId(const GEOSGeometry* g1);
00588 
00589 extern int GEOS_DLL GEOSGeomTypeId_r(GEOSContextHandle_t handle,
00590                                      const GEOSGeometry* g1);
00591 
00592 /* Return 0 on exception */
00593 extern int GEOS_DLL GEOSGetSRID(const GEOSGeometry* g);
00594 extern int GEOS_DLL GEOSGetSRID_r(GEOSContextHandle_t handle,
00595                                   const GEOSGeometry* g);
00596 
00597 extern void GEOS_DLL GEOSSetSRID(GEOSGeometry* g, int SRID);
00598 extern void GEOS_DLL GEOSSetSRID_r(GEOSContextHandle_t handle,
00599                                    GEOSGeometry* g, int SRID);
00600 
00601 /* May be called on all geometries in GEOS 3.x, returns -1 on error and 1
00602  * for non-multi geometries. Older GEOS versions only accept 
00603  * GeometryCollections or Multi* geometries here, and are likely to crash
00604  * when feeded simple geometries, so beware if you need compatibility with
00605  * old GEOS versions.
00606  */
00607 extern int GEOS_DLL GEOSGetNumGeometries(const GEOSGeometry* g);
00608 
00609 extern int GEOS_DLL GEOSGetNumGeometries_r(GEOSContextHandle_t handle,
00610                                            const GEOSGeometry* g);
00611 
00612 /*
00613  * Return NULL on exception, Geometry must be a Collection.
00614  * Returned object is a pointer to internal storage:
00615  * it must NOT be destroyed directly.
00616  */
00617 extern const GEOSGeometry GEOS_DLL *GEOSGetGeometryN(const GEOSGeometry* g, int n);
00618 
00619 extern const GEOSGeometry GEOS_DLL *GEOSGetGeometryN_r(
00620                                     GEOSContextHandle_t handle,
00621                                     const GEOSGeometry* g, int n);
00622 
00623 /* Return -1 on exception */
00624 extern int GEOS_DLL GEOSNormalize(GEOSGeometry* g1);
00625 
00626 extern int GEOS_DLL GEOSNormalize_r(GEOSContextHandle_t handle,
00627                                     GEOSGeometry* g1);
00628 
00629 /* Return -1 on exception */
00630 extern int GEOS_DLL GEOSGetNumInteriorRings(const GEOSGeometry* g1);
00631 
00632 extern int GEOS_DLL GEOSGetNumInteriorRings_r(GEOSContextHandle_t handle,
00633                                               const GEOSGeometry* g1);
00634 
00635 /*
00636  * Return NULL on exception, Geometry must be a Polygon.
00637  * Returned object is a pointer to internal storage:
00638  * it must NOT be destroyed directly.
00639  */
00640 extern const GEOSGeometry GEOS_DLL *GEOSGetInteriorRingN(const GEOSGeometry* g, int n);
00641 
00642 extern const GEOSGeometry GEOS_DLL *GEOSGetInteriorRingN_r(
00643                                     GEOSContextHandle_t handle,
00644                                     const GEOSGeometry* g, int n);
00645 
00646 /*
00647  * Return NULL on exception, Geometry must be a Polygon.
00648  * Returned object is a pointer to internal storage:
00649  * it must NOT be destroyed directly.
00650  */
00651 extern const GEOSGeometry GEOS_DLL *GEOSGetExteriorRing(const GEOSGeometry* g);
00652 
00653 extern const GEOSGeometry GEOS_DLL *GEOSGetExteriorRing_r(
00654                                     GEOSContextHandle_t handle,
00655                                     const GEOSGeometry* g);
00656 
00657 /* Return -1 on exception */
00658 extern int GEOS_DLL GEOSGetNumCoordinates(const GEOSGeometry* g1);
00659 
00660 extern int GEOS_DLL GEOSGetNumCoordinates_r(GEOSContextHandle_t handle,
00661                                             const GEOSGeometry* g1);
00662 
00663 /*
00664  * Return NULL on exception.
00665  * Geometry must be a LineString, LinearRing or Point.
00666  */
00667 extern const GEOSCoordSequence GEOS_DLL *GEOSGeom_getCoordSeq(const GEOSGeometry* g);
00668 
00669 extern const GEOSCoordSequence GEOS_DLL *GEOSGeom_getCoordSeq_r(
00670                                          GEOSContextHandle_t handle,
00671                                          const GEOSGeometry* g);
00672 
00673 /*
00674  * Return 0 on exception (or empty geometry)
00675  * See also GEOSCoordSeq_getDimensions 
00676  */
00677 extern int GEOS_DLL GEOSGeom_getDimensions(const GEOSGeometry* g);
00678 
00679 extern int GEOS_DLL GEOSGeom_getDimensions_r(GEOSContextHandle_t handle,
00680                                              const GEOSGeometry* g);
00681 
00682 /************************************************************************
00683  *
00684  *  Misc functions 
00685  *
00686  ***********************************************************************/
00687 
00688 /* Return 0 on exception, 1 otherwise */
00689 extern int GEOS_DLL GEOSArea(const GEOSGeometry* g1, double *area);
00690 extern int GEOS_DLL GEOSLength(const GEOSGeometry* g1, double *length);
00691 extern int GEOS_DLL GEOSDistance(const GEOSGeometry* g1, const GEOSGeometry* g2,
00692         double *dist);
00693 
00694 extern int GEOS_DLL GEOSArea_r(GEOSContextHandle_t handle,
00695                                const GEOSGeometry* g1, double *area);
00696 extern int GEOS_DLL GEOSLength_r(GEOSContextHandle_t handle,
00697                                  const GEOSGeometry* g1, double *length);
00698 extern int GEOS_DLL GEOSDistance_r(GEOSContextHandle_t handle,
00699                                    const GEOSGeometry* g1,
00700                                    const GEOSGeometry* g2, double *dist);
00701 
00702 
00703 /************************************************************************
00704  *
00705  * Reader and Writer APIs
00706  *
00707  ***********************************************************************/
00708 
00709 typedef struct GEOSWKTReader_t GEOSWKTReader;
00710 typedef struct GEOSWKTWriter_t GEOSWKTWriter;
00711 typedef struct GEOSWKBReader_t GEOSWKBReader;
00712 typedef struct GEOSWKBWriter_t GEOSWKBWriter;
00713 
00714 
00715 /* WKT Reader */
00716 extern GEOSWKTReader GEOS_DLL *GEOSWKTReader_create();
00717 extern void GEOS_DLL GEOSWKTReader_destroy(GEOSWKTReader* reader);
00718 extern GEOSGeometry GEOS_DLL *GEOSWKTReader_read(GEOSWKTReader* reader, const char *wkt);
00719 
00720 extern GEOSWKTReader GEOS_DLL *GEOSWKTReader_create_r(
00721                                              GEOSContextHandle_t handle);
00722 extern void GEOS_DLL GEOSWKTReader_destroy_r(GEOSContextHandle_t handle,
00723                                              GEOSWKTReader* reader);
00724 extern GEOSGeometry GEOS_DLL *GEOSWKTReader_read_r(GEOSContextHandle_t handle,
00725                                                    GEOSWKTReader* reader,
00726                                                    const char *wkt);
00727 
00728 /* WKT Writer */
00729 extern GEOSWKTWriter GEOS_DLL *GEOSWKTWriter_create();
00730 extern void GEOS_DLL GEOSWKTWriter_destroy(GEOSWKTWriter* writer);
00731 extern char GEOS_DLL *GEOSWKTWriter_write(GEOSWKTWriter* reader, const GEOSGeometry* g);
00732 
00733 extern GEOSWKTWriter GEOS_DLL *GEOSWKTWriter_create_r(
00734                                              GEOSContextHandle_t handle);
00735 extern void GEOS_DLL GEOSWKTWriter_destroy_r(GEOSContextHandle_t handle,
00736                                              GEOSWKTWriter* writer);
00737 extern char GEOS_DLL *GEOSWKTWriter_write_r(GEOSContextHandle_t handle,
00738                                             GEOSWKTWriter* reader,
00739                                             const GEOSGeometry* g);
00740 
00741 /* WKB Reader */
00742 extern GEOSWKBReader GEOS_DLL *GEOSWKBReader_create();
00743 extern void GEOS_DLL GEOSWKBReader_destroy(GEOSWKBReader* reader);
00744 extern GEOSGeometry GEOS_DLL *GEOSWKBReader_read(GEOSWKBReader* reader, const unsigned char *wkb, size_t size);
00745 extern GEOSGeometry GEOS_DLL *GEOSWKBReader_readHEX(GEOSWKBReader* reader, const unsigned char *hex, size_t size);
00746 
00747 extern GEOSWKBReader GEOS_DLL *GEOSWKBReader_create_r(
00748                                              GEOSContextHandle_t handle);
00749 extern void GEOS_DLL GEOSWKBReader_destroy_r(GEOSContextHandle_t handle,
00750                                              GEOSWKBReader* reader);
00751 extern GEOSGeometry GEOS_DLL *GEOSWKBReader_read_r(GEOSContextHandle_t handle,
00752                                                    GEOSWKBReader* reader,
00753                                                    const unsigned char *wkb,
00754                                                    size_t size);
00755 extern GEOSGeometry GEOS_DLL *GEOSWKBReader_readHEX_r(
00756                                             GEOSContextHandle_t handle,
00757                                             GEOSWKBReader* reader,
00758                                             const unsigned char *hex,
00759                                             size_t size);
00760 
00761 /* WKB Writer */
00762 extern GEOSWKBWriter GEOS_DLL *GEOSWKBWriter_create();
00763 extern void GEOS_DLL GEOSWKBWriter_destroy(GEOSWKBWriter* writer);
00764 
00765 extern GEOSWKBWriter GEOS_DLL *GEOSWKBWriter_create_r(
00766                                              GEOSContextHandle_t handle);
00767 extern void GEOS_DLL GEOSWKBWriter_destroy_r(GEOSContextHandle_t handle,
00768                                              GEOSWKBWriter* writer);
00769 
00770 /* The owner owns the results for these two methods! */
00771 extern unsigned char GEOS_DLL *GEOSWKBWriter_write(GEOSWKBWriter* writer, const GEOSGeometry* g, size_t *size);
00772 extern unsigned char GEOS_DLL *GEOSWKBWriter_writeHEX(GEOSWKBWriter* writer, const GEOSGeometry* g, size_t *size);
00773 
00774 extern unsigned char GEOS_DLL *GEOSWKBWriter_write_r(
00775                                              GEOSContextHandle_t handle,
00776                                              GEOSWKBWriter* writer,
00777                                              const GEOSGeometry* g,
00778                                              size_t *size);
00779 extern unsigned char GEOS_DLL *GEOSWKBWriter_writeHEX_r(
00780                                              GEOSContextHandle_t handle,
00781                                              GEOSWKBWriter* writer,
00782                                              const GEOSGeometry* g,
00783                                              size_t *size);
00784 
00785 /* 
00786  * Specify whether output WKB should be 2d or 3d.
00787  * Return previously set number of dimensions.
00788  */
00789 extern int GEOS_DLL GEOSWKBWriter_getOutputDimension(const GEOSWKBWriter* writer);
00790 extern void GEOS_DLL GEOSWKBWriter_setOutputDimension(GEOSWKBWriter* writer, int newDimension);
00791 
00792 extern int GEOS_DLL GEOSWKBWriter_getOutputDimension_r(
00793                                   GEOSContextHandle_t handle,
00794                                   const GEOSWKBWriter* writer);
00795 extern void GEOS_DLL GEOSWKBWriter_setOutputDimension_r(
00796                                    GEOSContextHandle_t handle,
00797                                    GEOSWKBWriter* writer, int newDimension);
00798 
00799 /*
00800  * Specify whether the WKB byte order is big or little endian. 
00801  * The return value is the previous byte order.
00802  */
00803 extern int GEOS_DLL GEOSWKBWriter_getByteOrder(const GEOSWKBWriter* writer);
00804 extern void GEOS_DLL GEOSWKBWriter_setByteOrder(GEOSWKBWriter* writer, int byteOrder);
00805 
00806 extern int GEOS_DLL GEOSWKBWriter_getByteOrder_r(GEOSContextHandle_t handle,
00807                                                  const GEOSWKBWriter* writer);
00808 extern void GEOS_DLL GEOSWKBWriter_setByteOrder_r(GEOSContextHandle_t handle,
00809                                                   GEOSWKBWriter* writer,
00810                                                   int byteOrder);
00811 
00812 /*
00813  * Specify whether SRID values should be output. 
00814  */
00815 extern char GEOS_DLL GEOSWKBWriter_getIncludeSRID(const GEOSWKBWriter* writer);
00816 extern void GEOS_DLL GEOSWKBWriter_setIncludeSRID(GEOSWKBWriter* writer, const char writeSRID);
00817 
00818 extern char GEOS_DLL GEOSWKBWriter_getIncludeSRID_r(GEOSContextHandle_t handle,
00819                                    const GEOSWKBWriter* writer);
00820 extern void GEOS_DLL GEOSWKBWriter_setIncludeSRID_r(GEOSContextHandle_t handle,
00821                                    GEOSWKBWriter* writer, const char writeSRID);
00822 
00823 
00824 /*
00825  * Free buffers returned by stuff like GEOSWKBWriter_write(), 
00826  * GEOSWKBWriter_writeHEX() and GEOSWKTWriter_write(). 
00827  */
00828 extern void GEOS_DLL GEOSFree( void *buffer );
00829 extern void GEOS_DLL GEOSFree_r( GEOSContextHandle_t handle, void *buffer );
00830 
00831 #ifdef __cplusplus
00832 } // extern "C"
00833 #endif
00834 
00835 #endif /* #ifndef GEOS_C_H_INCLUDED */

Generated on Thu Jun 11 06:17:01 2009 for GEOS by  doxygen 1.4.4