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