GEOS  3.9.0dev
geos_c.h
1 /************************************************************************
2  *
3  *
4  * C-Wrapper for GEOS library
5  *
6  * Copyright (C) 2010 2011 Sandro Santilli <strk@kbt.io>
7  * Copyright (C) 2005 Refractions Research Inc.
8  *
9  * This is free software; you can redistribute and/or modify it under
10  * the terms of the GNU Lesser General Public Licence as published
11  * by the Free Software Foundation.
12  * See the COPYING file for more information.
13  *
14  * Author: Sandro Santilli <strk@kbt.io>
15  *
16  ***********************************************************************
17  *
18  * GENERAL NOTES:
19  *
20  * - Remember to call initGEOS() before any use of this library's
21  * functions, and call finishGEOS() when done.
22  *
23  * - Currently you have to explicitly GEOSGeom_destroy() all
24  * GEOSGeom objects to avoid memory leaks, and GEOSFree()
25  * all returned char * (unless const).
26  *
27  * - Functions ending with _r are thread safe; see details in RFC 3
28  * http://trac.osgeo.org/geos/wiki/RFC3.
29  * To avoid using by accident non _r functions,
30  * define GEOS_USE_ONLY_R_API before including geos_c.h
31  *
32  ***********************************************************************/
33 
34 #ifndef GEOS_C_H_INCLUDED
35 #define GEOS_C_H_INCLUDED
36 
37 #ifndef __cplusplus
38 # include <stddef.h> /* for size_t definition */
39 #else
40 # include <cstddef>
41 using std::size_t;
42 #endif
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
48 /************************************************************************
49  *
50  * Version
51  *
52  ***********************************************************************/
53 
54 #ifndef GEOS_VERSION_MAJOR
55 #define GEOS_VERSION_MAJOR 3
56 #endif
57 #ifndef GEOS_VERSION_MINOR
58 #define GEOS_VERSION_MINOR 9
59 #endif
60 #ifndef GEOS_VERSION_PATCH
61 #define GEOS_VERSION_PATCH 0dev
62 #endif
63 #ifndef GEOS_VERSION
64 #define GEOS_VERSION "3.9.0dev"
65 #endif
66 #ifndef GEOS_JTS_PORT
67 #define GEOS_JTS_PORT "1.16.0"
68 #endif
69 
70 #define GEOS_CAPI_VERSION_MAJOR 1
71 #define GEOS_CAPI_VERSION_MINOR 14
72 #define GEOS_CAPI_VERSION_PATCH 0
73 #define GEOS_CAPI_VERSION "3.9.0dev-CAPI-1.14.0"
74 
75 #define GEOS_CAPI_FIRST_INTERFACE GEOS_CAPI_VERSION_MAJOR
76 #define GEOS_CAPI_LAST_INTERFACE (GEOS_CAPI_VERSION_MAJOR+GEOS_CAPI_VERSION_MINOR)
77 
78 
79 /************************************************************************
80  *
81  * (Abstract) type definitions
82  *
83  ************************************************************************/
84 
85 typedef struct GEOSContextHandle_HS *GEOSContextHandle_t;
86 
87 typedef void (*GEOSMessageHandler)(const char *fmt, ...);
88 
89 /*
90  * A GEOS message handler function.
91  *
92  * @param message the message contents
93  * @param userdata the user data pointer that was passed to GEOS when registering this message handler.
94  *
95  *
96  * @see GEOSContext_setErrorMessageHandler
97  * @see GEOSContext_setNoticeMessageHandler
98  */
99 typedef void (*GEOSMessageHandler_r)(const char *message, void *userdata);
100 
101 /* When we're included by geos_c.cpp, those are #defined to the original
102  * JTS definitions via preprocessor. We don't touch them to allow the
103  * compiler to cross-check the declarations. However, for all "normal"
104  * C-API users, we need to define them as "opaque" struct pointers, as
105  * those clients don't have access to the original C++ headers, by design.
106  */
107 #ifndef GEOSGeometry
108 typedef struct GEOSGeom_t GEOSGeometry;
109 typedef struct GEOSPrepGeom_t GEOSPreparedGeometry;
110 typedef struct GEOSCoordSeq_t GEOSCoordSequence;
111 typedef struct GEOSSTRtree_t GEOSSTRtree;
112 typedef struct GEOSBufParams_t GEOSBufferParams;
113 #endif
114 
115 /* Those are compatibility definitions for source compatibility
116  * with GEOS 2.X clients relying on that type.
117  */
118 typedef GEOSGeometry* GEOSGeom;
119 typedef GEOSCoordSequence* GEOSCoordSeq;
120 
121 /* Supported geometry types
122  * This was renamed from GEOSGeomTypeId in GEOS 2.2.X, which might
123  * break compatibility, this issue is still under investigation.
124  */
125 
126 enum GEOSGeomTypes {
127  GEOS_POINT,
130  GEOS_POLYGON,
135 };
136 
137 /* Byte orders exposed via the C API */
138 enum GEOSByteOrders {
139  GEOS_WKB_XDR = 0, /* Big Endian */
140  GEOS_WKB_NDR = 1 /* Little Endian */
141 };
142 
143 typedef void (*GEOSQueryCallback)(void *item, void *userdata);
144 typedef int (*GEOSDistanceCallback)(const void *item1, const void* item2, double* distance, void* userdata);
145 
146 /************************************************************************
147  *
148  * Initialization, cleanup, version
149  *
150  ***********************************************************************/
151 
152 #include <geos/export.h>
153 
154 /*
155  * Register an interruption checking callback
156  *
157  * The callback will be invoked _before_ checking for
158  * interruption, so can be used to request it.
159  */
160 typedef void (GEOSInterruptCallback)();
161 extern GEOSInterruptCallback GEOS_DLL *GEOS_interruptRegisterCallback(GEOSInterruptCallback* cb);
162 /* Request safe interruption of operations */
163 extern void GEOS_DLL GEOS_interruptRequest();
164 /* Cancel a pending interruption request */
165 extern void GEOS_DLL GEOS_interruptCancel();
166 
167 /*
168  * @deprecated in 3.5.0
169  * initialize using GEOS_init_r() and set the message handlers using
170  * GEOSContext_setNoticeHandler_r and/or GEOSContext_setErrorHandler_r
171  */
172 extern GEOSContextHandle_t GEOS_DLL initGEOS_r(
173  GEOSMessageHandler notice_function,
174  GEOSMessageHandler error_function);
175 /*
176  * @deprecated in 3.5.0 replaced by GEOS_finish_r.
177  */
178 extern void GEOS_DLL finishGEOS_r(GEOSContextHandle_t handle);
179 
180 extern GEOSContextHandle_t GEOS_DLL GEOS_init_r();
181 extern void GEOS_DLL GEOS_finish_r(GEOSContextHandle_t handle);
182 
183 
184 extern GEOSMessageHandler GEOS_DLL GEOSContext_setNoticeHandler_r(GEOSContextHandle_t extHandle,
185  GEOSMessageHandler nf);
186 extern GEOSMessageHandler GEOS_DLL GEOSContext_setErrorHandler_r(GEOSContextHandle_t extHandle,
187  GEOSMessageHandler ef);
188 
189 /*
190  * Sets a notice message handler on the given GEOS context.
191  *
192  * @param extHandle the GEOS context
193  * @param nf the message handler
194  * @param userData optional user data pointer that will be passed to the message handler
195  *
196  * @return the previously configured message handler or NULL if no message handler was configured
197  */
198 extern GEOSMessageHandler_r GEOS_DLL GEOSContext_setNoticeMessageHandler_r(GEOSContextHandle_t extHandle,
199  GEOSMessageHandler_r nf,
200  void *userData);
201 
202 /*
203  * Sets an error message handler on the given GEOS context.
204  *
205  * @param extHandle the GEOS context
206  * @param ef the message handler
207  * @param userData optional user data pointer that will be passed to the message handler
208  *
209  * @return the previously configured message handler or NULL if no message handler was configured
210  */
211 extern GEOSMessageHandler_r GEOS_DLL GEOSContext_setErrorMessageHandler_r(GEOSContextHandle_t extHandle,
212  GEOSMessageHandler_r ef,
213  void *userData);
214 
215 extern const char GEOS_DLL *GEOSversion();
216 
217 
218 /************************************************************************
219  *
220  * NOTE - These functions are DEPRECATED. Please use the new Reader and
221  * writer APIS!
222  *
223  ***********************************************************************/
224 
225 extern GEOSGeometry GEOS_DLL *GEOSGeomFromWKT_r(GEOSContextHandle_t handle,
226  const char *wkt);
227 extern char GEOS_DLL *GEOSGeomToWKT_r(GEOSContextHandle_t handle,
228  const GEOSGeometry* g);
229 
230 /*
231  * Specify whether output WKB should be 2d or 3d.
232  * Return previously set number of dimensions.
233  */
234 
235 extern int GEOS_DLL GEOS_getWKBOutputDims_r(GEOSContextHandle_t handle);
236 extern int GEOS_DLL GEOS_setWKBOutputDims_r(GEOSContextHandle_t handle,
237  int newDims);
238 
239 /*
240  * Specify whether the WKB byte order is big or little endian.
241  * The return value is the previous byte order.
242  */
243 
244 extern int GEOS_DLL GEOS_getWKBByteOrder_r(GEOSContextHandle_t handle);
245 extern int GEOS_DLL GEOS_setWKBByteOrder_r(GEOSContextHandle_t handle,
246  int byteOrder);
247 
248 extern GEOSGeometry GEOS_DLL *GEOSGeomFromWKB_buf_r(GEOSContextHandle_t handle,
249  const unsigned char *wkb,
250  size_t size);
251 extern unsigned char GEOS_DLL *GEOSGeomToWKB_buf_r(GEOSContextHandle_t handle,
252  const GEOSGeometry* g,
253  size_t *size);
254 
255 extern GEOSGeometry GEOS_DLL *GEOSGeomFromHEX_buf_r(GEOSContextHandle_t handle,
256  const unsigned char *hex,
257  size_t size);
258 extern unsigned char GEOS_DLL *GEOSGeomToHEX_buf_r(GEOSContextHandle_t handle,
259  const GEOSGeometry* g,
260  size_t *size);
261 
262 /************************************************************************
263  *
264  * Coordinate Sequence functions
265  *
266  ***********************************************************************/
267 
268 /*
269  * Create a Coordinate sequence with ``size'' coordinates
270  * of ``dims'' dimensions.
271  * Return NULL on exception.
272  */
273 extern GEOSCoordSequence GEOS_DLL *GEOSCoordSeq_create_r(
274  GEOSContextHandle_t handle,
275  unsigned int size,
276  unsigned int dims);
277 
278 /*
279  * Clone a Coordinate Sequence.
280  * Return NULL on exception.
281  */
282 extern GEOSCoordSequence GEOS_DLL *GEOSCoordSeq_clone_r(
283  GEOSContextHandle_t handle,
284  const GEOSCoordSequence* s);
285 
286 /*
287  * Destroy a Coordinate Sequence.
288  */
289 extern void GEOS_DLL GEOSCoordSeq_destroy_r(GEOSContextHandle_t handle,
290  GEOSCoordSequence* s);
291 
292 /*
293  * Set ordinate values in a Coordinate Sequence.
294  * Return 0 on exception.
295  */
296 extern int GEOS_DLL GEOSCoordSeq_setX_r(GEOSContextHandle_t handle,
297  GEOSCoordSequence* s, unsigned int idx,
298  double val);
299 extern int GEOS_DLL GEOSCoordSeq_setY_r(GEOSContextHandle_t handle,
300  GEOSCoordSequence* s, unsigned int idx,
301  double val);
302 extern int GEOS_DLL GEOSCoordSeq_setZ_r(GEOSContextHandle_t handle,
303  GEOSCoordSequence* s, unsigned int idx,
304  double val);
305 extern int GEOS_DLL GEOSCoordSeq_setXY_r(GEOSContextHandle_t handle,
306  GEOSCoordSequence* s, unsigned int idx,
307  double x, double y);
308 extern int GEOS_DLL GEOSCoordSeq_setXYZ_r(GEOSContextHandle_t handle,
309  GEOSCoordSequence* s, unsigned int idx,
310  double x, double y, double z);
311 
312 extern int GEOS_DLL GEOSCoordSeq_setOrdinate_r(GEOSContextHandle_t handle,
313  GEOSCoordSequence* s,
314  unsigned int idx,
315  unsigned int dim, double val);
316 
317 /*
318  * Get ordinate values from a Coordinate Sequence.
319  * Return 0 on exception.
320  */
321 extern int GEOS_DLL GEOSCoordSeq_getX_r(GEOSContextHandle_t handle,
322  const GEOSCoordSequence* s,
323  unsigned int idx, double *val);
324 extern int GEOS_DLL GEOSCoordSeq_getY_r(GEOSContextHandle_t handle,
325  const GEOSCoordSequence* s,
326  unsigned int idx, double *val);
327 extern int GEOS_DLL GEOSCoordSeq_getZ_r(GEOSContextHandle_t handle,
328  const GEOSCoordSequence* s,
329  unsigned int idx, double *val);
330 extern int GEOS_DLL GEOSCoordSeq_getXY_r(GEOSContextHandle_t handle,
331  const GEOSCoordSequence* s,
332  unsigned int idx, double *x, double *y);
333 extern int GEOS_DLL GEOSCoordSeq_getXYZ_r(GEOSContextHandle_t handle,
334  const GEOSCoordSequence* s,
335  unsigned int idx, double *x, double *y, double *z);
336 extern int GEOS_DLL GEOSCoordSeq_getOrdinate_r(GEOSContextHandle_t handle,
337  const GEOSCoordSequence* s,
338  unsigned int idx,
339  unsigned int dim, double *val);
340 /*
341  * Get size and dimensions info from a Coordinate Sequence.
342  * Return 0 on exception.
343  */
344 extern int GEOS_DLL GEOSCoordSeq_getSize_r(GEOSContextHandle_t handle,
345  const GEOSCoordSequence* s,
346  unsigned int *size);
347 extern int GEOS_DLL GEOSCoordSeq_getDimensions_r(GEOSContextHandle_t handle,
348  const GEOSCoordSequence* s,
349  unsigned int *dims);
350 /*
351  * Check orientation of a CoordinateSequence and set 'is_ccw' to 1
352  * if it has counter-clockwise orientation, 0 otherwise.
353  * Return 0 on exception, 1 on success.
354  */
355 extern int GEOS_DLL GEOSCoordSeq_isCCW_r(GEOSContextHandle_t handle,
356  const GEOSCoordSequence* s,
357  char* is_ccw);
358 
359 /************************************************************************
360  *
361  * Linear referencing functions -- there are more, but these are
362  * probably sufficient for most purposes
363  *
364  ***********************************************************************/
365 
366 /*
367  * GEOSGeometry ownership is retained by caller
368  */
369 
370 
371 /* Return distance of point 'p' projected on 'g' from origin
372  * of 'g'. Geometry 'g' must be a lineal geometry */
373 extern double GEOS_DLL GEOSProject_r(GEOSContextHandle_t handle,
374  const GEOSGeometry *g,
375  const GEOSGeometry *p);
376 
377 /* Return closest point to given distance within geometry
378  * Geometry must be a LineString */
379 extern GEOSGeometry GEOS_DLL *GEOSInterpolate_r(GEOSContextHandle_t handle,
380  const GEOSGeometry *g,
381  double d);
382 
383 extern double GEOS_DLL GEOSProjectNormalized_r(GEOSContextHandle_t handle,
384  const GEOSGeometry *g,
385  const GEOSGeometry *p);
386 
387 extern GEOSGeometry GEOS_DLL *GEOSInterpolateNormalized_r(
388  GEOSContextHandle_t handle,
389  const GEOSGeometry *g,
390  double d);
391 
392 /************************************************************************
393  *
394  * Buffer related functions
395  *
396  ***********************************************************************/
397 
398 
399 /* @return NULL on exception */
400 extern GEOSGeometry GEOS_DLL *GEOSBuffer_r(GEOSContextHandle_t handle,
401  const GEOSGeometry* g,
402  double width, int quadsegs);
403 
404 enum GEOSBufCapStyles {
405  GEOSBUF_CAP_ROUND=1,
406  GEOSBUF_CAP_FLAT=2,
407  GEOSBUF_CAP_SQUARE=3
408 };
409 
410 enum GEOSBufJoinStyles {
411  GEOSBUF_JOIN_ROUND=1,
412  GEOSBUF_JOIN_MITRE=2,
413  GEOSBUF_JOIN_BEVEL=3
414 };
415 
416 /* @return 0 on exception */
417 extern GEOSBufferParams GEOS_DLL *GEOSBufferParams_create_r(
418  GEOSContextHandle_t handle);
419 extern void GEOS_DLL GEOSBufferParams_destroy_r(
420  GEOSContextHandle_t handle,
421  GEOSBufferParams* parms);
422 
423 /* @return 0 on exception */
424 extern int GEOS_DLL GEOSBufferParams_setEndCapStyle_r(
425  GEOSContextHandle_t handle,
426  GEOSBufferParams* p,
427  int style);
428 
429 /* @return 0 on exception */
430 extern int GEOS_DLL GEOSBufferParams_setJoinStyle_r(
431  GEOSContextHandle_t handle,
432  GEOSBufferParams* p,
433  int joinStyle);
434 
435 /* @return 0 on exception */
436 extern int GEOS_DLL GEOSBufferParams_setMitreLimit_r(
437  GEOSContextHandle_t handle,
438  GEOSBufferParams* p,
439  double mitreLimit);
440 
441 /* @return 0 on exception */
442 extern int GEOS_DLL GEOSBufferParams_setQuadrantSegments_r(
443  GEOSContextHandle_t handle,
444  GEOSBufferParams* p,
445  int quadSegs);
446 
447 /* @param singleSided: 1 for single sided, 0 otherwise */
448 /* @return 0 on exception */
449 extern int GEOS_DLL GEOSBufferParams_setSingleSided_r(
450  GEOSContextHandle_t handle,
451  GEOSBufferParams* p,
452  int singleSided);
453 
454 /* @return NULL on exception */
455 extern GEOSGeometry GEOS_DLL *GEOSBufferWithParams_r(
456  GEOSContextHandle_t handle,
457  const GEOSGeometry* g,
458  const GEOSBufferParams* p,
459  double width);
460 
461 /* These functions return NULL on exception. */
462 extern GEOSGeometry GEOS_DLL *GEOSBufferWithStyle_r(GEOSContextHandle_t handle,
463  const GEOSGeometry* g, double width, int quadsegs, int endCapStyle,
464  int joinStyle, double mitreLimit);
465 
466 /* These functions return NULL on exception. Only LINESTRINGs are accepted. */
467 /* @deprecated in 3.3.0: use GEOSOffsetCurve instead */
468 extern GEOSGeometry GEOS_DLL *GEOSSingleSidedBuffer_r(
469  GEOSContextHandle_t handle,
470  const GEOSGeometry* g, double width, int quadsegs,
471  int joinStyle, double mitreLimit, int leftSide);
472 
473 /*
474  * Only LINESTRINGs are accepted.
475  * @param width : offset distance.
476  * negative for right side offset.
477  * positive for left side offset.
478  * @return NULL on exception
479  */
480 extern GEOSGeometry GEOS_DLL *GEOSOffsetCurve_r(GEOSContextHandle_t handle,
481  const GEOSGeometry* g, double width, int quadsegs,
482  int joinStyle, double mitreLimit);
483 
484 
485 /************************************************************************
486  *
487  * Geometry Constructors.
488  * GEOSCoordSequence* arguments will become ownership of the returned object.
489  * All functions return NULL on exception.
490  *
491  ***********************************************************************/
492 
493 extern GEOSGeometry GEOS_DLL *GEOSGeom_createPoint_r(
494  GEOSContextHandle_t handle,
495  GEOSCoordSequence* s);
496 extern GEOSGeometry GEOS_DLL *GEOSGeom_createPointFromXY_r(
497  GEOSContextHandle_t handle,
498  double x,
499  double y);
500 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyPoint_r(
501  GEOSContextHandle_t handle);
502 extern GEOSGeometry GEOS_DLL *GEOSGeom_createLinearRing_r(
503  GEOSContextHandle_t handle,
504  GEOSCoordSequence* s);
505 extern GEOSGeometry GEOS_DLL *GEOSGeom_createLineString_r(
506  GEOSContextHandle_t handle,
507  GEOSCoordSequence* s);
508 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyLineString_r(
509  GEOSContextHandle_t handle);
510 
511 /*
512  * Second argument is an array of GEOSGeometry* objects.
513  * The caller remains owner of the array, but pointed-to
514  * objects become ownership of the returned GEOSGeometry.
515  */
516 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyPolygon_r(
517  GEOSContextHandle_t handle);
518 extern GEOSGeometry GEOS_DLL *GEOSGeom_createPolygon_r(
519  GEOSContextHandle_t handle,
520  GEOSGeometry* shell,
521  GEOSGeometry** holes,
522  unsigned int nholes);
523 extern GEOSGeometry GEOS_DLL *GEOSGeom_createCollection_r(
524  GEOSContextHandle_t handle, int type,
525  GEOSGeometry* *geoms,
526  unsigned int ngeoms);
527 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyCollection_r(
528  GEOSContextHandle_t handle, int type);
529 
530 extern GEOSGeometry GEOS_DLL *GEOSGeom_clone_r(GEOSContextHandle_t handle,
531  const GEOSGeometry* g);
532 
533 /************************************************************************
534  *
535  * Memory management
536  *
537  ***********************************************************************/
538 
539 extern void GEOS_DLL GEOSGeom_destroy_r(GEOSContextHandle_t handle,
540  GEOSGeometry* g);
541 
542 /************************************************************************
543  *
544  * Topology operations - return NULL on exception.
545  *
546  ***********************************************************************/
547 
548 extern GEOSGeometry GEOS_DLL *GEOSEnvelope_r(GEOSContextHandle_t handle,
549  const GEOSGeometry* g);
550 extern GEOSGeometry GEOS_DLL *GEOSIntersection_r(GEOSContextHandle_t handle,
551  const GEOSGeometry* g1,
552  const GEOSGeometry* g2);
553 extern GEOSGeometry GEOS_DLL *GEOSIntersectionPrec_r(GEOSContextHandle_t handle,
554  const GEOSGeometry* g1,
555  const GEOSGeometry* g2,
556  double gridSize);
557 extern GEOSGeometry GEOS_DLL *GEOSConvexHull_r(GEOSContextHandle_t handle,
558  const GEOSGeometry* g);
559 
560 /* Returns the minimum rotated rectangular POLYGON which encloses the input geometry. The rectangle
561  * has width equal to the minimum diameter, and a longer length. If the convex hill of the input is
562  * degenerate (a line or point) a LINESTRING or POINT is returned. The minimum rotated rectangle can
563  * be used as an extremely generalized representation for the given geometry.
564  */
565 extern GEOSGeometry GEOS_DLL *GEOSMinimumRotatedRectangle_r(GEOSContextHandle_t handle,
566  const GEOSGeometry* g);
567 
568 extern GEOSGeometry GEOS_DLL *GEOSMaximumInscribedCircle_r(GEOSContextHandle_t handle, const GEOSGeometry* g, double tolerance);
569 extern GEOSGeometry GEOS_DLL *GEOSLargestEmptyCircle_r(GEOSContextHandle_t handle, const GEOSGeometry* g, const GEOSGeometry* boundary, double tolerance);
570 
571 /* Returns a LINESTRING geometry which represents the minimum diameter of the geometry.
572  * The minimum diameter is defined to be the width of the smallest band that
573  * contains the geometry, where a band is a strip of the plane defined
574  * by two parallel lines. This can be thought of as the smallest hole that the geometry
575  * can be moved through, with a single rotation.
576  */
577 extern GEOSGeometry GEOS_DLL *GEOSMinimumWidth_r(GEOSContextHandle_t handle,
578  const GEOSGeometry* g);
579 
580 extern GEOSGeometry GEOS_DLL *GEOSMinimumClearanceLine_r(GEOSContextHandle_t handle,
581  const GEOSGeometry* g);
582 
583 extern int GEOS_DLL GEOSMinimumClearance_r(GEOSContextHandle_t handle,
584  const GEOSGeometry* g,
585  double* distance);
586 
587 extern GEOSGeometry GEOS_DLL *GEOSDifference_r(GEOSContextHandle_t handle,
588  const GEOSGeometry* g1,
589  const GEOSGeometry* g2);
590 extern GEOSGeometry GEOS_DLL *GEOSDifferencePrec_r(GEOSContextHandle_t handle,
591  const GEOSGeometry* g1,
592  const GEOSGeometry* g2,
593  double gridSize);
594 extern GEOSGeometry GEOS_DLL *GEOSSymDifference_r(GEOSContextHandle_t handle,
595  const GEOSGeometry* g1,
596  const GEOSGeometry* g2);
597 extern GEOSGeometry GEOS_DLL *GEOSSymDifferencePrec_r(GEOSContextHandle_t handle,
598  const GEOSGeometry* g1,
599  const GEOSGeometry* g2,
600  double gridSize);
601 extern GEOSGeometry GEOS_DLL *GEOSBoundary_r(GEOSContextHandle_t handle,
602  const GEOSGeometry* g);
603 extern GEOSGeometry GEOS_DLL *GEOSUnion_r(GEOSContextHandle_t handle,
604  const GEOSGeometry* g1,
605  const GEOSGeometry* g2);
606 extern GEOSGeometry GEOS_DLL *GEOSUnionPrec_r(GEOSContextHandle_t handle,
607  const GEOSGeometry* g1,
608  const GEOSGeometry* g2,
609  double gridSize);
610 extern GEOSGeometry GEOS_DLL *GEOSUnaryUnion_r(GEOSContextHandle_t handle,
611  const GEOSGeometry* g);
612 extern GEOSGeometry GEOS_DLL *GEOSUnaryUnionPrec_r(GEOSContextHandle_t handle,
613  const GEOSGeometry* g,
614  double gridSize);
615 /* GEOSCoverageUnion is an optimized union algorithm for polygonal inputs that are correctly
616  * noded and do not overlap. It will not generate an error (return NULL) for inputs that
617  * do not satisfy this constraint. */
618 extern GEOSGeometry GEOS_DLL *GEOSCoverageUnion_r(GEOSContextHandle_t handle,
619  const GEOSGeometry* g);
620 /* @deprecated in 3.3.0: use GEOSUnaryUnion_r instead */
621 extern GEOSGeometry GEOS_DLL *GEOSUnionCascaded_r(GEOSContextHandle_t handle,
622  const GEOSGeometry* g);
623 extern GEOSGeometry GEOS_DLL *GEOSPointOnSurface_r(GEOSContextHandle_t handle,
624  const GEOSGeometry* g);
625 extern GEOSGeometry GEOS_DLL *GEOSGetCentroid_r(GEOSContextHandle_t handle,
626  const GEOSGeometry* g);
627 extern GEOSGeometry GEOS_DLL *GEOSMinimumBoundingCircle_r(GEOSContextHandle_t handle,
628  const GEOSGeometry* g, double* radius,
629  GEOSGeometry** center);
630 extern GEOSGeometry GEOS_DLL *GEOSNode_r(GEOSContextHandle_t handle,
631  const GEOSGeometry* g);
632 /* Fast, non-robust intersection between an arbitrary geometry and
633  * a rectangle. The returned geometry may be invalid. */
634 extern GEOSGeometry GEOS_DLL *GEOSClipByRect_r(GEOSContextHandle_t handle,
635  const GEOSGeometry* g,
636  double xmin, double ymin,
637  double xmax, double ymax);
638 
639 /*
640  * all arguments remain ownership of the caller
641  * (both Geometries and pointers)
642  */
643 /*
644  * Polygonizes a set of Geometries which contain linework that
645  * represents the edges of a planar graph.
646  *
647  * All types of Geometry are accepted as input; the constituent
648  * linework is extracted as the edges to be polygonized.
649  *
650  * The edges must be correctly noded; that is, they must only meet
651  * at their endpoints. Polygonization will accept incorrectly noded
652  * input but will not form polygons from non-noded edges, and reports
653  * them as errors.
654  *
655  * The Polygonizer reports the follow kinds of errors:
656  *
657  * - Dangles - edges which have one or both ends which are
658  * not incident on another edge endpoint
659  * - Cut Edges - edges which are connected at both ends but
660  * which do not form part of a polygon
661  * - Invalid Ring Lines - edges which form rings which are invalid
662  * (e.g. the component lines contain a self-intersection)
663  *
664  * Errors are reported to output parameters "cuts", "dangles" and
665  * "invalid" (if not-null). Formed polygons are returned as a
666  * collection. NULL is returned on exception. All returned
667  * geometries must be destroyed by caller.
668  *
669  * The GEOSPolygonize_valid_r variant allows extracting only polygons
670  * which form a valid polygonal result. The set of extracted polygons
671  * is guaranteed to be edge-disjoint. This is useful when it is known
672  * that the input lines form a valid polygonal geometry (which may
673  * include holes or nested polygons).
674  */
675 
676 extern GEOSGeometry GEOS_DLL *GEOSPolygonize_r(GEOSContextHandle_t handle,
677  const GEOSGeometry *const geoms[],
678  unsigned int ngeoms);
679 extern GEOSGeometry GEOS_DLL *GEOSPolygonize_valid_r(GEOSContextHandle_t handle,
680  const GEOSGeometry *const geoms[],
681  unsigned int ngems);
682 extern GEOSGeometry GEOS_DLL *GEOSPolygonizer_getCutEdges_r(
683  GEOSContextHandle_t handle,
684  const GEOSGeometry * const geoms[],
685  unsigned int ngeoms);
686 extern GEOSGeometry GEOS_DLL *GEOSPolygonize_full_r(GEOSContextHandle_t handle,
687  const GEOSGeometry* input, GEOSGeometry** cuts,
688  GEOSGeometry** dangles, GEOSGeometry** invalidRings);
689 
690 extern GEOSGeometry GEOS_DLL *GEOSBuildArea_r(
691  GEOSContextHandle_t handle,
692  const GEOSGeometry* g);
693 
694 extern GEOSGeometry GEOS_DLL *GEOSLineMerge_r(GEOSContextHandle_t handle,
695  const GEOSGeometry* g);
696 extern GEOSGeometry GEOS_DLL *GEOSReverse_r(GEOSContextHandle_t handle,
697  const GEOSGeometry* g);
698 extern GEOSGeometry GEOS_DLL *GEOSSimplify_r(GEOSContextHandle_t handle,
699  const GEOSGeometry* g,
700  double tolerance);
701 extern GEOSGeometry GEOS_DLL *GEOSTopologyPreserveSimplify_r(
702  GEOSContextHandle_t handle,
703  const GEOSGeometry* g, double tolerance);
704 
705 /*
706  * Return all distinct vertices of input geometry as a MULTIPOINT.
707  * Note that only 2 dimensions of the vertices are considered when
708  * testing for equality.
709  */
710 extern GEOSGeometry GEOS_DLL *GEOSGeom_extractUniquePoints_r(
711  GEOSContextHandle_t handle,
712  const GEOSGeometry* g);
713 
714 /*
715  * Find paths shared between the two given lineal geometries.
716  *
717  * Returns a GEOMETRYCOLLECTION having two elements:
718  * - first element is a MULTILINESTRING containing shared paths
719  * having the _same_ direction on both inputs
720  * - second element is a MULTILINESTRING containing shared paths
721  * having the _opposite_ direction on the two inputs
722  *
723  * Returns NULL on exception
724  */
725 extern GEOSGeometry GEOS_DLL *GEOSSharedPaths_r(GEOSContextHandle_t handle,
726  const GEOSGeometry* g1, const GEOSGeometry* g2);
727 
728 /*
729  * Snap first geometry on to second with given tolerance
730  * Returns a newly allocated geometry, or NULL on exception
731  */
732 extern GEOSGeometry GEOS_DLL *GEOSSnap_r(GEOSContextHandle_t handle,
733  const GEOSGeometry* g1, const GEOSGeometry* g2, double tolerance);
734 
735 /*
736  * Return a Delaunay triangulation of the vertex of the given geometry
737  *
738  * @param g the input geometry whose vertex will be used as "sites"
739  * @param tolerance optional snapping tolerance to use for improved robustness
740  * @param onlyEdges if non-zero will return a MULTILINESTRING, otherwise it will
741  * return a GEOMETRYCOLLECTION containing triangular POLYGONs.
742  *
743  * @return a newly allocated geometry, or NULL on exception
744  */
745 extern GEOSGeometry GEOS_DLL * GEOSDelaunayTriangulation_r(
746  GEOSContextHandle_t handle,
747  const GEOSGeometry *g,
748  double tolerance,
749  int onlyEdges);
750 
751 /*
752  * Returns the Voronoi polygons of a set of Vertices given as input
753  *
754  * @param g the input geometry whose vertex will be used as sites.
755  * @param tolerance snapping tolerance to use for improved robustness
756  * @param onlyEdges whether to return only edges of the Voronoi cells
757  * @param env clipping envelope for the returned diagram, automatically
758  * determined if NULL.
759  * The diagram will be clipped to the larger
760  * of this envelope or an envelope surrounding the sites.
761  *
762  * @return a newly allocated geometry, or NULL on exception.
763  */
764 extern GEOSGeometry GEOS_DLL * GEOSVoronoiDiagram_r(
765  GEOSContextHandle_t extHandle,
766  const GEOSGeometry *g,
767  const GEOSGeometry *env,
768  double tolerance,
769  int onlyEdges);
770 
771 /*
772  * Computes the coordinate where two line segments intersect, if any
773  *
774  * @param ax0 x-coordinate of first point in first segment
775  * @param ay0 y-coordinate of first point in first segment
776  * @param ax1 x-coordinate of second point in first segment
777  * @param ay1 y-coordinate of second point in first segment
778  * @param bx0 x-coordinate of first point in second segment
779  * @param by0 y-coordinate of first point in second segment
780  * @param bx1 x-coordinate of second point in second segment
781  * @param by1 y-coordinate of second point in second segment
782  * @param cx x-coordinate of intersection point
783  * @param cy y-coordinate of intersection point
784  *
785  * @return 0 on error, 1 on success, -1 if segments do not intersect
786  */
787 
788 extern int GEOS_DLL GEOSSegmentIntersection_r(
789  GEOSContextHandle_t extHandle,
790  double ax0, double ay0,
791  double ax1, double ay1,
792  double bx0, double by0,
793  double bx1, double by1,
794  double* cx, double* cy);
795 
796 /************************************************************************
797  *
798  * Binary predicates - return 2 on exception, 1 on true, 0 on false
799  *
800  ***********************************************************************/
801 
802 extern char GEOS_DLL GEOSDisjoint_r(GEOSContextHandle_t handle,
803  const GEOSGeometry* g1,
804  const GEOSGeometry* g2);
805 extern char GEOS_DLL GEOSTouches_r(GEOSContextHandle_t handle,
806  const GEOSGeometry* g1,
807  const GEOSGeometry* g2);
808 extern char GEOS_DLL GEOSIntersects_r(GEOSContextHandle_t handle,
809  const GEOSGeometry* g1,
810  const GEOSGeometry* g2);
811 extern char GEOS_DLL GEOSCrosses_r(GEOSContextHandle_t handle,
812  const GEOSGeometry* g1,
813  const GEOSGeometry* g2);
814 extern char GEOS_DLL GEOSWithin_r(GEOSContextHandle_t handle,
815  const GEOSGeometry* g1,
816  const GEOSGeometry* g2);
817 extern char GEOS_DLL GEOSContains_r(GEOSContextHandle_t handle,
818  const GEOSGeometry* g1,
819  const GEOSGeometry* g2);
820 extern char GEOS_DLL GEOSOverlaps_r(GEOSContextHandle_t handle,
821  const GEOSGeometry* g1,
822  const GEOSGeometry* g2);
823 extern char GEOS_DLL GEOSEquals_r(GEOSContextHandle_t handle,
824  const GEOSGeometry* g1,
825  const GEOSGeometry* g2);
826 extern char GEOS_DLL GEOSEqualsExact_r(GEOSContextHandle_t handle,
827  const GEOSGeometry* g1,
828  const GEOSGeometry* g2,
829  double tolerance);
830 extern char GEOS_DLL GEOSCovers_r(GEOSContextHandle_t handle,
831  const GEOSGeometry* g1,
832  const GEOSGeometry* g2);
833 extern char GEOS_DLL GEOSCoveredBy_r(GEOSContextHandle_t handle,
834  const GEOSGeometry* g1,
835  const GEOSGeometry* g2);
836 
837 /************************************************************************
838  *
839  * Prepared Geometry Binary predicates - return 2 on exception, 1 on true, 0 on false
840  *
841  ***********************************************************************/
842 
843 /*
844  * GEOSGeometry ownership is retained by caller
845  */
846 extern const GEOSPreparedGeometry GEOS_DLL *GEOSPrepare_r(
847  GEOSContextHandle_t handle,
848  const GEOSGeometry* g);
849 
850 extern void GEOS_DLL GEOSPreparedGeom_destroy_r(GEOSContextHandle_t handle,
851  const GEOSPreparedGeometry* g);
852 
853 extern char GEOS_DLL GEOSPreparedContains_r(GEOSContextHandle_t handle,
854  const GEOSPreparedGeometry* pg1,
855  const GEOSGeometry* g2);
856 extern char GEOS_DLL GEOSPreparedContainsProperly_r(GEOSContextHandle_t handle,
857  const GEOSPreparedGeometry* pg1,
858  const GEOSGeometry* g2);
859 extern char GEOS_DLL GEOSPreparedCoveredBy_r(GEOSContextHandle_t handle,
860  const GEOSPreparedGeometry* pg1,
861  const GEOSGeometry* g2);
862 extern char GEOS_DLL GEOSPreparedCovers_r(GEOSContextHandle_t handle,
863  const GEOSPreparedGeometry* pg1,
864  const GEOSGeometry* g2);
865 extern char GEOS_DLL GEOSPreparedCrosses_r(GEOSContextHandle_t handle,
866  const GEOSPreparedGeometry* pg1,
867  const GEOSGeometry* g2);
868 extern char GEOS_DLL GEOSPreparedDisjoint_r(GEOSContextHandle_t handle,
869  const GEOSPreparedGeometry* pg1,
870  const GEOSGeometry* g2);
871 extern char GEOS_DLL GEOSPreparedIntersects_r(GEOSContextHandle_t handle,
872  const GEOSPreparedGeometry* pg1,
873  const GEOSGeometry* g2);
874 extern char GEOS_DLL GEOSPreparedOverlaps_r(GEOSContextHandle_t handle,
875  const GEOSPreparedGeometry* pg1,
876  const GEOSGeometry* g2);
877 extern char GEOS_DLL GEOSPreparedTouches_r(GEOSContextHandle_t handle,
878  const GEOSPreparedGeometry* pg1,
879  const GEOSGeometry* g2);
880 extern char GEOS_DLL GEOSPreparedWithin_r(GEOSContextHandle_t handle,
881  const GEOSPreparedGeometry* pg1,
882  const GEOSGeometry* g2);
883 
884 /************************************************************************
885  *
886  * STRtree functions
887  *
888  ***********************************************************************/
889 
890 /*
891  * GEOSGeometry ownership is retained by caller
892  */
893 
894 extern GEOSSTRtree GEOS_DLL *GEOSSTRtree_create_r(
895  GEOSContextHandle_t handle,
896  size_t nodeCapacity);
897 extern void GEOS_DLL GEOSSTRtree_insert_r(GEOSContextHandle_t handle,
898  GEOSSTRtree *tree,
899  const GEOSGeometry *g,
900  void *item);
901 extern void GEOS_DLL GEOSSTRtree_query_r(GEOSContextHandle_t handle,
902  GEOSSTRtree *tree,
903  const GEOSGeometry *g,
904  GEOSQueryCallback callback,
905  void *userdata);
906 
907 extern const GEOSGeometry GEOS_DLL *GEOSSTRtree_nearest_r(GEOSContextHandle_t handle,
908  GEOSSTRtree *tree,
909  const GEOSGeometry* geom);
910 
911 
912 extern const void GEOS_DLL *GEOSSTRtree_nearest_generic_r(GEOSContextHandle_t handle,
913  GEOSSTRtree *tree,
914  const void* item,
915  const GEOSGeometry* itemEnvelope,
916  GEOSDistanceCallback distancefn,
917  void* userdata);
918 
919 extern void GEOS_DLL GEOSSTRtree_iterate_r(GEOSContextHandle_t handle,
920  GEOSSTRtree *tree,
921  GEOSQueryCallback callback,
922  void *userdata);
923 extern char GEOS_DLL GEOSSTRtree_remove_r(GEOSContextHandle_t handle,
924  GEOSSTRtree *tree,
925  const GEOSGeometry *g,
926  void *item);
927 extern void GEOS_DLL GEOSSTRtree_destroy_r(GEOSContextHandle_t handle,
928  GEOSSTRtree *tree);
929 
930 
931 /************************************************************************
932  *
933  * Unary predicate - return 2 on exception, 1 on true, 0 on false
934  *
935  ***********************************************************************/
936 
937 extern char GEOS_DLL GEOSisEmpty_r(GEOSContextHandle_t handle,
938  const GEOSGeometry* g);
939 extern char GEOS_DLL GEOSisSimple_r(GEOSContextHandle_t handle,
940  const GEOSGeometry* g);
941 extern char GEOS_DLL GEOSisRing_r(GEOSContextHandle_t handle,
942  const GEOSGeometry* g);
943 extern char GEOS_DLL GEOSHasZ_r(GEOSContextHandle_t handle,
944  const GEOSGeometry* g);
945 extern char GEOS_DLL GEOSisClosed_r(GEOSContextHandle_t handle,
946  const GEOSGeometry *g);
947 
948 /************************************************************************
949  *
950  * Dimensionally Extended 9 Intersection Model related
951  *
952  ***********************************************************************/
953 
954 /* These are for use with GEOSRelateBoundaryNodeRule (flags param) */
955 enum GEOSRelateBoundaryNodeRules {
956  /* MOD2 and OGC are the same rule, and is the default
957  * used by GEOSRelatePattern
958  */
959  GEOSRELATE_BNR_MOD2=1,
960  GEOSRELATE_BNR_OGC=1,
961  GEOSRELATE_BNR_ENDPOINT=2,
962  GEOSRELATE_BNR_MULTIVALENT_ENDPOINT=3,
963  GEOSRELATE_BNR_MONOVALENT_ENDPOINT=4
964 };
965 
966 /* return 2 on exception, 1 on true, 0 on false */
967 extern char GEOS_DLL GEOSRelatePattern_r(GEOSContextHandle_t handle,
968  const GEOSGeometry* g1,
969  const GEOSGeometry* g2,
970  const char *pat);
971 
972 /* return NULL on exception, a string to GEOSFree otherwise */
973 extern char GEOS_DLL *GEOSRelate_r(GEOSContextHandle_t handle,
974  const GEOSGeometry* g1,
975  const GEOSGeometry* g2);
976 
977 /* return 2 on exception, 1 on true, 0 on false */
978 extern char GEOS_DLL GEOSRelatePatternMatch_r(GEOSContextHandle_t handle,
979  const char *mat,
980  const char *pat);
981 
982 /* return NULL on exception, a string to GEOSFree otherwise */
983 extern char GEOS_DLL *GEOSRelateBoundaryNodeRule_r(GEOSContextHandle_t handle,
984  const GEOSGeometry* g1,
985  const GEOSGeometry* g2,
986  int bnr);
987 
988 /************************************************************************
989  *
990  * Validity checking
991  *
992  ***********************************************************************/
993 
994 /* These are for use with GEOSisValidDetail (flags param) */
995 enum GEOSValidFlags {
996  GEOSVALID_ALLOW_SELFTOUCHING_RING_FORMING_HOLE=1
997 };
998 
999 /* return 2 on exception, 1 on true, 0 on false */
1000 extern char GEOS_DLL GEOSisValid_r(GEOSContextHandle_t handle,
1001  const GEOSGeometry* g);
1002 
1003 /* return NULL on exception, a string to GEOSFree otherwise */
1004 extern char GEOS_DLL *GEOSisValidReason_r(GEOSContextHandle_t handle,
1005  const GEOSGeometry* g);
1006 
1007 /*
1008  * Caller has the responsibility to destroy 'reason' (GEOSFree)
1009  * and 'location' (GEOSGeom_destroy) params
1010  * return 2 on exception, 1 when valid, 0 when invalid
1011  */
1012 extern char GEOS_DLL GEOSisValidDetail_r(GEOSContextHandle_t handle,
1013  const GEOSGeometry* g,
1014  int flags,
1015  char** reason,
1016  GEOSGeometry** location);
1017 
1018 extern GEOSGeometry GEOS_DLL *GEOSMakeValid_r(GEOSContextHandle_t handle,
1019  const GEOSGeometry* g);
1020 
1021 /************************************************************************
1022  *
1023  * Geometry info
1024  *
1025  ***********************************************************************/
1026 
1027 /* Return NULL on exception, result must be freed by caller. */
1028 extern char GEOS_DLL *GEOSGeomType_r(GEOSContextHandle_t handle,
1029  const GEOSGeometry* g);
1030 
1031 /* Return -1 on exception */
1032 extern int GEOS_DLL GEOSGeomTypeId_r(GEOSContextHandle_t handle,
1033  const GEOSGeometry* g);
1034 
1035 /* Return 0 on exception */
1036 extern int GEOS_DLL GEOSGetSRID_r(GEOSContextHandle_t handle,
1037  const GEOSGeometry* g);
1038 
1039 extern void GEOS_DLL GEOSSetSRID_r(GEOSContextHandle_t handle,
1040  GEOSGeometry* g, int SRID);
1041 
1042 extern void GEOS_DLL *GEOSGeom_getUserData_r(GEOSContextHandle_t handle,
1043 const GEOSGeometry* g);
1044 
1045 extern void GEOS_DLL GEOSGeom_setUserData_r(GEOSContextHandle_t handle,
1046  GEOSGeometry* g, void* userData);
1047 
1048 /* May be called on all geometries in GEOS 3.x, returns -1 on error and 1
1049  * for non-multi geometries. Older GEOS versions only accept
1050  * GeometryCollections or Multi* geometries here, and are likely to crash
1051  * when fed simple geometries, so beware if you need compatibility with
1052  * old GEOS versions.
1053  */
1054 extern int GEOS_DLL GEOSGetNumGeometries_r(GEOSContextHandle_t handle,
1055  const GEOSGeometry* g);
1056 
1057 /*
1058  * Return NULL on exception.
1059  * Returned object is a pointer to internal storage:
1060  * it must NOT be destroyed directly.
1061  * Up to GEOS 3.2.0 the input geometry must be a Collection, in
1062  * later version it doesn't matter (getGeometryN(0) for a single will
1063  * return the input).
1064  */
1065 extern const GEOSGeometry GEOS_DLL *GEOSGetGeometryN_r(
1066  GEOSContextHandle_t handle,
1067  const GEOSGeometry* g, int n);
1068 
1069 /* Return -1 on exception */
1070 extern int GEOS_DLL GEOSNormalize_r(GEOSContextHandle_t handle,
1071  GEOSGeometry* g);
1072 
1075 #define GEOS_PREC_NO_TOPO (1<<0)
1076 
1079 #define GEOS_PREC_KEEP_COLLAPSED (1<<1)
1080 
1096 extern GEOSGeometry GEOS_DLL *GEOSGeom_setPrecision_r(
1097  GEOSContextHandle_t handle,
1098  const GEOSGeometry *g,
1099  double gridSize, int flags);
1100 
1107 extern double GEOS_DLL GEOSGeom_getPrecision_r(
1108  GEOSContextHandle_t handle,
1109  const GEOSGeometry *g);
1110 
1111 /* Return -1 on exception */
1112 extern int GEOS_DLL GEOSGetNumInteriorRings_r(GEOSContextHandle_t handle,
1113  const GEOSGeometry* g);
1114 
1115 /* Return -1 on exception, Geometry must be a LineString. */
1116 extern int GEOS_DLL GEOSGeomGetNumPoints_r(GEOSContextHandle_t handle,
1117  const GEOSGeometry* g);
1118 
1119 /* Return 0 on exception, otherwise 1, Geometry must be a Point. */
1120 extern int GEOS_DLL GEOSGeomGetX_r(GEOSContextHandle_t handle, const GEOSGeometry *g, double *x);
1121 extern int GEOS_DLL GEOSGeomGetY_r(GEOSContextHandle_t handle, const GEOSGeometry *g, double *y);
1122 extern int GEOS_DLL GEOSGeomGetZ_r(GEOSContextHandle_t handle, const GEOSGeometry *g, double *z);
1123 
1124 /*
1125  * Return NULL on exception, Geometry must be a Polygon.
1126  * Returned object is a pointer to internal storage:
1127  * it must NOT be destroyed directly.
1128  */
1129 extern const GEOSGeometry GEOS_DLL *GEOSGetInteriorRingN_r(
1130  GEOSContextHandle_t handle,
1131  const GEOSGeometry* g, int n);
1132 
1133 /*
1134  * Return NULL on exception, Geometry must be a Polygon.
1135  * Returned object is a pointer to internal storage:
1136  * it must NOT be destroyed directly.
1137  */
1138 extern const GEOSGeometry GEOS_DLL *GEOSGetExteriorRing_r(
1139  GEOSContextHandle_t handle,
1140  const GEOSGeometry* g);
1141 
1142 /* Return -1 on exception */
1143 extern int GEOS_DLL GEOSGetNumCoordinates_r(GEOSContextHandle_t handle,
1144  const GEOSGeometry* g);
1145 
1146 /*
1147  * Return NULL on exception.
1148  * Geometry must be a LineString, LinearRing or Point.
1149  */
1150 extern const GEOSCoordSequence GEOS_DLL *GEOSGeom_getCoordSeq_r(
1151  GEOSContextHandle_t handle,
1152  const GEOSGeometry* g);
1153 
1154 /*
1155  * Return 0 on exception (or empty geometry)
1156  */
1157 extern int GEOS_DLL GEOSGeom_getDimensions_r(GEOSContextHandle_t handle,
1158  const GEOSGeometry* g);
1159 
1160 /*
1161  * Return 2 or 3.
1162  */
1163 extern int GEOS_DLL GEOSGeom_getCoordinateDimension_r(GEOSContextHandle_t handle,
1164  const GEOSGeometry* g);
1165 /*
1166  * Return 0 on exception
1167  */
1168 extern int GEOS_DLL GEOSGeom_getXMin_r(GEOSContextHandle_t handle, const GEOSGeometry* g, double* value);
1169 extern int GEOS_DLL GEOSGeom_getYMin_r(GEOSContextHandle_t handle, const GEOSGeometry* g, double* value);
1170 extern int GEOS_DLL GEOSGeom_getXMax_r(GEOSContextHandle_t handle, const GEOSGeometry* g, double* value);
1171 extern int GEOS_DLL GEOSGeom_getYMax_r(GEOSContextHandle_t handle, const GEOSGeometry* g, double* value);
1172 
1173 /*
1174  * Return NULL on exception.
1175  * Must be LineString and must be freed by called.
1176  */
1177 extern GEOSGeometry GEOS_DLL *GEOSGeomGetPointN_r(GEOSContextHandle_t handle, const GEOSGeometry *g, int n);
1178 extern GEOSGeometry GEOS_DLL *GEOSGeomGetStartPoint_r(GEOSContextHandle_t handle, const GEOSGeometry *g);
1179 extern GEOSGeometry GEOS_DLL *GEOSGeomGetEndPoint_r(GEOSContextHandle_t handle, const GEOSGeometry *g);
1180 
1181 /************************************************************************
1182  *
1183  * Misc functions
1184  *
1185  ***********************************************************************/
1186 
1187 /* Return 0 on exception, 1 otherwise */
1188 extern int GEOS_DLL GEOSArea_r(GEOSContextHandle_t handle,
1189  const GEOSGeometry* g, double *area);
1190 extern int GEOS_DLL GEOSLength_r(GEOSContextHandle_t handle,
1191  const GEOSGeometry* g, double *length);
1192 extern int GEOS_DLL GEOSDistance_r(GEOSContextHandle_t handle,
1193  const GEOSGeometry* g1,
1194  const GEOSGeometry* g2, double *dist);
1195 extern int GEOS_DLL GEOSDistanceIndexed_r(GEOSContextHandle_t handle,
1196  const GEOSGeometry* g1,
1197  const GEOSGeometry* g2, double *dist);
1198 extern int GEOS_DLL GEOSHausdorffDistance_r(GEOSContextHandle_t handle,
1199  const GEOSGeometry *g1,
1200  const GEOSGeometry *g2,
1201  double *dist);
1202 extern int GEOS_DLL GEOSHausdorffDistanceDensify_r(GEOSContextHandle_t handle,
1203  const GEOSGeometry *g1,
1204  const GEOSGeometry *g2,
1205  double densifyFrac, double *dist);
1206 extern int GEOS_DLL GEOSFrechetDistance_r(GEOSContextHandle_t handle,
1207  const GEOSGeometry *g1,
1208  const GEOSGeometry *g2,
1209  double *dist);
1210 extern int GEOS_DLL GEOSFrechetDistanceDensify_r(GEOSContextHandle_t handle,
1211  const GEOSGeometry *g1,
1212  const GEOSGeometry *g2,
1213  double densifyFrac, double *dist);
1214 extern int GEOS_DLL GEOSGeomGetLength_r(GEOSContextHandle_t handle,
1215  const GEOSGeometry *g, double *length);
1216 
1217 /* Return 0 on exception, the closest points of the two geometries otherwise.
1218  * The first point comes from g1 geometry and the second point comes from g2.
1219  */
1220 extern GEOSCoordSequence GEOS_DLL *GEOSNearestPoints_r(
1221  GEOSContextHandle_t handle, const GEOSGeometry* g1, const GEOSGeometry* g2);
1222 
1223 
1224 /************************************************************************
1225  *
1226  * Algorithms
1227  *
1228  ***********************************************************************/
1229 
1230 /* Walking from A to B:
1231  * return -1 if reaching P takes a counter-clockwise (left) turn
1232  * return 1 if reaching P takes a clockwise (right) turn
1233  * return 0 if P is collinear with A-B
1234  *
1235  * On exceptions, return 2.
1236  *
1237  */
1238 extern int GEOS_DLL GEOSOrientationIndex_r(GEOSContextHandle_t handle,
1239  double Ax, double Ay, double Bx, double By, double Px, double Py);
1240 
1241 
1242 /************************************************************************
1243  *
1244  * Reader and Writer APIs
1245  *
1246  ***********************************************************************/
1247 
1248 #ifndef GEOSWKTReader
1249 typedef struct GEOSWKTReader_t GEOSWKTReader;
1250 typedef struct GEOSWKTWriter_t GEOSWKTWriter;
1251 typedef struct GEOSWKBReader_t GEOSWKBReader;
1252 typedef struct GEOSWKBWriter_t GEOSWKBWriter;
1253 #endif
1254 
1255 /* WKT Reader */
1256 extern GEOSWKTReader GEOS_DLL *GEOSWKTReader_create_r(
1257  GEOSContextHandle_t handle);
1258 extern void GEOS_DLL GEOSWKTReader_destroy_r(GEOSContextHandle_t handle,
1259  GEOSWKTReader* reader);
1260 extern GEOSGeometry GEOS_DLL *GEOSWKTReader_read_r(GEOSContextHandle_t handle,
1261  GEOSWKTReader* reader,
1262  const char *wkt);
1263 
1264 /* WKT Writer */
1265 extern GEOSWKTWriter GEOS_DLL *GEOSWKTWriter_create_r(
1266  GEOSContextHandle_t handle);
1267 extern void GEOS_DLL GEOSWKTWriter_destroy_r(GEOSContextHandle_t handle,
1268  GEOSWKTWriter* writer);
1269 extern char GEOS_DLL *GEOSWKTWriter_write_r(GEOSContextHandle_t handle,
1270  GEOSWKTWriter* writer,
1271  const GEOSGeometry* g);
1272 extern void GEOS_DLL GEOSWKTWriter_setTrim_r(GEOSContextHandle_t handle,
1273  GEOSWKTWriter *writer,
1274  char trim);
1275 extern void GEOS_DLL GEOSWKTWriter_setRoundingPrecision_r(GEOSContextHandle_t handle,
1276  GEOSWKTWriter *writer,
1277  int precision);
1278 extern void GEOS_DLL GEOSWKTWriter_setOutputDimension_r(GEOSContextHandle_t handle,
1279  GEOSWKTWriter *writer,
1280  int dim);
1281 extern int GEOS_DLL GEOSWKTWriter_getOutputDimension_r(GEOSContextHandle_t handle,
1282  GEOSWKTWriter *writer);
1283 extern void GEOS_DLL GEOSWKTWriter_setOld3D_r(GEOSContextHandle_t handle,
1284  GEOSWKTWriter *writer,
1285  int useOld3D);
1286 
1287 /* WKB Reader */
1288 extern GEOSWKBReader GEOS_DLL *GEOSWKBReader_create_r(
1289  GEOSContextHandle_t handle);
1290 extern void GEOS_DLL GEOSWKBReader_destroy_r(GEOSContextHandle_t handle,
1291  GEOSWKBReader* reader);
1292 extern GEOSGeometry GEOS_DLL *GEOSWKBReader_read_r(GEOSContextHandle_t handle,
1293  GEOSWKBReader* reader,
1294  const unsigned char *wkb,
1295  size_t size);
1296 extern GEOSGeometry GEOS_DLL *GEOSWKBReader_readHEX_r(
1297  GEOSContextHandle_t handle,
1298  GEOSWKBReader* reader,
1299  const unsigned char *hex,
1300  size_t size);
1301 
1302 /* WKB Writer */
1303 extern GEOSWKBWriter GEOS_DLL *GEOSWKBWriter_create_r(
1304  GEOSContextHandle_t handle);
1305 extern void GEOS_DLL GEOSWKBWriter_destroy_r(GEOSContextHandle_t handle,
1306  GEOSWKBWriter* writer);
1307 
1308 /* The caller owns the results for these two methods! */
1309 extern unsigned char GEOS_DLL *GEOSWKBWriter_write_r(
1310  GEOSContextHandle_t handle,
1311  GEOSWKBWriter* writer,
1312  const GEOSGeometry* g,
1313  size_t *size);
1314 extern unsigned char GEOS_DLL *GEOSWKBWriter_writeHEX_r(
1315  GEOSContextHandle_t handle,
1316  GEOSWKBWriter* writer,
1317  const GEOSGeometry* g,
1318  size_t *size);
1319 
1320 /*
1321  * Specify whether output WKB should be 2d or 3d.
1322  * Return previously set number of dimensions.
1323  */
1324 extern int GEOS_DLL GEOSWKBWriter_getOutputDimension_r(
1325  GEOSContextHandle_t handle,
1326  const GEOSWKBWriter* writer);
1327 extern void GEOS_DLL GEOSWKBWriter_setOutputDimension_r(
1328  GEOSContextHandle_t handle,
1329  GEOSWKBWriter* writer, int newDimension);
1330 
1331 /*
1332  * Specify whether the WKB byte order is big or little endian.
1333  * The return value is the previous byte order.
1334  */
1335 extern int GEOS_DLL GEOSWKBWriter_getByteOrder_r(GEOSContextHandle_t handle,
1336  const GEOSWKBWriter* writer);
1337 extern void GEOS_DLL GEOSWKBWriter_setByteOrder_r(GEOSContextHandle_t handle,
1338  GEOSWKBWriter* writer,
1339  int byteOrder);
1340 
1341 /*
1342  * Specify whether SRID values should be output.
1343  */
1344 extern char GEOS_DLL GEOSWKBWriter_getIncludeSRID_r(GEOSContextHandle_t handle,
1345  const GEOSWKBWriter* writer);
1346 extern void GEOS_DLL GEOSWKBWriter_setIncludeSRID_r(GEOSContextHandle_t handle,
1347  GEOSWKBWriter* writer, const char writeSRID);
1348 
1349 
1350 /*
1351  * Free buffers returned by stuff like GEOSWKBWriter_write(),
1352  * GEOSWKBWriter_writeHEX() and GEOSWKTWriter_write().
1353  */
1354 extern void GEOS_DLL GEOSFree_r(GEOSContextHandle_t handle, void *buffer);
1355 
1356 
1357 /* External code to GEOS can define GEOS_USE_ONLY_R_API to avoid the */
1358 /* non _r API to be available */
1359 #ifndef GEOS_USE_ONLY_R_API
1360 
1361 /************************************************************************
1362  *
1363  * Initialization, cleanup, version
1364  *
1365  ***********************************************************************/
1366 
1367 extern void GEOS_DLL initGEOS(GEOSMessageHandler notice_function,
1368  GEOSMessageHandler error_function);
1369 extern void GEOS_DLL finishGEOS(void);
1370 
1371 /************************************************************************
1372  *
1373  * NOTE - These functions are DEPRECATED. Please use the new Reader and
1374  * writer APIS!
1375  *
1376  ***********************************************************************/
1377 
1378 extern GEOSGeometry GEOS_DLL *GEOSGeomFromWKT(const char *wkt);
1379 extern char GEOS_DLL *GEOSGeomToWKT(const GEOSGeometry* g);
1380 
1381 /*
1382  * Specify whether output WKB should be 2d or 3d.
1383  * Return previously set number of dimensions.
1384  */
1385 extern int GEOS_DLL GEOS_getWKBOutputDims();
1386 extern int GEOS_DLL GEOS_setWKBOutputDims(int newDims);
1387 
1388 /*
1389  * Specify whether the WKB byte order is big or little endian.
1390  * The return value is the previous byte order.
1391  */
1392 extern int GEOS_DLL GEOS_getWKBByteOrder();
1393 extern int GEOS_DLL GEOS_setWKBByteOrder(int byteOrder);
1394 
1395 extern GEOSGeometry GEOS_DLL *GEOSGeomFromWKB_buf(const unsigned char *wkb, size_t size);
1396 extern unsigned char GEOS_DLL *GEOSGeomToWKB_buf(const GEOSGeometry* g, size_t *size);
1397 
1398 extern GEOSGeometry GEOS_DLL *GEOSGeomFromHEX_buf(const unsigned char *hex, size_t size);
1399 extern unsigned char GEOS_DLL *GEOSGeomToHEX_buf(const GEOSGeometry* g, size_t *size);
1400 
1401 /************************************************************************
1402  *
1403  * Coordinate Sequence functions
1404  *
1405  ***********************************************************************/
1406 
1407 /*
1408  * Create a Coordinate sequence with ``size'' coordinates
1409  * of ``dims'' dimensions.
1410  * Return NULL on exception.
1411  */
1412 extern GEOSCoordSequence GEOS_DLL *GEOSCoordSeq_create(unsigned int size, unsigned int dims);
1413 
1414 /*
1415  * Clone a Coordinate Sequence.
1416  * Return NULL on exception.
1417  */
1418 extern GEOSCoordSequence GEOS_DLL *GEOSCoordSeq_clone(const GEOSCoordSequence* s);
1419 
1420 /*
1421  * Destroy a Coordinate Sequence.
1422  */
1423 extern void GEOS_DLL GEOSCoordSeq_destroy(GEOSCoordSequence* s);
1424 
1425 /*
1426  * Set ordinate values in a Coordinate Sequence.
1427  * Return 0 on exception.
1428  */
1429 extern int GEOS_DLL GEOSCoordSeq_setX(GEOSCoordSequence* s,
1430  unsigned int idx, double val);
1431 extern int GEOS_DLL GEOSCoordSeq_setY(GEOSCoordSequence* s,
1432  unsigned int idx, double val);
1433 extern int GEOS_DLL GEOSCoordSeq_setZ(GEOSCoordSequence* s,
1434  unsigned int idx, double val);
1435 extern int GEOS_DLL GEOSCoordSeq_setXY(GEOSCoordSequence* s,
1436  unsigned int idx, double x, double y);
1437 extern int GEOS_DLL GEOSCoordSeq_setXYZ(GEOSCoordSequence* s,
1438  unsigned int idx, double x, double y, double z);
1439 extern int GEOS_DLL GEOSCoordSeq_setOrdinate(GEOSCoordSequence* s,
1440  unsigned int idx, unsigned int dim, double val);
1441 
1442 /*
1443  * Get ordinate values from a Coordinate Sequence.
1444  * Return 0 on exception.
1445  */
1446 extern int GEOS_DLL GEOSCoordSeq_getX(const GEOSCoordSequence* s,
1447  unsigned int idx, double *val);
1448 extern int GEOS_DLL GEOSCoordSeq_getY(const GEOSCoordSequence* s,
1449  unsigned int idx, double *val);
1450 extern int GEOS_DLL GEOSCoordSeq_getZ(const GEOSCoordSequence* s,
1451  unsigned int idx, double *val);
1452 extern int GEOS_DLL GEOSCoordSeq_getXY(const GEOSCoordSequence* s,
1453  unsigned int idx, double *x, double *y);
1454 extern int GEOS_DLL GEOSCoordSeq_getXYZ(const GEOSCoordSequence* s,
1455  unsigned int idx, double *x, double *y, double *z);
1456 extern int GEOS_DLL GEOSCoordSeq_getOrdinate(const GEOSCoordSequence* s,
1457  unsigned int idx, unsigned int dim, double *val);
1458 /*
1459  * Get size and dimensions info from a Coordinate Sequence.
1460  * Return 0 on exception.
1461  */
1462 extern int GEOS_DLL GEOSCoordSeq_getSize(const GEOSCoordSequence* s,
1463  unsigned int *size);
1464 extern int GEOS_DLL GEOSCoordSeq_getDimensions(const GEOSCoordSequence* s,
1465  unsigned int *dims);
1466 
1467 /*
1468  * Check orientation of a CoordinateSequence and set 'is_ccw' to 1
1469  * if it has counter-clockwise orientation, 0 otherwise.
1470  * Return 0 on exception, 1 on success.
1471  */
1472 extern int GEOS_DLL GEOSCoordSeq_isCCW(const GEOSCoordSequence* s, char* is_ccw);
1473 
1474 /************************************************************************
1475  *
1476  * Linear referencing functions -- there are more, but these are
1477  * probably sufficient for most purposes
1478  *
1479  ***********************************************************************/
1480 
1481 /*
1482  * GEOSGeometry ownership is retained by caller
1483  */
1484 
1485 
1486 /* Return distance of point 'p' projected on 'g' from origin
1487  * of 'g'. Geometry 'g' must be a lineal geometry */
1488 extern double GEOS_DLL GEOSProject(const GEOSGeometry *g,
1489  const GEOSGeometry* p);
1490 
1491 /* Return closest point to given distance within geometry
1492  * Geometry must be a LineString */
1493 extern GEOSGeometry GEOS_DLL *GEOSInterpolate(const GEOSGeometry *g,
1494  double d);
1495 
1496 extern double GEOS_DLL GEOSProjectNormalized(const GEOSGeometry *g,
1497  const GEOSGeometry* p);
1498 
1499 extern GEOSGeometry GEOS_DLL *GEOSInterpolateNormalized(const GEOSGeometry *g,
1500  double d);
1501 
1502 /************************************************************************
1503  *
1504  * Buffer related functions
1505  *
1506  ***********************************************************************/
1507 
1508 
1509 /* @return NULL on exception */
1510 extern GEOSGeometry GEOS_DLL *GEOSBuffer(const GEOSGeometry* g,
1511  double width, int quadsegs);
1512 
1513 /* @return 0 on exception */
1514 extern GEOSBufferParams GEOS_DLL *GEOSBufferParams_create();
1515 extern void GEOS_DLL GEOSBufferParams_destroy(GEOSBufferParams* parms);
1516 
1517 /* @return 0 on exception */
1518 extern int GEOS_DLL GEOSBufferParams_setEndCapStyle(
1519  GEOSBufferParams* p,
1520  int style);
1521 
1522 /* @return 0 on exception */
1523 extern int GEOS_DLL GEOSBufferParams_setJoinStyle(
1524  GEOSBufferParams* p,
1525  int joinStyle);
1526 
1527 /* @return 0 on exception */
1528 extern int GEOS_DLL GEOSBufferParams_setMitreLimit(
1529  GEOSBufferParams* p,
1530  double mitreLimit);
1531 
1532 /* @return 0 on exception */
1533 extern int GEOS_DLL GEOSBufferParams_setQuadrantSegments(
1534  GEOSBufferParams* p,
1535  int quadSegs);
1536 
1537 /* @param singleSided: 1 for single sided, 0 otherwise */
1538 /* @return 0 on exception */
1539 extern int GEOS_DLL GEOSBufferParams_setSingleSided(
1540  GEOSBufferParams* p,
1541  int singleSided);
1542 
1543 /* @return NULL on exception */
1544 extern GEOSGeometry GEOS_DLL *GEOSBufferWithParams(
1545  const GEOSGeometry* g,
1546  const GEOSBufferParams* p,
1547  double width);
1548 
1549 /* These functions return NULL on exception. */
1550 extern GEOSGeometry GEOS_DLL *GEOSBufferWithStyle(const GEOSGeometry* g,
1551  double width, int quadsegs, int endCapStyle, int joinStyle,
1552  double mitreLimit);
1553 
1554 /* These functions return NULL on exception. Only LINESTRINGs are accepted. */
1555 /* @deprecated in 3.3.0: use GEOSOffsetCurve instead */
1556 extern GEOSGeometry GEOS_DLL *GEOSSingleSidedBuffer(const GEOSGeometry* g,
1557  double width, int quadsegs, int joinStyle, double mitreLimit,
1558  int leftSide);
1559 
1560 /*
1561  * Only LINESTRINGs are accepted.
1562  * @param width : offset distance.
1563  * negative for right side offset.
1564  * positive for left side offset.
1565  * @return NULL on exception
1566  */
1567 extern GEOSGeometry GEOS_DLL *GEOSOffsetCurve(const GEOSGeometry* g,
1568  double width, int quadsegs, int joinStyle, double mitreLimit);
1569 
1570 /************************************************************************
1571  *
1572  * Geometry Constructors.
1573  * GEOSCoordSequence* arguments will become ownership of the returned object.
1574  * All functions return NULL on exception.
1575  *
1576  ***********************************************************************/
1577 
1578 extern GEOSGeometry GEOS_DLL *GEOSGeom_createPoint(GEOSCoordSequence* s);
1579 extern GEOSGeometry GEOS_DLL *GEOSGeom_createPointFromXY(double x, double y);
1580 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyPoint();
1581 extern GEOSGeometry GEOS_DLL *GEOSGeom_createLinearRing(GEOSCoordSequence* s);
1582 extern GEOSGeometry GEOS_DLL *GEOSGeom_createLineString(GEOSCoordSequence* s);
1583 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyLineString();
1584 
1585 /*
1586  * Second argument is an array of GEOSGeometry* objects.
1587  * The caller remains owner of the array, but pointed-to
1588  * objects become ownership of the returned GEOSGeometry.
1589  */
1590 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyPolygon();
1591 extern GEOSGeometry GEOS_DLL *GEOSGeom_createPolygon(GEOSGeometry* shell,
1592  GEOSGeometry** holes, unsigned int nholes);
1593 extern GEOSGeometry GEOS_DLL *GEOSGeom_createCollection(int type,
1594  GEOSGeometry* *geoms, unsigned int ngeoms);
1595 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyCollection(int type);
1596 
1597 extern GEOSGeometry GEOS_DLL *GEOSGeom_clone(const GEOSGeometry* g);
1598 
1599 /************************************************************************
1600  *
1601  * Memory management
1602  *
1603  ***********************************************************************/
1604 
1605 extern void GEOS_DLL GEOSGeom_destroy(GEOSGeometry* g);
1606 
1607 /************************************************************************
1608  *
1609  * Topology operations - return NULL on exception.
1610  *
1611  ***********************************************************************/
1612 
1613 extern GEOSGeometry GEOS_DLL *GEOSEnvelope(const GEOSGeometry* g);
1614 extern GEOSGeometry GEOS_DLL *GEOSIntersection(const GEOSGeometry* g1, const GEOSGeometry* g2);
1615 extern GEOSGeometry GEOS_DLL *GEOSIntersectionPrec(const GEOSGeometry* g1, const GEOSGeometry* g2, double gridSize);
1616 extern GEOSGeometry GEOS_DLL *GEOSConvexHull(const GEOSGeometry* g);
1617 
1618 /* Returns the minimum rotated rectangular POLYGON which encloses the input geometry. The rectangle
1619  * has width equal to the minimum diameter, and a longer length. If the convex hill of the input is
1620  * degenerate (a line or point) a LINESTRING or POINT is returned. The minimum rotated rectangle can
1621  * be used as an extremely generalized representation for the given geometry.
1622  */
1623 extern GEOSGeometry GEOS_DLL *GEOSMinimumRotatedRectangle(const GEOSGeometry* g);
1624 
1625 /* Constructs the Maximum Inscribed Circle for a polygonal geometry, up to a specified tolerance.
1626  * The Maximum Inscribed Circle is determined by a point in the interior of the area
1627  * which has the farthest distance from the area boundary, along with a boundary point at that distance.
1628  * In the context of geography the center of the Maximum Inscribed Circle is known as the
1629  * Pole of Inaccessibility. A cartographic use case is to determine a suitable point
1630  * to place a map label within a polygon.
1631  * The radius length of the Maximum Inscribed Circle is a measure of how "narrow" a polygon is. It is the
1632  * distance at which the negative buffer becomes empty.
1633  * The class supports polygons with holes and multipolygons.
1634  * The implementation uses a successive-approximation technique over a grid of square cells covering the area geometry.
1635  * The grid is refined using a branch-and-bound algorithm. Point containment and distance are computed in a performant
1636  * way by using spatial indexes.
1637  * Returns a two-point linestring, with one point at the center of the inscribed circle and the other
1638  * on the boundary of the inscribed circle.
1639 */
1640 extern GEOSGeometry GEOS_DLL *GEOSMaximumInscribedCircle(const GEOSGeometry* g, double tolerance);
1641 
1642 /* Constructs the Largest Empty Circle for a set of obstacle geometries, up to a
1643  * specified tolerance. The obstacles are point and line geometries.
1644  * The Largest Empty Circle is the largest circle which has its center in the convex hull of the
1645  * obstacles (the boundary), and whose interior does not intersect with any obstacle.
1646  * The circle center is the point in the interior of the boundary which has the farthest distance from
1647  * the obstacles (up to tolerance). The circle is determined by the center point and a point lying on an
1648  * obstacle indicating the circle radius.
1649  * The implementation uses a successive-approximation technique over a grid of square cells covering the obstacles and boundary.
1650  * The grid is refined using a branch-and-bound algorithm. Point containment and distance are computed in a performant
1651  * way by using spatial indexes.
1652  * Returns a two-point linestring, with one point at the center of the inscribed circle and the other
1653  * on the boundary of the inscribed circle.
1654  */
1655 extern GEOSGeometry GEOS_DLL *GEOSLargestEmptyCircle(const GEOSGeometry* g, const GEOSGeometry* boundary, double tolerance);
1656 
1657 /* Returns a LINESTRING geometry which represents the minimum diameter of the geometry.
1658  * The minimum diameter is defined to be the width of the smallest band that
1659  * contains the geometry, where a band is a strip of the plane defined
1660  * by two parallel lines. This can be thought of as the smallest hole that the geometry
1661  * can be moved through, with a single rotation.
1662  */
1663 extern GEOSGeometry GEOS_DLL *GEOSMinimumWidth(const GEOSGeometry* g);
1664 
1665 /* Computes the minimum clearance of a geometry. The minimum clearance is the smallest amount by which
1666  * a vertex could be move to produce an invalid polygon, a non-simple linestring, or a multipoint with
1667  * repeated points. If a geometry has a minimum clearance of 'eps', it can be said that:
1668  *
1669  * - No two distinct vertices in the geometry are separated by less than 'eps'
1670  * - No vertex is closer than 'eps' to a line segment of which it is not an endpoint.
1671  *
1672  * If the minimum clearance cannot be defined for a geometry (such as with a single point, or a multipoint
1673  * whose points are identical, a value of Infinity will be calculated.
1674  *
1675  * @param g the input geometry
1676  * @param d a double to which the result can be stored
1677  *
1678  * @return 0 if no exception occurred
1679  * 2 if an exception occurred
1680  */
1681 extern int GEOS_DLL GEOSMinimumClearance(const GEOSGeometry* g, double* d);
1682 
1683 /* Returns a LineString whose endpoints define the minimum clearance of a geometry.
1684  * If the geometry has no minimum clearance, an empty LineString will be returned.
1685  *
1686  * @param g the input geometry
1687  * @return a LineString, or NULL if an exception occurred.
1688  */
1689 extern GEOSGeometry GEOS_DLL *GEOSMinimumClearanceLine(const GEOSGeometry* g);
1690 
1691 extern GEOSGeometry GEOS_DLL *GEOSDifference(const GEOSGeometry* g1, const GEOSGeometry* g2);
1692 extern GEOSGeometry GEOS_DLL *GEOSDifferencePrec(const GEOSGeometry* g1, const GEOSGeometry* g2, double gridSize);
1693 extern GEOSGeometry GEOS_DLL *GEOSSymDifference(const GEOSGeometry* g1, const GEOSGeometry* g2);
1694 extern GEOSGeometry GEOS_DLL *GEOSSymDifferencePrec(const GEOSGeometry* g1, const GEOSGeometry* g2, double gridSize);
1695 extern GEOSGeometry GEOS_DLL *GEOSBoundary(const GEOSGeometry* g);
1696 extern GEOSGeometry GEOS_DLL *GEOSUnion(const GEOSGeometry* g1, const GEOSGeometry* g2);
1697 extern GEOSGeometry GEOS_DLL *GEOSUnionPrec(const GEOSGeometry* g1, const GEOSGeometry* g2, double gridSize);
1698 extern GEOSGeometry GEOS_DLL *GEOSUnaryUnion(const GEOSGeometry* g);
1699 extern GEOSGeometry GEOS_DLL *GEOSUnaryUnionPrec(const GEOSGeometry* g, double gridSize);
1700 
1701 /* GEOSCoverageUnion is an optimized union algorithm for polygonal inputs that are correctly
1702  * noded and do not overlap. It will not generate an error (return NULL) for inputs that
1703  * do not satisfy this constraint. */
1704 extern GEOSGeometry GEOS_DLL *GEOSCoverageUnion(const GEOSGeometry *g);
1705 
1706 /* @deprecated in 3.3.0: use GEOSUnaryUnion instead */
1707 extern GEOSGeometry GEOS_DLL *GEOSUnionCascaded(const GEOSGeometry* g);
1708 
1709 extern GEOSGeometry GEOS_DLL *GEOSPointOnSurface(const GEOSGeometry* g);
1710 extern GEOSGeometry GEOS_DLL *GEOSGetCentroid(const GEOSGeometry* g);
1711 extern GEOSGeometry GEOS_DLL *GEOSMinimumBoundingCircle(const GEOSGeometry* g, double* radius, GEOSGeometry** center);
1712 extern GEOSGeometry GEOS_DLL *GEOSNode(const GEOSGeometry* g);
1713 extern GEOSGeometry GEOS_DLL *GEOSClipByRect(const GEOSGeometry* g, double xmin, double ymin, double xmax, double ymax);
1714 
1715 /*
1716  * all arguments remain ownership of the caller
1717  * (both Geometries and pointers)
1718  */
1719 extern GEOSGeometry GEOS_DLL *GEOSPolygonize(const GEOSGeometry * const geoms[], unsigned int ngeoms);
1720 extern GEOSGeometry GEOS_DLL *GEOSPolygonize_valid(const GEOSGeometry * const geoms[], unsigned int ngeoms);
1721 extern GEOSGeometry GEOS_DLL *GEOSPolygonizer_getCutEdges(const GEOSGeometry * const geoms[], unsigned int ngeoms);
1722 extern GEOSGeometry GEOS_DLL *GEOSPolygonize_full(const GEOSGeometry* input,
1723  GEOSGeometry** cuts, GEOSGeometry** dangles, GEOSGeometry** invalid);
1724 
1725 extern GEOSGeometry GEOS_DLL *GEOSBuildArea(const GEOSGeometry* g);
1726 
1727 extern GEOSGeometry GEOS_DLL *GEOSLineMerge(const GEOSGeometry* g);
1728 extern GEOSGeometry GEOS_DLL *GEOSReverse(const GEOSGeometry* g);
1729 extern GEOSGeometry GEOS_DLL *GEOSSimplify(const GEOSGeometry* g, double tolerance);
1730 extern GEOSGeometry GEOS_DLL *GEOSTopologyPreserveSimplify(const GEOSGeometry* g,
1731  double tolerance);
1732 
1733 /*
1734  * Return all distinct vertices of input geometry as a MULTIPOINT.
1735  * Note that only 2 dimensions of the vertices are considered when
1736  * testing for equality.
1737  */
1738 extern GEOSGeometry GEOS_DLL *GEOSGeom_extractUniquePoints(
1739  const GEOSGeometry* g);
1740 
1741 /*
1742  * Find paths shared between the two given lineal geometries.
1743  *
1744  * Returns a GEOMETRYCOLLECTION having two elements:
1745  * - first element is a MULTILINESTRING containing shared paths
1746  * having the _same_ direction on both inputs
1747  * - second element is a MULTILINESTRING containing shared paths
1748  * having the _opposite_ direction on the two inputs
1749  *
1750  * Returns NULL on exception
1751  */
1752 extern GEOSGeometry GEOS_DLL *GEOSSharedPaths(const GEOSGeometry* g1,
1753  const GEOSGeometry* g2);
1754 
1755 /*
1756  * Snap first geometry on to second with given tolerance
1757  * Returns a newly allocated geometry, or NULL on exception
1758  */
1759 extern GEOSGeometry GEOS_DLL *GEOSSnap(const GEOSGeometry* g1,
1760  const GEOSGeometry* g2, double tolerance);
1761 
1762 /*
1763  * Return a Delaunay triangulation of the vertex of the given geometry
1764  *
1765  * @param g the input geometry whose vertex will be used as "sites"
1766  * @param tolerance optional snapping tolerance to use for improved robustness
1767  * @param onlyEdges if non-zero will return a MULTILINESTRING, otherwise it will
1768  * return a GEOMETRYCOLLECTION containing triangular POLYGONs.
1769  *
1770  * @return a newly allocated geometry, or NULL on exception
1771  */
1772 extern GEOSGeometry GEOS_DLL * GEOSDelaunayTriangulation(
1773  const GEOSGeometry *g,
1774  double tolerance,
1775  int onlyEdges);
1776 
1777 /*
1778  * Returns the Voronoi polygons of a set of Vertices given as input
1779  *
1780  * @param g the input geometry whose vertex will be used as sites.
1781  * @param tolerance snapping tolerance to use for improved robustness
1782  * @param onlyEdges whether to return only edges of the voronoi cells
1783  * @param env clipping envelope for the returned diagram, automatically
1784  * determined if NULL.
1785  * The diagram will be clipped to the larger
1786  * of this envelope or an envelope surrounding the sites.
1787  *
1788  * @return a newly allocated geometry, or NULL on exception.
1789  */
1790 extern GEOSGeometry GEOS_DLL * GEOSVoronoiDiagram(
1791  const GEOSGeometry *g,
1792  const GEOSGeometry *env,
1793  double tolerance,
1794  int onlyEdges);
1795 /*
1796  * Computes the coordinate where two line segments intersect, if any
1797  *
1798  * @param ax0 x-coordinate of first point in first segment
1799  * @param ay0 y-coordinate of first point in first segment
1800  * @param ax1 x-coordinate of second point in first segment
1801  * @param ay1 y-coordinate of second point in first segment
1802  * @param bx0 x-coordinate of first point in second segment
1803  * @param by0 y-coordinate of first point in second segment
1804  * @param bx1 x-coordinate of second point in second segment
1805  * @param by1 y-coordinate of second point in second segment
1806  * @param cx x-coordinate of intersection point
1807  * @param cy y-coordinate of intersection point
1808  *
1809  * @return 0 on error, 1 on success, -1 if segments do not intersect
1810  */
1811 
1812 extern int GEOS_DLL GEOSSegmentIntersection(
1813  double ax0, double ay0,
1814  double ax1, double ay1,
1815  double bx0, double by0,
1816  double bx1, double by1,
1817  double* cx, double* cy);
1818 
1819 /************************************************************************
1820  *
1821  * Binary predicates - return 2 on exception, 1 on true, 0 on false
1822  *
1823  ***********************************************************************/
1824 
1825 extern char GEOS_DLL GEOSDisjoint(const GEOSGeometry* g1, const GEOSGeometry* g2);
1826 extern char GEOS_DLL GEOSTouches(const GEOSGeometry* g1, const GEOSGeometry* g2);
1827 extern char GEOS_DLL GEOSIntersects(const GEOSGeometry* g1, const GEOSGeometry* g2);
1828 extern char GEOS_DLL GEOSCrosses(const GEOSGeometry* g1, const GEOSGeometry* g2);
1829 extern char GEOS_DLL GEOSWithin(const GEOSGeometry* g1, const GEOSGeometry* g2);
1830 extern char GEOS_DLL GEOSContains(const GEOSGeometry* g1, const GEOSGeometry* g2);
1831 extern char GEOS_DLL GEOSOverlaps(const GEOSGeometry* g1, const GEOSGeometry* g2);
1832 extern char GEOS_DLL GEOSEquals(const GEOSGeometry* g1, const GEOSGeometry* g2);
1833 extern char GEOS_DLL GEOSCovers(const GEOSGeometry* g1, const GEOSGeometry* g2);
1834 extern char GEOS_DLL GEOSCoveredBy(const GEOSGeometry* g1, const GEOSGeometry* g2);
1835 
1844 extern char GEOS_DLL GEOSEqualsExact(const GEOSGeometry* g1, const GEOSGeometry* g2, double tolerance);
1845 
1846 /************************************************************************
1847  *
1848  * Prepared Geometry Binary predicates - return 2 on exception, 1 on true, 0 on false
1849  *
1850  ***********************************************************************/
1851 
1852 /*
1853  * GEOSGeometry ownership is retained by caller
1854  */
1855 extern const GEOSPreparedGeometry GEOS_DLL *GEOSPrepare(const GEOSGeometry* g);
1856 
1857 extern void GEOS_DLL GEOSPreparedGeom_destroy(const GEOSPreparedGeometry* g);
1858 
1859 extern char GEOS_DLL GEOSPreparedContains(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
1860 extern char GEOS_DLL GEOSPreparedContainsProperly(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
1861 extern char GEOS_DLL GEOSPreparedCoveredBy(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
1862 extern char GEOS_DLL GEOSPreparedCovers(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
1863 extern char GEOS_DLL GEOSPreparedCrosses(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
1864 extern char GEOS_DLL GEOSPreparedDisjoint(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
1865 extern char GEOS_DLL GEOSPreparedIntersects(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
1866 extern char GEOS_DLL GEOSPreparedOverlaps(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
1867 extern char GEOS_DLL GEOSPreparedTouches(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
1868 extern char GEOS_DLL GEOSPreparedWithin(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
1869 
1870 /************************************************************************
1871  *
1872  * STRtree functions
1873  *
1874  ***********************************************************************/
1875 
1876 /*
1877  * GEOSGeometry ownership is retained by caller
1878  */
1879 
1880 /*
1881  * Create a new R-tree using the Sort-Tile-Recursive algorithm (STRtree) for two-dimensional
1882  * spatial data.
1883  *
1884  * @param nodeCapacity the maximum number of child nodes that a node may have. The minimum
1885  * recommended capacity value is 4. If unsure, use a default node capacity of 10.
1886  * @return a pointer to the created tree
1887  */
1888 extern GEOSSTRtree GEOS_DLL *GEOSSTRtree_create(size_t nodeCapacity);
1889 
1890 /*
1891  * Insert an item into an STRtree
1892  *
1893  * @param tree the STRtree in which the item should be inserted
1894  * @param g a GEOSGeometry whose envelope corresponds to the extent of 'item'
1895  * @param item the item to insert into the tree
1896  */
1897 extern void GEOS_DLL GEOSSTRtree_insert(GEOSSTRtree *tree,
1898  const GEOSGeometry *g,
1899  void *item);
1900 
1901 /*
1902  * Query an STRtree for items intersecting a specified envelope
1903  *
1904  * @param tree the STRtree to search
1905  * @param g a GEOSGeomety from which a query envelope will be extracted
1906  * @param callback a function to be executed for each item in the tree whose envelope intersects
1907  * the envelope of 'g'. The callback function should take two parameters: a void
1908  * pointer representing the located item in the tree, and a void userdata pointer.
1909  * @param userdata an optional pointer to pe passed to 'callback' as an argument
1910  */
1911 extern void GEOS_DLL GEOSSTRtree_query(GEOSSTRtree *tree,
1912  const GEOSGeometry *g,
1913  GEOSQueryCallback callback,
1914  void *userdata);
1915 /*
1916  * Returns the nearest item in the STRtree to the supplied GEOSGeometry.
1917  * All items in the tree MUST be of type GEOSGeometry. If this is not the case, use
1918  * GEOSSTRtree_nearest_generic instead.
1919 *
1920  * @param tree the STRtree to search
1921  * @param geom the geometry with which the tree should be queried
1922  * @return a const pointer to the nearest GEOSGeometry in the tree to 'geom', or NULL in
1923  * case of exception
1924  */
1925 extern const GEOSGeometry GEOS_DLL *GEOSSTRtree_nearest(GEOSSTRtree *tree, const GEOSGeometry* geom);
1926 
1927 /*
1928  * Returns the nearest item in the STRtree to the supplied item
1929  *
1930  * @param tree the STRtree to search
1931  * @param item the item with which the tree should be queried
1932  * @param itemEnvelope a GEOSGeometry having the bounding box of 'item'
1933  * @param distancefn a function that can compute the distance between two items
1934  * in the STRtree. The function should return zero in case of error,
1935  * and should store the computed distance to the location pointed to by
1936  * the 'distance' argument. The computed distance between two items
1937  * must not exceed the Cartesian distance between their envelopes.
1938  * @param userdata optional pointer to arbitrary data; will be passed to distancefn
1939  * each time it is called.
1940  * @return a const pointer to the nearest item in the tree to 'item', or NULL in
1941  * case of exception
1942  */
1943 extern const void GEOS_DLL *GEOSSTRtree_nearest_generic(GEOSSTRtree *tree,
1944  const void* item,
1945  const GEOSGeometry* itemEnvelope,
1946  GEOSDistanceCallback distancefn,
1947  void* userdata);
1948 /*
1949  * Iterates over all items in the STRtree
1950  *
1951  * @param tree the STRtree over which to iterate
1952  * @param callback a function to be executed for each item in the tree.
1953  */
1954 extern void GEOS_DLL GEOSSTRtree_iterate(GEOSSTRtree *tree,
1955  GEOSQueryCallback callback,
1956  void *userdata);
1957 
1958 /*
1959  * Removes an item from the STRtree
1960  *
1961  * @param tree the STRtree from which to remove an item
1962  * @param g the envelope of the item to remove
1963  * @param the item to remove
1964  * @return 0 if the item was not removed;
1965  * 1 if the item was removed;
1966  * 2 if an exception occurred
1967  */
1968 extern char GEOS_DLL GEOSSTRtree_remove(GEOSSTRtree *tree,
1969  const GEOSGeometry *g,
1970  void *item);
1971 extern void GEOS_DLL GEOSSTRtree_destroy(GEOSSTRtree *tree);
1972 
1973 
1974 /************************************************************************
1975  *
1976  * Unary predicate - return 2 on exception, 1 on true, 0 on false
1977  *
1978  ***********************************************************************/
1979 
1980 extern char GEOS_DLL GEOSisEmpty(const GEOSGeometry* g);
1981 extern char GEOS_DLL GEOSisSimple(const GEOSGeometry* g);
1982 extern char GEOS_DLL GEOSisRing(const GEOSGeometry* g);
1983 extern char GEOS_DLL GEOSHasZ(const GEOSGeometry* g);
1984 extern char GEOS_DLL GEOSisClosed(const GEOSGeometry *g);
1985 
1986 /************************************************************************
1987  *
1988  * Dimensionally Extended 9 Intersection Model related
1989  *
1990  ***********************************************************************/
1991 
1992 /* return 2 on exception, 1 on true, 0 on false */
1993 extern char GEOS_DLL GEOSRelatePattern(const GEOSGeometry* g1, const GEOSGeometry* g2, const char *pat);
1994 
1995 /* return NULL on exception, a string to GEOSFree otherwise */
1996 extern char GEOS_DLL *GEOSRelate(const GEOSGeometry* g1, const GEOSGeometry* g2);
1997 
1998 /* return 2 on exception, 1 on true, 0 on false */
1999 extern char GEOS_DLL GEOSRelatePatternMatch(const char *mat, const char *pat);
2000 
2001 /* return NULL on exception, a string to GEOSFree otherwise */
2002 extern char GEOS_DLL *GEOSRelateBoundaryNodeRule(const GEOSGeometry* g1,
2003  const GEOSGeometry* g2,
2004  int bnr);
2005 
2006 /************************************************************************
2007  *
2008  * Validity checking
2009  *
2010  ***********************************************************************/
2011 
2012 /* return 2 on exception, 1 on true, 0 on false */
2013 extern char GEOS_DLL GEOSisValid(const GEOSGeometry* g);
2014 
2015 /* return NULL on exception, a string to GEOSFree otherwise */
2016 extern char GEOS_DLL *GEOSisValidReason(const GEOSGeometry *g);
2017 /*
2018  * Caller has the responsibility to destroy 'reason' (GEOSFree)
2019  * and 'location' (GEOSGeom_destroy) params
2020  * return 2 on exception, 1 when valid, 0 when invalid
2021  * Use enum GEOSValidFlags values for the flags param.
2022  */
2023 extern char GEOS_DLL GEOSisValidDetail(const GEOSGeometry* g,
2024  int flags,
2025  char** reason, GEOSGeometry** location);
2026 
2027 extern GEOSGeometry GEOS_DLL *GEOSMakeValid(const GEOSGeometry* g);
2028 
2029 /************************************************************************
2030  *
2031  * Geometry info
2032  *
2033  ***********************************************************************/
2034 
2035 /* Return NULL on exception, result must be freed by caller. */
2036 extern char GEOS_DLL *GEOSGeomType(const GEOSGeometry* g);
2037 
2038 /* Return -1 on exception */
2039 extern int GEOS_DLL GEOSGeomTypeId(const GEOSGeometry* g);
2040 
2041 /* Return 0 on exception */
2042 extern int GEOS_DLL GEOSGetSRID(const GEOSGeometry* g);
2043 
2044 extern void GEOS_DLL GEOSSetSRID(GEOSGeometry* g, int SRID);
2045 
2046 extern void GEOS_DLL *GEOSGeom_getUserData(const GEOSGeometry* g);
2047 
2048 extern void GEOS_DLL GEOSGeom_setUserData(GEOSGeometry* g, void* userData);
2049 
2050 
2051 /* May be called on all geometries in GEOS 3.x, returns -1 on error and 1
2052  * for non-multi geometries. Older GEOS versions only accept
2053  * GeometryCollections or Multi* geometries here, and are likely to crash
2054  * when fed simple geometries, so beware if you need compatibility with
2055  * old GEOS versions.
2056  */
2057 extern int GEOS_DLL GEOSGetNumGeometries(const GEOSGeometry* g);
2058 
2059 /*
2060  * Return NULL on exception.
2061  * Returned object is a pointer to internal storage:
2062  * it must NOT be destroyed directly.
2063  * Up to GEOS 3.2.0 the input geometry must be a Collection, in
2064  * later version it doesn't matter (getGeometryN(0) for a single will
2065  * return the input).
2066  */
2067 extern const GEOSGeometry GEOS_DLL *GEOSGetGeometryN(const GEOSGeometry* g, int n);
2068 
2069 /* Return -1 on exception */
2070 extern int GEOS_DLL GEOSNormalize(GEOSGeometry* g);
2071 
2072 /* Return NULL on exception */
2073 extern GEOSGeometry GEOS_DLL *GEOSGeom_setPrecision(
2074  const GEOSGeometry *g, double gridSize, int flags);
2075 
2076 /* Return -1 on exception */
2077 extern double GEOS_DLL GEOSGeom_getPrecision(const GEOSGeometry *g);
2078 
2079 /* Return -1 on exception */
2080 extern int GEOS_DLL GEOSGetNumInteriorRings(const GEOSGeometry* g);
2081 
2082 /* Return -1 on exception, Geometry must be a LineString. */
2083 extern int GEOS_DLL GEOSGeomGetNumPoints(const GEOSGeometry* g);
2084 
2085 /* Return 0 on exception, otherwise 1, Geometry must be a Point. */
2086 extern int GEOS_DLL GEOSGeomGetX(const GEOSGeometry *g, double *x);
2087 extern int GEOS_DLL GEOSGeomGetY(const GEOSGeometry *g, double *y);
2088 extern int GEOS_DLL GEOSGeomGetZ(const GEOSGeometry *g, double *z);
2089 
2090 /*
2091  * Return NULL on exception, Geometry must be a Polygon.
2092  * Returned object is a pointer to internal storage:
2093  * it must NOT be destroyed directly.
2094  */
2095 extern const GEOSGeometry GEOS_DLL *GEOSGetInteriorRingN(const GEOSGeometry* g, int n);
2096 
2097 /*
2098  * Return NULL on exception, Geometry must be a Polygon.
2099  * Returned object is a pointer to internal storage:
2100  * it must NOT be destroyed directly.
2101  */
2102 extern const GEOSGeometry GEOS_DLL *GEOSGetExteriorRing(const GEOSGeometry* g);
2103 
2104 /* Return -1 on exception */
2105 extern int GEOS_DLL GEOSGetNumCoordinates(const GEOSGeometry* g);
2106 
2107 /*
2108  * Return NULL on exception.
2109  * Geometry must be a LineString, LinearRing or Point.
2110  */
2111 extern const GEOSCoordSequence GEOS_DLL *GEOSGeom_getCoordSeq(const GEOSGeometry* g);
2112 
2113 /*
2114  * Return 0 on exception (or empty geometry)
2115  */
2116 extern int GEOS_DLL GEOSGeom_getDimensions(const GEOSGeometry* g);
2117 
2118 /*
2119  * Return 2 or 3.
2120  */
2121 extern int GEOS_DLL GEOSGeom_getCoordinateDimension(const GEOSGeometry* g);
2122 
2123 /*
2124  * Return 0 on exception
2125  */
2126 extern int GEOS_DLL GEOSGeom_getXMin(const GEOSGeometry* g, double* value);
2127 extern int GEOS_DLL GEOSGeom_getYMin(const GEOSGeometry* g, double* value);
2128 extern int GEOS_DLL GEOSGeom_getXMax(const GEOSGeometry* g, double* value);
2129 extern int GEOS_DLL GEOSGeom_getYMax(const GEOSGeometry* g, double* value);
2130 
2131 /*
2132  * Return NULL on exception.
2133  * Must be LineString and must be freed by called.
2134  */
2135 extern GEOSGeometry GEOS_DLL *GEOSGeomGetPointN(const GEOSGeometry *g, int n);
2136 extern GEOSGeometry GEOS_DLL *GEOSGeomGetStartPoint(const GEOSGeometry *g);
2137 extern GEOSGeometry GEOS_DLL *GEOSGeomGetEndPoint(const GEOSGeometry *g);
2138 
2139 /************************************************************************
2140  *
2141  * Misc functions
2142  *
2143  ***********************************************************************/
2144 
2145 /* Return 0 on exception, 1 otherwise */
2146 extern int GEOS_DLL GEOSArea(const GEOSGeometry* g, double *area);
2147 extern int GEOS_DLL GEOSLength(const GEOSGeometry* g, double *length);
2148 extern int GEOS_DLL GEOSDistance(const GEOSGeometry* g1, const GEOSGeometry* g2,
2149  double *dist);
2150 extern int GEOS_DLL GEOSDistanceIndexed(const GEOSGeometry* g1, const GEOSGeometry* g2,
2151  double *dist);
2152 extern int GEOS_DLL GEOSHausdorffDistance(const GEOSGeometry *g1,
2153  const GEOSGeometry *g2, double *dist);
2154 extern int GEOS_DLL GEOSHausdorffDistanceDensify(const GEOSGeometry *g1,
2155  const GEOSGeometry *g2, double densifyFrac, double *dist);
2156 extern int GEOS_DLL GEOSFrechetDistance(const GEOSGeometry *g1,
2157  const GEOSGeometry *g2, double *dist);
2158 extern int GEOS_DLL GEOSFrechetDistanceDensify(const GEOSGeometry *g1,
2159  const GEOSGeometry *g2, double densifyFrac, double *dist);
2160 extern int GEOS_DLL GEOSGeomGetLength(const GEOSGeometry *g, double *length);
2161 
2162 /* Return 0 on exception, the closest points of the two geometries otherwise.
2163  * The first point comes from g1 geometry and the second point comes from g2.
2164  */
2165 extern GEOSCoordSequence GEOS_DLL *GEOSNearestPoints(
2166  const GEOSGeometry* g1, const GEOSGeometry* g2);
2167 
2168 
2169 /************************************************************************
2170  *
2171  * Algorithms
2172  *
2173  ***********************************************************************/
2174 
2175 /* Walking from A to B:
2176  * return -1 if reaching P takes a counter-clockwise (left) turn
2177  * return 1 if reaching P takes a clockwise (right) turn
2178  * return 0 if P is collinear with A-B
2179  *
2180  * On exceptions, return 2.
2181  *
2182  */
2183 extern int GEOS_DLL GEOSOrientationIndex(double Ax, double Ay, double Bx, double By,
2184  double Px, double Py);
2185 
2186 /************************************************************************
2187  *
2188  * Reader and Writer APIs
2189  *
2190  ***********************************************************************/
2191 
2192 /* WKT Reader */
2193 extern GEOSWKTReader GEOS_DLL *GEOSWKTReader_create();
2194 extern void GEOS_DLL GEOSWKTReader_destroy(GEOSWKTReader* reader);
2195 extern GEOSGeometry GEOS_DLL *GEOSWKTReader_read(GEOSWKTReader* reader, const char *wkt);
2196 
2197 /* WKT Writer */
2198 extern GEOSWKTWriter GEOS_DLL *GEOSWKTWriter_create();
2199 extern void GEOS_DLL GEOSWKTWriter_destroy(GEOSWKTWriter* writer);
2200 extern char GEOS_DLL *GEOSWKTWriter_write(GEOSWKTWriter* writer, const GEOSGeometry* g);
2201 extern void GEOS_DLL GEOSWKTWriter_setTrim(GEOSWKTWriter *writer, char trim);
2202 extern void GEOS_DLL GEOSWKTWriter_setRoundingPrecision(GEOSWKTWriter *writer, int precision);
2203 extern void GEOS_DLL GEOSWKTWriter_setOutputDimension(GEOSWKTWriter *writer, int dim);
2204 extern int GEOS_DLL GEOSWKTWriter_getOutputDimension(GEOSWKTWriter *writer);
2205 extern void GEOS_DLL GEOSWKTWriter_setOld3D(GEOSWKTWriter *writer, int useOld3D);
2206 
2207 /* WKB Reader */
2208 extern GEOSWKBReader GEOS_DLL *GEOSWKBReader_create();
2209 extern void GEOS_DLL GEOSWKBReader_destroy(GEOSWKBReader* reader);
2210 extern GEOSGeometry GEOS_DLL *GEOSWKBReader_read(GEOSWKBReader* reader, const unsigned char *wkb, size_t size);
2211 extern GEOSGeometry GEOS_DLL *GEOSWKBReader_readHEX(GEOSWKBReader* reader, const unsigned char *hex, size_t size);
2212 
2213 /* WKB Writer */
2214 extern GEOSWKBWriter GEOS_DLL *GEOSWKBWriter_create();
2215 extern void GEOS_DLL GEOSWKBWriter_destroy(GEOSWKBWriter* writer);
2216 
2217 /* The caller owns the results for these two methods! */
2218 extern unsigned char GEOS_DLL *GEOSWKBWriter_write(GEOSWKBWriter* writer, const GEOSGeometry* g, size_t *size);
2219 extern unsigned char GEOS_DLL *GEOSWKBWriter_writeHEX(GEOSWKBWriter* writer, const GEOSGeometry* g, size_t *size);
2220 
2221 /*
2222  * Specify whether output WKB should be 2d or 3d.
2223  * Return previously set number of dimensions.
2224  */
2225 extern int GEOS_DLL GEOSWKBWriter_getOutputDimension(const GEOSWKBWriter* writer);
2226 extern void GEOS_DLL GEOSWKBWriter_setOutputDimension(GEOSWKBWriter* writer, int newDimension);
2227 
2228 /*
2229  * Specify whether the WKB byte order is big or little endian.
2230  * The return value is the previous byte order.
2231  */
2232 extern int GEOS_DLL GEOSWKBWriter_getByteOrder(const GEOSWKBWriter* writer);
2233 extern void GEOS_DLL GEOSWKBWriter_setByteOrder(GEOSWKBWriter* writer, int byteOrder);
2234 
2235 /*
2236  * Specify whether SRID values should be output.
2237  */
2238 extern char GEOS_DLL GEOSWKBWriter_getIncludeSRID(const GEOSWKBWriter* writer);
2239 extern void GEOS_DLL GEOSWKBWriter_setIncludeSRID(GEOSWKBWriter* writer, const char writeSRID);
2240 
2241 /*
2242  * Free buffers returned by stuff like GEOSWKBWriter_write(),
2243  * GEOSWKBWriter_writeHEX() and GEOSWKTWriter_write().
2244  */
2245 extern void GEOS_DLL GEOSFree(void *buffer);
2246 
2247 #endif /* #ifndef GEOS_USE_ONLY_R_API */
2248 
2249 
2250 #ifdef __cplusplus
2251 } // extern "C"
2252 #endif
2253 
2254 #endif /* #ifndef GEOS_C_H_INCLUDED */
a linestring
Definition: Geometry.h:79
a collection of heterogeneus geometries
Definition: Geometry.h:91
a collection of linestrings
Definition: Geometry.h:87
a collection of points
Definition: Geometry.h:85
a polygon
Definition: Geometry.h:83
a linear ring (linestring with 1st point == last point)
Definition: Geometry.h:81
a point
Definition: Geometry.h:77
a collection of polygons
Definition: Geometry.h:89