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