|
GEOS 3.5.1
|
00001 /************************************************************************ 00002 * 00003 * 00004 * C-Wrapper for GEOS library 00005 * 00006 * Copyright (C) 2010 2011 Sandro Santilli <strk@keybit.net> 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@keybit.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 * - Functions ending with _r are thread safe; see details in RFC 3 00028 * http://trac.osgeo.org/geos/wiki/RFC3. 00029 * To avoid using by accident non _r functions, 00030 * define GEOS_USE_ONLY_R_API before including geos_c.h 00031 * 00032 ***********************************************************************/ 00033 00034 #ifndef GEOS_C_H_INCLUDED 00035 #define GEOS_C_H_INCLUDED 00036 00037 #ifndef __cplusplus 00038 # include <stddef.h> /* for size_t definition */ 00039 #else 00040 # include <cstddef> 00041 using std::size_t; 00042 #endif 00043 00044 #ifdef __cplusplus 00045 extern "C" { 00046 #endif 00047 00048 /************************************************************************ 00049 * 00050 * Version 00051 * 00052 ***********************************************************************/ 00053 00054 /* 00055 * Following 'ifdef' hack fixes problem with generating geos_c.h on Windows, 00056 * when building with Visual C++ compiler. 00057 * 00058 */ 00059 #if defined(_MSC_VER) 00060 #include <geos/version.h> 00061 #define GEOS_CAPI_VERSION_MAJOR 1 00062 #define GEOS_CAPI_VERSION_MINOR 9 00063 #define GEOS_CAPI_VERSION_PATCH 1 00064 #define GEOS_CAPI_VERSION "3.5.1-CAPI-1.9.1" 00065 #else 00066 #ifndef GEOS_VERSION_MAJOR 00067 #define GEOS_VERSION_MAJOR 3 00068 #endif 00069 #ifndef GEOS_VERSION_MINOR 00070 #define GEOS_VERSION_MINOR 5 00071 #endif 00072 #ifndef GEOS_VERSION_PATCH 00073 #define GEOS_VERSION_PATCH 1 00074 #endif 00075 #ifndef GEOS_VERSION 00076 #define GEOS_VERSION "3.5.1" 00077 #endif 00078 #ifndef GEOS_JTS_PORT 00079 #define GEOS_JTS_PORT "1.13.0" 00080 #endif 00081 00082 #define GEOS_CAPI_VERSION_MAJOR 1 00083 #define GEOS_CAPI_VERSION_MINOR 9 00084 #define GEOS_CAPI_VERSION_PATCH 1 00085 #define GEOS_CAPI_VERSION "3.5.1-CAPI-1.9.1" 00086 #endif 00087 00088 #define GEOS_CAPI_FIRST_INTERFACE GEOS_CAPI_VERSION_MAJOR 00089 #define GEOS_CAPI_LAST_INTERFACE (GEOS_CAPI_VERSION_MAJOR+GEOS_CAPI_VERSION_MINOR) 00090 00091 /************************************************************************ 00092 * 00093 * (Abstract) type definitions 00094 * 00095 ************************************************************************/ 00096 00097 typedef struct GEOSContextHandle_HS *GEOSContextHandle_t; 00098 00099 typedef void (*GEOSMessageHandler)(const char *fmt, ...); 00100 00101 /* 00102 * A GEOS message handler function. 00103 * 00104 * @param message the message contents 00105 * @param userdata the user data pointer that was passed to GEOS when registering this message handler. 00106 * 00107 * 00108 * @see GEOSContext_setErrorMessageHandler 00109 * @see GEOSContext_setNoticeMessageHandler 00110 */ 00111 typedef void (*GEOSMessageHandler_r)(const char *message, void *userdata); 00112 00113 /* When we're included by geos_c.cpp, those are #defined to the original 00114 * JTS definitions via preprocessor. We don't touch them to allow the 00115 * compiler to cross-check the declarations. However, for all "normal" 00116 * C-API users, we need to define them as "opaque" struct pointers, as 00117 * those clients don't have access to the original C++ headers, by design. 00118 */ 00119 #ifndef GEOSGeometry 00120 typedef struct GEOSGeom_t GEOSGeometry; 00121 typedef struct GEOSPrepGeom_t GEOSPreparedGeometry; 00122 typedef struct GEOSCoordSeq_t GEOSCoordSequence; 00123 typedef struct GEOSSTRtree_t GEOSSTRtree; 00124 typedef struct GEOSBufParams_t GEOSBufferParams; 00125 #endif 00126 00127 /* Those are compatibility definitions for source compatibility 00128 * with GEOS 2.X clients relying on that type. 00129 */ 00130 typedef GEOSGeometry* GEOSGeom; 00131 typedef GEOSCoordSequence* GEOSCoordSeq; 00132 00133 /* Supported geometry types 00134 * This was renamed from GEOSGeomTypeId in GEOS 2.2.X, which might 00135 * break compatibility, this issue is still under investigation. 00136 */ 00137 00138 enum GEOSGeomTypes { 00139 GEOS_POINT, 00140 GEOS_LINESTRING, 00141 GEOS_LINEARRING, 00142 GEOS_POLYGON, 00143 GEOS_MULTIPOINT, 00144 GEOS_MULTILINESTRING, 00145 GEOS_MULTIPOLYGON, 00146 GEOS_GEOMETRYCOLLECTION 00147 }; 00148 00149 /* Byte oders exposed via the c api */ 00150 enum GEOSByteOrders { 00151 GEOS_WKB_XDR = 0, /* Big Endian */ 00152 GEOS_WKB_NDR = 1 /* Little Endian */ 00153 }; 00154 00155 typedef void (*GEOSQueryCallback)(void *item, void *userdata); 00156 00157 /************************************************************************ 00158 * 00159 * Initialization, cleanup, version 00160 * 00161 ***********************************************************************/ 00162 00163 #include <geos/export.h> 00164 00165 /* 00166 * Register an interruption checking callback 00167 * 00168 * The callback will be invoked _before_ checking for 00169 * interruption, so can be used to request it. 00170 */ 00171 typedef void (GEOSInterruptCallback)(); 00172 extern GEOSInterruptCallback GEOS_DLL *GEOS_interruptRegisterCallback(GEOSInterruptCallback* cb); 00173 /* Request safe interruption of operations */ 00174 extern void GEOS_DLL GEOS_interruptRequest(); 00175 /* Cancel a pending interruption request */ 00176 extern void GEOS_DLL GEOS_interruptCancel(); 00177 00178 /* 00179 * @deprecated in 3.5.0 00180 * initialize using GEOS_init_r() and set the message handlers using 00181 * GEOSContext_setNoticeHandler_r and/or GEOSContext_setErrorHandler_r 00182 */ 00183 extern GEOSContextHandle_t GEOS_DLL initGEOS_r( 00184 GEOSMessageHandler notice_function, 00185 GEOSMessageHandler error_function); 00186 /* 00187 * @deprecated in 3.5.0 replaced by GEOS_finish_r. 00188 */ 00189 extern void GEOS_DLL finishGEOS_r(GEOSContextHandle_t handle); 00190 00191 extern GEOSContextHandle_t GEOS_DLL GEOS_init_r(); 00192 extern void GEOS_DLL GEOS_finish_r(GEOSContextHandle_t handle); 00193 00194 00195 extern GEOSMessageHandler GEOS_DLL GEOSContext_setNoticeHandler_r(GEOSContextHandle_t extHandle, 00196 GEOSMessageHandler nf); 00197 extern GEOSMessageHandler GEOS_DLL GEOSContext_setErrorHandler_r(GEOSContextHandle_t extHandle, 00198 GEOSMessageHandler ef); 00199 00200 /* 00201 * Sets a notice message handler on the given GEOS context. 00202 * 00203 * @param extHandle the GEOS context 00204 * @param nf the message handler 00205 * @param userData optional user data pointer that will be passed to the message handler 00206 * 00207 * @return the previously configured message handler or NULL if no message handler was configured 00208 */ 00209 extern GEOSMessageHandler_r GEOS_DLL GEOSContext_setNoticeMessageHandler_r(GEOSContextHandle_t extHandle, 00210 GEOSMessageHandler_r nf, 00211 void *userData); 00212 00213 /* 00214 * Sets an error message handler on the given GEOS context. 00215 * 00216 * @param extHandle the GEOS context 00217 * @param ef the message handler 00218 * @param userData optional user data pointer that will be passed to the message handler 00219 * 00220 * @return the previously configured message handler or NULL if no message handler was configured 00221 */ 00222 extern GEOSMessageHandler_r GEOS_DLL GEOSContext_setErrorMessageHandler_r(GEOSContextHandle_t extHandle, 00223 GEOSMessageHandler_r ef, 00224 void *userData); 00225 00226 extern const char GEOS_DLL *GEOSversion(); 00227 00228 00229 /************************************************************************ 00230 * 00231 * NOTE - These functions are DEPRECATED. Please use the new Reader and 00232 * writer APIS! 00233 * 00234 ***********************************************************************/ 00235 00236 extern GEOSGeometry GEOS_DLL *GEOSGeomFromWKT_r(GEOSContextHandle_t handle, 00237 const char *wkt); 00238 extern char GEOS_DLL *GEOSGeomToWKT_r(GEOSContextHandle_t handle, 00239 const GEOSGeometry* g); 00240 00241 /* 00242 * Specify whether output WKB should be 2d or 3d. 00243 * Return previously set number of dimensions. 00244 */ 00245 00246 extern int GEOS_DLL GEOS_getWKBOutputDims_r(GEOSContextHandle_t handle); 00247 extern int GEOS_DLL GEOS_setWKBOutputDims_r(GEOSContextHandle_t handle, 00248 int newDims); 00249 00250 /* 00251 * Specify whether the WKB byte order is big or little endian. 00252 * The return value is the previous byte order. 00253 */ 00254 00255 extern int GEOS_DLL GEOS_getWKBByteOrder_r(GEOSContextHandle_t handle); 00256 extern int GEOS_DLL GEOS_setWKBByteOrder_r(GEOSContextHandle_t handle, 00257 int byteOrder); 00258 00259 extern GEOSGeometry GEOS_DLL *GEOSGeomFromWKB_buf_r(GEOSContextHandle_t handle, 00260 const unsigned char *wkb, 00261 size_t size); 00262 extern unsigned char GEOS_DLL *GEOSGeomToWKB_buf_r(GEOSContextHandle_t handle, 00263 const GEOSGeometry* g, 00264 size_t *size); 00265 00266 extern GEOSGeometry GEOS_DLL *GEOSGeomFromHEX_buf_r(GEOSContextHandle_t handle, 00267 const unsigned char *hex, 00268 size_t size); 00269 extern unsigned char GEOS_DLL *GEOSGeomToHEX_buf_r(GEOSContextHandle_t handle, 00270 const GEOSGeometry* g, 00271 size_t *size); 00272 00273 /************************************************************************ 00274 * 00275 * Coordinate Sequence functions 00276 * 00277 ***********************************************************************/ 00278 00279 /* 00280 * Create a Coordinate sequence with ``size'' coordinates 00281 * of ``dims'' dimensions. 00282 * Return NULL on exception. 00283 */ 00284 extern GEOSCoordSequence GEOS_DLL *GEOSCoordSeq_create_r( 00285 GEOSContextHandle_t handle, 00286 unsigned int size, 00287 unsigned int dims); 00288 00289 /* 00290 * Clone a Coordinate Sequence. 00291 * Return NULL on exception. 00292 */ 00293 extern GEOSCoordSequence GEOS_DLL *GEOSCoordSeq_clone_r( 00294 GEOSContextHandle_t handle, 00295 const GEOSCoordSequence* s); 00296 00297 /* 00298 * Destroy a Coordinate Sequence. 00299 */ 00300 extern void GEOS_DLL GEOSCoordSeq_destroy_r(GEOSContextHandle_t handle, 00301 GEOSCoordSequence* s); 00302 00303 /* 00304 * Set ordinate values in a Coordinate Sequence. 00305 * Return 0 on exception. 00306 */ 00307 extern int GEOS_DLL GEOSCoordSeq_setX_r(GEOSContextHandle_t handle, 00308 GEOSCoordSequence* s, unsigned int idx, 00309 double val); 00310 extern int GEOS_DLL GEOSCoordSeq_setY_r(GEOSContextHandle_t handle, 00311 GEOSCoordSequence* s, unsigned int idx, 00312 double val); 00313 extern int GEOS_DLL GEOSCoordSeq_setZ_r(GEOSContextHandle_t handle, 00314 GEOSCoordSequence* s, unsigned int idx, 00315 double val); 00316 extern int GEOS_DLL GEOSCoordSeq_setOrdinate_r(GEOSContextHandle_t handle, 00317 GEOSCoordSequence* s, 00318 unsigned int idx, 00319 unsigned int dim, double val); 00320 00321 /* 00322 * Get ordinate values from a Coordinate Sequence. 00323 * Return 0 on exception. 00324 */ 00325 extern int GEOS_DLL GEOSCoordSeq_getX_r(GEOSContextHandle_t handle, 00326 const GEOSCoordSequence* s, 00327 unsigned int idx, double *val); 00328 extern int GEOS_DLL GEOSCoordSeq_getY_r(GEOSContextHandle_t handle, 00329 const GEOSCoordSequence* s, 00330 unsigned int idx, double *val); 00331 extern int GEOS_DLL GEOSCoordSeq_getZ_r(GEOSContextHandle_t handle, 00332 const GEOSCoordSequence* s, 00333 unsigned int idx, double *val); 00334 extern int GEOS_DLL GEOSCoordSeq_getOrdinate_r(GEOSContextHandle_t handle, 00335 const GEOSCoordSequence* s, 00336 unsigned int idx, 00337 unsigned int dim, double *val); 00338 /* 00339 * Get size and dimensions info from a Coordinate Sequence. 00340 * Return 0 on exception. 00341 */ 00342 extern int GEOS_DLL GEOSCoordSeq_getSize_r(GEOSContextHandle_t handle, 00343 const GEOSCoordSequence* s, 00344 unsigned int *size); 00345 extern int GEOS_DLL GEOSCoordSeq_getDimensions_r(GEOSContextHandle_t handle, 00346 const GEOSCoordSequence* s, 00347 unsigned int *dims); 00348 00349 /************************************************************************ 00350 * 00351 * Linear referencing functions -- there are more, but these are 00352 * probably sufficient for most purposes 00353 * 00354 ***********************************************************************/ 00355 00356 /* 00357 * GEOSGeometry ownership is retained by caller 00358 */ 00359 00360 00361 /* Return distance of point 'p' projected on 'g' from origin 00362 * of 'g'. Geometry 'g' must be a lineal geometry */ 00363 extern double GEOS_DLL GEOSProject_r(GEOSContextHandle_t handle, 00364 const GEOSGeometry *g, 00365 const GEOSGeometry *p); 00366 00367 /* Return closest point to given distance within geometry 00368 * Geometry must be a LineString */ 00369 extern GEOSGeometry GEOS_DLL *GEOSInterpolate_r(GEOSContextHandle_t handle, 00370 const GEOSGeometry *g, 00371 double d); 00372 00373 extern double GEOS_DLL GEOSProjectNormalized_r(GEOSContextHandle_t handle, 00374 const GEOSGeometry *g, 00375 const GEOSGeometry *p); 00376 00377 extern GEOSGeometry GEOS_DLL *GEOSInterpolateNormalized_r( 00378 GEOSContextHandle_t handle, 00379 const GEOSGeometry *g, 00380 double d); 00381 00382 /************************************************************************ 00383 * 00384 * Buffer related functions 00385 * 00386 ***********************************************************************/ 00387 00388 00389 /* @return NULL on exception */ 00390 extern GEOSGeometry GEOS_DLL *GEOSBuffer_r(GEOSContextHandle_t handle, 00391 const GEOSGeometry* g, 00392 double width, int quadsegs); 00393 00394 enum GEOSBufCapStyles { 00395 GEOSBUF_CAP_ROUND=1, 00396 GEOSBUF_CAP_FLAT=2, 00397 GEOSBUF_CAP_SQUARE=3 00398 }; 00399 00400 enum GEOSBufJoinStyles { 00401 GEOSBUF_JOIN_ROUND=1, 00402 GEOSBUF_JOIN_MITRE=2, 00403 GEOSBUF_JOIN_BEVEL=3 00404 }; 00405 00406 /* @return 0 on exception */ 00407 extern GEOSBufferParams GEOS_DLL *GEOSBufferParams_create_r( 00408 GEOSContextHandle_t handle); 00409 extern void GEOS_DLL GEOSBufferParams_destroy_r( 00410 GEOSContextHandle_t handle, 00411 GEOSBufferParams* parms); 00412 00413 /* @return 0 on exception */ 00414 extern int GEOS_DLL GEOSBufferParams_setEndCapStyle_r( 00415 GEOSContextHandle_t handle, 00416 GEOSBufferParams* p, 00417 int style); 00418 00419 /* @return 0 on exception */ 00420 extern int GEOS_DLL GEOSBufferParams_setJoinStyle_r( 00421 GEOSContextHandle_t handle, 00422 GEOSBufferParams* p, 00423 int joinStyle); 00424 00425 /* @return 0 on exception */ 00426 extern int GEOS_DLL GEOSBufferParams_setMitreLimit_r( 00427 GEOSContextHandle_t handle, 00428 GEOSBufferParams* p, 00429 double mitreLimit); 00430 00431 /* @return 0 on exception */ 00432 extern int GEOS_DLL GEOSBufferParams_setQuadrantSegments_r( 00433 GEOSContextHandle_t handle, 00434 GEOSBufferParams* p, 00435 int quadSegs); 00436 00437 /* @param singleSided: 1 for single sided, 0 otherwise */ 00438 /* @return 0 on exception */ 00439 extern int GEOS_DLL GEOSBufferParams_setSingleSided_r( 00440 GEOSContextHandle_t handle, 00441 GEOSBufferParams* p, 00442 int singleSided); 00443 00444 /* @return NULL on exception */ 00445 extern GEOSGeometry GEOS_DLL *GEOSBufferWithParams_r( 00446 GEOSContextHandle_t handle, 00447 const GEOSGeometry* g, 00448 const GEOSBufferParams* p, 00449 double width); 00450 00451 /* These functions return NULL on exception. */ 00452 extern GEOSGeometry GEOS_DLL *GEOSBufferWithStyle_r(GEOSContextHandle_t handle, 00453 const GEOSGeometry* g, double width, int quadsegs, int endCapStyle, 00454 int joinStyle, double mitreLimit); 00455 00456 /* These functions return NULL on exception. Only LINESTRINGs are accepted. */ 00457 /* @deprecated in 3.3.0: use GEOSOffsetCurve instead */ 00458 extern GEOSGeometry GEOS_DLL *GEOSSingleSidedBuffer_r( 00459 GEOSContextHandle_t handle, 00460 const GEOSGeometry* g, double width, int quadsegs, 00461 int joinStyle, double mitreLimit, int leftSide); 00462 00463 /* 00464 * Only LINESTRINGs are accepted. 00465 * @param width : offset distance. 00466 * negative for right side offset. 00467 * positive for left side offset. 00468 * @return NULL on exception 00469 */ 00470 extern GEOSGeometry GEOS_DLL *GEOSOffsetCurve_r(GEOSContextHandle_t handle, 00471 const GEOSGeometry* g, double width, int quadsegs, 00472 int joinStyle, double mitreLimit); 00473 00474 00475 /************************************************************************ 00476 * 00477 * Geometry Constructors. 00478 * GEOSCoordSequence* arguments will become ownership of the returned object. 00479 * All functions return NULL on exception. 00480 * 00481 ***********************************************************************/ 00482 00483 extern GEOSGeometry GEOS_DLL *GEOSGeom_createPoint_r( 00484 GEOSContextHandle_t handle, 00485 GEOSCoordSequence* s); 00486 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyPoint_r( 00487 GEOSContextHandle_t handle); 00488 extern GEOSGeometry GEOS_DLL *GEOSGeom_createLinearRing_r( 00489 GEOSContextHandle_t handle, 00490 GEOSCoordSequence* s); 00491 extern GEOSGeometry GEOS_DLL *GEOSGeom_createLineString_r( 00492 GEOSContextHandle_t handle, 00493 GEOSCoordSequence* s); 00494 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyLineString_r( 00495 GEOSContextHandle_t handle); 00496 00497 /* 00498 * Second argument is an array of GEOSGeometry* objects. 00499 * The caller remains owner of the array, but pointed-to 00500 * objects become ownership of the returned GEOSGeometry. 00501 */ 00502 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyPolygon_r( 00503 GEOSContextHandle_t handle); 00504 extern GEOSGeometry GEOS_DLL *GEOSGeom_createPolygon_r( 00505 GEOSContextHandle_t handle, 00506 GEOSGeometry* shell, 00507 GEOSGeometry** holes, 00508 unsigned int nholes); 00509 extern GEOSGeometry GEOS_DLL *GEOSGeom_createCollection_r( 00510 GEOSContextHandle_t handle, int type, 00511 GEOSGeometry* *geoms, 00512 unsigned int ngeoms); 00513 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyCollection_r( 00514 GEOSContextHandle_t handle, int type); 00515 00516 extern GEOSGeometry GEOS_DLL *GEOSGeom_clone_r(GEOSContextHandle_t handle, 00517 const GEOSGeometry* g); 00518 00519 /************************************************************************ 00520 * 00521 * Memory management 00522 * 00523 ***********************************************************************/ 00524 00525 extern void GEOS_DLL GEOSGeom_destroy_r(GEOSContextHandle_t handle, 00526 GEOSGeometry* g); 00527 00528 /************************************************************************ 00529 * 00530 * Topology operations - return NULL on exception. 00531 * 00532 ***********************************************************************/ 00533 00534 extern GEOSGeometry GEOS_DLL *GEOSEnvelope_r(GEOSContextHandle_t handle, 00535 const GEOSGeometry* g); 00536 extern GEOSGeometry GEOS_DLL *GEOSIntersection_r(GEOSContextHandle_t handle, 00537 const GEOSGeometry* g1, 00538 const GEOSGeometry* g2); 00539 extern GEOSGeometry GEOS_DLL *GEOSConvexHull_r(GEOSContextHandle_t handle, 00540 const GEOSGeometry* g); 00541 extern GEOSGeometry GEOS_DLL *GEOSDifference_r(GEOSContextHandle_t handle, 00542 const GEOSGeometry* g1, 00543 const GEOSGeometry* g2); 00544 extern GEOSGeometry GEOS_DLL *GEOSSymDifference_r(GEOSContextHandle_t handle, 00545 const GEOSGeometry* g1, 00546 const GEOSGeometry* g2); 00547 extern GEOSGeometry GEOS_DLL *GEOSBoundary_r(GEOSContextHandle_t handle, 00548 const GEOSGeometry* g); 00549 extern GEOSGeometry GEOS_DLL *GEOSUnion_r(GEOSContextHandle_t handle, 00550 const GEOSGeometry* g1, 00551 const GEOSGeometry* g2); 00552 extern GEOSGeometry GEOS_DLL *GEOSUnaryUnion_r(GEOSContextHandle_t handle, 00553 const GEOSGeometry* g); 00554 /* @deprecated in 3.3.0: use GEOSUnaryUnion_r instead */ 00555 extern GEOSGeometry GEOS_DLL *GEOSUnionCascaded_r(GEOSContextHandle_t handle, 00556 const GEOSGeometry* g); 00557 extern GEOSGeometry GEOS_DLL *GEOSPointOnSurface_r(GEOSContextHandle_t handle, 00558 const GEOSGeometry* g); 00559 extern GEOSGeometry GEOS_DLL *GEOSGetCentroid_r(GEOSContextHandle_t handle, 00560 const GEOSGeometry* g); 00561 extern GEOSGeometry GEOS_DLL *GEOSNode_r(GEOSContextHandle_t handle, 00562 const GEOSGeometry* g); 00563 /* Fast, non-robust intersection between an arbitrary geometry and 00564 * a rectangle. The returned geometry may be invalid. */ 00565 extern GEOSGeometry GEOS_DLL *GEOSClipByRect_r(GEOSContextHandle_t handle, 00566 const GEOSGeometry* g, 00567 double xmin, double ymin, 00568 double xmax, double ymax); 00569 00570 /* 00571 * all arguments remain ownership of the caller 00572 * (both Geometries and pointers) 00573 */ 00574 /* 00575 * Polygonizes a set of Geometries which contain linework that 00576 * represents the edges of a planar graph. 00577 * 00578 * Any dimension of Geometry is handled - the constituent linework 00579 * is extracted to form the edges. 00580 * 00581 * The edges must be correctly noded; that is, they must only meet 00582 * at their endpoints. 00583 * The Polygonizer will still run on incorrectly noded input 00584 * but will not form polygons from incorrectly noded edges. 00585 * 00586 * The Polygonizer reports the follow kinds of errors: 00587 * 00588 * - Dangles - edges which have one or both ends which are 00589 * not incident on another edge endpoint 00590 * - Cut Edges - edges which are connected at both ends but 00591 * which do not form part of polygon 00592 * - Invalid Ring Lines - edges which form rings which are invalid 00593 * (e.g. the component lines contain a self-intersection) 00594 * 00595 * Errors are reported to output parameters "cuts", "dangles" and 00596 * "invalid" (if not-null). Formed polygons are returned as a 00597 * collection. NULL is returned on exception. All returned 00598 * geometries must be destroyed by caller. 00599 * 00600 */ 00601 00602 extern GEOSGeometry GEOS_DLL *GEOSPolygonize_r(GEOSContextHandle_t handle, 00603 const GEOSGeometry *const geoms[], 00604 unsigned int ngeoms); 00605 extern GEOSGeometry GEOS_DLL *GEOSPolygonizer_getCutEdges_r( 00606 GEOSContextHandle_t handle, 00607 const GEOSGeometry * const geoms[], 00608 unsigned int ngeoms); 00609 extern GEOSGeometry GEOS_DLL *GEOSPolygonize_full_r(GEOSContextHandle_t handle, 00610 const GEOSGeometry* input, GEOSGeometry** cuts, 00611 GEOSGeometry** dangles, GEOSGeometry** invalidRings); 00612 00613 extern GEOSGeometry GEOS_DLL *GEOSLineMerge_r(GEOSContextHandle_t handle, 00614 const GEOSGeometry* g); 00615 extern GEOSGeometry GEOS_DLL *GEOSSimplify_r(GEOSContextHandle_t handle, 00616 const GEOSGeometry* g, 00617 double tolerance); 00618 extern GEOSGeometry GEOS_DLL *GEOSTopologyPreserveSimplify_r( 00619 GEOSContextHandle_t handle, 00620 const GEOSGeometry* g, double tolerance); 00621 00622 /* 00623 * Return all distinct vertices of input geometry as a MULTIPOINT. 00624 * Note that only 2 dimensions of the vertices are considered when 00625 * testing for equality. 00626 */ 00627 extern GEOSGeometry GEOS_DLL *GEOSGeom_extractUniquePoints_r( 00628 GEOSContextHandle_t handle, 00629 const GEOSGeometry* g); 00630 00631 /* 00632 * Find paths shared between the two given lineal geometries. 00633 * 00634 * Returns a GEOMETRYCOLLECTION having two elements: 00635 * - first element is a MULTILINESTRING containing shared paths 00636 * having the _same_ direction on both inputs 00637 * - second element is a MULTILINESTRING containing shared paths 00638 * having the _opposite_ direction on the two inputs 00639 * 00640 * Returns NULL on exception 00641 */ 00642 extern GEOSGeometry GEOS_DLL *GEOSSharedPaths_r(GEOSContextHandle_t handle, 00643 const GEOSGeometry* g1, const GEOSGeometry* g2); 00644 00645 /* 00646 * Snap first geometry on to second with given tolerance 00647 * Returns a newly allocated geometry, or NULL on exception 00648 */ 00649 extern GEOSGeometry GEOS_DLL *GEOSSnap_r(GEOSContextHandle_t handle, 00650 const GEOSGeometry* g1, const GEOSGeometry* g2, double tolerance); 00651 00652 /* 00653 * Return a Delaunay triangulation of the vertex of the given geometry 00654 * 00655 * @param g the input geometry whose vertex will be used as "sites" 00656 * @param tolerance optional snapping tolerance to use for improved robustness 00657 * @param onlyEdges if non-zero will return a MULTILINESTRING, otherwise it will 00658 * return a GEOMETRYCOLLECTION containing triangular POLYGONs. 00659 * 00660 * @return a newly allocated geometry, or NULL on exception 00661 */ 00662 extern GEOSGeometry GEOS_DLL * GEOSDelaunayTriangulation_r( 00663 GEOSContextHandle_t handle, 00664 const GEOSGeometry *g, 00665 double tolerance, 00666 int onlyEdges); 00667 00668 /* 00669 * Returns the Voronoi polygons of a set of Vertices given as input 00670 * 00671 * @param g the input geometry whose vertex will be used as sites. 00672 * @param tolerance snapping tolerance to use for improved robustness 00673 * @param onlyEdges whether to return only edges of the voronoi cells 00674 * @param env clipping envelope for the returned diagram, automatically 00675 * determined if NULL. 00676 * The diagram will be clipped to the larger 00677 * of this envelope or an envelope surrounding the sites. 00678 * 00679 * @return a newly allocated geometry, or NULL on exception. 00680 */ 00681 extern GEOSGeometry GEOS_DLL * GEOSVoronoiDiagram_r( 00682 GEOSContextHandle_t extHandle, 00683 const GEOSGeometry *g, 00684 const GEOSGeometry *env, 00685 double tolerance, 00686 int onlyEdges); 00687 00688 00689 /************************************************************************ 00690 * 00691 * Binary predicates - return 2 on exception, 1 on true, 0 on false 00692 * 00693 ***********************************************************************/ 00694 00695 extern char GEOS_DLL GEOSDisjoint_r(GEOSContextHandle_t handle, 00696 const GEOSGeometry* g1, 00697 const GEOSGeometry* g2); 00698 extern char GEOS_DLL GEOSTouches_r(GEOSContextHandle_t handle, 00699 const GEOSGeometry* g1, 00700 const GEOSGeometry* g2); 00701 extern char GEOS_DLL GEOSIntersects_r(GEOSContextHandle_t handle, 00702 const GEOSGeometry* g1, 00703 const GEOSGeometry* g2); 00704 extern char GEOS_DLL GEOSCrosses_r(GEOSContextHandle_t handle, 00705 const GEOSGeometry* g1, 00706 const GEOSGeometry* g2); 00707 extern char GEOS_DLL GEOSWithin_r(GEOSContextHandle_t handle, 00708 const GEOSGeometry* g1, 00709 const GEOSGeometry* g2); 00710 extern char GEOS_DLL GEOSContains_r(GEOSContextHandle_t handle, 00711 const GEOSGeometry* g1, 00712 const GEOSGeometry* g2); 00713 extern char GEOS_DLL GEOSOverlaps_r(GEOSContextHandle_t handle, 00714 const GEOSGeometry* g1, 00715 const GEOSGeometry* g2); 00716 extern char GEOS_DLL GEOSEquals_r(GEOSContextHandle_t handle, 00717 const GEOSGeometry* g1, 00718 const GEOSGeometry* g2); 00719 extern char GEOS_DLL GEOSEqualsExact_r(GEOSContextHandle_t handle, 00720 const GEOSGeometry* g1, 00721 const GEOSGeometry* g2, 00722 double tolerance); 00723 extern char GEOS_DLL GEOSCovers_r(GEOSContextHandle_t handle, 00724 const GEOSGeometry* g1, 00725 const GEOSGeometry* g2); 00726 extern char GEOS_DLL GEOSCoveredBy_r(GEOSContextHandle_t handle, 00727 const GEOSGeometry* g1, 00728 const GEOSGeometry* g2); 00729 00730 /************************************************************************ 00731 * 00732 * Prepared Geometry Binary predicates - return 2 on exception, 1 on true, 0 on false 00733 * 00734 ***********************************************************************/ 00735 00736 /* 00737 * GEOSGeometry ownership is retained by caller 00738 */ 00739 extern const GEOSPreparedGeometry GEOS_DLL *GEOSPrepare_r( 00740 GEOSContextHandle_t handle, 00741 const GEOSGeometry* g); 00742 00743 extern void GEOS_DLL GEOSPreparedGeom_destroy_r(GEOSContextHandle_t handle, 00744 const GEOSPreparedGeometry* g); 00745 00746 extern char GEOS_DLL GEOSPreparedContains_r(GEOSContextHandle_t handle, 00747 const GEOSPreparedGeometry* pg1, 00748 const GEOSGeometry* g2); 00749 extern char GEOS_DLL GEOSPreparedContainsProperly_r(GEOSContextHandle_t handle, 00750 const GEOSPreparedGeometry* pg1, 00751 const GEOSGeometry* g2); 00752 extern char GEOS_DLL GEOSPreparedCoveredBy_r(GEOSContextHandle_t handle, 00753 const GEOSPreparedGeometry* pg1, 00754 const GEOSGeometry* g2); 00755 extern char GEOS_DLL GEOSPreparedCovers_r(GEOSContextHandle_t handle, 00756 const GEOSPreparedGeometry* pg1, 00757 const GEOSGeometry* g2); 00758 extern char GEOS_DLL GEOSPreparedCrosses_r(GEOSContextHandle_t handle, 00759 const GEOSPreparedGeometry* pg1, 00760 const GEOSGeometry* g2); 00761 extern char GEOS_DLL GEOSPreparedDisjoint_r(GEOSContextHandle_t handle, 00762 const GEOSPreparedGeometry* pg1, 00763 const GEOSGeometry* g2); 00764 extern char GEOS_DLL GEOSPreparedIntersects_r(GEOSContextHandle_t handle, 00765 const GEOSPreparedGeometry* pg1, 00766 const GEOSGeometry* g2); 00767 extern char GEOS_DLL GEOSPreparedOverlaps_r(GEOSContextHandle_t handle, 00768 const GEOSPreparedGeometry* pg1, 00769 const GEOSGeometry* g2); 00770 extern char GEOS_DLL GEOSPreparedTouches_r(GEOSContextHandle_t handle, 00771 const GEOSPreparedGeometry* pg1, 00772 const GEOSGeometry* g2); 00773 extern char GEOS_DLL GEOSPreparedWithin_r(GEOSContextHandle_t handle, 00774 const GEOSPreparedGeometry* pg1, 00775 const GEOSGeometry* g2); 00776 00777 /************************************************************************ 00778 * 00779 * STRtree functions 00780 * 00781 ***********************************************************************/ 00782 00783 /* 00784 * GEOSGeometry ownership is retained by caller 00785 */ 00786 00787 extern GEOSSTRtree GEOS_DLL *GEOSSTRtree_create_r( 00788 GEOSContextHandle_t handle, 00789 size_t nodeCapacity); 00790 extern void GEOS_DLL GEOSSTRtree_insert_r(GEOSContextHandle_t handle, 00791 GEOSSTRtree *tree, 00792 const GEOSGeometry *g, 00793 void *item); 00794 extern void GEOS_DLL GEOSSTRtree_query_r(GEOSContextHandle_t handle, 00795 GEOSSTRtree *tree, 00796 const GEOSGeometry *g, 00797 GEOSQueryCallback callback, 00798 void *userdata); 00799 extern void GEOS_DLL GEOSSTRtree_iterate_r(GEOSContextHandle_t handle, 00800 GEOSSTRtree *tree, 00801 GEOSQueryCallback callback, 00802 void *userdata); 00803 extern char GEOS_DLL GEOSSTRtree_remove_r(GEOSContextHandle_t handle, 00804 GEOSSTRtree *tree, 00805 const GEOSGeometry *g, 00806 void *item); 00807 extern void GEOS_DLL GEOSSTRtree_destroy_r(GEOSContextHandle_t handle, 00808 GEOSSTRtree *tree); 00809 00810 00811 /************************************************************************ 00812 * 00813 * Unary predicate - return 2 on exception, 1 on true, 0 on false 00814 * 00815 ***********************************************************************/ 00816 00817 extern char GEOS_DLL GEOSisEmpty_r(GEOSContextHandle_t handle, 00818 const GEOSGeometry* g); 00819 extern char GEOS_DLL GEOSisSimple_r(GEOSContextHandle_t handle, 00820 const GEOSGeometry* g); 00821 extern char GEOS_DLL GEOSisRing_r(GEOSContextHandle_t handle, 00822 const GEOSGeometry* g); 00823 extern char GEOS_DLL GEOSHasZ_r(GEOSContextHandle_t handle, 00824 const GEOSGeometry* g); 00825 extern char GEOS_DLL GEOSisClosed_r(GEOSContextHandle_t handle, 00826 const GEOSGeometry *g); 00827 00828 /************************************************************************ 00829 * 00830 * Dimensionally Extended 9 Intersection Model related 00831 * 00832 ***********************************************************************/ 00833 00834 /* These are for use with GEOSRelateBoundaryNodeRule (flags param) */ 00835 enum GEOSRelateBoundaryNodeRules { 00836 /* MOD2 and OGC are the same rule, and is the default 00837 * used by GEOSRelatePattern 00838 */ 00839 GEOSRELATE_BNR_MOD2=1, 00840 GEOSRELATE_BNR_OGC=1, 00841 GEOSRELATE_BNR_ENDPOINT=2, 00842 GEOSRELATE_BNR_MULTIVALENT_ENDPOINT=3, 00843 GEOSRELATE_BNR_MONOVALENT_ENDPOINT=4 00844 }; 00845 00846 /* return 2 on exception, 1 on true, 0 on false */ 00847 extern char GEOS_DLL GEOSRelatePattern_r(GEOSContextHandle_t handle, 00848 const GEOSGeometry* g1, 00849 const GEOSGeometry* g2, 00850 const char *pat); 00851 00852 /* return NULL on exception, a string to GEOSFree otherwise */ 00853 extern char GEOS_DLL *GEOSRelate_r(GEOSContextHandle_t handle, 00854 const GEOSGeometry* g1, 00855 const GEOSGeometry* g2); 00856 00857 /* return 2 on exception, 1 on true, 0 on false */ 00858 extern char GEOS_DLL GEOSRelatePatternMatch_r(GEOSContextHandle_t handle, 00859 const char *mat, 00860 const char *pat); 00861 00862 /* return NULL on exception, a string to GEOSFree otherwise */ 00863 extern char GEOS_DLL *GEOSRelateBoundaryNodeRule_r(GEOSContextHandle_t handle, 00864 const GEOSGeometry* g1, 00865 const GEOSGeometry* g2, 00866 int bnr); 00867 00868 /************************************************************************ 00869 * 00870 * Validity checking 00871 * 00872 ***********************************************************************/ 00873 00874 /* These are for use with GEOSisValidDetail (flags param) */ 00875 enum GEOSValidFlags { 00876 GEOSVALID_ALLOW_SELFTOUCHING_RING_FORMING_HOLE=1 00877 }; 00878 00879 /* return 2 on exception, 1 on true, 0 on false */ 00880 extern char GEOS_DLL GEOSisValid_r(GEOSContextHandle_t handle, 00881 const GEOSGeometry* g); 00882 00883 /* return NULL on exception, a string to GEOSFree otherwise */ 00884 extern char GEOS_DLL *GEOSisValidReason_r(GEOSContextHandle_t handle, 00885 const GEOSGeometry* g); 00886 00887 /* 00888 * Caller has the responsibility to destroy 'reason' (GEOSFree) 00889 * and 'location' (GEOSGeom_destroy) params 00890 * return 2 on exception, 1 when valid, 0 when invalid 00891 */ 00892 extern char GEOS_DLL GEOSisValidDetail_r(GEOSContextHandle_t handle, 00893 const GEOSGeometry* g, 00894 int flags, 00895 char** reason, 00896 GEOSGeometry** location); 00897 00898 /************************************************************************ 00899 * 00900 * Geometry info 00901 * 00902 ***********************************************************************/ 00903 00904 /* Return NULL on exception, result must be freed by caller. */ 00905 extern char GEOS_DLL *GEOSGeomType_r(GEOSContextHandle_t handle, 00906 const GEOSGeometry* g); 00907 00908 /* Return -1 on exception */ 00909 extern int GEOS_DLL GEOSGeomTypeId_r(GEOSContextHandle_t handle, 00910 const GEOSGeometry* g); 00911 00912 /* Return 0 on exception */ 00913 extern int GEOS_DLL GEOSGetSRID_r(GEOSContextHandle_t handle, 00914 const GEOSGeometry* g); 00915 00916 extern void GEOS_DLL GEOSSetSRID_r(GEOSContextHandle_t handle, 00917 GEOSGeometry* g, int SRID); 00918 00919 /* May be called on all geometries in GEOS 3.x, returns -1 on error and 1 00920 * for non-multi geometries. Older GEOS versions only accept 00921 * GeometryCollections or Multi* geometries here, and are likely to crash 00922 * when fed simple geometries, so beware if you need compatibility with 00923 * old GEOS versions. 00924 */ 00925 extern int GEOS_DLL GEOSGetNumGeometries_r(GEOSContextHandle_t handle, 00926 const GEOSGeometry* g); 00927 00928 /* 00929 * Return NULL on exception. 00930 * Returned object is a pointer to internal storage: 00931 * it must NOT be destroyed directly. 00932 * Up to GEOS 3.2.0 the input geometry must be a Collection, in 00933 * later version it doesn't matter (getGeometryN(0) for a single will 00934 * return the input). 00935 */ 00936 extern const GEOSGeometry GEOS_DLL *GEOSGetGeometryN_r( 00937 GEOSContextHandle_t handle, 00938 const GEOSGeometry* g, int n); 00939 00940 /* Return -1 on exception */ 00941 extern int GEOS_DLL GEOSNormalize_r(GEOSContextHandle_t handle, 00942 GEOSGeometry* g); 00943 00944 /* Return -1 on exception */ 00945 extern int GEOS_DLL GEOSGetNumInteriorRings_r(GEOSContextHandle_t handle, 00946 const GEOSGeometry* g); 00947 00948 /* Return -1 on exception, Geometry must be a LineString. */ 00949 extern int GEOS_DLL GEOSGeomGetNumPoints_r(GEOSContextHandle_t handle, 00950 const GEOSGeometry* g); 00951 00952 /* Return -1 on exception, Geometry must be a Point. */ 00953 extern int GEOS_DLL GEOSGeomGetX_r(GEOSContextHandle_t handle, const GEOSGeometry *g, double *x); 00954 extern int GEOS_DLL GEOSGeomGetY_r(GEOSContextHandle_t handle, const GEOSGeometry *g, double *y); 00955 00956 /* 00957 * Return NULL on exception, Geometry must be a Polygon. 00958 * Returned object is a pointer to internal storage: 00959 * it must NOT be destroyed directly. 00960 */ 00961 extern const GEOSGeometry GEOS_DLL *GEOSGetInteriorRingN_r( 00962 GEOSContextHandle_t handle, 00963 const GEOSGeometry* g, int n); 00964 00965 /* 00966 * Return NULL on exception, Geometry must be a Polygon. 00967 * Returned object is a pointer to internal storage: 00968 * it must NOT be destroyed directly. 00969 */ 00970 extern const GEOSGeometry GEOS_DLL *GEOSGetExteriorRing_r( 00971 GEOSContextHandle_t handle, 00972 const GEOSGeometry* g); 00973 00974 /* Return -1 on exception */ 00975 extern int GEOS_DLL GEOSGetNumCoordinates_r(GEOSContextHandle_t handle, 00976 const GEOSGeometry* g); 00977 00978 /* 00979 * Return NULL on exception. 00980 * Geometry must be a LineString, LinearRing or Point. 00981 */ 00982 extern const GEOSCoordSequence GEOS_DLL *GEOSGeom_getCoordSeq_r( 00983 GEOSContextHandle_t handle, 00984 const GEOSGeometry* g); 00985 00986 /* 00987 * Return 0 on exception (or empty geometry) 00988 */ 00989 extern int GEOS_DLL GEOSGeom_getDimensions_r(GEOSContextHandle_t handle, 00990 const GEOSGeometry* g); 00991 00992 /* 00993 * Return 2 or 3. 00994 */ 00995 extern int GEOS_DLL GEOSGeom_getCoordinateDimension_r(GEOSContextHandle_t handle, 00996 const GEOSGeometry* g); 00997 00998 /* 00999 * Return NULL on exception. 01000 * Must be LineString and must be freed by called. 01001 */ 01002 extern GEOSGeometry GEOS_DLL *GEOSGeomGetPointN_r(GEOSContextHandle_t handle, const GEOSGeometry *g, int n); 01003 extern GEOSGeometry GEOS_DLL *GEOSGeomGetStartPoint_r(GEOSContextHandle_t handle, const GEOSGeometry *g); 01004 extern GEOSGeometry GEOS_DLL *GEOSGeomGetEndPoint_r(GEOSContextHandle_t handle, const GEOSGeometry *g); 01005 01006 /************************************************************************ 01007 * 01008 * Misc functions 01009 * 01010 ***********************************************************************/ 01011 01012 /* Return 0 on exception, 1 otherwise */ 01013 extern int GEOS_DLL GEOSArea_r(GEOSContextHandle_t handle, 01014 const GEOSGeometry* g, double *area); 01015 extern int GEOS_DLL GEOSLength_r(GEOSContextHandle_t handle, 01016 const GEOSGeometry* g, double *length); 01017 extern int GEOS_DLL GEOSDistance_r(GEOSContextHandle_t handle, 01018 const GEOSGeometry* g1, 01019 const GEOSGeometry* g2, double *dist); 01020 extern int GEOS_DLL GEOSHausdorffDistance_r(GEOSContextHandle_t handle, 01021 const GEOSGeometry *g1, 01022 const GEOSGeometry *g2, 01023 double *dist); 01024 extern int GEOS_DLL GEOSHausdorffDistanceDensify_r(GEOSContextHandle_t handle, 01025 const GEOSGeometry *g1, 01026 const GEOSGeometry *g2, 01027 double densifyFrac, double *dist); 01028 extern int GEOS_DLL GEOSGeomGetLength_r(GEOSContextHandle_t handle, 01029 const GEOSGeometry *g, double *length); 01030 01031 /* Return 0 on exception, the closest points of the two geometries otherwise. 01032 * The first point comes from g1 geometry and the second point comes from g2. 01033 */ 01034 extern GEOSCoordSequence GEOS_DLL *GEOSNearestPoints_r( 01035 GEOSContextHandle_t handle, const GEOSGeometry* g1, const GEOSGeometry* g2); 01036 01037 01038 /************************************************************************ 01039 * 01040 * Algorithms 01041 * 01042 ***********************************************************************/ 01043 01044 /* Walking from A to B: 01045 * return -1 if reaching P takes a counter-clockwise (left) turn 01046 * return 1 if reaching P takes a clockwise (right) turn 01047 * return 0 if P is collinear with A-B 01048 * 01049 * On exceptions, return 2. 01050 * 01051 */ 01052 extern int GEOS_DLL GEOSOrientationIndex_r(GEOSContextHandle_t handle, 01053 double Ax, double Ay, double Bx, double By, double Px, double Py); 01054 01055 01056 /************************************************************************ 01057 * 01058 * Reader and Writer APIs 01059 * 01060 ***********************************************************************/ 01061 01062 typedef struct GEOSWKTReader_t GEOSWKTReader; 01063 typedef struct GEOSWKTWriter_t GEOSWKTWriter; 01064 typedef struct GEOSWKBReader_t GEOSWKBReader; 01065 typedef struct GEOSWKBWriter_t GEOSWKBWriter; 01066 01067 01068 /* WKT Reader */ 01069 extern GEOSWKTReader GEOS_DLL *GEOSWKTReader_create_r( 01070 GEOSContextHandle_t handle); 01071 extern void GEOS_DLL GEOSWKTReader_destroy_r(GEOSContextHandle_t handle, 01072 GEOSWKTReader* reader); 01073 extern GEOSGeometry GEOS_DLL *GEOSWKTReader_read_r(GEOSContextHandle_t handle, 01074 GEOSWKTReader* reader, 01075 const char *wkt); 01076 01077 /* WKT Writer */ 01078 extern GEOSWKTWriter GEOS_DLL *GEOSWKTWriter_create_r( 01079 GEOSContextHandle_t handle); 01080 extern void GEOS_DLL GEOSWKTWriter_destroy_r(GEOSContextHandle_t handle, 01081 GEOSWKTWriter* writer); 01082 extern char GEOS_DLL *GEOSWKTWriter_write_r(GEOSContextHandle_t handle, 01083 GEOSWKTWriter* writer, 01084 const GEOSGeometry* g); 01085 extern void GEOS_DLL GEOSWKTWriter_setTrim_r(GEOSContextHandle_t handle, 01086 GEOSWKTWriter *writer, 01087 char trim); 01088 extern void GEOS_DLL GEOSWKTWriter_setRoundingPrecision_r(GEOSContextHandle_t handle, 01089 GEOSWKTWriter *writer, 01090 int precision); 01091 extern void GEOS_DLL GEOSWKTWriter_setOutputDimension_r(GEOSContextHandle_t handle, 01092 GEOSWKTWriter *writer, 01093 int dim); 01094 extern int GEOS_DLL GEOSWKTWriter_getOutputDimension_r(GEOSContextHandle_t handle, 01095 GEOSWKTWriter *writer); 01096 extern void GEOS_DLL GEOSWKTWriter_setOld3D_r(GEOSContextHandle_t handle, 01097 GEOSWKTWriter *writer, 01098 int useOld3D); 01099 01100 /* WKB Reader */ 01101 extern GEOSWKBReader GEOS_DLL *GEOSWKBReader_create_r( 01102 GEOSContextHandle_t handle); 01103 extern void GEOS_DLL GEOSWKBReader_destroy_r(GEOSContextHandle_t handle, 01104 GEOSWKBReader* reader); 01105 extern GEOSGeometry GEOS_DLL *GEOSWKBReader_read_r(GEOSContextHandle_t handle, 01106 GEOSWKBReader* reader, 01107 const unsigned char *wkb, 01108 size_t size); 01109 extern GEOSGeometry GEOS_DLL *GEOSWKBReader_readHEX_r( 01110 GEOSContextHandle_t handle, 01111 GEOSWKBReader* reader, 01112 const unsigned char *hex, 01113 size_t size); 01114 01115 /* WKB Writer */ 01116 extern GEOSWKBWriter GEOS_DLL *GEOSWKBWriter_create_r( 01117 GEOSContextHandle_t handle); 01118 extern void GEOS_DLL GEOSWKBWriter_destroy_r(GEOSContextHandle_t handle, 01119 GEOSWKBWriter* writer); 01120 01121 /* The caller owns the results for these two methods! */ 01122 extern unsigned char GEOS_DLL *GEOSWKBWriter_write_r( 01123 GEOSContextHandle_t handle, 01124 GEOSWKBWriter* writer, 01125 const GEOSGeometry* g, 01126 size_t *size); 01127 extern unsigned char GEOS_DLL *GEOSWKBWriter_writeHEX_r( 01128 GEOSContextHandle_t handle, 01129 GEOSWKBWriter* writer, 01130 const GEOSGeometry* g, 01131 size_t *size); 01132 01133 /* 01134 * Specify whether output WKB should be 2d or 3d. 01135 * Return previously set number of dimensions. 01136 */ 01137 extern int GEOS_DLL GEOSWKBWriter_getOutputDimension_r( 01138 GEOSContextHandle_t handle, 01139 const GEOSWKBWriter* writer); 01140 extern void GEOS_DLL GEOSWKBWriter_setOutputDimension_r( 01141 GEOSContextHandle_t handle, 01142 GEOSWKBWriter* writer, int newDimension); 01143 01144 /* 01145 * Specify whether the WKB byte order is big or little endian. 01146 * The return value is the previous byte order. 01147 */ 01148 extern int GEOS_DLL GEOSWKBWriter_getByteOrder_r(GEOSContextHandle_t handle, 01149 const GEOSWKBWriter* writer); 01150 extern void GEOS_DLL GEOSWKBWriter_setByteOrder_r(GEOSContextHandle_t handle, 01151 GEOSWKBWriter* writer, 01152 int byteOrder); 01153 01154 /* 01155 * Specify whether SRID values should be output. 01156 */ 01157 extern char GEOS_DLL GEOSWKBWriter_getIncludeSRID_r(GEOSContextHandle_t handle, 01158 const GEOSWKBWriter* writer); 01159 extern void GEOS_DLL GEOSWKBWriter_setIncludeSRID_r(GEOSContextHandle_t handle, 01160 GEOSWKBWriter* writer, const char writeSRID); 01161 01162 01163 /* 01164 * Free buffers returned by stuff like GEOSWKBWriter_write(), 01165 * GEOSWKBWriter_writeHEX() and GEOSWKTWriter_write(). 01166 */ 01167 extern void GEOS_DLL GEOSFree_r(GEOSContextHandle_t handle, void *buffer); 01168 01169 01170 /* External code to GEOS can define GEOS_USE_ONLY_R_API to avoid the */ 01171 /* non _r API to be available */ 01172 #ifndef GEOS_USE_ONLY_R_API 01173 01174 /************************************************************************ 01175 * 01176 * Initialization, cleanup, version 01177 * 01178 ***********************************************************************/ 01179 01180 extern void GEOS_DLL initGEOS(GEOSMessageHandler notice_function, 01181 GEOSMessageHandler error_function); 01182 extern void GEOS_DLL finishGEOS(void); 01183 01184 /************************************************************************ 01185 * 01186 * NOTE - These functions are DEPRECATED. Please use the new Reader and 01187 * writer APIS! 01188 * 01189 ***********************************************************************/ 01190 01191 extern GEOSGeometry GEOS_DLL *GEOSGeomFromWKT(const char *wkt); 01192 extern char GEOS_DLL *GEOSGeomToWKT(const GEOSGeometry* g); 01193 01194 /* 01195 * Specify whether output WKB should be 2d or 3d. 01196 * Return previously set number of dimensions. 01197 */ 01198 extern int GEOS_DLL GEOS_getWKBOutputDims(); 01199 extern int GEOS_DLL GEOS_setWKBOutputDims(int newDims); 01200 01201 /* 01202 * Specify whether the WKB byte order is big or little endian. 01203 * The return value is the previous byte order. 01204 */ 01205 extern int GEOS_DLL GEOS_getWKBByteOrder(); 01206 extern int GEOS_DLL GEOS_setWKBByteOrder(int byteOrder); 01207 01208 extern GEOSGeometry GEOS_DLL *GEOSGeomFromWKB_buf(const unsigned char *wkb, size_t size); 01209 extern unsigned char GEOS_DLL *GEOSGeomToWKB_buf(const GEOSGeometry* g, size_t *size); 01210 01211 extern GEOSGeometry GEOS_DLL *GEOSGeomFromHEX_buf(const unsigned char *hex, size_t size); 01212 extern unsigned char GEOS_DLL *GEOSGeomToHEX_buf(const GEOSGeometry* g, size_t *size); 01213 01214 /************************************************************************ 01215 * 01216 * Coordinate Sequence functions 01217 * 01218 ***********************************************************************/ 01219 01220 /* 01221 * Create a Coordinate sequence with ``size'' coordinates 01222 * of ``dims'' dimensions. 01223 * Return NULL on exception. 01224 */ 01225 extern GEOSCoordSequence GEOS_DLL *GEOSCoordSeq_create(unsigned int size, unsigned int dims); 01226 01227 /* 01228 * Clone a Coordinate Sequence. 01229 * Return NULL on exception. 01230 */ 01231 extern GEOSCoordSequence GEOS_DLL *GEOSCoordSeq_clone(const GEOSCoordSequence* s); 01232 01233 /* 01234 * Destroy a Coordinate Sequence. 01235 */ 01236 extern void GEOS_DLL GEOSCoordSeq_destroy(GEOSCoordSequence* s); 01237 01238 /* 01239 * Set ordinate values in a Coordinate Sequence. 01240 * Return 0 on exception. 01241 */ 01242 extern int GEOS_DLL GEOSCoordSeq_setX(GEOSCoordSequence* s, 01243 unsigned int idx, double val); 01244 extern int GEOS_DLL GEOSCoordSeq_setY(GEOSCoordSequence* s, 01245 unsigned int idx, double val); 01246 extern int GEOS_DLL GEOSCoordSeq_setZ(GEOSCoordSequence* s, 01247 unsigned int idx, double val); 01248 extern int GEOS_DLL GEOSCoordSeq_setOrdinate(GEOSCoordSequence* s, 01249 unsigned int idx, unsigned int dim, double val); 01250 01251 /* 01252 * Get ordinate values from a Coordinate Sequence. 01253 * Return 0 on exception. 01254 */ 01255 extern int GEOS_DLL GEOSCoordSeq_getX(const GEOSCoordSequence* s, 01256 unsigned int idx, double *val); 01257 extern int GEOS_DLL GEOSCoordSeq_getY(const GEOSCoordSequence* s, 01258 unsigned int idx, double *val); 01259 extern int GEOS_DLL GEOSCoordSeq_getZ(const GEOSCoordSequence* s, 01260 unsigned int idx, double *val); 01261 extern int GEOS_DLL GEOSCoordSeq_getOrdinate(const GEOSCoordSequence* s, 01262 unsigned int idx, unsigned int dim, double *val); 01263 /* 01264 * Get size and dimensions info from a Coordinate Sequence. 01265 * Return 0 on exception. 01266 */ 01267 extern int GEOS_DLL GEOSCoordSeq_getSize(const GEOSCoordSequence* s, 01268 unsigned int *size); 01269 extern int GEOS_DLL GEOSCoordSeq_getDimensions(const GEOSCoordSequence* s, 01270 unsigned int *dims); 01271 01272 /************************************************************************ 01273 * 01274 * Linear referencing functions -- there are more, but these are 01275 * probably sufficient for most purposes 01276 * 01277 ***********************************************************************/ 01278 01279 /* 01280 * GEOSGeometry ownership is retained by caller 01281 */ 01282 01283 01284 /* Return distance of point 'p' projected on 'g' from origin 01285 * of 'g'. Geometry 'g' must be a lineal geometry */ 01286 extern double GEOS_DLL GEOSProject(const GEOSGeometry *g, 01287 const GEOSGeometry* p); 01288 01289 /* Return closest point to given distance within geometry 01290 * Geometry must be a LineString */ 01291 extern GEOSGeometry GEOS_DLL *GEOSInterpolate(const GEOSGeometry *g, 01292 double d); 01293 01294 extern double GEOS_DLL GEOSProjectNormalized(const GEOSGeometry *g, 01295 const GEOSGeometry* p); 01296 01297 extern GEOSGeometry GEOS_DLL *GEOSInterpolateNormalized(const GEOSGeometry *g, 01298 double d); 01299 01300 /************************************************************************ 01301 * 01302 * Buffer related functions 01303 * 01304 ***********************************************************************/ 01305 01306 01307 /* @return NULL on exception */ 01308 extern GEOSGeometry GEOS_DLL *GEOSBuffer(const GEOSGeometry* g, 01309 double width, int quadsegs); 01310 01311 /* @return 0 on exception */ 01312 extern GEOSBufferParams GEOS_DLL *GEOSBufferParams_create(); 01313 extern void GEOS_DLL GEOSBufferParams_destroy(GEOSBufferParams* parms); 01314 01315 /* @return 0 on exception */ 01316 extern int GEOS_DLL GEOSBufferParams_setEndCapStyle( 01317 GEOSBufferParams* p, 01318 int style); 01319 01320 /* @return 0 on exception */ 01321 extern int GEOS_DLL GEOSBufferParams_setJoinStyle( 01322 GEOSBufferParams* p, 01323 int joinStyle); 01324 01325 /* @return 0 on exception */ 01326 extern int GEOS_DLL GEOSBufferParams_setMitreLimit( 01327 GEOSBufferParams* p, 01328 double mitreLimit); 01329 01330 /* @return 0 on exception */ 01331 extern int GEOS_DLL GEOSBufferParams_setQuadrantSegments( 01332 GEOSBufferParams* p, 01333 int quadSegs); 01334 01335 /* @param singleSided: 1 for single sided, 0 otherwise */ 01336 /* @return 0 on exception */ 01337 extern int GEOS_DLL GEOSBufferParams_setSingleSided( 01338 GEOSBufferParams* p, 01339 int singleSided); 01340 01341 /* @return NULL on exception */ 01342 extern GEOSGeometry GEOS_DLL *GEOSBufferWithParams( 01343 const GEOSGeometry* g, 01344 const GEOSBufferParams* p, 01345 double width); 01346 01347 /* These functions return NULL on exception. */ 01348 extern GEOSGeometry GEOS_DLL *GEOSBufferWithStyle(const GEOSGeometry* g, 01349 double width, int quadsegs, int endCapStyle, int joinStyle, 01350 double mitreLimit); 01351 01352 /* These functions return NULL on exception. Only LINESTRINGs are accepted. */ 01353 /* @deprecated in 3.3.0: use GEOSOffsetCurve instead */ 01354 extern GEOSGeometry GEOS_DLL *GEOSSingleSidedBuffer(const GEOSGeometry* g, 01355 double width, int quadsegs, int joinStyle, double mitreLimit, 01356 int leftSide); 01357 01358 /* 01359 * Only LINESTRINGs are accepted. 01360 * @param width : offset distance. 01361 * negative for right side offset. 01362 * positive for left side offset. 01363 * @return NULL on exception 01364 */ 01365 extern GEOSGeometry GEOS_DLL *GEOSOffsetCurve(const GEOSGeometry* g, 01366 double width, int quadsegs, int joinStyle, double mitreLimit); 01367 01368 /************************************************************************ 01369 * 01370 * Geometry Constructors. 01371 * GEOSCoordSequence* arguments will become ownership of the returned object. 01372 * All functions return NULL on exception. 01373 * 01374 ***********************************************************************/ 01375 01376 extern GEOSGeometry GEOS_DLL *GEOSGeom_createPoint(GEOSCoordSequence* s); 01377 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyPoint(); 01378 extern GEOSGeometry GEOS_DLL *GEOSGeom_createLinearRing(GEOSCoordSequence* s); 01379 extern GEOSGeometry GEOS_DLL *GEOSGeom_createLineString(GEOSCoordSequence* s); 01380 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyLineString(); 01381 01382 /* 01383 * Second argument is an array of GEOSGeometry* objects. 01384 * The caller remains owner of the array, but pointed-to 01385 * objects become ownership of the returned GEOSGeometry. 01386 */ 01387 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyPolygon(); 01388 extern GEOSGeometry GEOS_DLL *GEOSGeom_createPolygon(GEOSGeometry* shell, 01389 GEOSGeometry** holes, unsigned int nholes); 01390 extern GEOSGeometry GEOS_DLL *GEOSGeom_createCollection(int type, 01391 GEOSGeometry* *geoms, unsigned int ngeoms); 01392 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyCollection(int type); 01393 01394 extern GEOSGeometry GEOS_DLL *GEOSGeom_clone(const GEOSGeometry* g); 01395 01396 /************************************************************************ 01397 * 01398 * Memory management 01399 * 01400 ***********************************************************************/ 01401 01402 extern void GEOS_DLL GEOSGeom_destroy(GEOSGeometry* g); 01403 01404 /************************************************************************ 01405 * 01406 * Topology operations - return NULL on exception. 01407 * 01408 ***********************************************************************/ 01409 01410 extern GEOSGeometry GEOS_DLL *GEOSEnvelope(const GEOSGeometry* g); 01411 extern GEOSGeometry GEOS_DLL *GEOSIntersection(const GEOSGeometry* g1, const GEOSGeometry* g2); 01412 extern GEOSGeometry GEOS_DLL *GEOSConvexHull(const GEOSGeometry* g); 01413 extern GEOSGeometry GEOS_DLL *GEOSDifference(const GEOSGeometry* g1, const GEOSGeometry* g2); 01414 extern GEOSGeometry GEOS_DLL *GEOSSymDifference(const GEOSGeometry* g1, const GEOSGeometry* g2); 01415 extern GEOSGeometry GEOS_DLL *GEOSBoundary(const GEOSGeometry* g); 01416 extern GEOSGeometry GEOS_DLL *GEOSUnion(const GEOSGeometry* g1, const GEOSGeometry* g2); 01417 extern GEOSGeometry GEOS_DLL *GEOSUnaryUnion(const GEOSGeometry* g); 01418 01419 /* @deprecated in 3.3.0: use GEOSUnaryUnion instead */ 01420 extern GEOSGeometry GEOS_DLL *GEOSUnionCascaded(const GEOSGeometry* g); 01421 extern GEOSGeometry GEOS_DLL *GEOSPointOnSurface(const GEOSGeometry* g); 01422 extern GEOSGeometry GEOS_DLL *GEOSGetCentroid(const GEOSGeometry* g); 01423 extern GEOSGeometry GEOS_DLL *GEOSNode(const GEOSGeometry* g); 01424 extern GEOSGeometry GEOS_DLL *GEOSClipByRect(const GEOSGeometry* g, double xmin, double ymin, double xmax, double ymax); 01425 01426 /* 01427 * all arguments remain ownership of the caller 01428 * (both Geometries and pointers) 01429 */ 01430 extern GEOSGeometry GEOS_DLL *GEOSPolygonize(const GEOSGeometry * const geoms[], unsigned int ngeoms); 01431 extern GEOSGeometry GEOS_DLL *GEOSPolygonizer_getCutEdges(const GEOSGeometry * const geoms[], unsigned int ngeoms); 01432 /* 01433 * Polygonizes a set of Geometries which contain linework that 01434 * represents the edges of a planar graph. 01435 * 01436 * Any dimension of Geometry is handled - the constituent linework 01437 * is extracted to form the edges. 01438 * 01439 * The edges must be correctly noded; that is, they must only meet 01440 * at their endpoints. 01441 * The Polygonizer will still run on incorrectly noded input 01442 * but will not form polygons from incorrectly noded edges. 01443 * 01444 * The Polygonizer reports the follow kinds of errors: 01445 * 01446 * - Dangles - edges which have one or both ends which are 01447 * not incident on another edge endpoint 01448 * - Cut Edges - edges which are connected at both ends but 01449 * which do not form part of polygon 01450 * - Invalid Ring Lines - edges which form rings which are invalid 01451 * (e.g. the component lines contain a self-intersection) 01452 * 01453 * Errors are reported to output parameters "cuts", "dangles" and 01454 * "invalid" (if not-null). Formed polygons are returned as a 01455 * collection. NULL is returned on exception. All returned 01456 * geometries must be destroyed by caller. 01457 * 01458 */ 01459 extern GEOSGeometry GEOS_DLL *GEOSPolygonize_full(const GEOSGeometry* input, 01460 GEOSGeometry** cuts, GEOSGeometry** dangles, GEOSGeometry** invalid); 01461 01462 extern GEOSGeometry GEOS_DLL *GEOSLineMerge(const GEOSGeometry* g); 01463 extern GEOSGeometry GEOS_DLL *GEOSSimplify(const GEOSGeometry* g, double tolerance); 01464 extern GEOSGeometry GEOS_DLL *GEOSTopologyPreserveSimplify(const GEOSGeometry* g, 01465 double tolerance); 01466 01467 /* 01468 * Return all distinct vertices of input geometry as a MULTIPOINT. 01469 * Note that only 2 dimensions of the vertices are considered when 01470 * testing for equality. 01471 */ 01472 extern GEOSGeometry GEOS_DLL *GEOSGeom_extractUniquePoints( 01473 const GEOSGeometry* g); 01474 01475 /* 01476 * Find paths shared between the two given lineal geometries. 01477 * 01478 * Returns a GEOMETRYCOLLECTION having two elements: 01479 * - first element is a MULTILINESTRING containing shared paths 01480 * having the _same_ direction on both inputs 01481 * - second element is a MULTILINESTRING containing shared paths 01482 * having the _opposite_ direction on the two inputs 01483 * 01484 * Returns NULL on exception 01485 */ 01486 extern GEOSGeometry GEOS_DLL *GEOSSharedPaths(const GEOSGeometry* g1, 01487 const GEOSGeometry* g2); 01488 01489 /* 01490 * Snap first geometry on to second with given tolerance 01491 * Returns a newly allocated geometry, or NULL on exception 01492 */ 01493 extern GEOSGeometry GEOS_DLL *GEOSSnap(const GEOSGeometry* g1, 01494 const GEOSGeometry* g2, double tolerance); 01495 01496 /* 01497 * Return a Delaunay triangulation of the vertex of the given geometry 01498 * 01499 * @param g the input geometry whose vertex will be used as "sites" 01500 * @param tolerance optional snapping tolerance to use for improved robustness 01501 * @param onlyEdges if non-zero will return a MULTILINESTRING, otherwise it will 01502 * return a GEOMETRYCOLLECTION containing triangular POLYGONs. 01503 * 01504 * @return a newly allocated geometry, or NULL on exception 01505 */ 01506 extern GEOSGeometry GEOS_DLL * GEOSDelaunayTriangulation( 01507 const GEOSGeometry *g, 01508 double tolerance, 01509 int onlyEdges); 01510 01511 /* 01512 * Returns the Voronoi polygons of a set of Vertices given as input 01513 * 01514 * @param g the input geometry whose vertex will be used as sites. 01515 * @param tolerance snapping tolerance to use for improved robustness 01516 * @param onlyEdges whether to return only edges of the voronoi cells 01517 * @param env clipping envelope for the returned diagram, automatically 01518 * determined if NULL. 01519 * The diagram will be clipped to the larger 01520 * of this envelope or an envelope surrounding the sites. 01521 * 01522 * @return a newly allocated geometry, or NULL on exception. 01523 */ 01524 extern GEOSGeometry GEOS_DLL * GEOSVoronoiDiagram( 01525 const GEOSGeometry *g, 01526 const GEOSGeometry *env, 01527 double tolerance, 01528 int onlyEdges); 01529 01530 /************************************************************************ 01531 * 01532 * Binary predicates - return 2 on exception, 1 on true, 0 on false 01533 * 01534 ***********************************************************************/ 01535 01536 extern char GEOS_DLL GEOSDisjoint(const GEOSGeometry* g1, const GEOSGeometry* g2); 01537 extern char GEOS_DLL GEOSTouches(const GEOSGeometry* g1, const GEOSGeometry* g2); 01538 extern char GEOS_DLL GEOSIntersects(const GEOSGeometry* g1, const GEOSGeometry* g2); 01539 extern char GEOS_DLL GEOSCrosses(const GEOSGeometry* g1, const GEOSGeometry* g2); 01540 extern char GEOS_DLL GEOSWithin(const GEOSGeometry* g1, const GEOSGeometry* g2); 01541 extern char GEOS_DLL GEOSContains(const GEOSGeometry* g1, const GEOSGeometry* g2); 01542 extern char GEOS_DLL GEOSOverlaps(const GEOSGeometry* g1, const GEOSGeometry* g2); 01543 extern char GEOS_DLL GEOSEquals(const GEOSGeometry* g1, const GEOSGeometry* g2); 01544 extern char GEOS_DLL GEOSEqualsExact(const GEOSGeometry* g1, const GEOSGeometry* g2, double tolerance); 01545 extern char GEOS_DLL GEOSCovers(const GEOSGeometry* g1, const GEOSGeometry* g2); 01546 extern char GEOS_DLL GEOSCoveredBy(const GEOSGeometry* g1, const GEOSGeometry* g2); 01547 01548 /************************************************************************ 01549 * 01550 * Prepared Geometry Binary predicates - return 2 on exception, 1 on true, 0 on false 01551 * 01552 ***********************************************************************/ 01553 01554 /* 01555 * GEOSGeometry ownership is retained by caller 01556 */ 01557 extern const GEOSPreparedGeometry GEOS_DLL *GEOSPrepare(const GEOSGeometry* g); 01558 01559 extern void GEOS_DLL GEOSPreparedGeom_destroy(const GEOSPreparedGeometry* g); 01560 01561 extern char GEOS_DLL GEOSPreparedContains(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2); 01562 extern char GEOS_DLL GEOSPreparedContainsProperly(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2); 01563 extern char GEOS_DLL GEOSPreparedCoveredBy(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2); 01564 extern char GEOS_DLL GEOSPreparedCovers(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2); 01565 extern char GEOS_DLL GEOSPreparedCrosses(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2); 01566 extern char GEOS_DLL GEOSPreparedDisjoint(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2); 01567 extern char GEOS_DLL GEOSPreparedIntersects(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2); 01568 extern char GEOS_DLL GEOSPreparedOverlaps(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2); 01569 extern char GEOS_DLL GEOSPreparedTouches(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2); 01570 extern char GEOS_DLL GEOSPreparedWithin(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2); 01571 01572 /************************************************************************ 01573 * 01574 * STRtree functions 01575 * 01576 ***********************************************************************/ 01577 01578 /* 01579 * GEOSGeometry ownership is retained by caller 01580 */ 01581 01582 extern GEOSSTRtree GEOS_DLL *GEOSSTRtree_create(size_t nodeCapacity); 01583 extern void GEOS_DLL GEOSSTRtree_insert(GEOSSTRtree *tree, 01584 const GEOSGeometry *g, 01585 void *item); 01586 extern void GEOS_DLL GEOSSTRtree_query(GEOSSTRtree *tree, 01587 const GEOSGeometry *g, 01588 GEOSQueryCallback callback, 01589 void *userdata); 01590 extern void GEOS_DLL GEOSSTRtree_iterate(GEOSSTRtree *tree, 01591 GEOSQueryCallback callback, 01592 void *userdata); 01593 extern char GEOS_DLL GEOSSTRtree_remove(GEOSSTRtree *tree, 01594 const GEOSGeometry *g, 01595 void *item); 01596 extern void GEOS_DLL GEOSSTRtree_destroy(GEOSSTRtree *tree); 01597 01598 01599 /************************************************************************ 01600 * 01601 * Unary predicate - return 2 on exception, 1 on true, 0 on false 01602 * 01603 ***********************************************************************/ 01604 01605 extern char GEOS_DLL GEOSisEmpty(const GEOSGeometry* g); 01606 extern char GEOS_DLL GEOSisSimple(const GEOSGeometry* g); 01607 extern char GEOS_DLL GEOSisRing(const GEOSGeometry* g); 01608 extern char GEOS_DLL GEOSHasZ(const GEOSGeometry* g); 01609 extern char GEOS_DLL GEOSisClosed(const GEOSGeometry *g); 01610 01611 /************************************************************************ 01612 * 01613 * Dimensionally Extended 9 Intersection Model related 01614 * 01615 ***********************************************************************/ 01616 01617 /* return 2 on exception, 1 on true, 0 on false */ 01618 extern char GEOS_DLL GEOSRelatePattern(const GEOSGeometry* g1, const GEOSGeometry* g2, const char *pat); 01619 01620 /* return NULL on exception, a string to GEOSFree otherwise */ 01621 extern char GEOS_DLL *GEOSRelate(const GEOSGeometry* g1, const GEOSGeometry* g2); 01622 01623 /* return 2 on exception, 1 on true, 0 on false */ 01624 extern char GEOS_DLL GEOSRelatePatternMatch(const char *mat, const char *pat); 01625 01626 /* return NULL on exception, a string to GEOSFree otherwise */ 01627 extern char GEOS_DLL *GEOSRelateBoundaryNodeRule(const GEOSGeometry* g1, 01628 const GEOSGeometry* g2, 01629 int bnr); 01630 01631 /************************************************************************ 01632 * 01633 * Validity checking 01634 * 01635 ***********************************************************************/ 01636 01637 /* return 2 on exception, 1 on true, 0 on false */ 01638 extern char GEOS_DLL GEOSisValid(const GEOSGeometry* g); 01639 01640 /* return NULL on exception, a string to GEOSFree otherwise */ 01641 extern char GEOS_DLL *GEOSisValidReason(const GEOSGeometry *g); 01642 /* 01643 * Caller has the responsibility to destroy 'reason' (GEOSFree) 01644 * and 'location' (GEOSGeom_destroy) params 01645 * return 2 on exception, 1 when valid, 0 when invalid 01646 * Use enum GEOSValidFlags values for the flags param. 01647 */ 01648 extern char GEOS_DLL GEOSisValidDetail(const GEOSGeometry* g, 01649 int flags, 01650 char** reason, GEOSGeometry** location); 01651 01652 /************************************************************************ 01653 * 01654 * Geometry info 01655 * 01656 ***********************************************************************/ 01657 01658 /* Return NULL on exception, result must be freed by caller. */ 01659 extern char GEOS_DLL *GEOSGeomType(const GEOSGeometry* g); 01660 01661 /* Return -1 on exception */ 01662 extern int GEOS_DLL GEOSGeomTypeId(const GEOSGeometry* g); 01663 01664 /* Return 0 on exception */ 01665 extern int GEOS_DLL GEOSGetSRID(const GEOSGeometry* g); 01666 01667 extern void GEOS_DLL GEOSSetSRID(GEOSGeometry* g, int SRID); 01668 01669 /* May be called on all geometries in GEOS 3.x, returns -1 on error and 1 01670 * for non-multi geometries. Older GEOS versions only accept 01671 * GeometryCollections or Multi* geometries here, and are likely to crash 01672 * when fed simple geometries, so beware if you need compatibility with 01673 * old GEOS versions. 01674 */ 01675 extern int GEOS_DLL GEOSGetNumGeometries(const GEOSGeometry* g); 01676 01677 /* 01678 * Return NULL on exception. 01679 * Returned object is a pointer to internal storage: 01680 * it must NOT be destroyed directly. 01681 * Up to GEOS 3.2.0 the input geometry must be a Collection, in 01682 * later version it doesn't matter (getGeometryN(0) for a single will 01683 * return the input). 01684 */ 01685 extern const GEOSGeometry GEOS_DLL *GEOSGetGeometryN(const GEOSGeometry* g, int n); 01686 01687 /* Return -1 on exception */ 01688 extern int GEOS_DLL GEOSNormalize(GEOSGeometry* g); 01689 01690 /* Return -1 on exception */ 01691 extern int GEOS_DLL GEOSGetNumInteriorRings(const GEOSGeometry* g); 01692 01693 /* Return -1 on exception, Geometry must be a LineString. */ 01694 extern int GEOS_DLL GEOSGeomGetNumPoints(const GEOSGeometry* g); 01695 01696 /* Return -1 on exception, Geometry must be a Point. */ 01697 extern int GEOS_DLL GEOSGeomGetX(const GEOSGeometry *g, double *x); 01698 extern int GEOS_DLL GEOSGeomGetY(const GEOSGeometry *g, double *y); 01699 01700 /* 01701 * Return NULL on exception, Geometry must be a Polygon. 01702 * Returned object is a pointer to internal storage: 01703 * it must NOT be destroyed directly. 01704 */ 01705 extern const GEOSGeometry GEOS_DLL *GEOSGetInteriorRingN(const GEOSGeometry* g, int n); 01706 01707 /* 01708 * Return NULL on exception, Geometry must be a Polygon. 01709 * Returned object is a pointer to internal storage: 01710 * it must NOT be destroyed directly. 01711 */ 01712 extern const GEOSGeometry GEOS_DLL *GEOSGetExteriorRing(const GEOSGeometry* g); 01713 01714 /* Return -1 on exception */ 01715 extern int GEOS_DLL GEOSGetNumCoordinates(const GEOSGeometry* g); 01716 01717 /* 01718 * Return NULL on exception. 01719 * Geometry must be a LineString, LinearRing or Point. 01720 */ 01721 extern const GEOSCoordSequence GEOS_DLL *GEOSGeom_getCoordSeq(const GEOSGeometry* g); 01722 01723 /* 01724 * Return 0 on exception (or empty geometry) 01725 */ 01726 extern int GEOS_DLL GEOSGeom_getDimensions(const GEOSGeometry* g); 01727 01728 /* 01729 * Return 2 or 3. 01730 */ 01731 extern int GEOS_DLL GEOSGeom_getCoordinateDimension(const GEOSGeometry* g); 01732 01733 /* 01734 * Return NULL on exception. 01735 * Must be LineString and must be freed by called. 01736 */ 01737 extern GEOSGeometry GEOS_DLL *GEOSGeomGetPointN(const GEOSGeometry *g, int n); 01738 extern GEOSGeometry GEOS_DLL *GEOSGeomGetStartPoint(const GEOSGeometry *g); 01739 extern GEOSGeometry GEOS_DLL *GEOSGeomGetEndPoint(const GEOSGeometry *g); 01740 01741 /************************************************************************ 01742 * 01743 * Misc functions 01744 * 01745 ***********************************************************************/ 01746 01747 /* Return 0 on exception, 1 otherwise */ 01748 extern int GEOS_DLL GEOSArea(const GEOSGeometry* g, double *area); 01749 extern int GEOS_DLL GEOSLength(const GEOSGeometry* g, double *length); 01750 extern int GEOS_DLL GEOSDistance(const GEOSGeometry* g1, const GEOSGeometry* g2, 01751 double *dist); 01752 extern int GEOS_DLL GEOSHausdorffDistance(const GEOSGeometry *g1, 01753 const GEOSGeometry *g2, double *dist); 01754 extern int GEOS_DLL GEOSHausdorffDistanceDensify(const GEOSGeometry *g1, 01755 const GEOSGeometry *g2, double densifyFrac, double *dist); 01756 extern int GEOS_DLL GEOSGeomGetLength(const GEOSGeometry *g, double *length); 01757 01758 /* Return 0 on exception, the closest points of the two geometries otherwise. 01759 * The first point comes from g1 geometry and the second point comes from g2. 01760 */ 01761 extern GEOSCoordSequence GEOS_DLL *GEOSNearestPoints( 01762 const GEOSGeometry* g1, const GEOSGeometry* g2); 01763 01764 01765 /************************************************************************ 01766 * 01767 * Algorithms 01768 * 01769 ***********************************************************************/ 01770 01771 /* Walking from A to B: 01772 * return -1 if reaching P takes a counter-clockwise (left) turn 01773 * return 1 if reaching P takes a clockwise (right) turn 01774 * return 0 if P is collinear with A-B 01775 * 01776 * On exceptions, return 2. 01777 * 01778 */ 01779 extern int GEOS_DLL GEOSOrientationIndex(double Ax, double Ay, double Bx, double By, 01780 double Px, double Py); 01781 01782 /************************************************************************ 01783 * 01784 * Reader and Writer APIs 01785 * 01786 ***********************************************************************/ 01787 01788 /* WKT Reader */ 01789 extern GEOSWKTReader GEOS_DLL *GEOSWKTReader_create(); 01790 extern void GEOS_DLL GEOSWKTReader_destroy(GEOSWKTReader* reader); 01791 extern GEOSGeometry GEOS_DLL *GEOSWKTReader_read(GEOSWKTReader* reader, const char *wkt); 01792 01793 /* WKT Writer */ 01794 extern GEOSWKTWriter GEOS_DLL *GEOSWKTWriter_create(); 01795 extern void GEOS_DLL GEOSWKTWriter_destroy(GEOSWKTWriter* writer); 01796 extern char GEOS_DLL *GEOSWKTWriter_write(GEOSWKTWriter* writer, const GEOSGeometry* g); 01797 extern void GEOS_DLL GEOSWKTWriter_setTrim(GEOSWKTWriter *writer, char trim); 01798 extern void GEOS_DLL GEOSWKTWriter_setRoundingPrecision(GEOSWKTWriter *writer, int precision); 01799 extern void GEOS_DLL GEOSWKTWriter_setOutputDimension(GEOSWKTWriter *writer, int dim); 01800 extern int GEOS_DLL GEOSWKTWriter_getOutputDimension(GEOSWKTWriter *writer); 01801 extern void GEOS_DLL GEOSWKTWriter_setOld3D(GEOSWKTWriter *writer, int useOld3D); 01802 01803 /* WKB Reader */ 01804 extern GEOSWKBReader GEOS_DLL *GEOSWKBReader_create(); 01805 extern void GEOS_DLL GEOSWKBReader_destroy(GEOSWKBReader* reader); 01806 extern GEOSGeometry GEOS_DLL *GEOSWKBReader_read(GEOSWKBReader* reader, const unsigned char *wkb, size_t size); 01807 extern GEOSGeometry GEOS_DLL *GEOSWKBReader_readHEX(GEOSWKBReader* reader, const unsigned char *hex, size_t size); 01808 01809 /* WKB Writer */ 01810 extern GEOSWKBWriter GEOS_DLL *GEOSWKBWriter_create(); 01811 extern void GEOS_DLL GEOSWKBWriter_destroy(GEOSWKBWriter* writer); 01812 01813 /* The caller owns the results for these two methods! */ 01814 extern unsigned char GEOS_DLL *GEOSWKBWriter_write(GEOSWKBWriter* writer, const GEOSGeometry* g, size_t *size); 01815 extern unsigned char GEOS_DLL *GEOSWKBWriter_writeHEX(GEOSWKBWriter* writer, const GEOSGeometry* g, size_t *size); 01816 01817 /* 01818 * Specify whether output WKB should be 2d or 3d. 01819 * Return previously set number of dimensions. 01820 */ 01821 extern int GEOS_DLL GEOSWKBWriter_getOutputDimension(const GEOSWKBWriter* writer); 01822 extern void GEOS_DLL GEOSWKBWriter_setOutputDimension(GEOSWKBWriter* writer, int newDimension); 01823 01824 /* 01825 * Specify whether the WKB byte order is big or little endian. 01826 * The return value is the previous byte order. 01827 */ 01828 extern int GEOS_DLL GEOSWKBWriter_getByteOrder(const GEOSWKBWriter* writer); 01829 extern void GEOS_DLL GEOSWKBWriter_setByteOrder(GEOSWKBWriter* writer, int byteOrder); 01830 01831 /* 01832 * Specify whether SRID values should be output. 01833 */ 01834 extern char GEOS_DLL GEOSWKBWriter_getIncludeSRID(const GEOSWKBWriter* writer); 01835 extern void GEOS_DLL GEOSWKBWriter_setIncludeSRID(GEOSWKBWriter* writer, const char writeSRID); 01836 01837 /* 01838 * Free buffers returned by stuff like GEOSWKBWriter_write(), 01839 * GEOSWKBWriter_writeHEX() and GEOSWKTWriter_write(). 01840 */ 01841 extern void GEOS_DLL GEOSFree(void *buffer); 01842 01843 #endif /* #ifndef GEOS_USE_ONLY_R_API */ 01844 01845 01846 #ifdef __cplusplus 01847 } // extern "C" 01848 #endif 01849 01850 #endif /* #ifndef GEOS_C_H_INCLUDED */
1.7.3