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