GEOS  3.8.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 8
59 #endif
60 #ifndef GEOS_VERSION_PATCH
61 #define GEOS_VERSION_PATCH 0dev
62 #endif
63 #ifndef GEOS_VERSION
64 #define GEOS_VERSION "3.8.0dev"
65 #endif
66 #ifndef GEOS_JTS_PORT
67 #define GEOS_JTS_PORT "1.13.0"
68 #endif
69 
70 #define GEOS_CAPI_VERSION_MAJOR 1
71 #define GEOS_CAPI_VERSION_MINOR 11
72 #define GEOS_CAPI_VERSION_PATCH 0
73 #define GEOS_CAPI_VERSION "3.8.0dev-CAPI-1.11.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_setOrdinate_r(GEOSContextHandle_t handle,
306  GEOSCoordSequence* s,
307  unsigned int idx,
308  unsigned int dim, double val);
309 
310 /*
311  * Get ordinate values from a Coordinate Sequence.
312  * Return 0 on exception.
313  */
314 extern int GEOS_DLL GEOSCoordSeq_getX_r(GEOSContextHandle_t handle,
315  const GEOSCoordSequence* s,
316  unsigned int idx, double *val);
317 extern int GEOS_DLL GEOSCoordSeq_getY_r(GEOSContextHandle_t handle,
318  const GEOSCoordSequence* s,
319  unsigned int idx, double *val);
320 extern int GEOS_DLL GEOSCoordSeq_getZ_r(GEOSContextHandle_t handle,
321  const GEOSCoordSequence* s,
322  unsigned int idx, double *val);
323 extern int GEOS_DLL GEOSCoordSeq_getOrdinate_r(GEOSContextHandle_t handle,
324  const GEOSCoordSequence* s,
325  unsigned int idx,
326  unsigned int dim, double *val);
327 /*
328  * Get size and dimensions info from a Coordinate Sequence.
329  * Return 0 on exception.
330  */
331 extern int GEOS_DLL GEOSCoordSeq_getSize_r(GEOSContextHandle_t handle,
332  const GEOSCoordSequence* s,
333  unsigned int *size);
334 extern int GEOS_DLL GEOSCoordSeq_getDimensions_r(GEOSContextHandle_t handle,
335  const GEOSCoordSequence* s,
336  unsigned int *dims);
337 /*
338  * Check orientation of a CoordinateSequence and set 'is_ccw' to 1
339  * if it has counter-clockwise orientation, 0 otherwise.
340  * Return 0 on exception, 1 on success.
341  */
342 extern int GEOS_DLL GEOSCoordSeq_isCCW_r(GEOSContextHandle_t handle,
343  const GEOSCoordSequence* s,
344  char* is_ccw);
345 
346 /************************************************************************
347  *
348  * Linear referencing functions -- there are more, but these are
349  * probably sufficient for most purposes
350  *
351  ***********************************************************************/
352 
353 /*
354  * GEOSGeometry ownership is retained by caller
355  */
356 
357 
358 /* Return distance of point 'p' projected on 'g' from origin
359  * of 'g'. Geometry 'g' must be a lineal geometry */
360 extern double GEOS_DLL GEOSProject_r(GEOSContextHandle_t handle,
361  const GEOSGeometry *g,
362  const GEOSGeometry *p);
363 
364 /* Return closest point to given distance within geometry
365  * Geometry must be a LineString */
366 extern GEOSGeometry GEOS_DLL *GEOSInterpolate_r(GEOSContextHandle_t handle,
367  const GEOSGeometry *g,
368  double d);
369 
370 extern double GEOS_DLL GEOSProjectNormalized_r(GEOSContextHandle_t handle,
371  const GEOSGeometry *g,
372  const GEOSGeometry *p);
373 
374 extern GEOSGeometry GEOS_DLL *GEOSInterpolateNormalized_r(
375  GEOSContextHandle_t handle,
376  const GEOSGeometry *g,
377  double d);
378 
379 /************************************************************************
380  *
381  * Buffer related functions
382  *
383  ***********************************************************************/
384 
385 
386 /* @return NULL on exception */
387 extern GEOSGeometry GEOS_DLL *GEOSBuffer_r(GEOSContextHandle_t handle,
388  const GEOSGeometry* g,
389  double width, int quadsegs);
390 
391 enum GEOSBufCapStyles {
392  GEOSBUF_CAP_ROUND=1,
393  GEOSBUF_CAP_FLAT=2,
394  GEOSBUF_CAP_SQUARE=3
395 };
396 
397 enum GEOSBufJoinStyles {
398  GEOSBUF_JOIN_ROUND=1,
399  GEOSBUF_JOIN_MITRE=2,
400  GEOSBUF_JOIN_BEVEL=3
401 };
402 
403 /* @return 0 on exception */
404 extern GEOSBufferParams GEOS_DLL *GEOSBufferParams_create_r(
405  GEOSContextHandle_t handle);
406 extern void GEOS_DLL GEOSBufferParams_destroy_r(
407  GEOSContextHandle_t handle,
408  GEOSBufferParams* parms);
409 
410 /* @return 0 on exception */
411 extern int GEOS_DLL GEOSBufferParams_setEndCapStyle_r(
412  GEOSContextHandle_t handle,
413  GEOSBufferParams* p,
414  int style);
415 
416 /* @return 0 on exception */
417 extern int GEOS_DLL GEOSBufferParams_setJoinStyle_r(
418  GEOSContextHandle_t handle,
419  GEOSBufferParams* p,
420  int joinStyle);
421 
422 /* @return 0 on exception */
423 extern int GEOS_DLL GEOSBufferParams_setMitreLimit_r(
424  GEOSContextHandle_t handle,
425  GEOSBufferParams* p,
426  double mitreLimit);
427 
428 /* @return 0 on exception */
429 extern int GEOS_DLL GEOSBufferParams_setQuadrantSegments_r(
430  GEOSContextHandle_t handle,
431  GEOSBufferParams* p,
432  int quadSegs);
433 
434 /* @param singleSided: 1 for single sided, 0 otherwise */
435 /* @return 0 on exception */
436 extern int GEOS_DLL GEOSBufferParams_setSingleSided_r(
437  GEOSContextHandle_t handle,
438  GEOSBufferParams* p,
439  int singleSided);
440 
441 /* @return NULL on exception */
442 extern GEOSGeometry GEOS_DLL *GEOSBufferWithParams_r(
443  GEOSContextHandle_t handle,
444  const GEOSGeometry* g,
445  const GEOSBufferParams* p,
446  double width);
447 
448 /* These functions return NULL on exception. */
449 extern GEOSGeometry GEOS_DLL *GEOSBufferWithStyle_r(GEOSContextHandle_t handle,
450  const GEOSGeometry* g, double width, int quadsegs, int endCapStyle,
451  int joinStyle, double mitreLimit);
452 
453 /* These functions return NULL on exception. Only LINESTRINGs are accepted. */
454 /* @deprecated in 3.3.0: use GEOSOffsetCurve instead */
455 extern GEOSGeometry GEOS_DLL *GEOSSingleSidedBuffer_r(
456  GEOSContextHandle_t handle,
457  const GEOSGeometry* g, double width, int quadsegs,
458  int joinStyle, double mitreLimit, int leftSide);
459 
460 /*
461  * Only LINESTRINGs are accepted.
462  * @param width : offset distance.
463  * negative for right side offset.
464  * positive for left side offset.
465  * @return NULL on exception
466  */
467 extern GEOSGeometry GEOS_DLL *GEOSOffsetCurve_r(GEOSContextHandle_t handle,
468  const GEOSGeometry* g, double width, int quadsegs,
469  int joinStyle, double mitreLimit);
470 
471 
472 /************************************************************************
473  *
474  * Geometry Constructors.
475  * GEOSCoordSequence* arguments will become ownership of the returned object.
476  * All functions return NULL on exception.
477  *
478  ***********************************************************************/
479 
480 extern GEOSGeometry GEOS_DLL *GEOSGeom_createPoint_r(
481  GEOSContextHandle_t handle,
482  GEOSCoordSequence* s);
483 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyPoint_r(
484  GEOSContextHandle_t handle);
485 extern GEOSGeometry GEOS_DLL *GEOSGeom_createLinearRing_r(
486  GEOSContextHandle_t handle,
487  GEOSCoordSequence* s);
488 extern GEOSGeometry GEOS_DLL *GEOSGeom_createLineString_r(
489  GEOSContextHandle_t handle,
490  GEOSCoordSequence* s);
491 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyLineString_r(
492  GEOSContextHandle_t handle);
493 
494 /*
495  * Second argument is an array of GEOSGeometry* objects.
496  * The caller remains owner of the array, but pointed-to
497  * objects become ownership of the returned GEOSGeometry.
498  */
499 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyPolygon_r(
500  GEOSContextHandle_t handle);
501 extern GEOSGeometry GEOS_DLL *GEOSGeom_createPolygon_r(
502  GEOSContextHandle_t handle,
503  GEOSGeometry* shell,
504  GEOSGeometry** holes,
505  unsigned int nholes);
506 extern GEOSGeometry GEOS_DLL *GEOSGeom_createCollection_r(
507  GEOSContextHandle_t handle, int type,
508  GEOSGeometry* *geoms,
509  unsigned int ngeoms);
510 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyCollection_r(
511  GEOSContextHandle_t handle, int type);
512 
513 extern GEOSGeometry GEOS_DLL *GEOSGeom_clone_r(GEOSContextHandle_t handle,
514  const GEOSGeometry* g);
515 
516 /************************************************************************
517  *
518  * Memory management
519  *
520  ***********************************************************************/
521 
522 extern void GEOS_DLL GEOSGeom_destroy_r(GEOSContextHandle_t handle,
523  GEOSGeometry* g);
524 
525 /************************************************************************
526  *
527  * Topology operations - return NULL on exception.
528  *
529  ***********************************************************************/
530 
531 extern GEOSGeometry GEOS_DLL *GEOSEnvelope_r(GEOSContextHandle_t handle,
532  const GEOSGeometry* g);
533 extern GEOSGeometry GEOS_DLL *GEOSIntersection_r(GEOSContextHandle_t handle,
534  const GEOSGeometry* g1,
535  const GEOSGeometry* g2);
536 extern GEOSGeometry GEOS_DLL *GEOSConvexHull_r(GEOSContextHandle_t handle,
537  const GEOSGeometry* g);
538 
539 /* Returns the minimum rotated rectangular POLYGON which encloses the input geometry. The rectangle
540  * has width equal to the minimum diameter, and a longer length. If the convex hill of the input is
541  * degenerate (a line or point) a LINESTRING or POINT is returned. The minimum rotated rectangle can
542  * be used as an extremely generalized representation for the given geometry.
543  */
544 extern GEOSGeometry GEOS_DLL *GEOSMinimumRotatedRectangle_r(GEOSContextHandle_t handle,
545  const GEOSGeometry* g);
546 
547 /* Returns a LINESTRING geometry which represents the minimum diameter of the geometry.
548  * The minimum diameter is defined to be the width of the smallest band that
549  * contains the geometry, where a band is a strip of the plane defined
550  * by two parallel lines. This can be thought of as the smallest hole that the geometry
551  * can be moved through, with a single rotation.
552  */
553 extern GEOSGeometry GEOS_DLL *GEOSMinimumWidth_r(GEOSContextHandle_t handle,
554  const GEOSGeometry* g);
555 
556 extern GEOSGeometry GEOS_DLL *GEOSMinimumClearanceLine_r(GEOSContextHandle_t handle,
557  const GEOSGeometry* g);
558 
559 extern int GEOS_DLL GEOSMinimumClearance_r(GEOSContextHandle_t handle,
560  const GEOSGeometry* g,
561  double* distance);
562 
563 extern GEOSGeometry GEOS_DLL *GEOSDifference_r(GEOSContextHandle_t handle,
564  const GEOSGeometry* g1,
565  const GEOSGeometry* g2);
566 extern GEOSGeometry GEOS_DLL *GEOSSymDifference_r(GEOSContextHandle_t handle,
567  const GEOSGeometry* g1,
568  const GEOSGeometry* g2);
569 extern GEOSGeometry GEOS_DLL *GEOSBoundary_r(GEOSContextHandle_t handle,
570  const GEOSGeometry* g);
571 extern GEOSGeometry GEOS_DLL *GEOSUnion_r(GEOSContextHandle_t handle,
572  const GEOSGeometry* g1,
573  const GEOSGeometry* g2);
574 extern GEOSGeometry GEOS_DLL *GEOSUnaryUnion_r(GEOSContextHandle_t handle,
575  const GEOSGeometry* g);
576 /* GEOSCoverageUnion is an optimized union algorithm for polygonal inputs that are correctly
577  * noded and do not overlap. It will not generate an error (return NULL) for inputs that
578  * do not satisfy this constraint. */
579 extern GEOSGeometry GEOS_DLL *GEOSCoverageUnion_r(GEOSContextHandle_t handle,
580  const GEOSGeometry* g);
581 /* @deprecated in 3.3.0: use GEOSUnaryUnion_r instead */
582 extern GEOSGeometry GEOS_DLL *GEOSUnionCascaded_r(GEOSContextHandle_t handle,
583  const GEOSGeometry* g);
584 extern GEOSGeometry GEOS_DLL *GEOSPointOnSurface_r(GEOSContextHandle_t handle,
585  const GEOSGeometry* g);
586 extern GEOSGeometry GEOS_DLL *GEOSGetCentroid_r(GEOSContextHandle_t handle,
587  const GEOSGeometry* g);
588 extern GEOSGeometry GEOS_DLL *GEOSNode_r(GEOSContextHandle_t handle,
589  const GEOSGeometry* g);
590 /* Fast, non-robust intersection between an arbitrary geometry and
591  * a rectangle. The returned geometry may be invalid. */
592 extern GEOSGeometry GEOS_DLL *GEOSClipByRect_r(GEOSContextHandle_t handle,
593  const GEOSGeometry* g,
594  double xmin, double ymin,
595  double xmax, double ymax);
596 
597 /*
598  * all arguments remain ownership of the caller
599  * (both Geometries and pointers)
600  */
601 /*
602  * Polygonizes a set of Geometries which contain linework that
603  * represents the edges of a planar graph.
604  *
605  * All types of Geometry are accepted as input; the constituent
606  * linework is extracted as the edges to be polygonized.
607  *
608  * The edges must be correctly noded; that is, they must only meet
609  * at their endpoints. Polygonization will accept incorrectly noded
610  * input but will not form polygons from non-noded edges, and reports
611  * them as errors.
612  *
613  * The Polygonizer reports the follow kinds of errors:
614  *
615  * - Dangles - edges which have one or both ends which are
616  * not incident on another edge endpoint
617  * - Cut Edges - edges which are connected at both ends but
618  * which do not form part of a polygon
619  * - Invalid Ring Lines - edges which form rings which are invalid
620  * (e.g. the component lines contain a self-intersection)
621  *
622  * Errors are reported to output parameters "cuts", "dangles" and
623  * "invalid" (if not-null). Formed polygons are returned as a
624  * collection. NULL is returned on exception. All returned
625  * geometries must be destroyed by caller.
626  *
627  * The GEOSPolygonize_valid_r variant allows extracting only polygons
628  * which form a valid polygonal result. The set of extracted polygons
629  * is guaranteed to be edge-disjoint. This is useful when it is known
630  * that the input lines form a valid polygonal geometry (which may
631  * include holes or nested polygons).
632  */
633 
634 extern GEOSGeometry GEOS_DLL *GEOSPolygonize_r(GEOSContextHandle_t handle,
635  const GEOSGeometry *const geoms[],
636  unsigned int ngeoms);
637 extern GEOSGeometry GEOS_DLL *GEOSPolygonize_valid_r(GEOSContextHandle_t handle,
638  const GEOSGeometry *const geoms[],
639  unsigned int ngems);
640 extern GEOSGeometry GEOS_DLL *GEOSPolygonizer_getCutEdges_r(
641  GEOSContextHandle_t handle,
642  const GEOSGeometry * const geoms[],
643  unsigned int ngeoms);
644 extern GEOSGeometry GEOS_DLL *GEOSPolygonize_full_r(GEOSContextHandle_t handle,
645  const GEOSGeometry* input, GEOSGeometry** cuts,
646  GEOSGeometry** dangles, GEOSGeometry** invalidRings);
647 
648 extern GEOSGeometry GEOS_DLL *GEOSBuildArea_r(
649  GEOSContextHandle_t handle,
650  const GEOSGeometry* g);
651 
652 extern GEOSGeometry GEOS_DLL *GEOSLineMerge_r(GEOSContextHandle_t handle,
653  const GEOSGeometry* g);
654 extern GEOSGeometry GEOS_DLL *GEOSReverse_r(GEOSContextHandle_t handle,
655  const GEOSGeometry* g);
656 extern GEOSGeometry GEOS_DLL *GEOSSimplify_r(GEOSContextHandle_t handle,
657  const GEOSGeometry* g,
658  double tolerance);
659 extern GEOSGeometry GEOS_DLL *GEOSTopologyPreserveSimplify_r(
660  GEOSContextHandle_t handle,
661  const GEOSGeometry* g, double tolerance);
662 
663 /*
664  * Return all distinct vertices of input geometry as a MULTIPOINT.
665  * Note that only 2 dimensions of the vertices are considered when
666  * testing for equality.
667  */
668 extern GEOSGeometry GEOS_DLL *GEOSGeom_extractUniquePoints_r(
669  GEOSContextHandle_t handle,
670  const GEOSGeometry* g);
671 
672 /*
673  * Find paths shared between the two given lineal geometries.
674  *
675  * Returns a GEOMETRYCOLLECTION having two elements:
676  * - first element is a MULTILINESTRING containing shared paths
677  * having the _same_ direction on both inputs
678  * - second element is a MULTILINESTRING containing shared paths
679  * having the _opposite_ direction on the two inputs
680  *
681  * Returns NULL on exception
682  */
683 extern GEOSGeometry GEOS_DLL *GEOSSharedPaths_r(GEOSContextHandle_t handle,
684  const GEOSGeometry* g1, const GEOSGeometry* g2);
685 
686 /*
687  * Snap first geometry on to second with given tolerance
688  * Returns a newly allocated geometry, or NULL on exception
689  */
690 extern GEOSGeometry GEOS_DLL *GEOSSnap_r(GEOSContextHandle_t handle,
691  const GEOSGeometry* g1, const GEOSGeometry* g2, double tolerance);
692 
693 /*
694  * Return a Delaunay triangulation of the vertex of the given geometry
695  *
696  * @param g the input geometry whose vertex will be used as "sites"
697  * @param tolerance optional snapping tolerance to use for improved robustness
698  * @param onlyEdges if non-zero will return a MULTILINESTRING, otherwise it will
699  * return a GEOMETRYCOLLECTION containing triangular POLYGONs.
700  *
701  * @return a newly allocated geometry, or NULL on exception
702  */
703 extern GEOSGeometry GEOS_DLL * GEOSDelaunayTriangulation_r(
704  GEOSContextHandle_t handle,
705  const GEOSGeometry *g,
706  double tolerance,
707  int onlyEdges);
708 
709 /*
710  * Returns the Voronoi polygons of a set of Vertices given as input
711  *
712  * @param g the input geometry whose vertex will be used as sites.
713  * @param tolerance snapping tolerance to use for improved robustness
714  * @param onlyEdges whether to return only edges of the Voronoi cells
715  * @param env clipping envelope for the returned diagram, automatically
716  * determined if NULL.
717  * The diagram will be clipped to the larger
718  * of this envelope or an envelope surrounding the sites.
719  *
720  * @return a newly allocated geometry, or NULL on exception.
721  */
722 extern GEOSGeometry GEOS_DLL * GEOSVoronoiDiagram_r(
723  GEOSContextHandle_t extHandle,
724  const GEOSGeometry *g,
725  const GEOSGeometry *env,
726  double tolerance,
727  int onlyEdges);
728 
729 /*
730  * Computes the coordinate where two line segments intersect, if any
731  *
732  * @param ax0 x-coordinate of first point in first segment
733  * @param ay0 y-coordinate of first point in first segment
734  * @param ax1 x-coordinate of second point in first segment
735  * @param ay1 y-coordinate of second point in first segment
736  * @param bx0 x-coordinate of first point in second segment
737  * @param by0 y-coordinate of first point in second segment
738  * @param bx1 x-coordinate of second point in second segment
739  * @param by1 y-coordinate of second point in second segment
740  * @param cx x-coordinate of intersection point
741  * @param cy y-coordinate of intersection point
742  *
743  * @return 0 on error, 1 on success, -1 if segments do not intersect
744  */
745 
746 extern int GEOS_DLL GEOSSegmentIntersection_r(
747  GEOSContextHandle_t extHandle,
748  double ax0, double ay0,
749  double ax1, double ay1,
750  double bx0, double by0,
751  double bx1, double by1,
752  double* cx, double* cy);
753 
754 /************************************************************************
755  *
756  * Binary predicates - return 2 on exception, 1 on true, 0 on false
757  *
758  ***********************************************************************/
759 
760 extern char GEOS_DLL GEOSDisjoint_r(GEOSContextHandle_t handle,
761  const GEOSGeometry* g1,
762  const GEOSGeometry* g2);
763 extern char GEOS_DLL GEOSTouches_r(GEOSContextHandle_t handle,
764  const GEOSGeometry* g1,
765  const GEOSGeometry* g2);
766 extern char GEOS_DLL GEOSIntersects_r(GEOSContextHandle_t handle,
767  const GEOSGeometry* g1,
768  const GEOSGeometry* g2);
769 extern char GEOS_DLL GEOSCrosses_r(GEOSContextHandle_t handle,
770  const GEOSGeometry* g1,
771  const GEOSGeometry* g2);
772 extern char GEOS_DLL GEOSWithin_r(GEOSContextHandle_t handle,
773  const GEOSGeometry* g1,
774  const GEOSGeometry* g2);
775 extern char GEOS_DLL GEOSContains_r(GEOSContextHandle_t handle,
776  const GEOSGeometry* g1,
777  const GEOSGeometry* g2);
778 extern char GEOS_DLL GEOSOverlaps_r(GEOSContextHandle_t handle,
779  const GEOSGeometry* g1,
780  const GEOSGeometry* g2);
781 extern char GEOS_DLL GEOSEquals_r(GEOSContextHandle_t handle,
782  const GEOSGeometry* g1,
783  const GEOSGeometry* g2);
784 extern char GEOS_DLL GEOSEqualsExact_r(GEOSContextHandle_t handle,
785  const GEOSGeometry* g1,
786  const GEOSGeometry* g2,
787  double tolerance);
788 extern char GEOS_DLL GEOSCovers_r(GEOSContextHandle_t handle,
789  const GEOSGeometry* g1,
790  const GEOSGeometry* g2);
791 extern char GEOS_DLL GEOSCoveredBy_r(GEOSContextHandle_t handle,
792  const GEOSGeometry* g1,
793  const GEOSGeometry* g2);
794 
795 /************************************************************************
796  *
797  * Prepared Geometry Binary predicates - return 2 on exception, 1 on true, 0 on false
798  *
799  ***********************************************************************/
800 
801 /*
802  * GEOSGeometry ownership is retained by caller
803  */
804 extern const GEOSPreparedGeometry GEOS_DLL *GEOSPrepare_r(
805  GEOSContextHandle_t handle,
806  const GEOSGeometry* g);
807 
808 extern void GEOS_DLL GEOSPreparedGeom_destroy_r(GEOSContextHandle_t handle,
809  const GEOSPreparedGeometry* g);
810 
811 extern char GEOS_DLL GEOSPreparedContains_r(GEOSContextHandle_t handle,
812  const GEOSPreparedGeometry* pg1,
813  const GEOSGeometry* g2);
814 extern char GEOS_DLL GEOSPreparedContainsProperly_r(GEOSContextHandle_t handle,
815  const GEOSPreparedGeometry* pg1,
816  const GEOSGeometry* g2);
817 extern char GEOS_DLL GEOSPreparedCoveredBy_r(GEOSContextHandle_t handle,
818  const GEOSPreparedGeometry* pg1,
819  const GEOSGeometry* g2);
820 extern char GEOS_DLL GEOSPreparedCovers_r(GEOSContextHandle_t handle,
821  const GEOSPreparedGeometry* pg1,
822  const GEOSGeometry* g2);
823 extern char GEOS_DLL GEOSPreparedCrosses_r(GEOSContextHandle_t handle,
824  const GEOSPreparedGeometry* pg1,
825  const GEOSGeometry* g2);
826 extern char GEOS_DLL GEOSPreparedDisjoint_r(GEOSContextHandle_t handle,
827  const GEOSPreparedGeometry* pg1,
828  const GEOSGeometry* g2);
829 extern char GEOS_DLL GEOSPreparedIntersects_r(GEOSContextHandle_t handle,
830  const GEOSPreparedGeometry* pg1,
831  const GEOSGeometry* g2);
832 extern char GEOS_DLL GEOSPreparedOverlaps_r(GEOSContextHandle_t handle,
833  const GEOSPreparedGeometry* pg1,
834  const GEOSGeometry* g2);
835 extern char GEOS_DLL GEOSPreparedTouches_r(GEOSContextHandle_t handle,
836  const GEOSPreparedGeometry* pg1,
837  const GEOSGeometry* g2);
838 extern char GEOS_DLL GEOSPreparedWithin_r(GEOSContextHandle_t handle,
839  const GEOSPreparedGeometry* pg1,
840  const GEOSGeometry* g2);
841 
842 /************************************************************************
843  *
844  * STRtree functions
845  *
846  ***********************************************************************/
847 
848 /*
849  * GEOSGeometry ownership is retained by caller
850  */
851 
852 extern GEOSSTRtree GEOS_DLL *GEOSSTRtree_create_r(
853  GEOSContextHandle_t handle,
854  size_t nodeCapacity);
855 extern void GEOS_DLL GEOSSTRtree_insert_r(GEOSContextHandle_t handle,
856  GEOSSTRtree *tree,
857  const GEOSGeometry *g,
858  void *item);
859 extern void GEOS_DLL GEOSSTRtree_query_r(GEOSContextHandle_t handle,
860  GEOSSTRtree *tree,
861  const GEOSGeometry *g,
862  GEOSQueryCallback callback,
863  void *userdata);
864 
865 extern const GEOSGeometry GEOS_DLL *GEOSSTRtree_nearest_r(GEOSContextHandle_t handle,
866  GEOSSTRtree *tree,
867  const GEOSGeometry* geom);
868 
869 
870 extern const void GEOS_DLL *GEOSSTRtree_nearest_generic_r(GEOSContextHandle_t handle,
871  GEOSSTRtree *tree,
872  const void* item,
873  const GEOSGeometry* itemEnvelope,
874  GEOSDistanceCallback distancefn,
875  void* userdata);
876 
877 extern void GEOS_DLL GEOSSTRtree_iterate_r(GEOSContextHandle_t handle,
878  GEOSSTRtree *tree,
879  GEOSQueryCallback callback,
880  void *userdata);
881 extern char GEOS_DLL GEOSSTRtree_remove_r(GEOSContextHandle_t handle,
882  GEOSSTRtree *tree,
883  const GEOSGeometry *g,
884  void *item);
885 extern void GEOS_DLL GEOSSTRtree_destroy_r(GEOSContextHandle_t handle,
886  GEOSSTRtree *tree);
887 
888 
889 /************************************************************************
890  *
891  * Unary predicate - return 2 on exception, 1 on true, 0 on false
892  *
893  ***********************************************************************/
894 
895 extern char GEOS_DLL GEOSisEmpty_r(GEOSContextHandle_t handle,
896  const GEOSGeometry* g);
897 extern char GEOS_DLL GEOSisSimple_r(GEOSContextHandle_t handle,
898  const GEOSGeometry* g);
899 extern char GEOS_DLL GEOSisRing_r(GEOSContextHandle_t handle,
900  const GEOSGeometry* g);
901 extern char GEOS_DLL GEOSHasZ_r(GEOSContextHandle_t handle,
902  const GEOSGeometry* g);
903 extern char GEOS_DLL GEOSisClosed_r(GEOSContextHandle_t handle,
904  const GEOSGeometry *g);
905 
906 /************************************************************************
907  *
908  * Dimensionally Extended 9 Intersection Model related
909  *
910  ***********************************************************************/
911 
912 /* These are for use with GEOSRelateBoundaryNodeRule (flags param) */
913 enum GEOSRelateBoundaryNodeRules {
914  /* MOD2 and OGC are the same rule, and is the default
915  * used by GEOSRelatePattern
916  */
917  GEOSRELATE_BNR_MOD2=1,
918  GEOSRELATE_BNR_OGC=1,
919  GEOSRELATE_BNR_ENDPOINT=2,
920  GEOSRELATE_BNR_MULTIVALENT_ENDPOINT=3,
921  GEOSRELATE_BNR_MONOVALENT_ENDPOINT=4
922 };
923 
924 /* return 2 on exception, 1 on true, 0 on false */
925 extern char GEOS_DLL GEOSRelatePattern_r(GEOSContextHandle_t handle,
926  const GEOSGeometry* g1,
927  const GEOSGeometry* g2,
928  const char *pat);
929 
930 /* return NULL on exception, a string to GEOSFree otherwise */
931 extern char GEOS_DLL *GEOSRelate_r(GEOSContextHandle_t handle,
932  const GEOSGeometry* g1,
933  const GEOSGeometry* g2);
934 
935 /* return 2 on exception, 1 on true, 0 on false */
936 extern char GEOS_DLL GEOSRelatePatternMatch_r(GEOSContextHandle_t handle,
937  const char *mat,
938  const char *pat);
939 
940 /* return NULL on exception, a string to GEOSFree otherwise */
941 extern char GEOS_DLL *GEOSRelateBoundaryNodeRule_r(GEOSContextHandle_t handle,
942  const GEOSGeometry* g1,
943  const GEOSGeometry* g2,
944  int bnr);
945 
946 /************************************************************************
947  *
948  * Validity checking
949  *
950  ***********************************************************************/
951 
952 /* These are for use with GEOSisValidDetail (flags param) */
953 enum GEOSValidFlags {
954  GEOSVALID_ALLOW_SELFTOUCHING_RING_FORMING_HOLE=1
955 };
956 
957 /* return 2 on exception, 1 on true, 0 on false */
958 extern char GEOS_DLL GEOSisValid_r(GEOSContextHandle_t handle,
959  const GEOSGeometry* g);
960 
961 /* return NULL on exception, a string to GEOSFree otherwise */
962 extern char GEOS_DLL *GEOSisValidReason_r(GEOSContextHandle_t handle,
963  const GEOSGeometry* g);
964 
965 /*
966  * Caller has the responsibility to destroy 'reason' (GEOSFree)
967  * and 'location' (GEOSGeom_destroy) params
968  * return 2 on exception, 1 when valid, 0 when invalid
969  */
970 extern char GEOS_DLL GEOSisValidDetail_r(GEOSContextHandle_t handle,
971  const GEOSGeometry* g,
972  int flags,
973  char** reason,
974  GEOSGeometry** location);
975 
976 extern GEOSGeometry GEOS_DLL *GEOSMakeValid_r(GEOSContextHandle_t handle,
977  const GEOSGeometry* g);
978 
979 /************************************************************************
980  *
981  * Geometry info
982  *
983  ***********************************************************************/
984 
985 /* Return NULL on exception, result must be freed by caller. */
986 extern char GEOS_DLL *GEOSGeomType_r(GEOSContextHandle_t handle,
987  const GEOSGeometry* g);
988 
989 /* Return -1 on exception */
990 extern int GEOS_DLL GEOSGeomTypeId_r(GEOSContextHandle_t handle,
991  const GEOSGeometry* g);
992 
993 /* Return 0 on exception */
994 extern int GEOS_DLL GEOSGetSRID_r(GEOSContextHandle_t handle,
995  const GEOSGeometry* g);
996 
997 extern void GEOS_DLL GEOSSetSRID_r(GEOSContextHandle_t handle,
998  GEOSGeometry* g, int SRID);
999 
1000 extern void GEOS_DLL *GEOSGeom_getUserData_r(GEOSContextHandle_t handle,
1001 const GEOSGeometry* g);
1002 
1003 extern void GEOS_DLL GEOSGeom_setUserData_r(GEOSContextHandle_t handle,
1004  GEOSGeometry* g, void* userData);
1005 
1006 /* May be called on all geometries in GEOS 3.x, returns -1 on error and 1
1007  * for non-multi geometries. Older GEOS versions only accept
1008  * GeometryCollections or Multi* geometries here, and are likely to crash
1009  * when fed simple geometries, so beware if you need compatibility with
1010  * old GEOS versions.
1011  */
1012 extern int GEOS_DLL GEOSGetNumGeometries_r(GEOSContextHandle_t handle,
1013  const GEOSGeometry* g);
1014 
1015 /*
1016  * Return NULL on exception.
1017  * Returned object is a pointer to internal storage:
1018  * it must NOT be destroyed directly.
1019  * Up to GEOS 3.2.0 the input geometry must be a Collection, in
1020  * later version it doesn't matter (getGeometryN(0) for a single will
1021  * return the input).
1022  */
1023 extern const GEOSGeometry GEOS_DLL *GEOSGetGeometryN_r(
1024  GEOSContextHandle_t handle,
1025  const GEOSGeometry* g, int n);
1026 
1027 /* Return -1 on exception */
1028 extern int GEOS_DLL GEOSNormalize_r(GEOSContextHandle_t handle,
1029  GEOSGeometry* g);
1030 
1033 #define GEOS_PREC_NO_TOPO (1<<0)
1034 
1037 #define GEOS_PREC_KEEP_COLLAPSED (1<<1)
1038 
1054 extern GEOSGeometry GEOS_DLL *GEOSGeom_setPrecision_r(
1055  GEOSContextHandle_t handle,
1056  const GEOSGeometry *g,
1057  double gridSize, int flags);
1058 
1065 extern double GEOS_DLL GEOSGeom_getPrecision_r(
1066  GEOSContextHandle_t handle,
1067  const GEOSGeometry *g);
1068 
1069 /* Return -1 on exception */
1070 extern int GEOS_DLL GEOSGetNumInteriorRings_r(GEOSContextHandle_t handle,
1071  const GEOSGeometry* g);
1072 
1073 /* Return -1 on exception, Geometry must be a LineString. */
1074 extern int GEOS_DLL GEOSGeomGetNumPoints_r(GEOSContextHandle_t handle,
1075  const GEOSGeometry* g);
1076 
1077 /* Return 0 on exception, otherwise 1, Geometry must be a Point. */
1078 extern int GEOS_DLL GEOSGeomGetX_r(GEOSContextHandle_t handle, const GEOSGeometry *g, double *x);
1079 extern int GEOS_DLL GEOSGeomGetY_r(GEOSContextHandle_t handle, const GEOSGeometry *g, double *y);
1080 extern int GEOS_DLL GEOSGeomGetZ_r(GEOSContextHandle_t handle, const GEOSGeometry *g, double *z);
1081 
1082 /*
1083  * Return NULL on exception, Geometry must be a Polygon.
1084  * Returned object is a pointer to internal storage:
1085  * it must NOT be destroyed directly.
1086  */
1087 extern const GEOSGeometry GEOS_DLL *GEOSGetInteriorRingN_r(
1088  GEOSContextHandle_t handle,
1089  const GEOSGeometry* g, int n);
1090 
1091 /*
1092  * Return NULL on exception, Geometry must be a Polygon.
1093  * Returned object is a pointer to internal storage:
1094  * it must NOT be destroyed directly.
1095  */
1096 extern const GEOSGeometry GEOS_DLL *GEOSGetExteriorRing_r(
1097  GEOSContextHandle_t handle,
1098  const GEOSGeometry* g);
1099 
1100 /* Return -1 on exception */
1101 extern int GEOS_DLL GEOSGetNumCoordinates_r(GEOSContextHandle_t handle,
1102  const GEOSGeometry* g);
1103 
1104 /*
1105  * Return NULL on exception.
1106  * Geometry must be a LineString, LinearRing or Point.
1107  */
1108 extern const GEOSCoordSequence GEOS_DLL *GEOSGeom_getCoordSeq_r(
1109  GEOSContextHandle_t handle,
1110  const GEOSGeometry* g);
1111 
1112 /*
1113  * Return 0 on exception (or empty geometry)
1114  */
1115 extern int GEOS_DLL GEOSGeom_getDimensions_r(GEOSContextHandle_t handle,
1116  const GEOSGeometry* g);
1117 
1118 /*
1119  * Return 2 or 3.
1120  */
1121 extern int GEOS_DLL GEOSGeom_getCoordinateDimension_r(GEOSContextHandle_t handle,
1122  const GEOSGeometry* g);
1123 /*
1124  * Return 0 on exception
1125  */
1126 extern int GEOS_DLL GEOSGeom_getXMin_r(GEOSContextHandle_t handle, const GEOSGeometry* g, double* value);
1127 extern int GEOS_DLL GEOSGeom_getYMin_r(GEOSContextHandle_t handle, const GEOSGeometry* g, double* value);
1128 extern int GEOS_DLL GEOSGeom_getXMax_r(GEOSContextHandle_t handle, const GEOSGeometry* g, double* value);
1129 extern int GEOS_DLL GEOSGeom_getYMax_r(GEOSContextHandle_t handle, const GEOSGeometry* g, double* value);
1130 
1131 /*
1132  * Return NULL on exception.
1133  * Must be LineString and must be freed by called.
1134  */
1135 extern GEOSGeometry GEOS_DLL *GEOSGeomGetPointN_r(GEOSContextHandle_t handle, const GEOSGeometry *g, int n);
1136 extern GEOSGeometry GEOS_DLL *GEOSGeomGetStartPoint_r(GEOSContextHandle_t handle, const GEOSGeometry *g);
1137 extern GEOSGeometry GEOS_DLL *GEOSGeomGetEndPoint_r(GEOSContextHandle_t handle, const GEOSGeometry *g);
1138 
1139 /************************************************************************
1140  *
1141  * Misc functions
1142  *
1143  ***********************************************************************/
1144 
1145 /* Return 0 on exception, 1 otherwise */
1146 extern int GEOS_DLL GEOSArea_r(GEOSContextHandle_t handle,
1147  const GEOSGeometry* g, double *area);
1148 extern int GEOS_DLL GEOSLength_r(GEOSContextHandle_t handle,
1149  const GEOSGeometry* g, double *length);
1150 extern int GEOS_DLL GEOSDistance_r(GEOSContextHandle_t handle,
1151  const GEOSGeometry* g1,
1152  const GEOSGeometry* g2, double *dist);
1153 extern int GEOS_DLL GEOSDistanceIndexed_r(GEOSContextHandle_t handle,
1154  const GEOSGeometry* g1,
1155  const GEOSGeometry* g2, double *dist);
1156 extern int GEOS_DLL GEOSHausdorffDistance_r(GEOSContextHandle_t handle,
1157  const GEOSGeometry *g1,
1158  const GEOSGeometry *g2,
1159  double *dist);
1160 extern int GEOS_DLL GEOSHausdorffDistanceDensify_r(GEOSContextHandle_t handle,
1161  const GEOSGeometry *g1,
1162  const GEOSGeometry *g2,
1163  double densifyFrac, double *dist);
1164 extern int GEOS_DLL GEOSFrechetDistance_r(GEOSContextHandle_t handle,
1165  const GEOSGeometry *g1,
1166  const GEOSGeometry *g2,
1167  double *dist);
1168 extern int GEOS_DLL GEOSFrechetDistanceDensify_r(GEOSContextHandle_t handle,
1169  const GEOSGeometry *g1,
1170  const GEOSGeometry *g2,
1171  double densifyFrac, double *dist);
1172 extern int GEOS_DLL GEOSGeomGetLength_r(GEOSContextHandle_t handle,
1173  const GEOSGeometry *g, double *length);
1174 
1175 /* Return 0 on exception, the closest points of the two geometries otherwise.
1176  * The first point comes from g1 geometry and the second point comes from g2.
1177  */
1178 extern GEOSCoordSequence GEOS_DLL *GEOSNearestPoints_r(
1179  GEOSContextHandle_t handle, const GEOSGeometry* g1, const GEOSGeometry* g2);
1180 
1181 
1182 /************************************************************************
1183  *
1184  * Algorithms
1185  *
1186  ***********************************************************************/
1187 
1188 /* Walking from A to B:
1189  * return -1 if reaching P takes a counter-clockwise (left) turn
1190  * return 1 if reaching P takes a clockwise (right) turn
1191  * return 0 if P is collinear with A-B
1192  *
1193  * On exceptions, return 2.
1194  *
1195  */
1196 extern int GEOS_DLL GEOSOrientationIndex_r(GEOSContextHandle_t handle,
1197  double Ax, double Ay, double Bx, double By, double Px, double Py);
1198 
1199 
1200 /************************************************************************
1201  *
1202  * Reader and Writer APIs
1203  *
1204  ***********************************************************************/
1205 
1206 typedef struct GEOSWKTReader_t GEOSWKTReader;
1207 typedef struct GEOSWKTWriter_t GEOSWKTWriter;
1208 typedef struct GEOSWKBReader_t GEOSWKBReader;
1209 typedef struct GEOSWKBWriter_t GEOSWKBWriter;
1210 
1211 
1212 /* WKT Reader */
1213 extern GEOSWKTReader GEOS_DLL *GEOSWKTReader_create_r(
1214  GEOSContextHandle_t handle);
1215 extern void GEOS_DLL GEOSWKTReader_destroy_r(GEOSContextHandle_t handle,
1216  GEOSWKTReader* reader);
1217 extern GEOSGeometry GEOS_DLL *GEOSWKTReader_read_r(GEOSContextHandle_t handle,
1218  GEOSWKTReader* reader,
1219  const char *wkt);
1220 
1221 /* WKT Writer */
1222 extern GEOSWKTWriter GEOS_DLL *GEOSWKTWriter_create_r(
1223  GEOSContextHandle_t handle);
1224 extern void GEOS_DLL GEOSWKTWriter_destroy_r(GEOSContextHandle_t handle,
1225  GEOSWKTWriter* writer);
1226 extern char GEOS_DLL *GEOSWKTWriter_write_r(GEOSContextHandle_t handle,
1227  GEOSWKTWriter* writer,
1228  const GEOSGeometry* g);
1229 extern void GEOS_DLL GEOSWKTWriter_setTrim_r(GEOSContextHandle_t handle,
1230  GEOSWKTWriter *writer,
1231  char trim);
1232 extern void GEOS_DLL GEOSWKTWriter_setRoundingPrecision_r(GEOSContextHandle_t handle,
1233  GEOSWKTWriter *writer,
1234  int precision);
1235 extern void GEOS_DLL GEOSWKTWriter_setOutputDimension_r(GEOSContextHandle_t handle,
1236  GEOSWKTWriter *writer,
1237  int dim);
1238 extern int GEOS_DLL GEOSWKTWriter_getOutputDimension_r(GEOSContextHandle_t handle,
1239  GEOSWKTWriter *writer);
1240 extern void GEOS_DLL GEOSWKTWriter_setOld3D_r(GEOSContextHandle_t handle,
1241  GEOSWKTWriter *writer,
1242  int useOld3D);
1243 
1244 /* WKB Reader */
1245 extern GEOSWKBReader GEOS_DLL *GEOSWKBReader_create_r(
1246  GEOSContextHandle_t handle);
1247 extern void GEOS_DLL GEOSWKBReader_destroy_r(GEOSContextHandle_t handle,
1248  GEOSWKBReader* reader);
1249 extern GEOSGeometry GEOS_DLL *GEOSWKBReader_read_r(GEOSContextHandle_t handle,
1250  GEOSWKBReader* reader,
1251  const unsigned char *wkb,
1252  size_t size);
1253 extern GEOSGeometry GEOS_DLL *GEOSWKBReader_readHEX_r(
1254  GEOSContextHandle_t handle,
1255  GEOSWKBReader* reader,
1256  const unsigned char *hex,
1257  size_t size);
1258 
1259 /* WKB Writer */
1260 extern GEOSWKBWriter GEOS_DLL *GEOSWKBWriter_create_r(
1261  GEOSContextHandle_t handle);
1262 extern void GEOS_DLL GEOSWKBWriter_destroy_r(GEOSContextHandle_t handle,
1263  GEOSWKBWriter* writer);
1264 
1265 /* The caller owns the results for these two methods! */
1266 extern unsigned char GEOS_DLL *GEOSWKBWriter_write_r(
1267  GEOSContextHandle_t handle,
1268  GEOSWKBWriter* writer,
1269  const GEOSGeometry* g,
1270  size_t *size);
1271 extern unsigned char GEOS_DLL *GEOSWKBWriter_writeHEX_r(
1272  GEOSContextHandle_t handle,
1273  GEOSWKBWriter* writer,
1274  const GEOSGeometry* g,
1275  size_t *size);
1276 
1277 /*
1278  * Specify whether output WKB should be 2d or 3d.
1279  * Return previously set number of dimensions.
1280  */
1281 extern int GEOS_DLL GEOSWKBWriter_getOutputDimension_r(
1282  GEOSContextHandle_t handle,
1283  const GEOSWKBWriter* writer);
1284 extern void GEOS_DLL GEOSWKBWriter_setOutputDimension_r(
1285  GEOSContextHandle_t handle,
1286  GEOSWKBWriter* writer, int newDimension);
1287 
1288 /*
1289  * Specify whether the WKB byte order is big or little endian.
1290  * The return value is the previous byte order.
1291  */
1292 extern int GEOS_DLL GEOSWKBWriter_getByteOrder_r(GEOSContextHandle_t handle,
1293  const GEOSWKBWriter* writer);
1294 extern void GEOS_DLL GEOSWKBWriter_setByteOrder_r(GEOSContextHandle_t handle,
1295  GEOSWKBWriter* writer,
1296  int byteOrder);
1297 
1298 /*
1299  * Specify whether SRID values should be output.
1300  */
1301 extern char GEOS_DLL GEOSWKBWriter_getIncludeSRID_r(GEOSContextHandle_t handle,
1302  const GEOSWKBWriter* writer);
1303 extern void GEOS_DLL GEOSWKBWriter_setIncludeSRID_r(GEOSContextHandle_t handle,
1304  GEOSWKBWriter* writer, const char writeSRID);
1305 
1306 
1307 /*
1308  * Free buffers returned by stuff like GEOSWKBWriter_write(),
1309  * GEOSWKBWriter_writeHEX() and GEOSWKTWriter_write().
1310  */
1311 extern void GEOS_DLL GEOSFree_r(GEOSContextHandle_t handle, void *buffer);
1312 
1313 
1314 /* External code to GEOS can define GEOS_USE_ONLY_R_API to avoid the */
1315 /* non _r API to be available */
1316 #ifndef GEOS_USE_ONLY_R_API
1317 
1318 /************************************************************************
1319  *
1320  * Initialization, cleanup, version
1321  *
1322  ***********************************************************************/
1323 
1324 extern void GEOS_DLL initGEOS(GEOSMessageHandler notice_function,
1325  GEOSMessageHandler error_function);
1326 extern void GEOS_DLL finishGEOS(void);
1327 
1328 /************************************************************************
1329  *
1330  * NOTE - These functions are DEPRECATED. Please use the new Reader and
1331  * writer APIS!
1332  *
1333  ***********************************************************************/
1334 
1335 extern GEOSGeometry GEOS_DLL *GEOSGeomFromWKT(const char *wkt);
1336 extern char GEOS_DLL *GEOSGeomToWKT(const GEOSGeometry* g);
1337 
1338 /*
1339  * Specify whether output WKB should be 2d or 3d.
1340  * Return previously set number of dimensions.
1341  */
1342 extern int GEOS_DLL GEOS_getWKBOutputDims();
1343 extern int GEOS_DLL GEOS_setWKBOutputDims(int newDims);
1344 
1345 /*
1346  * Specify whether the WKB byte order is big or little endian.
1347  * The return value is the previous byte order.
1348  */
1349 extern int GEOS_DLL GEOS_getWKBByteOrder();
1350 extern int GEOS_DLL GEOS_setWKBByteOrder(int byteOrder);
1351 
1352 extern GEOSGeometry GEOS_DLL *GEOSGeomFromWKB_buf(const unsigned char *wkb, size_t size);
1353 extern unsigned char GEOS_DLL *GEOSGeomToWKB_buf(const GEOSGeometry* g, size_t *size);
1354 
1355 extern GEOSGeometry GEOS_DLL *GEOSGeomFromHEX_buf(const unsigned char *hex, size_t size);
1356 extern unsigned char GEOS_DLL *GEOSGeomToHEX_buf(const GEOSGeometry* g, size_t *size);
1357 
1358 /************************************************************************
1359  *
1360  * Coordinate Sequence functions
1361  *
1362  ***********************************************************************/
1363 
1364 /*
1365  * Create a Coordinate sequence with ``size'' coordinates
1366  * of ``dims'' dimensions.
1367  * Return NULL on exception.
1368  */
1369 extern GEOSCoordSequence GEOS_DLL *GEOSCoordSeq_create(unsigned int size, unsigned int dims);
1370 
1371 /*
1372  * Clone a Coordinate Sequence.
1373  * Return NULL on exception.
1374  */
1375 extern GEOSCoordSequence GEOS_DLL *GEOSCoordSeq_clone(const GEOSCoordSequence* s);
1376 
1377 /*
1378  * Destroy a Coordinate Sequence.
1379  */
1380 extern void GEOS_DLL GEOSCoordSeq_destroy(GEOSCoordSequence* s);
1381 
1382 /*
1383  * Set ordinate values in a Coordinate Sequence.
1384  * Return 0 on exception.
1385  */
1386 extern int GEOS_DLL GEOSCoordSeq_setX(GEOSCoordSequence* s,
1387  unsigned int idx, double val);
1388 extern int GEOS_DLL GEOSCoordSeq_setY(GEOSCoordSequence* s,
1389  unsigned int idx, double val);
1390 extern int GEOS_DLL GEOSCoordSeq_setZ(GEOSCoordSequence* s,
1391  unsigned int idx, double val);
1392 extern int GEOS_DLL GEOSCoordSeq_setOrdinate(GEOSCoordSequence* s,
1393  unsigned int idx, unsigned int dim, double val);
1394 
1395 /*
1396  * Get ordinate values from a Coordinate Sequence.
1397  * Return 0 on exception.
1398  */
1399 extern int GEOS_DLL GEOSCoordSeq_getX(const GEOSCoordSequence* s,
1400  unsigned int idx, double *val);
1401 extern int GEOS_DLL GEOSCoordSeq_getY(const GEOSCoordSequence* s,
1402  unsigned int idx, double *val);
1403 extern int GEOS_DLL GEOSCoordSeq_getZ(const GEOSCoordSequence* s,
1404  unsigned int idx, double *val);
1405 extern int GEOS_DLL GEOSCoordSeq_getOrdinate(const GEOSCoordSequence* s,
1406  unsigned int idx, unsigned int dim, double *val);
1407 /*
1408  * Get size and dimensions info from a Coordinate Sequence.
1409  * Return 0 on exception.
1410  */
1411 extern int GEOS_DLL GEOSCoordSeq_getSize(const GEOSCoordSequence* s,
1412  unsigned int *size);
1413 extern int GEOS_DLL GEOSCoordSeq_getDimensions(const GEOSCoordSequence* s,
1414  unsigned int *dims);
1415 
1416 /*
1417  * Check orientation of a CoordinateSequence and set 'is_ccw' to 1
1418  * if it has counter-clockwise orientation, 0 otherwise.
1419  * Return 0 on exception, 1 on success.
1420  */
1421 extern int GEOS_DLL GEOSCoordSeq_isCCW(const GEOSCoordSequence* s, char* is_ccw);
1422 
1423 /************************************************************************
1424  *
1425  * Linear referencing functions -- there are more, but these are
1426  * probably sufficient for most purposes
1427  *
1428  ***********************************************************************/
1429 
1430 /*
1431  * GEOSGeometry ownership is retained by caller
1432  */
1433 
1434 
1435 /* Return distance of point 'p' projected on 'g' from origin
1436  * of 'g'. Geometry 'g' must be a lineal geometry */
1437 extern double GEOS_DLL GEOSProject(const GEOSGeometry *g,
1438  const GEOSGeometry* p);
1439 
1440 /* Return closest point to given distance within geometry
1441  * Geometry must be a LineString */
1442 extern GEOSGeometry GEOS_DLL *GEOSInterpolate(const GEOSGeometry *g,
1443  double d);
1444 
1445 extern double GEOS_DLL GEOSProjectNormalized(const GEOSGeometry *g,
1446  const GEOSGeometry* p);
1447 
1448 extern GEOSGeometry GEOS_DLL *GEOSInterpolateNormalized(const GEOSGeometry *g,
1449  double d);
1450 
1451 /************************************************************************
1452  *
1453  * Buffer related functions
1454  *
1455  ***********************************************************************/
1456 
1457 
1458 /* @return NULL on exception */
1459 extern GEOSGeometry GEOS_DLL *GEOSBuffer(const GEOSGeometry* g,
1460  double width, int quadsegs);
1461 
1462 /* @return 0 on exception */
1463 extern GEOSBufferParams GEOS_DLL *GEOSBufferParams_create();
1464 extern void GEOS_DLL GEOSBufferParams_destroy(GEOSBufferParams* parms);
1465 
1466 /* @return 0 on exception */
1467 extern int GEOS_DLL GEOSBufferParams_setEndCapStyle(
1468  GEOSBufferParams* p,
1469  int style);
1470 
1471 /* @return 0 on exception */
1472 extern int GEOS_DLL GEOSBufferParams_setJoinStyle(
1473  GEOSBufferParams* p,
1474  int joinStyle);
1475 
1476 /* @return 0 on exception */
1477 extern int GEOS_DLL GEOSBufferParams_setMitreLimit(
1478  GEOSBufferParams* p,
1479  double mitreLimit);
1480 
1481 /* @return 0 on exception */
1482 extern int GEOS_DLL GEOSBufferParams_setQuadrantSegments(
1483  GEOSBufferParams* p,
1484  int quadSegs);
1485 
1486 /* @param singleSided: 1 for single sided, 0 otherwise */
1487 /* @return 0 on exception */
1488 extern int GEOS_DLL GEOSBufferParams_setSingleSided(
1489  GEOSBufferParams* p,
1490  int singleSided);
1491 
1492 /* @return NULL on exception */
1493 extern GEOSGeometry GEOS_DLL *GEOSBufferWithParams(
1494  const GEOSGeometry* g,
1495  const GEOSBufferParams* p,
1496  double width);
1497 
1498 /* These functions return NULL on exception. */
1499 extern GEOSGeometry GEOS_DLL *GEOSBufferWithStyle(const GEOSGeometry* g,
1500  double width, int quadsegs, int endCapStyle, int joinStyle,
1501  double mitreLimit);
1502 
1503 /* These functions return NULL on exception. Only LINESTRINGs are accepted. */
1504 /* @deprecated in 3.3.0: use GEOSOffsetCurve instead */
1505 extern GEOSGeometry GEOS_DLL *GEOSSingleSidedBuffer(const GEOSGeometry* g,
1506  double width, int quadsegs, int joinStyle, double mitreLimit,
1507  int leftSide);
1508 
1509 /*
1510  * Only LINESTRINGs are accepted.
1511  * @param width : offset distance.
1512  * negative for right side offset.
1513  * positive for left side offset.
1514  * @return NULL on exception
1515  */
1516 extern GEOSGeometry GEOS_DLL *GEOSOffsetCurve(const GEOSGeometry* g,
1517  double width, int quadsegs, int joinStyle, double mitreLimit);
1518 
1519 /************************************************************************
1520  *
1521  * Geometry Constructors.
1522  * GEOSCoordSequence* arguments will become ownership of the returned object.
1523  * All functions return NULL on exception.
1524  *
1525  ***********************************************************************/
1526 
1527 extern GEOSGeometry GEOS_DLL *GEOSGeom_createPoint(GEOSCoordSequence* s);
1528 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyPoint();
1529 extern GEOSGeometry GEOS_DLL *GEOSGeom_createLinearRing(GEOSCoordSequence* s);
1530 extern GEOSGeometry GEOS_DLL *GEOSGeom_createLineString(GEOSCoordSequence* s);
1531 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyLineString();
1532 
1533 /*
1534  * Second argument is an array of GEOSGeometry* objects.
1535  * The caller remains owner of the array, but pointed-to
1536  * objects become ownership of the returned GEOSGeometry.
1537  */
1538 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyPolygon();
1539 extern GEOSGeometry GEOS_DLL *GEOSGeom_createPolygon(GEOSGeometry* shell,
1540  GEOSGeometry** holes, unsigned int nholes);
1541 extern GEOSGeometry GEOS_DLL *GEOSGeom_createCollection(int type,
1542  GEOSGeometry* *geoms, unsigned int ngeoms);
1543 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyCollection(int type);
1544 
1545 extern GEOSGeometry GEOS_DLL *GEOSGeom_clone(const GEOSGeometry* g);
1546 
1547 /************************************************************************
1548  *
1549  * Memory management
1550  *
1551  ***********************************************************************/
1552 
1553 extern void GEOS_DLL GEOSGeom_destroy(GEOSGeometry* g);
1554 
1555 /************************************************************************
1556  *
1557  * Topology operations - return NULL on exception.
1558  *
1559  ***********************************************************************/
1560 
1561 extern GEOSGeometry GEOS_DLL *GEOSEnvelope(const GEOSGeometry* g);
1562 extern GEOSGeometry GEOS_DLL *GEOSIntersection(const GEOSGeometry* g1, const GEOSGeometry* g2);
1563 extern GEOSGeometry GEOS_DLL *GEOSConvexHull(const GEOSGeometry* g);
1564 
1565 /* Returns the minimum rotated rectangular POLYGON which encloses the input geometry. The rectangle
1566  * has width equal to the minimum diameter, and a longer length. If the convex hill of the input is
1567  * degenerate (a line or point) a LINESTRING or POINT is returned. The minimum rotated rectangle can
1568  * be used as an extremely generalized representation for the given geometry.
1569  */
1570 extern GEOSGeometry GEOS_DLL *GEOSMinimumRotatedRectangle(const GEOSGeometry* g);
1571 
1572 /* Returns a LINESTRING geometry which represents the minimum diameter of the geometry.
1573  * The minimum diameter is defined to be the width of the smallest band that
1574  * contains the geometry, where a band is a strip of the plane defined
1575  * by two parallel lines. This can be thought of as the smallest hole that the geometry
1576  * can be moved through, with a single rotation.
1577  */
1578 extern GEOSGeometry GEOS_DLL *GEOSMinimumWidth(const GEOSGeometry* g);
1579 
1580 /* Computes the minimum clearance of a geometry. The minimum clearance is the smallest amount by which
1581  * a vertex could be move to produce an invalid polygon, a non-simple linestring, or a multipoint with
1582  * repeated points. If a geometry has a minimum clearance of 'eps', it can be said that:
1583  *
1584  * - No two distinct vertices in the geometry are separated by less than 'eps'
1585  * - No vertex is closer than 'eps' to a line segment of which it is not an endpoint.
1586  *
1587  * If the minimum clearance cannot be defined for a geometry (such as with a single point, or a multipoint
1588  * whose points are identical, a value of Infinity will be calculated.
1589  *
1590  * @param g the input geometry
1591  * @param d a double to which the result can be stored
1592  *
1593  * @return 0 if no exception occurred
1594  * 2 if an exception occurred
1595  */
1596 extern int GEOS_DLL GEOSMinimumClearance(const GEOSGeometry* g, double* d);
1597 
1598 /* Returns a LineString whose endpoints define the minimum clearance of a geometry.
1599  * If the geometry has no minimum clearance, an empty LineString will be returned.
1600  *
1601  * @param g the input geometry
1602  * @return a LineString, or NULL if an exception occurred.
1603  */
1604 extern GEOSGeometry GEOS_DLL *GEOSMinimumClearanceLine(const GEOSGeometry* g);
1605 
1606 extern GEOSGeometry GEOS_DLL *GEOSDifference(const GEOSGeometry* g1, const GEOSGeometry* g2);
1607 extern GEOSGeometry GEOS_DLL *GEOSSymDifference(const GEOSGeometry* g1, const GEOSGeometry* g2);
1608 extern GEOSGeometry GEOS_DLL *GEOSBoundary(const GEOSGeometry* g);
1609 extern GEOSGeometry GEOS_DLL *GEOSUnion(const GEOSGeometry* g1, const GEOSGeometry* g2);
1610 extern GEOSGeometry GEOS_DLL *GEOSUnaryUnion(const GEOSGeometry* g);
1611 
1612 /* GEOSCoverageUnion is an optimized union algorithm for polygonal inputs that are correctly
1613  * noded and do not overlap. It will not generate an error (return NULL) for inputs that
1614  * do not satisfy this constraint. */
1615 extern GEOSGeometry GEOS_DLL *GEOSCoverageUnion(const GEOSGeometry *g);
1616 
1617 /* @deprecated in 3.3.0: use GEOSUnaryUnion instead */
1618 extern GEOSGeometry GEOS_DLL *GEOSUnionCascaded(const GEOSGeometry* g);
1619 extern GEOSGeometry GEOS_DLL *GEOSPointOnSurface(const GEOSGeometry* g);
1620 extern GEOSGeometry GEOS_DLL *GEOSGetCentroid(const GEOSGeometry* g);
1621 extern GEOSGeometry GEOS_DLL *GEOSNode(const GEOSGeometry* g);
1622 extern GEOSGeometry GEOS_DLL *GEOSClipByRect(const GEOSGeometry* g, double xmin, double ymin, double xmax, double ymax);
1623 
1624 /*
1625  * all arguments remain ownership of the caller
1626  * (both Geometries and pointers)
1627  */
1628 extern GEOSGeometry GEOS_DLL *GEOSPolygonize(const GEOSGeometry * const geoms[], unsigned int ngeoms);
1629 extern GEOSGeometry GEOS_DLL *GEOSPolygonize_valid(const GEOSGeometry * const geoms[], unsigned int ngeoms);
1630 extern GEOSGeometry GEOS_DLL *GEOSPolygonizer_getCutEdges(const GEOSGeometry * const geoms[], unsigned int ngeoms);
1631 extern GEOSGeometry GEOS_DLL *GEOSPolygonize_full(const GEOSGeometry* input,
1632  GEOSGeometry** cuts, GEOSGeometry** dangles, GEOSGeometry** invalid);
1633 
1634 extern GEOSGeometry GEOS_DLL *GEOSBuildArea(const GEOSGeometry* g);
1635 
1636 extern GEOSGeometry GEOS_DLL *GEOSLineMerge(const GEOSGeometry* g);
1637 extern GEOSGeometry GEOS_DLL *GEOSReverse(const GEOSGeometry* g);
1638 extern GEOSGeometry GEOS_DLL *GEOSSimplify(const GEOSGeometry* g, double tolerance);
1639 extern GEOSGeometry GEOS_DLL *GEOSTopologyPreserveSimplify(const GEOSGeometry* g,
1640  double tolerance);
1641 
1642 /*
1643  * Return all distinct vertices of input geometry as a MULTIPOINT.
1644  * Note that only 2 dimensions of the vertices are considered when
1645  * testing for equality.
1646  */
1647 extern GEOSGeometry GEOS_DLL *GEOSGeom_extractUniquePoints(
1648  const GEOSGeometry* g);
1649 
1650 /*
1651  * Find paths shared between the two given lineal geometries.
1652  *
1653  * Returns a GEOMETRYCOLLECTION having two elements:
1654  * - first element is a MULTILINESTRING containing shared paths
1655  * having the _same_ direction on both inputs
1656  * - second element is a MULTILINESTRING containing shared paths
1657  * having the _opposite_ direction on the two inputs
1658  *
1659  * Returns NULL on exception
1660  */
1661 extern GEOSGeometry GEOS_DLL *GEOSSharedPaths(const GEOSGeometry* g1,
1662  const GEOSGeometry* g2);
1663 
1664 /*
1665  * Snap first geometry on to second with given tolerance
1666  * Returns a newly allocated geometry, or NULL on exception
1667  */
1668 extern GEOSGeometry GEOS_DLL *GEOSSnap(const GEOSGeometry* g1,
1669  const GEOSGeometry* g2, double tolerance);
1670 
1671 /*
1672  * Return a Delaunay triangulation of the vertex of the given geometry
1673  *
1674  * @param g the input geometry whose vertex will be used as "sites"
1675  * @param tolerance optional snapping tolerance to use for improved robustness
1676  * @param onlyEdges if non-zero will return a MULTILINESTRING, otherwise it will
1677  * return a GEOMETRYCOLLECTION containing triangular POLYGONs.
1678  *
1679  * @return a newly allocated geometry, or NULL on exception
1680  */
1681 extern GEOSGeometry GEOS_DLL * GEOSDelaunayTriangulation(
1682  const GEOSGeometry *g,
1683  double tolerance,
1684  int onlyEdges);
1685 
1686 /*
1687  * Returns the Voronoi polygons of a set of Vertices given as input
1688  *
1689  * @param g the input geometry whose vertex will be used as sites.
1690  * @param tolerance snapping tolerance to use for improved robustness
1691  * @param onlyEdges whether to return only edges of the voronoi cells
1692  * @param env clipping envelope for the returned diagram, automatically
1693  * determined if NULL.
1694  * The diagram will be clipped to the larger
1695  * of this envelope or an envelope surrounding the sites.
1696  *
1697  * @return a newly allocated geometry, or NULL on exception.
1698  */
1699 extern GEOSGeometry GEOS_DLL * GEOSVoronoiDiagram(
1700  const GEOSGeometry *g,
1701  const GEOSGeometry *env,
1702  double tolerance,
1703  int onlyEdges);
1704 /*
1705  * Computes the coordinate where two line segments intersect, if any
1706  *
1707  * @param ax0 x-coordinate of first point in first segment
1708  * @param ay0 y-coordinate of first point in first segment
1709  * @param ax1 x-coordinate of second point in first segment
1710  * @param ay1 y-coordinate of second point in first segment
1711  * @param bx0 x-coordinate of first point in second segment
1712  * @param by0 y-coordinate of first point in second segment
1713  * @param bx1 x-coordinate of second point in second segment
1714  * @param by1 y-coordinate of second point in second segment
1715  * @param cx x-coordinate of intersection point
1716  * @param cy y-coordinate of intersection point
1717  *
1718  * @return 0 on error, 1 on success, -1 if segments do not intersect
1719  */
1720 
1721 extern int GEOS_DLL GEOSSegmentIntersection(
1722  double ax0, double ay0,
1723  double ax1, double ay1,
1724  double bx0, double by0,
1725  double bx1, double by1,
1726  double* cx, double* cy);
1727 
1728 /************************************************************************
1729  *
1730  * Binary predicates - return 2 on exception, 1 on true, 0 on false
1731  *
1732  ***********************************************************************/
1733 
1734 extern char GEOS_DLL GEOSDisjoint(const GEOSGeometry* g1, const GEOSGeometry* g2);
1735 extern char GEOS_DLL GEOSTouches(const GEOSGeometry* g1, const GEOSGeometry* g2);
1736 extern char GEOS_DLL GEOSIntersects(const GEOSGeometry* g1, const GEOSGeometry* g2);
1737 extern char GEOS_DLL GEOSCrosses(const GEOSGeometry* g1, const GEOSGeometry* g2);
1738 extern char GEOS_DLL GEOSWithin(const GEOSGeometry* g1, const GEOSGeometry* g2);
1739 extern char GEOS_DLL GEOSContains(const GEOSGeometry* g1, const GEOSGeometry* g2);
1740 extern char GEOS_DLL GEOSOverlaps(const GEOSGeometry* g1, const GEOSGeometry* g2);
1741 extern char GEOS_DLL GEOSEquals(const GEOSGeometry* g1, const GEOSGeometry* g2);
1742 extern char GEOS_DLL GEOSCovers(const GEOSGeometry* g1, const GEOSGeometry* g2);
1743 extern char GEOS_DLL GEOSCoveredBy(const GEOSGeometry* g1, const GEOSGeometry* g2);
1744 
1753 extern char GEOS_DLL GEOSEqualsExact(const GEOSGeometry* g1, const GEOSGeometry* g2, double tolerance);
1754 
1755 /************************************************************************
1756  *
1757  * Prepared Geometry Binary predicates - return 2 on exception, 1 on true, 0 on false
1758  *
1759  ***********************************************************************/
1760 
1761 /*
1762  * GEOSGeometry ownership is retained by caller
1763  */
1764 extern const GEOSPreparedGeometry GEOS_DLL *GEOSPrepare(const GEOSGeometry* g);
1765 
1766 extern void GEOS_DLL GEOSPreparedGeom_destroy(const GEOSPreparedGeometry* g);
1767 
1768 extern char GEOS_DLL GEOSPreparedContains(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
1769 extern char GEOS_DLL GEOSPreparedContainsProperly(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
1770 extern char GEOS_DLL GEOSPreparedCoveredBy(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
1771 extern char GEOS_DLL GEOSPreparedCovers(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
1772 extern char GEOS_DLL GEOSPreparedCrosses(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
1773 extern char GEOS_DLL GEOSPreparedDisjoint(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
1774 extern char GEOS_DLL GEOSPreparedIntersects(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
1775 extern char GEOS_DLL GEOSPreparedOverlaps(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
1776 extern char GEOS_DLL GEOSPreparedTouches(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
1777 extern char GEOS_DLL GEOSPreparedWithin(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
1778 
1779 /************************************************************************
1780  *
1781  * STRtree functions
1782  *
1783  ***********************************************************************/
1784 
1785 /*
1786  * GEOSGeometry ownership is retained by caller
1787  */
1788 
1789 /*
1790  * Create a new R-tree using the Sort-Tile-Recursive algorithm (STRtree) for two-dimensional
1791  * spatial data.
1792  *
1793  * @param nodeCapacity the maximum number of child nodes that a node may have. The minimum
1794  * recommended capacity value is 4. If unsure, use a default node capacity of 10.
1795  * @return a pointer to the created tree
1796  */
1797 extern GEOSSTRtree GEOS_DLL *GEOSSTRtree_create(size_t nodeCapacity);
1798 
1799 /*
1800  * Insert an item into an STRtree
1801  *
1802  * @param tree the STRtree in which the item should be inserted
1803  * @param g a GEOSGeometry whose envelope corresponds to the extent of 'item'
1804  * @param item the item to insert into the tree
1805  */
1806 extern void GEOS_DLL GEOSSTRtree_insert(GEOSSTRtree *tree,
1807  const GEOSGeometry *g,
1808  void *item);
1809 
1810 /*
1811  * Query an STRtree for items intersecting a specified envelope
1812  *
1813  * @param tree the STRtree to search
1814  * @param g a GEOSGeomety from which a query envelope will be extracted
1815  * @param callback a function to be executed for each item in the tree whose envelope intersects
1816  * the envelope of 'g'. The callback function should take two parameters: a void
1817  * pointer representing the located item in the tree, and a void userdata pointer.
1818  * @param userdata an optional pointer to pe passed to 'callback' as an argument
1819  */
1820 extern void GEOS_DLL GEOSSTRtree_query(GEOSSTRtree *tree,
1821  const GEOSGeometry *g,
1822  GEOSQueryCallback callback,
1823  void *userdata);
1824 /*
1825  * Returns the nearest item in the STRtree to the supplied GEOSGeometry.
1826  * All items in the tree MUST be of type GEOSGeometry. If this is not the case, use
1827  * GEOSSTRtree_nearest_generic instead.
1828 *
1829  * @param tree the STRtree to search
1830  * @param geom the geometry with which the tree should be queried
1831  * @return a const pointer to the nearest GEOSGeometry in the tree to 'geom', or NULL in
1832  * case of exception
1833  */
1834 extern const GEOSGeometry GEOS_DLL *GEOSSTRtree_nearest(GEOSSTRtree *tree, const GEOSGeometry* geom);
1835 
1836 /*
1837  * Returns the nearest item in the STRtree to the supplied item
1838  *
1839  * @param tree the STRtree to search
1840  * @param item the item with which the tree should be queried
1841  * @param itemEnvelope a GEOSGeometry having the bounding box of 'item'
1842  * @param distancefn a function that can compute the distance between two items
1843  * in the STRtree. The function should return zero in case of error,
1844  * and should store the computed distance to the location pointed to by
1845  * the 'distance' argument. The computed distance between two items
1846  * must not exceed the Cartesian distance between their envelopes.
1847  * @param userdata optional pointer to arbitrary data; will be passed to distancefn
1848  * each time it is called.
1849  * @return a const pointer to the nearest item in the tree to 'item', or NULL in
1850  * case of exception
1851  */
1852 extern const void GEOS_DLL *GEOSSTRtree_nearest_generic(GEOSSTRtree *tree,
1853  const void* item,
1854  const GEOSGeometry* itemEnvelope,
1855  GEOSDistanceCallback distancefn,
1856  void* userdata);
1857 /*
1858  * Iterates over all items in the STRtree
1859  *
1860  * @param tree the STRtree over which to iterate
1861  * @param callback a function to be executed for each item in the tree.
1862  */
1863 extern void GEOS_DLL GEOSSTRtree_iterate(GEOSSTRtree *tree,
1864  GEOSQueryCallback callback,
1865  void *userdata);
1866 
1867 /*
1868  * Removes an item from the STRtree
1869  *
1870  * @param tree the STRtree from which to remove an item
1871  * @param g the envelope of the item to remove
1872  * @param the item to remove
1873  * @return 0 if the item was not removed;
1874  * 1 if the item was removed;
1875  * 2 if an exception occurred
1876  */
1877 extern char GEOS_DLL GEOSSTRtree_remove(GEOSSTRtree *tree,
1878  const GEOSGeometry *g,
1879  void *item);
1880 extern void GEOS_DLL GEOSSTRtree_destroy(GEOSSTRtree *tree);
1881 
1882 
1883 /************************************************************************
1884  *
1885  * Unary predicate - return 2 on exception, 1 on true, 0 on false
1886  *
1887  ***********************************************************************/
1888 
1889 extern char GEOS_DLL GEOSisEmpty(const GEOSGeometry* g);
1890 extern char GEOS_DLL GEOSisSimple(const GEOSGeometry* g);
1891 extern char GEOS_DLL GEOSisRing(const GEOSGeometry* g);
1892 extern char GEOS_DLL GEOSHasZ(const GEOSGeometry* g);
1893 extern char GEOS_DLL GEOSisClosed(const GEOSGeometry *g);
1894 
1895 /************************************************************************
1896  *
1897  * Dimensionally Extended 9 Intersection Model related
1898  *
1899  ***********************************************************************/
1900 
1901 /* return 2 on exception, 1 on true, 0 on false */
1902 extern char GEOS_DLL GEOSRelatePattern(const GEOSGeometry* g1, const GEOSGeometry* g2, const char *pat);
1903 
1904 /* return NULL on exception, a string to GEOSFree otherwise */
1905 extern char GEOS_DLL *GEOSRelate(const GEOSGeometry* g1, const GEOSGeometry* g2);
1906 
1907 /* return 2 on exception, 1 on true, 0 on false */
1908 extern char GEOS_DLL GEOSRelatePatternMatch(const char *mat, const char *pat);
1909 
1910 /* return NULL on exception, a string to GEOSFree otherwise */
1911 extern char GEOS_DLL *GEOSRelateBoundaryNodeRule(const GEOSGeometry* g1,
1912  const GEOSGeometry* g2,
1913  int bnr);
1914 
1915 /************************************************************************
1916  *
1917  * Validity checking
1918  *
1919  ***********************************************************************/
1920 
1921 /* return 2 on exception, 1 on true, 0 on false */
1922 extern char GEOS_DLL GEOSisValid(const GEOSGeometry* g);
1923 
1924 /* return NULL on exception, a string to GEOSFree otherwise */
1925 extern char GEOS_DLL *GEOSisValidReason(const GEOSGeometry *g);
1926 /*
1927  * Caller has the responsibility to destroy 'reason' (GEOSFree)
1928  * and 'location' (GEOSGeom_destroy) params
1929  * return 2 on exception, 1 when valid, 0 when invalid
1930  * Use enum GEOSValidFlags values for the flags param.
1931  */
1932 extern char GEOS_DLL GEOSisValidDetail(const GEOSGeometry* g,
1933  int flags,
1934  char** reason, GEOSGeometry** location);
1935 
1936 extern GEOSGeometry GEOS_DLL *GEOSMakeValid(const GEOSGeometry* g);
1937 
1938 /************************************************************************
1939  *
1940  * Geometry info
1941  *
1942  ***********************************************************************/
1943 
1944 /* Return NULL on exception, result must be freed by caller. */
1945 extern char GEOS_DLL *GEOSGeomType(const GEOSGeometry* g);
1946 
1947 /* Return -1 on exception */
1948 extern int GEOS_DLL GEOSGeomTypeId(const GEOSGeometry* g);
1949 
1950 /* Return 0 on exception */
1951 extern int GEOS_DLL GEOSGetSRID(const GEOSGeometry* g);
1952 
1953 extern void GEOS_DLL GEOSSetSRID(GEOSGeometry* g, int SRID);
1954 
1955 extern void GEOS_DLL *GEOSGeom_getUserData(const GEOSGeometry* g);
1956 
1957 extern void GEOS_DLL GEOSGeom_setUserData(GEOSGeometry* g, void* userData);
1958 
1959 
1960 /* May be called on all geometries in GEOS 3.x, returns -1 on error and 1
1961  * for non-multi geometries. Older GEOS versions only accept
1962  * GeometryCollections or Multi* geometries here, and are likely to crash
1963  * when fed simple geometries, so beware if you need compatibility with
1964  * old GEOS versions.
1965  */
1966 extern int GEOS_DLL GEOSGetNumGeometries(const GEOSGeometry* g);
1967 
1968 /*
1969  * Return NULL on exception.
1970  * Returned object is a pointer to internal storage:
1971  * it must NOT be destroyed directly.
1972  * Up to GEOS 3.2.0 the input geometry must be a Collection, in
1973  * later version it doesn't matter (getGeometryN(0) for a single will
1974  * return the input).
1975  */
1976 extern const GEOSGeometry GEOS_DLL *GEOSGetGeometryN(const GEOSGeometry* g, int n);
1977 
1978 /* Return -1 on exception */
1979 extern int GEOS_DLL GEOSNormalize(GEOSGeometry* g);
1980 
1981 /* Return NULL on exception */
1982 extern GEOSGeometry GEOS_DLL *GEOSGeom_setPrecision(
1983  const GEOSGeometry *g, double gridSize, int flags);
1984 
1985 /* Return -1 on exception */
1986 extern double GEOS_DLL GEOSGeom_getPrecision(const GEOSGeometry *g);
1987 
1988 /* Return -1 on exception */
1989 extern int GEOS_DLL GEOSGetNumInteriorRings(const GEOSGeometry* g);
1990 
1991 /* Return -1 on exception, Geometry must be a LineString. */
1992 extern int GEOS_DLL GEOSGeomGetNumPoints(const GEOSGeometry* g);
1993 
1994 /* Return 0 on exception, otherwise 1, Geometry must be a Point. */
1995 extern int GEOS_DLL GEOSGeomGetX(const GEOSGeometry *g, double *x);
1996 extern int GEOS_DLL GEOSGeomGetY(const GEOSGeometry *g, double *y);
1997 extern int GEOS_DLL GEOSGeomGetZ(const GEOSGeometry *g, double *z);
1998 
1999 /*
2000  * Return NULL on exception, Geometry must be a Polygon.
2001  * Returned object is a pointer to internal storage:
2002  * it must NOT be destroyed directly.
2003  */
2004 extern const GEOSGeometry GEOS_DLL *GEOSGetInteriorRingN(const GEOSGeometry* g, int n);
2005 
2006 /*
2007  * Return NULL on exception, Geometry must be a Polygon.
2008  * Returned object is a pointer to internal storage:
2009  * it must NOT be destroyed directly.
2010  */
2011 extern const GEOSGeometry GEOS_DLL *GEOSGetExteriorRing(const GEOSGeometry* g);
2012 
2013 /* Return -1 on exception */
2014 extern int GEOS_DLL GEOSGetNumCoordinates(const GEOSGeometry* g);
2015 
2016 /*
2017  * Return NULL on exception.
2018  * Geometry must be a LineString, LinearRing or Point.
2019  */
2020 extern const GEOSCoordSequence GEOS_DLL *GEOSGeom_getCoordSeq(const GEOSGeometry* g);
2021 
2022 /*
2023  * Return 0 on exception (or empty geometry)
2024  */
2025 extern int GEOS_DLL GEOSGeom_getDimensions(const GEOSGeometry* g);
2026 
2027 /*
2028  * Return 2 or 3.
2029  */
2030 extern int GEOS_DLL GEOSGeom_getCoordinateDimension(const GEOSGeometry* g);
2031 
2032 /*
2033  * Return 0 on exception
2034  */
2035 extern int GEOS_DLL GEOSGeom_getXMin(const GEOSGeometry* g, double* value);
2036 extern int GEOS_DLL GEOSGeom_getYMin(const GEOSGeometry* g, double* value);
2037 extern int GEOS_DLL GEOSGeom_getXMax(const GEOSGeometry* g, double* value);
2038 extern int GEOS_DLL GEOSGeom_getYMax(const GEOSGeometry* g, double* value);
2039 
2040 /*
2041  * Return NULL on exception.
2042  * Must be LineString and must be freed by called.
2043  */
2044 extern GEOSGeometry GEOS_DLL *GEOSGeomGetPointN(const GEOSGeometry *g, int n);
2045 extern GEOSGeometry GEOS_DLL *GEOSGeomGetStartPoint(const GEOSGeometry *g);
2046 extern GEOSGeometry GEOS_DLL *GEOSGeomGetEndPoint(const GEOSGeometry *g);
2047 
2048 /************************************************************************
2049  *
2050  * Misc functions
2051  *
2052  ***********************************************************************/
2053 
2054 /* Return 0 on exception, 1 otherwise */
2055 extern int GEOS_DLL GEOSArea(const GEOSGeometry* g, double *area);
2056 extern int GEOS_DLL GEOSLength(const GEOSGeometry* g, double *length);
2057 extern int GEOS_DLL GEOSDistance(const GEOSGeometry* g1, const GEOSGeometry* g2,
2058  double *dist);
2059 extern int GEOS_DLL GEOSDistanceIndexed(const GEOSGeometry* g1, const GEOSGeometry* g2,
2060  double *dist);
2061 extern int GEOS_DLL GEOSHausdorffDistance(const GEOSGeometry *g1,
2062  const GEOSGeometry *g2, double *dist);
2063 extern int GEOS_DLL GEOSHausdorffDistanceDensify(const GEOSGeometry *g1,
2064  const GEOSGeometry *g2, double densifyFrac, double *dist);
2065 extern int GEOS_DLL GEOSFrechetDistance(const GEOSGeometry *g1,
2066  const GEOSGeometry *g2, double *dist);
2067 extern int GEOS_DLL GEOSFrechetDistanceDensify(const GEOSGeometry *g1,
2068  const GEOSGeometry *g2, double densifyFrac, double *dist);
2069 extern int GEOS_DLL GEOSGeomGetLength(const GEOSGeometry *g, double *length);
2070 
2071 /* Return 0 on exception, the closest points of the two geometries otherwise.
2072  * The first point comes from g1 geometry and the second point comes from g2.
2073  */
2074 extern GEOSCoordSequence GEOS_DLL *GEOSNearestPoints(
2075  const GEOSGeometry* g1, const GEOSGeometry* g2);
2076 
2077 
2078 /************************************************************************
2079  *
2080  * Algorithms
2081  *
2082  ***********************************************************************/
2083 
2084 /* Walking from A to B:
2085  * return -1 if reaching P takes a counter-clockwise (left) turn
2086  * return 1 if reaching P takes a clockwise (right) turn
2087  * return 0 if P is collinear with A-B
2088  *
2089  * On exceptions, return 2.
2090  *
2091  */
2092 extern int GEOS_DLL GEOSOrientationIndex(double Ax, double Ay, double Bx, double By,
2093  double Px, double Py);
2094 
2095 /************************************************************************
2096  *
2097  * Reader and Writer APIs
2098  *
2099  ***********************************************************************/
2100 
2101 /* WKT Reader */
2102 extern GEOSWKTReader GEOS_DLL *GEOSWKTReader_create();
2103 extern void GEOS_DLL GEOSWKTReader_destroy(GEOSWKTReader* reader);
2104 extern GEOSGeometry GEOS_DLL *GEOSWKTReader_read(GEOSWKTReader* reader, const char *wkt);
2105 
2106 /* WKT Writer */
2107 extern GEOSWKTWriter GEOS_DLL *GEOSWKTWriter_create();
2108 extern void GEOS_DLL GEOSWKTWriter_destroy(GEOSWKTWriter* writer);
2109 extern char GEOS_DLL *GEOSWKTWriter_write(GEOSWKTWriter* writer, const GEOSGeometry* g);
2110 extern void GEOS_DLL GEOSWKTWriter_setTrim(GEOSWKTWriter *writer, char trim);
2111 extern void GEOS_DLL GEOSWKTWriter_setRoundingPrecision(GEOSWKTWriter *writer, int precision);
2112 extern void GEOS_DLL GEOSWKTWriter_setOutputDimension(GEOSWKTWriter *writer, int dim);
2113 extern int GEOS_DLL GEOSWKTWriter_getOutputDimension(GEOSWKTWriter *writer);
2114 extern void GEOS_DLL GEOSWKTWriter_setOld3D(GEOSWKTWriter *writer, int useOld3D);
2115 
2116 /* WKB Reader */
2117 extern GEOSWKBReader GEOS_DLL *GEOSWKBReader_create();
2118 extern void GEOS_DLL GEOSWKBReader_destroy(GEOSWKBReader* reader);
2119 extern GEOSGeometry GEOS_DLL *GEOSWKBReader_read(GEOSWKBReader* reader, const unsigned char *wkb, size_t size);
2120 extern GEOSGeometry GEOS_DLL *GEOSWKBReader_readHEX(GEOSWKBReader* reader, const unsigned char *hex, size_t size);
2121 
2122 /* WKB Writer */
2123 extern GEOSWKBWriter GEOS_DLL *GEOSWKBWriter_create();
2124 extern void GEOS_DLL GEOSWKBWriter_destroy(GEOSWKBWriter* writer);
2125 
2126 /* The caller owns the results for these two methods! */
2127 extern unsigned char GEOS_DLL *GEOSWKBWriter_write(GEOSWKBWriter* writer, const GEOSGeometry* g, size_t *size);
2128 extern unsigned char GEOS_DLL *GEOSWKBWriter_writeHEX(GEOSWKBWriter* writer, const GEOSGeometry* g, size_t *size);
2129 
2130 /*
2131  * Specify whether output WKB should be 2d or 3d.
2132  * Return previously set number of dimensions.
2133  */
2134 extern int GEOS_DLL GEOSWKBWriter_getOutputDimension(const GEOSWKBWriter* writer);
2135 extern void GEOS_DLL GEOSWKBWriter_setOutputDimension(GEOSWKBWriter* writer, int newDimension);
2136 
2137 /*
2138  * Specify whether the WKB byte order is big or little endian.
2139  * The return value is the previous byte order.
2140  */
2141 extern int GEOS_DLL GEOSWKBWriter_getByteOrder(const GEOSWKBWriter* writer);
2142 extern void GEOS_DLL GEOSWKBWriter_setByteOrder(GEOSWKBWriter* writer, int byteOrder);
2143 
2144 /*
2145  * Specify whether SRID values should be output.
2146  */
2147 extern char GEOS_DLL GEOSWKBWriter_getIncludeSRID(const GEOSWKBWriter* writer);
2148 extern void GEOS_DLL GEOSWKBWriter_setIncludeSRID(GEOSWKBWriter* writer, const char writeSRID);
2149 
2150 /*
2151  * Free buffers returned by stuff like GEOSWKBWriter_write(),
2152  * GEOSWKBWriter_writeHEX() and GEOSWKTWriter_write().
2153  */
2154 extern void GEOS_DLL GEOSFree(void *buffer);
2155 
2156 #endif /* #ifndef GEOS_USE_ONLY_R_API */
2157 
2158 
2159 #ifdef __cplusplus
2160 } // extern "C"
2161 #endif
2162 
2163 #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