Rename CAPI method GEOSVoronoiDiagramBuilder to GEOSVoronoiDiagram
[geos.git] / capi / geos_c.h.in
blob48bf553d195ddecfb687e836d0f4ef9eb4c2dc16
1 /************************************************************************
4 * C-Wrapper for GEOS library
6 * Copyright (C) 2010 2011 Sandro Santilli <strk@keybit.net>
7 * Copyright (C) 2005 Refractions Research Inc.
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.
14 * Author: Sandro Santilli <strk@keybit.net>
16 ***********************************************************************
18 * GENERAL NOTES:
20 * - Remember to call initGEOS() before any use of this library's
21 * functions, and call finishGEOS() when done.
23 * - Currently you have to explicitly GEOSGeom_destroy() all
24 * GEOSGeom objects to avoid memory leaks, and to GEOSFree()
25 * all returned char * (unless const).
27 * - Functions ending with _r are thread safe; see details in RFC 3
28 * http://trac.osgeo.org/geos/wiki/RFC3
30 ***********************************************************************/
32 #ifndef GEOS_C_H_INCLUDED
33 #define GEOS_C_H_INCLUDED
35 #ifndef __cplusplus
36 # include <stddef.h> /* for size_t definition */
37 #else
38 # include <cstddef>
39 using std::size_t;
40 #endif
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
46 /************************************************************************
48 * Version
50 ***********************************************************************/
53 * Following 'ifdef' hack fixes problem with generating geos_c.h on Windows,
54 * when building with Visual C++ compiler.
57 #if defined(_MSC_VER)
58 #include <geos/version.h>
59 #define GEOS_CAPI_VERSION_MAJOR 1
60 #define GEOS_CAPI_VERSION_MINOR 9
61 #define GEOS_CAPI_VERSION_PATCH 0
62 #define GEOS_CAPI_VERSION "3.5.0-CAPI-1.9.0"
63 #else
64 #ifndef GEOS_VERSION_MAJOR
65 #define GEOS_VERSION_MAJOR @VERSION_MAJOR@
66 #endif
67 #ifndef GEOS_VERSION_MINOR
68 #define GEOS_VERSION_MINOR @VERSION_MINOR@
69 #endif
70 #ifndef GEOS_VERSION_PATCH
71 #define GEOS_VERSION_PATCH @VERSION_PATCH@
72 #endif
73 #ifndef GEOS_VERSION
74 #define GEOS_VERSION "@VERSION@"
75 #endif
76 #ifndef GEOS_JTS_PORT
77 #define GEOS_JTS_PORT "@JTS_PORT@"
78 #endif
80 #define GEOS_CAPI_VERSION_MAJOR @CAPI_VERSION_MAJOR@
81 #define GEOS_CAPI_VERSION_MINOR @CAPI_VERSION_MINOR@
82 #define GEOS_CAPI_VERSION_PATCH @CAPI_VERSION_PATCH@
83 #define GEOS_CAPI_VERSION "@VERSION@-CAPI-@CAPI_VERSION@"
84 #endif
86 #define GEOS_CAPI_FIRST_INTERFACE GEOS_CAPI_VERSION_MAJOR
87 #define GEOS_CAPI_LAST_INTERFACE (GEOS_CAPI_VERSION_MAJOR+GEOS_CAPI_VERSION_MINOR)
89 /************************************************************************
91 * (Abstract) type definitions
93 ************************************************************************/
95 typedef void (*GEOSMessageHandler)(const char *fmt, ...);
97 /* When we're included by geos_c.cpp, those are #defined to the original
98 * JTS definitions via preprocessor. We don't touch them to allow the
99 * compiler to cross-check the declarations. However, for all "normal"
100 * C-API users, we need to define them as "opaque" struct pointers, as
101 * those clients don't have access to the original C++ headers, by design.
103 #ifndef GEOSGeometry
104 typedef struct GEOSGeom_t GEOSGeometry;
105 typedef struct GEOSPrepGeom_t GEOSPreparedGeometry;
106 typedef struct GEOSCoordSeq_t GEOSCoordSequence;
107 typedef struct GEOSSTRtree_t GEOSSTRtree;
108 typedef struct GEOSBufParams_t GEOSBufferParams;
109 #endif
111 /* Those are compatibility definitions for source compatibility
112 * with GEOS 2.X clients relying on that type.
114 typedef GEOSGeometry* GEOSGeom;
115 typedef GEOSCoordSequence* GEOSCoordSeq;
117 /* Supported geometry types
118 * This was renamed from GEOSGeomTypeId in GEOS 2.2.X, which might
119 * break compatibility, this issue is still under investigation.
122 enum GEOSGeomTypes {
123 GEOS_POINT,
124 GEOS_LINESTRING,
125 GEOS_LINEARRING,
126 GEOS_POLYGON,
127 GEOS_MULTIPOINT,
128 GEOS_MULTILINESTRING,
129 GEOS_MULTIPOLYGON,
130 GEOS_GEOMETRYCOLLECTION
133 /* Byte oders exposed via the c api */
134 enum GEOSByteOrders {
135 GEOS_WKB_XDR = 0, /* Big Endian */
136 GEOS_WKB_NDR = 1 /* Little Endian */
139 typedef struct GEOSContextHandle_HS *GEOSContextHandle_t;
141 typedef void (*GEOSQueryCallback)(void *item, void *userdata);
143 /************************************************************************
145 * Initialization, cleanup, version
147 ***********************************************************************/
149 #include <geos/export.h>
151 extern void GEOS_DLL initGEOS(GEOSMessageHandler notice_function,
152 GEOSMessageHandler error_function);
153 extern void GEOS_DLL finishGEOS(void);
156 * Register an interruption checking callback
158 * The callback will be invoked _before_ checking for
159 * interruption, so can be used to request it.
161 typedef void (GEOSInterruptCallback)();
162 extern GEOSInterruptCallback GEOS_DLL *GEOS_interruptRegisterCallback(GEOSInterruptCallback* cb);
163 /* Request safe interruption of operations */
164 extern void GEOS_DLL GEOS_interruptRequest();
165 /* Cancel a pending interruption request */
166 extern void GEOS_DLL GEOS_interruptCancel();
169 extern GEOSContextHandle_t GEOS_DLL initGEOS_r(
170 GEOSMessageHandler notice_function,
171 GEOSMessageHandler error_function);
172 extern void GEOS_DLL finishGEOS_r(GEOSContextHandle_t handle);
174 extern GEOSMessageHandler GEOS_DLL GEOSContext_setNoticeHandler_r(GEOSContextHandle_t extHandle,
175 GEOSMessageHandler nf);
176 extern GEOSMessageHandler GEOS_DLL GEOSContext_setErrorHandler_r(GEOSContextHandle_t extHandle,
177 GEOSMessageHandler ef);
179 extern const char GEOS_DLL *GEOSversion();
182 /************************************************************************
184 * NOTE - These functions are DEPRECATED. Please use the new Reader and
185 * writer APIS!
187 ***********************************************************************/
189 extern GEOSGeometry GEOS_DLL *GEOSGeomFromWKT(const char *wkt);
190 extern char GEOS_DLL *GEOSGeomToWKT(const GEOSGeometry* g);
192 extern GEOSGeometry GEOS_DLL *GEOSGeomFromWKT_r(GEOSContextHandle_t handle,
193 const char *wkt);
194 extern char GEOS_DLL *GEOSGeomToWKT_r(GEOSContextHandle_t handle,
195 const GEOSGeometry* g);
198 * Specify whether output WKB should be 2d or 3d.
199 * Return previously set number of dimensions.
201 extern int GEOS_DLL GEOS_getWKBOutputDims();
202 extern int GEOS_DLL GEOS_setWKBOutputDims(int newDims);
204 extern int GEOS_DLL GEOS_getWKBOutputDims_r(GEOSContextHandle_t handle);
205 extern int GEOS_DLL GEOS_setWKBOutputDims_r(GEOSContextHandle_t handle,
206 int newDims);
209 * Specify whether the WKB byte order is big or little endian.
210 * The return value is the previous byte order.
212 extern int GEOS_DLL GEOS_getWKBByteOrder();
213 extern int GEOS_DLL GEOS_setWKBByteOrder(int byteOrder);
215 extern GEOSGeometry GEOS_DLL *GEOSGeomFromWKB_buf(const unsigned char *wkb, size_t size);
216 extern unsigned char GEOS_DLL *GEOSGeomToWKB_buf(const GEOSGeometry* g, size_t *size);
218 extern GEOSGeometry GEOS_DLL *GEOSGeomFromHEX_buf(const unsigned char *hex, size_t size);
219 extern unsigned char GEOS_DLL *GEOSGeomToHEX_buf(const GEOSGeometry* g, size_t *size);
221 extern int GEOS_DLL GEOS_getWKBByteOrder_r(GEOSContextHandle_t handle);
222 extern int GEOS_DLL GEOS_setWKBByteOrder_r(GEOSContextHandle_t handle,
223 int byteOrder);
225 extern GEOSGeometry GEOS_DLL *GEOSGeomFromWKB_buf_r(GEOSContextHandle_t handle,
226 const unsigned char *wkb,
227 size_t size);
228 extern unsigned char GEOS_DLL *GEOSGeomToWKB_buf_r(GEOSContextHandle_t handle,
229 const GEOSGeometry* g,
230 size_t *size);
232 extern GEOSGeometry GEOS_DLL *GEOSGeomFromHEX_buf_r(GEOSContextHandle_t handle,
233 const unsigned char *hex,
234 size_t size);
235 extern unsigned char GEOS_DLL *GEOSGeomToHEX_buf_r(GEOSContextHandle_t handle,
236 const GEOSGeometry* g,
237 size_t *size);
239 /************************************************************************
241 * Coordinate Sequence functions
243 ***********************************************************************/
246 * Create a Coordinate sequence with ``size'' coordinates
247 * of ``dims'' dimensions.
248 * Return NULL on exception.
250 extern GEOSCoordSequence GEOS_DLL *GEOSCoordSeq_create(unsigned int size, unsigned int dims);
252 extern GEOSCoordSequence GEOS_DLL *GEOSCoordSeq_create_r(
253 GEOSContextHandle_t handle,
254 unsigned int size,
255 unsigned int dims);
258 * Clone a Coordinate Sequence.
259 * Return NULL on exception.
261 extern GEOSCoordSequence GEOS_DLL *GEOSCoordSeq_clone(const GEOSCoordSequence* s);
263 extern GEOSCoordSequence GEOS_DLL *GEOSCoordSeq_clone_r(
264 GEOSContextHandle_t handle,
265 const GEOSCoordSequence* s);
268 * Destroy a Coordinate Sequence.
270 extern void GEOS_DLL GEOSCoordSeq_destroy(GEOSCoordSequence* s);
272 extern void GEOS_DLL GEOSCoordSeq_destroy_r(GEOSContextHandle_t handle,
273 GEOSCoordSequence* s);
276 * Set ordinate values in a Coordinate Sequence.
277 * Return 0 on exception.
279 extern int GEOS_DLL GEOSCoordSeq_setX(GEOSCoordSequence* s,
280 unsigned int idx, double val);
281 extern int GEOS_DLL GEOSCoordSeq_setY(GEOSCoordSequence* s,
282 unsigned int idx, double val);
283 extern int GEOS_DLL GEOSCoordSeq_setZ(GEOSCoordSequence* s,
284 unsigned int idx, double val);
285 extern int GEOS_DLL GEOSCoordSeq_setOrdinate(GEOSCoordSequence* s,
286 unsigned int idx, unsigned int dim, double val);
288 extern int GEOS_DLL GEOSCoordSeq_setX_r(GEOSContextHandle_t handle,
289 GEOSCoordSequence* s, unsigned int idx,
290 double val);
291 extern int GEOS_DLL GEOSCoordSeq_setY_r(GEOSContextHandle_t handle,
292 GEOSCoordSequence* s, unsigned int idx,
293 double val);
294 extern int GEOS_DLL GEOSCoordSeq_setZ_r(GEOSContextHandle_t handle,
295 GEOSCoordSequence* s, unsigned int idx,
296 double val);
297 extern int GEOS_DLL GEOSCoordSeq_setOrdinate_r(GEOSContextHandle_t handle,
298 GEOSCoordSequence* s,
299 unsigned int idx,
300 unsigned int dim, double val);
303 * Get ordinate values from a Coordinate Sequence.
304 * Return 0 on exception.
306 extern int GEOS_DLL GEOSCoordSeq_getX(const GEOSCoordSequence* s,
307 unsigned int idx, double *val);
308 extern int GEOS_DLL GEOSCoordSeq_getY(const GEOSCoordSequence* s,
309 unsigned int idx, double *val);
310 extern int GEOS_DLL GEOSCoordSeq_getZ(const GEOSCoordSequence* s,
311 unsigned int idx, double *val);
312 extern int GEOS_DLL GEOSCoordSeq_getOrdinate(const GEOSCoordSequence* s,
313 unsigned int idx, unsigned int dim, double *val);
315 extern int GEOS_DLL GEOSCoordSeq_getX_r(GEOSContextHandle_t handle,
316 const GEOSCoordSequence* s,
317 unsigned int idx, double *val);
318 extern int GEOS_DLL GEOSCoordSeq_getY_r(GEOSContextHandle_t handle,
319 const GEOSCoordSequence* s,
320 unsigned int idx, double *val);
321 extern int GEOS_DLL GEOSCoordSeq_getZ_r(GEOSContextHandle_t handle,
322 const GEOSCoordSequence* s,
323 unsigned int idx, double *val);
324 extern int GEOS_DLL GEOSCoordSeq_getOrdinate_r(GEOSContextHandle_t handle,
325 const GEOSCoordSequence* s,
326 unsigned int idx,
327 unsigned int dim, double *val);
329 * Get size and dimensions info from a Coordinate Sequence.
330 * Return 0 on exception.
332 extern int GEOS_DLL GEOSCoordSeq_getSize(const GEOSCoordSequence* s,
333 unsigned int *size);
334 extern int GEOS_DLL GEOSCoordSeq_getDimensions(const GEOSCoordSequence* s,
335 unsigned int *dims);
337 extern int GEOS_DLL GEOSCoordSeq_getSize_r(GEOSContextHandle_t handle,
338 const GEOSCoordSequence* s,
339 unsigned int *size);
340 extern int GEOS_DLL GEOSCoordSeq_getDimensions_r(GEOSContextHandle_t handle,
341 const GEOSCoordSequence* s,
342 unsigned int *dims);
344 /************************************************************************
346 * Linear referencing functions -- there are more, but these are
347 * probably sufficient for most purposes
349 ***********************************************************************/
352 * GEOSGeometry ownership is retained by caller
356 /* Return distance of point 'p' projected on 'g' from origin
357 * of 'g'. Geometry 'g' must be a lineal geometry */
358 extern double GEOS_DLL GEOSProject(const GEOSGeometry *g,
359 const GEOSGeometry* p);
360 extern double GEOS_DLL GEOSProject_r(GEOSContextHandle_t handle,
361 const GEOSGeometry *g,
362 const GEOSGeometry *p);
364 /* Return closest point to given distance within geometry
365 * Geometry must be a LineString */
366 extern GEOSGeometry GEOS_DLL *GEOSInterpolate(const GEOSGeometry *g,
367 double d);
368 extern GEOSGeometry GEOS_DLL *GEOSInterpolate_r(GEOSContextHandle_t handle,
369 const GEOSGeometry *g,
370 double d);
372 extern double GEOS_DLL GEOSProjectNormalized(const GEOSGeometry *g,
373 const GEOSGeometry* p);
374 extern double GEOS_DLL GEOSProjectNormalized_r(GEOSContextHandle_t handle,
375 const GEOSGeometry *g,
376 const GEOSGeometry *p);
378 extern GEOSGeometry GEOS_DLL *GEOSInterpolateNormalized(const GEOSGeometry *g,
379 double d);
380 extern GEOSGeometry GEOS_DLL *GEOSInterpolateNormalized_r(
381 GEOSContextHandle_t handle,
382 const GEOSGeometry *g,
383 double d);
385 /************************************************************************
387 * Buffer related functions
389 ***********************************************************************/
392 /* @return NULL on exception */
393 extern GEOSGeometry GEOS_DLL *GEOSBuffer(const GEOSGeometry* g,
394 double width, int quadsegs);
395 extern GEOSGeometry GEOS_DLL *GEOSBuffer_r(GEOSContextHandle_t handle,
396 const GEOSGeometry* g,
397 double width, int quadsegs);
399 enum GEOSBufCapStyles {
400 GEOSBUF_CAP_ROUND=1,
401 GEOSBUF_CAP_FLAT=2,
402 GEOSBUF_CAP_SQUARE=3
405 enum GEOSBufJoinStyles {
406 GEOSBUF_JOIN_ROUND=1,
407 GEOSBUF_JOIN_MITRE=2,
408 GEOSBUF_JOIN_BEVEL=3
411 /* @return 0 on exception */
412 extern GEOSBufferParams GEOS_DLL *GEOSBufferParams_create();
413 extern GEOSBufferParams GEOS_DLL *GEOSBufferParams_create_r(
414 GEOSContextHandle_t handle);
415 extern void GEOS_DLL GEOSBufferParams_destroy(GEOSBufferParams* parms);
416 extern void GEOS_DLL GEOSBufferParams_destroy_r(
417 GEOSContextHandle_t handle,
418 GEOSBufferParams* parms);
420 /* @return 0 on exception */
421 extern int GEOS_DLL GEOSBufferParams_setEndCapStyle(
422 GEOSBufferParams* p,
423 int style);
424 extern int GEOS_DLL GEOSBufferParams_setEndCapStyle_r(
425 GEOSContextHandle_t handle,
426 GEOSBufferParams* p,
427 int style);
429 /* @return 0 on exception */
430 extern int GEOS_DLL GEOSBufferParams_setJoinStyle(
431 GEOSBufferParams* p,
432 int joinStyle);
433 extern int GEOS_DLL GEOSBufferParams_setJoinStyle_r(
434 GEOSContextHandle_t handle,
435 GEOSBufferParams* p,
436 int joinStyle);
438 /* @return 0 on exception */
439 extern int GEOS_DLL GEOSBufferParams_setMitreLimit(
440 GEOSBufferParams* p,
441 double mitreLimit);
442 extern int GEOS_DLL GEOSBufferParams_setMitreLimit_r(
443 GEOSContextHandle_t handle,
444 GEOSBufferParams* p,
445 double mitreLimit);
447 /* @return 0 on exception */
448 extern int GEOS_DLL GEOSBufferParams_setQuadrantSegments(
449 GEOSBufferParams* p,
450 int quadSegs);
451 extern int GEOS_DLL GEOSBufferParams_setQuadrantSegments_r(
452 GEOSContextHandle_t handle,
453 GEOSBufferParams* p,
454 int quadSegs);
456 /* @param singleSided: 1 for single sided, 0 otherwise */
457 /* @return 0 on exception */
458 extern int GEOS_DLL GEOSBufferParams_setSingleSided(
459 GEOSBufferParams* p,
460 int singleSided);
461 extern int GEOS_DLL GEOSBufferParams_setSingleSided_r(
462 GEOSContextHandle_t handle,
463 GEOSBufferParams* p,
464 int singleSided);
466 /* @return NULL on exception */
467 extern GEOSGeometry GEOS_DLL *GEOSBufferWithParams(
468 const GEOSGeometry* g,
469 const GEOSBufferParams* p,
470 double width);
471 extern GEOSGeometry GEOS_DLL *GEOSBufferWithParams_r(
472 GEOSContextHandle_t handle,
473 const GEOSGeometry* g,
474 const GEOSBufferParams* p,
475 double width);
477 /* These functions return NULL on exception. */
478 extern GEOSGeometry GEOS_DLL *GEOSBufferWithStyle(const GEOSGeometry* g,
479 double width, int quadsegs, int endCapStyle, int joinStyle,
480 double mitreLimit);
481 extern GEOSGeometry GEOS_DLL *GEOSBufferWithStyle_r(GEOSContextHandle_t handle,
482 const GEOSGeometry* g, double width, int quadsegs, int endCapStyle,
483 int joinStyle, double mitreLimit);
485 /* These functions return NULL on exception. Only LINESTRINGs are accepted. */
486 /* @deprecated in 3.3.0: use GEOSOffsetCurve instead */
487 extern GEOSGeometry GEOS_DLL *GEOSSingleSidedBuffer(const GEOSGeometry* g,
488 double width, int quadsegs, int joinStyle, double mitreLimit,
489 int leftSide);
490 extern GEOSGeometry GEOS_DLL *GEOSSingleSidedBuffer_r(
491 GEOSContextHandle_t handle,
492 const GEOSGeometry* g, double width, int quadsegs,
493 int joinStyle, double mitreLimit, int leftSide);
496 * Only LINESTRINGs are accepted.
497 * @param width : offset distance.
498 * negative for right side offset.
499 * positive for left side offset.
500 * @return NULL on exception
502 extern GEOSGeometry GEOS_DLL *GEOSOffsetCurve(const GEOSGeometry* g,
503 double width, int quadsegs, int joinStyle, double mitreLimit);
504 extern GEOSGeometry GEOS_DLL *GEOSOffsetCurve_r(GEOSContextHandle_t handle,
505 const GEOSGeometry* g, double width, int quadsegs,
506 int joinStyle, double mitreLimit);
509 /************************************************************************
511 * Geometry Constructors.
512 * GEOSCoordSequence* arguments will become ownership of the returned object.
513 * All functions return NULL on exception.
515 ***********************************************************************/
517 extern GEOSGeometry GEOS_DLL *GEOSGeom_createPoint(GEOSCoordSequence* s);
518 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyPoint();
519 extern GEOSGeometry GEOS_DLL *GEOSGeom_createLinearRing(GEOSCoordSequence* s);
520 extern GEOSGeometry GEOS_DLL *GEOSGeom_createLineString(GEOSCoordSequence* s);
521 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyLineString();
523 extern GEOSGeometry GEOS_DLL *GEOSGeom_createPoint_r(
524 GEOSContextHandle_t handle,
525 GEOSCoordSequence* s);
526 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyPoint_r(
527 GEOSContextHandle_t handle);
528 extern GEOSGeometry GEOS_DLL *GEOSGeom_createLinearRing_r(
529 GEOSContextHandle_t handle,
530 GEOSCoordSequence* s);
531 extern GEOSGeometry GEOS_DLL *GEOSGeom_createLineString_r(
532 GEOSContextHandle_t handle,
533 GEOSCoordSequence* s);
534 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyLineString_r(
535 GEOSContextHandle_t handle);
538 * Second argument is an array of GEOSGeometry* objects.
539 * The caller remains owner of the array, but pointed-to
540 * objects become ownership of the returned GEOSGeometry.
542 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyPolygon();
543 extern GEOSGeometry GEOS_DLL *GEOSGeom_createPolygon(GEOSGeometry* shell,
544 GEOSGeometry** holes, unsigned int nholes);
545 extern GEOSGeometry GEOS_DLL *GEOSGeom_createCollection(int type,
546 GEOSGeometry* *geoms, unsigned int ngeoms);
547 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyCollection(int type);
549 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyPolygon_r(
550 GEOSContextHandle_t handle);
551 extern GEOSGeometry GEOS_DLL *GEOSGeom_createPolygon_r(
552 GEOSContextHandle_t handle,
553 GEOSGeometry* shell,
554 GEOSGeometry** holes,
555 unsigned int nholes);
556 extern GEOSGeometry GEOS_DLL *GEOSGeom_createCollection_r(
557 GEOSContextHandle_t handle, int type,
558 GEOSGeometry* *geoms,
559 unsigned int ngeoms);
560 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyCollection_r(
561 GEOSContextHandle_t handle, int type);
563 extern GEOSGeometry GEOS_DLL *GEOSGeom_clone(const GEOSGeometry* g);
565 extern GEOSGeometry GEOS_DLL *GEOSGeom_clone_r(GEOSContextHandle_t handle,
566 const GEOSGeometry* g);
568 /************************************************************************
570 * Memory management
572 ***********************************************************************/
574 extern void GEOS_DLL GEOSGeom_destroy(GEOSGeometry* g);
576 extern void GEOS_DLL GEOSGeom_destroy_r(GEOSContextHandle_t handle,
577 GEOSGeometry* g);
579 /************************************************************************
581 * Topology operations - return NULL on exception.
583 ***********************************************************************/
585 extern GEOSGeometry GEOS_DLL *GEOSEnvelope(const GEOSGeometry* g);
586 extern GEOSGeometry GEOS_DLL *GEOSIntersection(const GEOSGeometry* g1, const GEOSGeometry* g2);
587 extern GEOSGeometry GEOS_DLL *GEOSConvexHull(const GEOSGeometry* g);
588 extern GEOSGeometry GEOS_DLL *GEOSDifference(const GEOSGeometry* g1, const GEOSGeometry* g2);
589 extern GEOSGeometry GEOS_DLL *GEOSSymDifference(const GEOSGeometry* g1, const GEOSGeometry* g2);
590 extern GEOSGeometry GEOS_DLL *GEOSBoundary(const GEOSGeometry* g);
591 extern GEOSGeometry GEOS_DLL *GEOSUnion(const GEOSGeometry* g1, const GEOSGeometry* g2);
592 extern GEOSGeometry GEOS_DLL *GEOSUnaryUnion(const GEOSGeometry* g);
594 /* @deprecated in 3.3.0: use GEOSUnaryUnion instead */
595 extern GEOSGeometry GEOS_DLL *GEOSUnionCascaded(const GEOSGeometry* g);
596 extern GEOSGeometry GEOS_DLL *GEOSPointOnSurface(const GEOSGeometry* g);
597 extern GEOSGeometry GEOS_DLL *GEOSGetCentroid(const GEOSGeometry* g);
598 extern GEOSGeometry GEOS_DLL *GEOSNode(const GEOSGeometry* g);
600 extern GEOSGeometry GEOS_DLL *GEOSEnvelope_r(GEOSContextHandle_t handle,
601 const GEOSGeometry* g);
602 extern GEOSGeometry GEOS_DLL *GEOSIntersection_r(GEOSContextHandle_t handle,
603 const GEOSGeometry* g1,
604 const GEOSGeometry* g2);
605 extern GEOSGeometry GEOS_DLL *GEOSConvexHull_r(GEOSContextHandle_t handle,
606 const GEOSGeometry* g);
607 extern GEOSGeometry GEOS_DLL *GEOSDifference_r(GEOSContextHandle_t handle,
608 const GEOSGeometry* g1,
609 const GEOSGeometry* g2);
610 extern GEOSGeometry GEOS_DLL *GEOSSymDifference_r(GEOSContextHandle_t handle,
611 const GEOSGeometry* g1,
612 const GEOSGeometry* g2);
613 extern GEOSGeometry GEOS_DLL *GEOSBoundary_r(GEOSContextHandle_t handle,
614 const GEOSGeometry* g);
615 extern GEOSGeometry GEOS_DLL *GEOSUnion_r(GEOSContextHandle_t handle,
616 const GEOSGeometry* g1,
617 const GEOSGeometry* g2);
618 extern GEOSGeometry GEOS_DLL *GEOSUnaryUnion_r(GEOSContextHandle_t handle,
619 const GEOSGeometry* g);
620 extern GEOSGeometry GEOS_DLL *GEOSUnionCascaded_r(GEOSContextHandle_t handle,
621 const GEOSGeometry* g);
622 extern GEOSGeometry GEOS_DLL *GEOSPointOnSurface_r(GEOSContextHandle_t handle,
623 const GEOSGeometry* g);
624 extern GEOSGeometry GEOS_DLL *GEOSGetCentroid_r(GEOSContextHandle_t handle,
625 const GEOSGeometry* g);
626 extern GEOSGeometry GEOS_DLL *GEOSNode_r(GEOSContextHandle_t handle,
627 const GEOSGeometry* g);
630 * all arguments remain ownership of the caller
631 * (both Geometries and pointers)
633 extern GEOSGeometry GEOS_DLL *GEOSPolygonize(const GEOSGeometry * const geoms[], unsigned int ngeoms);
634 extern GEOSGeometry GEOS_DLL *GEOSPolygonizer_getCutEdges(const GEOSGeometry * const geoms[], unsigned int ngeoms);
636 * Polygonizes a set of Geometries which contain linework that
637 * represents the edges of a planar graph.
639 * Any dimension of Geometry is handled - the constituent linework
640 * is extracted to form the edges.
642 * The edges must be correctly noded; that is, they must only meet
643 * at their endpoints.
644 * The Polygonizer will still run on incorrectly noded input
645 * but will not form polygons from incorrectly noded edges.
647 * The Polygonizer reports the follow kinds of errors:
649 * - Dangles - edges which have one or both ends which are
650 * not incident on another edge endpoint
651 * - Cut Edges - edges which are connected at both ends but
652 * which do not form part of polygon
653 * - Invalid Ring Lines - edges which form rings which are invalid
654 * (e.g. the component lines contain a self-intersection)
656 * Errors are reported to output parameters "cuts", "dangles" and
657 * "invalid" (if not-null). Formed polygons are returned as a
658 * collection. NULL is returned on exception. All returned
659 * geometries must be destroyed by caller.
662 extern GEOSGeometry GEOS_DLL *GEOSPolygonize_full(const GEOSGeometry* input,
663 GEOSGeometry** cuts, GEOSGeometry** dangles, GEOSGeometry** invalid);
665 extern GEOSGeometry GEOS_DLL *GEOSLineMerge(const GEOSGeometry* g);
666 extern GEOSGeometry GEOS_DLL *GEOSSimplify(const GEOSGeometry* g, double tolerance);
667 extern GEOSGeometry GEOS_DLL *GEOSTopologyPreserveSimplify(const GEOSGeometry* g,
668 double tolerance);
670 extern GEOSGeometry GEOS_DLL *GEOSPolygonize_r(GEOSContextHandle_t handle,
671 const GEOSGeometry *const geoms[],
672 unsigned int ngeoms);
673 extern GEOSGeometry GEOS_DLL *GEOSPolygonizer_getCutEdges_r(
674 GEOSContextHandle_t handle,
675 const GEOSGeometry * const geoms[],
676 unsigned int ngeoms);
677 extern GEOSGeometry GEOS_DLL *GEOSPolygonize_full_r(GEOSContextHandle_t handle,
678 const GEOSGeometry* input, GEOSGeometry** cuts,
679 GEOSGeometry** dangles, GEOSGeometry** invalidRings);
681 extern GEOSGeometry GEOS_DLL *GEOSLineMerge_r(GEOSContextHandle_t handle,
682 const GEOSGeometry* g);
683 extern GEOSGeometry GEOS_DLL *GEOSSimplify_r(GEOSContextHandle_t handle,
684 const GEOSGeometry* g,
685 double tolerance);
686 extern GEOSGeometry GEOS_DLL *GEOSTopologyPreserveSimplify_r(
687 GEOSContextHandle_t handle,
688 const GEOSGeometry* g, double tolerance);
691 * Return all distinct vertices of input geometry as a MULTIPOINT.
692 * Note that only 2 dimensions of the vertices are considered when
693 * testing for equality.
695 extern GEOSGeometry GEOS_DLL *GEOSGeom_extractUniquePoints(
696 const GEOSGeometry* g);
697 extern GEOSGeometry GEOS_DLL *GEOSGeom_extractUniquePoints_r(
698 GEOSContextHandle_t handle,
699 const GEOSGeometry* g);
702 * Find paths shared between the two given lineal geometries.
704 * Returns a GEOMETRYCOLLECTION having two elements:
705 * - first element is a MULTILINESTRING containing shared paths
706 * having the _same_ direction on both inputs
707 * - second element is a MULTILINESTRING containing shared paths
708 * having the _opposite_ direction on the two inputs
710 * Returns NULL on exception
712 extern GEOSGeometry GEOS_DLL *GEOSSharedPaths(const GEOSGeometry* g1,
713 const GEOSGeometry* g2);
714 extern GEOSGeometry GEOS_DLL *GEOSSharedPaths_r(GEOSContextHandle_t handle,
715 const GEOSGeometry* g1, const GEOSGeometry* g2);
718 * Snap first geometry on to second with given tolerance
719 * Returns a newly allocated geometry, or NULL on exception
721 extern GEOSGeometry GEOS_DLL *GEOSSnap(const GEOSGeometry* g1,
722 const GEOSGeometry* g2, double tolerance);
723 extern GEOSGeometry GEOS_DLL *GEOSSnap_r(GEOSContextHandle_t handle,
724 const GEOSGeometry* g1, const GEOSGeometry* g2, double tolerance);
727 * Return a Delaunay triangulation of the vertex of the given geometry
729 * @param g the input geometry whose vertex will be used as "sites"
730 * @param tolerance optional snapping tolerance to use for improved robustness
731 * @param onlyEdges if non-zero will return a MULTILINESTRING, otherwise it will
732 * return a GEOMETRYCOLLECTION containing triangular POLYGONs.
734 * @return a newly allocated geometry, or NULL on exception
736 extern GEOSGeometry GEOS_DLL * GEOSDelaunayTriangulation(
737 const GEOSGeometry *g,
738 double tolerance,
739 int onlyEdges);
741 extern GEOSGeometry GEOS_DLL * GEOSDelaunayTriangulation_r(
742 GEOSContextHandle_t handle,
743 const GEOSGeometry *g,
744 double tolerance,
745 int onlyEdges);
748 * Returns the Voronoi polygons of a set of Vertices given as input
750 * @param g the input geometry whose vertex will be used as sites.
751 * @param tolerance optional snapping tolerance to use for improved robustness
753 * @return a newly allocated geometry, or NULL on exception.
755 extern GEOSGeometry GEOS_DLL * GEOSVoronoiDiagram(
756 const GEOSGeometry *g,
757 double tolerance);
759 extern GEOSGeometry GEOS_DLL * GEOSVoronoiDiagram_r(
760 GEOSContextHandle_t extHandle,
761 const GEOSGeometry *g1,
762 double tolerance);
765 /************************************************************************
767 * Binary predicates - return 2 on exception, 1 on true, 0 on false
769 ***********************************************************************/
771 extern char GEOS_DLL GEOSDisjoint(const GEOSGeometry* g1, const GEOSGeometry* g2);
772 extern char GEOS_DLL GEOSTouches(const GEOSGeometry* g1, const GEOSGeometry* g2);
773 extern char GEOS_DLL GEOSIntersects(const GEOSGeometry* g1, const GEOSGeometry* g2);
774 extern char GEOS_DLL GEOSCrosses(const GEOSGeometry* g1, const GEOSGeometry* g2);
775 extern char GEOS_DLL GEOSWithin(const GEOSGeometry* g1, const GEOSGeometry* g2);
776 extern char GEOS_DLL GEOSContains(const GEOSGeometry* g1, const GEOSGeometry* g2);
777 extern char GEOS_DLL GEOSOverlaps(const GEOSGeometry* g1, const GEOSGeometry* g2);
778 extern char GEOS_DLL GEOSEquals(const GEOSGeometry* g1, const GEOSGeometry* g2);
779 extern char GEOS_DLL GEOSEqualsExact(const GEOSGeometry* g1, const GEOSGeometry* g2, double tolerance);
780 extern char GEOS_DLL GEOSCovers(const GEOSGeometry* g1, const GEOSGeometry* g2);
781 extern char GEOS_DLL GEOSCoveredBy(const GEOSGeometry* g1, const GEOSGeometry* g2);
783 extern char GEOS_DLL GEOSDisjoint_r(GEOSContextHandle_t handle,
784 const GEOSGeometry* g1,
785 const GEOSGeometry* g2);
786 extern char GEOS_DLL GEOSTouches_r(GEOSContextHandle_t handle,
787 const GEOSGeometry* g1,
788 const GEOSGeometry* g2);
789 extern char GEOS_DLL GEOSIntersects_r(GEOSContextHandle_t handle,
790 const GEOSGeometry* g1,
791 const GEOSGeometry* g2);
792 extern char GEOS_DLL GEOSCrosses_r(GEOSContextHandle_t handle,
793 const GEOSGeometry* g1,
794 const GEOSGeometry* g2);
795 extern char GEOS_DLL GEOSWithin_r(GEOSContextHandle_t handle,
796 const GEOSGeometry* g1,
797 const GEOSGeometry* g2);
798 extern char GEOS_DLL GEOSContains_r(GEOSContextHandle_t handle,
799 const GEOSGeometry* g1,
800 const GEOSGeometry* g2);
801 extern char GEOS_DLL GEOSOverlaps_r(GEOSContextHandle_t handle,
802 const GEOSGeometry* g1,
803 const GEOSGeometry* g2);
804 extern char GEOS_DLL GEOSEquals_r(GEOSContextHandle_t handle,
805 const GEOSGeometry* g1,
806 const GEOSGeometry* g2);
807 extern char GEOS_DLL GEOSEqualsExact_r(GEOSContextHandle_t handle,
808 const GEOSGeometry* g1,
809 const GEOSGeometry* g2,
810 double tolerance);
811 extern char GEOS_DLL GEOSCovers_r(GEOSContextHandle_t handle,
812 const GEOSGeometry* g1,
813 const GEOSGeometry* g2);
814 extern char GEOS_DLL GEOSCoveredBy_r(GEOSContextHandle_t handle,
815 const GEOSGeometry* g1,
816 const GEOSGeometry* g2);
818 /************************************************************************
820 * Prepared Geometry Binary predicates - return 2 on exception, 1 on true, 0 on false
822 ***********************************************************************/
825 * GEOSGeometry ownership is retained by caller
827 extern const GEOSPreparedGeometry GEOS_DLL *GEOSPrepare(const GEOSGeometry* g);
829 extern void GEOS_DLL GEOSPreparedGeom_destroy(const GEOSPreparedGeometry* g);
831 extern char GEOS_DLL GEOSPreparedContains(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
832 extern char GEOS_DLL GEOSPreparedContainsProperly(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
833 extern char GEOS_DLL GEOSPreparedCoveredBy(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
834 extern char GEOS_DLL GEOSPreparedCovers(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
835 extern char GEOS_DLL GEOSPreparedCrosses(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
836 extern char GEOS_DLL GEOSPreparedDisjoint(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
837 extern char GEOS_DLL GEOSPreparedIntersects(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
838 extern char GEOS_DLL GEOSPreparedOverlaps(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
839 extern char GEOS_DLL GEOSPreparedTouches(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
840 extern char GEOS_DLL GEOSPreparedWithin(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
843 * GEOSGeometry ownership is retained by caller
845 extern const GEOSPreparedGeometry GEOS_DLL *GEOSPrepare_r(
846 GEOSContextHandle_t handle,
847 const GEOSGeometry* g);
849 extern void GEOS_DLL GEOSPreparedGeom_destroy_r(GEOSContextHandle_t handle,
850 const GEOSPreparedGeometry* g);
852 extern char GEOS_DLL GEOSPreparedContains_r(GEOSContextHandle_t handle,
853 const GEOSPreparedGeometry* pg1,
854 const GEOSGeometry* g2);
855 extern char GEOS_DLL GEOSPreparedContainsProperly_r(GEOSContextHandle_t handle,
856 const GEOSPreparedGeometry* pg1,
857 const GEOSGeometry* g2);
858 extern char GEOS_DLL GEOSPreparedCoveredBy_r(GEOSContextHandle_t handle,
859 const GEOSPreparedGeometry* pg1,
860 const GEOSGeometry* g2);
861 extern char GEOS_DLL GEOSPreparedCovers_r(GEOSContextHandle_t handle,
862 const GEOSPreparedGeometry* pg1,
863 const GEOSGeometry* g2);
864 extern char GEOS_DLL GEOSPreparedCrosses_r(GEOSContextHandle_t handle,
865 const GEOSPreparedGeometry* pg1,
866 const GEOSGeometry* g2);
867 extern char GEOS_DLL GEOSPreparedDisjoint_r(GEOSContextHandle_t handle,
868 const GEOSPreparedGeometry* pg1,
869 const GEOSGeometry* g2);
870 extern char GEOS_DLL GEOSPreparedIntersects_r(GEOSContextHandle_t handle,
871 const GEOSPreparedGeometry* pg1,
872 const GEOSGeometry* g2);
873 extern char GEOS_DLL GEOSPreparedOverlaps_r(GEOSContextHandle_t handle,
874 const GEOSPreparedGeometry* pg1,
875 const GEOSGeometry* g2);
876 extern char GEOS_DLL GEOSPreparedTouches_r(GEOSContextHandle_t handle,
877 const GEOSPreparedGeometry* pg1,
878 const GEOSGeometry* g2);
879 extern char GEOS_DLL GEOSPreparedWithin_r(GEOSContextHandle_t handle,
880 const GEOSPreparedGeometry* pg1,
881 const GEOSGeometry* g2);
883 /************************************************************************
885 * STRtree functions
887 ***********************************************************************/
890 * GEOSGeometry ownership is retained by caller
893 extern GEOSSTRtree GEOS_DLL *GEOSSTRtree_create(size_t nodeCapacity);
894 extern void GEOS_DLL GEOSSTRtree_insert(GEOSSTRtree *tree,
895 const GEOSGeometry *g,
896 void *item);
897 extern void GEOS_DLL GEOSSTRtree_query(GEOSSTRtree *tree,
898 const GEOSGeometry *g,
899 GEOSQueryCallback callback,
900 void *userdata);
901 extern void GEOS_DLL GEOSSTRtree_iterate(GEOSSTRtree *tree,
902 GEOSQueryCallback callback,
903 void *userdata);
904 extern char GEOS_DLL GEOSSTRtree_remove(GEOSSTRtree *tree,
905 const GEOSGeometry *g,
906 void *item);
907 extern void GEOS_DLL GEOSSTRtree_destroy(GEOSSTRtree *tree);
910 extern GEOSSTRtree GEOS_DLL *GEOSSTRtree_create_r(
911 GEOSContextHandle_t handle,
912 size_t nodeCapacity);
913 extern void GEOS_DLL GEOSSTRtree_insert_r(GEOSContextHandle_t handle,
914 GEOSSTRtree *tree,
915 const GEOSGeometry *g,
916 void *item);
917 extern void GEOS_DLL GEOSSTRtree_query_r(GEOSContextHandle_t handle,
918 GEOSSTRtree *tree,
919 const GEOSGeometry *g,
920 GEOSQueryCallback callback,
921 void *userdata);
922 extern void GEOS_DLL GEOSSTRtree_iterate_r(GEOSContextHandle_t handle,
923 GEOSSTRtree *tree,
924 GEOSQueryCallback callback,
925 void *userdata);
926 extern char GEOS_DLL GEOSSTRtree_remove_r(GEOSContextHandle_t handle,
927 GEOSSTRtree *tree,
928 const GEOSGeometry *g,
929 void *item);
930 extern void GEOS_DLL GEOSSTRtree_destroy_r(GEOSContextHandle_t handle,
931 GEOSSTRtree *tree);
934 /************************************************************************
936 * Unary predicate - return 2 on exception, 1 on true, 0 on false
938 ***********************************************************************/
940 extern char GEOS_DLL GEOSisEmpty(const GEOSGeometry* g);
941 extern char GEOS_DLL GEOSisSimple(const GEOSGeometry* g);
942 extern char GEOS_DLL GEOSisRing(const GEOSGeometry* g);
943 extern char GEOS_DLL GEOSHasZ(const GEOSGeometry* g);
944 extern char GEOS_DLL GEOSisClosed(const GEOSGeometry *g);
946 extern char GEOS_DLL GEOSisEmpty_r(GEOSContextHandle_t handle,
947 const GEOSGeometry* g);
948 extern char GEOS_DLL GEOSisSimple_r(GEOSContextHandle_t handle,
949 const GEOSGeometry* g);
950 extern char GEOS_DLL GEOSisRing_r(GEOSContextHandle_t handle,
951 const GEOSGeometry* g);
952 extern char GEOS_DLL GEOSHasZ_r(GEOSContextHandle_t handle,
953 const GEOSGeometry* g);
954 extern char GEOS_DLL GEOSisClosed_r(GEOSContextHandle_t handle,
955 const GEOSGeometry *g);
957 /************************************************************************
959 * Dimensionally Extended 9 Intersection Model related
961 ***********************************************************************/
963 /* These are for use with GEOSRelateBoundaryNodeRule (flags param) */
964 enum GEOSRelateBoundaryNodeRules {
965 /* MOD2 and OGC are the same rule, and is the default
966 * used by GEOSRelatePattern
968 GEOSRELATE_BNR_MOD2=1,
969 GEOSRELATE_BNR_OGC=1,
970 GEOSRELATE_BNR_ENDPOINT=2,
971 GEOSRELATE_BNR_MULTIVALENT_ENDPOINT=3,
972 GEOSRELATE_BNR_MONOVALENT_ENDPOINT=4
975 /* return 2 on exception, 1 on true, 0 on false */
976 extern char GEOS_DLL GEOSRelatePattern(const GEOSGeometry* g1, const GEOSGeometry* g2, const char *pat);
977 extern char GEOS_DLL GEOSRelatePattern_r(GEOSContextHandle_t handle,
978 const GEOSGeometry* g1,
979 const GEOSGeometry* g2,
980 const char *pat);
982 /* return NULL on exception, a string to GEOSFree otherwise */
983 extern char GEOS_DLL *GEOSRelate(const GEOSGeometry* g1, const GEOSGeometry* g2);
984 extern char GEOS_DLL *GEOSRelate_r(GEOSContextHandle_t handle,
985 const GEOSGeometry* g1,
986 const GEOSGeometry* g2);
988 /* return 2 on exception, 1 on true, 0 on false */
989 extern char GEOS_DLL GEOSRelatePatternMatch(const char *mat, const char *pat);
990 extern char GEOS_DLL GEOSRelatePatternMatch_r(GEOSContextHandle_t handle,
991 const char *mat,
992 const char *pat);
994 /* return NULL on exception, a string to GEOSFree otherwise */
995 extern char GEOS_DLL *GEOSRelateBoundaryNodeRule(const GEOSGeometry* g1,
996 const GEOSGeometry* g2,
997 int bnr);
998 extern char GEOS_DLL *GEOSRelateBoundaryNodeRule_r(GEOSContextHandle_t handle,
999 const GEOSGeometry* g1,
1000 const GEOSGeometry* g2,
1001 int bnr);
1003 /************************************************************************
1005 * Validity checking
1007 ***********************************************************************/
1009 /* These are for use with GEOSisValidDetail (flags param) */
1010 enum GEOSValidFlags {
1011 GEOSVALID_ALLOW_SELFTOUCHING_RING_FORMING_HOLE=1
1014 /* return 2 on exception, 1 on true, 0 on false */
1015 extern char GEOS_DLL GEOSisValid(const GEOSGeometry* g);
1016 extern char GEOS_DLL GEOSisValid_r(GEOSContextHandle_t handle,
1017 const GEOSGeometry* g);
1019 /* return NULL on exception, a string to GEOSFree otherwise */
1020 extern char GEOS_DLL *GEOSisValidReason(const GEOSGeometry *g);
1021 extern char GEOS_DLL *GEOSisValidReason_r(GEOSContextHandle_t handle,
1022 const GEOSGeometry* g);
1025 * Caller has the responsibility to destroy 'reason' (GEOSFree)
1026 * and 'location' (GEOSGeom_destroy) params
1027 * return 2 on exception, 1 when valid, 0 when invalid
1029 extern char GEOS_DLL GEOSisValidDetail(const GEOSGeometry* g,
1030 int flags,
1031 char** reason, GEOSGeometry** location);
1032 extern char GEOS_DLL GEOSisValidDetail_r(GEOSContextHandle_t handle,
1033 const GEOSGeometry* g,
1034 int flags,
1035 char** reason,
1036 GEOSGeometry** location);
1038 /************************************************************************
1040 * Geometry info
1042 ***********************************************************************/
1044 /* Return NULL on exception, result must be freed by caller. */
1045 extern char GEOS_DLL *GEOSGeomType(const GEOSGeometry* g);
1047 extern char GEOS_DLL *GEOSGeomType_r(GEOSContextHandle_t handle,
1048 const GEOSGeometry* g);
1050 /* Return -1 on exception */
1051 extern int GEOS_DLL GEOSGeomTypeId(const GEOSGeometry* g);
1053 extern int GEOS_DLL GEOSGeomTypeId_r(GEOSContextHandle_t handle,
1054 const GEOSGeometry* g);
1056 /* Return 0 on exception */
1057 extern int GEOS_DLL GEOSGetSRID(const GEOSGeometry* g);
1058 extern int GEOS_DLL GEOSGetSRID_r(GEOSContextHandle_t handle,
1059 const GEOSGeometry* g);
1061 extern void GEOS_DLL GEOSSetSRID(GEOSGeometry* g, int SRID);
1062 extern void GEOS_DLL GEOSSetSRID_r(GEOSContextHandle_t handle,
1063 GEOSGeometry* g, int SRID);
1065 /* May be called on all geometries in GEOS 3.x, returns -1 on error and 1
1066 * for non-multi geometries. Older GEOS versions only accept
1067 * GeometryCollections or Multi* geometries here, and are likely to crash
1068 * when fed simple geometries, so beware if you need compatibility with
1069 * old GEOS versions.
1071 extern int GEOS_DLL GEOSGetNumGeometries(const GEOSGeometry* g);
1073 extern int GEOS_DLL GEOSGetNumGeometries_r(GEOSContextHandle_t handle,
1074 const GEOSGeometry* g);
1077 * Return NULL on exception.
1078 * Returned object is a pointer to internal storage:
1079 * it must NOT be destroyed directly.
1080 * Up to GEOS 3.2.0 the input geometry must be a Collection, in
1081 * later version it doesn't matter (getGeometryN(0) for a single will
1082 * return the input).
1084 extern const GEOSGeometry GEOS_DLL *GEOSGetGeometryN(const GEOSGeometry* g, int n);
1086 extern const GEOSGeometry GEOS_DLL *GEOSGetGeometryN_r(
1087 GEOSContextHandle_t handle,
1088 const GEOSGeometry* g, int n);
1090 /* Return -1 on exception */
1091 extern int GEOS_DLL GEOSNormalize(GEOSGeometry* g);
1093 extern int GEOS_DLL GEOSNormalize_r(GEOSContextHandle_t handle,
1094 GEOSGeometry* g);
1096 /* Return -1 on exception */
1097 extern int GEOS_DLL GEOSGetNumInteriorRings(const GEOSGeometry* g);
1099 extern int GEOS_DLL GEOSGetNumInteriorRings_r(GEOSContextHandle_t handle,
1100 const GEOSGeometry* g);
1102 /* Return -1 on exception, Geometry must be a LineString. */
1103 extern int GEOS_DLL GEOSGeomGetNumPoints(const GEOSGeometry* g);
1105 extern int GEOS_DLL GEOSGeomGetNumPoints_r(GEOSContextHandle_t handle,
1106 const GEOSGeometry* g);
1108 /* Return -1 on exception, Geometry must be a Point. */
1109 extern int GEOS_DLL GEOSGeomGetX(const GEOSGeometry *g, double *x);
1110 extern int GEOS_DLL GEOSGeomGetY(const GEOSGeometry *g, double *y);
1112 extern int GEOS_DLL GEOSGeomGetX_r(GEOSContextHandle_t handle, const GEOSGeometry *g, double *x);
1113 extern int GEOS_DLL GEOSGeomGetY_r(GEOSContextHandle_t handle, const GEOSGeometry *g, double *y);
1116 * Return NULL on exception, Geometry must be a Polygon.
1117 * Returned object is a pointer to internal storage:
1118 * it must NOT be destroyed directly.
1120 extern const GEOSGeometry GEOS_DLL *GEOSGetInteriorRingN(const GEOSGeometry* g, int n);
1122 extern const GEOSGeometry GEOS_DLL *GEOSGetInteriorRingN_r(
1123 GEOSContextHandle_t handle,
1124 const GEOSGeometry* g, int n);
1127 * Return NULL on exception, Geometry must be a Polygon.
1128 * Returned object is a pointer to internal storage:
1129 * it must NOT be destroyed directly.
1131 extern const GEOSGeometry GEOS_DLL *GEOSGetExteriorRing(const GEOSGeometry* g);
1133 extern const GEOSGeometry GEOS_DLL *GEOSGetExteriorRing_r(
1134 GEOSContextHandle_t handle,
1135 const GEOSGeometry* g);
1137 /* Return -1 on exception */
1138 extern int GEOS_DLL GEOSGetNumCoordinates(const GEOSGeometry* g);
1140 extern int GEOS_DLL GEOSGetNumCoordinates_r(GEOSContextHandle_t handle,
1141 const GEOSGeometry* g);
1144 * Return NULL on exception.
1145 * Geometry must be a LineString, LinearRing or Point.
1147 extern const GEOSCoordSequence GEOS_DLL *GEOSGeom_getCoordSeq(const GEOSGeometry* g);
1149 extern const GEOSCoordSequence GEOS_DLL *GEOSGeom_getCoordSeq_r(
1150 GEOSContextHandle_t handle,
1151 const GEOSGeometry* g);
1154 * Return 0 on exception (or empty geometry)
1156 extern int GEOS_DLL GEOSGeom_getDimensions(const GEOSGeometry* g);
1158 extern int GEOS_DLL GEOSGeom_getDimensions_r(GEOSContextHandle_t handle,
1159 const GEOSGeometry* g);
1162 * Return 2 or 3.
1164 extern int GEOS_DLL GEOSGeom_getCoordinateDimension(const GEOSGeometry* g);
1166 extern int GEOS_DLL GEOSGeom_getCoordinateDimension_r(GEOSContextHandle_t handle,
1167 const GEOSGeometry* g);
1170 * Return NULL on exception.
1171 * Must be LineString and must be freed by called.
1173 extern GEOSGeometry GEOS_DLL *GEOSGeomGetPointN(const GEOSGeometry *g, int n);
1174 extern GEOSGeometry GEOS_DLL *GEOSGeomGetStartPoint(const GEOSGeometry *g);
1175 extern GEOSGeometry GEOS_DLL *GEOSGeomGetEndPoint(const GEOSGeometry *g);
1177 extern GEOSGeometry GEOS_DLL *GEOSGeomGetPointN_r(GEOSContextHandle_t handle, const GEOSGeometry *g, int n);
1178 extern GEOSGeometry GEOS_DLL *GEOSGeomGetStartPoint_r(GEOSContextHandle_t handle, const GEOSGeometry *g);
1179 extern GEOSGeometry GEOS_DLL *GEOSGeomGetEndPoint_r(GEOSContextHandle_t handle, const GEOSGeometry *g);
1181 /************************************************************************
1183 * Misc functions
1185 ***********************************************************************/
1187 /* Return 0 on exception, 1 otherwise */
1188 extern int GEOS_DLL GEOSArea(const GEOSGeometry* g, double *area);
1189 extern int GEOS_DLL GEOSLength(const GEOSGeometry* g, double *length);
1190 extern int GEOS_DLL GEOSDistance(const GEOSGeometry* g1, const GEOSGeometry* g2,
1191 double *dist);
1192 extern int GEOS_DLL GEOSHausdorffDistance(const GEOSGeometry *g1,
1193 const GEOSGeometry *g2, double *dist);
1194 extern int GEOS_DLL GEOSHausdorffDistanceDensify(const GEOSGeometry *g1,
1195 const GEOSGeometry *g2, double densifyFrac, double *dist);
1196 extern int GEOS_DLL GEOSGeomGetLength(const GEOSGeometry *g, double *length);
1198 extern int GEOS_DLL GEOSArea_r(GEOSContextHandle_t handle,
1199 const GEOSGeometry* g, double *area);
1200 extern int GEOS_DLL GEOSLength_r(GEOSContextHandle_t handle,
1201 const GEOSGeometry* g, double *length);
1202 extern int GEOS_DLL GEOSDistance_r(GEOSContextHandle_t handle,
1203 const GEOSGeometry* g1,
1204 const GEOSGeometry* g2, double *dist);
1205 extern int GEOS_DLL GEOSHausdorffDistance_r(GEOSContextHandle_t handle,
1206 const GEOSGeometry *g1,
1207 const GEOSGeometry *g2,
1208 double *dist);
1209 extern int GEOS_DLL GEOSHausdorffDistanceDensify_r(GEOSContextHandle_t handle,
1210 const GEOSGeometry *g1,
1211 const GEOSGeometry *g2,
1212 double densifyFrac, double *dist);
1213 extern int GEOS_DLL GEOSGeomGetLength_r(GEOSContextHandle_t handle,
1214 const GEOSGeometry *g, double *length);
1216 /* Return 0 on exception, the closest points of the two geometries otherwise.
1217 * The first point comes from g1 geometry and the second point comes from g2.
1219 extern GEOSCoordSequence GEOS_DLL *GEOSNearestPoints(
1220 const GEOSGeometry* g1, const GEOSGeometry* g2);
1221 extern GEOSCoordSequence GEOS_DLL *GEOSNearestPoints_r(
1222 GEOSContextHandle_t handle, const GEOSGeometry* g1, const GEOSGeometry* g2);
1225 /************************************************************************
1227 * Algorithms
1229 ***********************************************************************/
1231 /* Walking from A to B:
1232 * return -1 if reaching P takes a counter-clockwise (left) turn
1233 * return 1 if reaching P takes a clockwise (right) turn
1234 * return 0 if P is collinear with A-B
1236 * On exceptions, return 2.
1239 extern int GEOS_DLL GEOSOrientationIndex(double Ax, double Ay, double Bx, double By,
1240 double Px, double Py);
1241 extern int GEOS_DLL GEOSOrientationIndex_r(GEOSContextHandle_t handle,
1242 double Ax, double Ay, double Bx, double By, double Px, double Py);
1245 /************************************************************************
1247 * Reader and Writer APIs
1249 ***********************************************************************/
1251 typedef struct GEOSWKTReader_t GEOSWKTReader;
1252 typedef struct GEOSWKTWriter_t GEOSWKTWriter;
1253 typedef struct GEOSWKBReader_t GEOSWKBReader;
1254 typedef struct GEOSWKBWriter_t GEOSWKBWriter;
1257 /* WKT Reader */
1258 extern GEOSWKTReader GEOS_DLL *GEOSWKTReader_create();
1259 extern void GEOS_DLL GEOSWKTReader_destroy(GEOSWKTReader* reader);
1260 extern GEOSGeometry GEOS_DLL *GEOSWKTReader_read(GEOSWKTReader* reader, const char *wkt);
1262 extern GEOSWKTReader GEOS_DLL *GEOSWKTReader_create_r(
1263 GEOSContextHandle_t handle);
1264 extern void GEOS_DLL GEOSWKTReader_destroy_r(GEOSContextHandle_t handle,
1265 GEOSWKTReader* reader);
1266 extern GEOSGeometry GEOS_DLL *GEOSWKTReader_read_r(GEOSContextHandle_t handle,
1267 GEOSWKTReader* reader,
1268 const char *wkt);
1270 /* WKT Writer */
1271 extern GEOSWKTWriter GEOS_DLL *GEOSWKTWriter_create();
1272 extern void GEOS_DLL GEOSWKTWriter_destroy(GEOSWKTWriter* writer);
1273 extern char GEOS_DLL *GEOSWKTWriter_write(GEOSWKTWriter* writer, const GEOSGeometry* g);
1274 extern void GEOS_DLL GEOSWKTWriter_setTrim(GEOSWKTWriter *writer, char trim);
1275 extern void GEOS_DLL GEOSWKTWriter_setRoundingPrecision(GEOSWKTWriter *writer, int precision);
1276 extern void GEOS_DLL GEOSWKTWriter_setOutputDimension(GEOSWKTWriter *writer, int dim);
1277 extern int GEOS_DLL GEOSWKTWriter_getOutputDimension(GEOSWKTWriter *writer);
1278 extern void GEOS_DLL GEOSWKTWriter_setOld3D(GEOSWKTWriter *writer, int useOld3D);
1280 extern GEOSWKTWriter GEOS_DLL *GEOSWKTWriter_create_r(
1281 GEOSContextHandle_t handle);
1282 extern void GEOS_DLL GEOSWKTWriter_destroy_r(GEOSContextHandle_t handle,
1283 GEOSWKTWriter* writer);
1284 extern char GEOS_DLL *GEOSWKTWriter_write_r(GEOSContextHandle_t handle,
1285 GEOSWKTWriter* writer,
1286 const GEOSGeometry* g);
1287 extern void GEOS_DLL GEOSWKTWriter_setTrim_r(GEOSContextHandle_t handle,
1288 GEOSWKTWriter *writer,
1289 char trim);
1290 extern void GEOS_DLL GEOSWKTWriter_setRoundingPrecision_r(GEOSContextHandle_t handle,
1291 GEOSWKTWriter *writer,
1292 int precision);
1293 extern void GEOS_DLL GEOSWKTWriter_setOutputDimension_r(GEOSContextHandle_t handle,
1294 GEOSWKTWriter *writer,
1295 int dim);
1296 extern int GEOS_DLL GEOSWKTWriter_getOutputDimension_r(GEOSContextHandle_t handle,
1297 GEOSWKTWriter *writer);
1298 extern void GEOS_DLL GEOSWKTWriter_setOld3D_r(GEOSContextHandle_t handle,
1299 GEOSWKTWriter *writer,
1300 int useOld3D);
1302 /* WKB Reader */
1303 extern GEOSWKBReader GEOS_DLL *GEOSWKBReader_create();
1304 extern void GEOS_DLL GEOSWKBReader_destroy(GEOSWKBReader* reader);
1305 extern GEOSGeometry GEOS_DLL *GEOSWKBReader_read(GEOSWKBReader* reader, const unsigned char *wkb, size_t size);
1306 extern GEOSGeometry GEOS_DLL *GEOSWKBReader_readHEX(GEOSWKBReader* reader, const unsigned char *hex, size_t size);
1308 extern GEOSWKBReader GEOS_DLL *GEOSWKBReader_create_r(
1309 GEOSContextHandle_t handle);
1310 extern void GEOS_DLL GEOSWKBReader_destroy_r(GEOSContextHandle_t handle,
1311 GEOSWKBReader* reader);
1312 extern GEOSGeometry GEOS_DLL *GEOSWKBReader_read_r(GEOSContextHandle_t handle,
1313 GEOSWKBReader* reader,
1314 const unsigned char *wkb,
1315 size_t size);
1316 extern GEOSGeometry GEOS_DLL *GEOSWKBReader_readHEX_r(
1317 GEOSContextHandle_t handle,
1318 GEOSWKBReader* reader,
1319 const unsigned char *hex,
1320 size_t size);
1322 /* WKB Writer */
1323 extern GEOSWKBWriter GEOS_DLL *GEOSWKBWriter_create();
1324 extern void GEOS_DLL GEOSWKBWriter_destroy(GEOSWKBWriter* writer);
1326 extern GEOSWKBWriter GEOS_DLL *GEOSWKBWriter_create_r(
1327 GEOSContextHandle_t handle);
1328 extern void GEOS_DLL GEOSWKBWriter_destroy_r(GEOSContextHandle_t handle,
1329 GEOSWKBWriter* writer);
1331 /* The caller owns the results for these two methods! */
1332 extern unsigned char GEOS_DLL *GEOSWKBWriter_write(GEOSWKBWriter* writer, const GEOSGeometry* g, size_t *size);
1333 extern unsigned char GEOS_DLL *GEOSWKBWriter_writeHEX(GEOSWKBWriter* writer, const GEOSGeometry* g, size_t *size);
1335 extern unsigned char GEOS_DLL *GEOSWKBWriter_write_r(
1336 GEOSContextHandle_t handle,
1337 GEOSWKBWriter* writer,
1338 const GEOSGeometry* g,
1339 size_t *size);
1340 extern unsigned char GEOS_DLL *GEOSWKBWriter_writeHEX_r(
1341 GEOSContextHandle_t handle,
1342 GEOSWKBWriter* writer,
1343 const GEOSGeometry* g,
1344 size_t *size);
1347 * Specify whether output WKB should be 2d or 3d.
1348 * Return previously set number of dimensions.
1350 extern int GEOS_DLL GEOSWKBWriter_getOutputDimension(const GEOSWKBWriter* writer);
1351 extern void GEOS_DLL GEOSWKBWriter_setOutputDimension(GEOSWKBWriter* writer, int newDimension);
1353 extern int GEOS_DLL GEOSWKBWriter_getOutputDimension_r(
1354 GEOSContextHandle_t handle,
1355 const GEOSWKBWriter* writer);
1356 extern void GEOS_DLL GEOSWKBWriter_setOutputDimension_r(
1357 GEOSContextHandle_t handle,
1358 GEOSWKBWriter* writer, int newDimension);
1361 * Specify whether the WKB byte order is big or little endian.
1362 * The return value is the previous byte order.
1364 extern int GEOS_DLL GEOSWKBWriter_getByteOrder(const GEOSWKBWriter* writer);
1365 extern void GEOS_DLL GEOSWKBWriter_setByteOrder(GEOSWKBWriter* writer, int byteOrder);
1367 extern int GEOS_DLL GEOSWKBWriter_getByteOrder_r(GEOSContextHandle_t handle,
1368 const GEOSWKBWriter* writer);
1369 extern void GEOS_DLL GEOSWKBWriter_setByteOrder_r(GEOSContextHandle_t handle,
1370 GEOSWKBWriter* writer,
1371 int byteOrder);
1374 * Specify whether SRID values should be output.
1376 extern char GEOS_DLL GEOSWKBWriter_getIncludeSRID(const GEOSWKBWriter* writer);
1377 extern void GEOS_DLL GEOSWKBWriter_setIncludeSRID(GEOSWKBWriter* writer, const char writeSRID);
1379 extern char GEOS_DLL GEOSWKBWriter_getIncludeSRID_r(GEOSContextHandle_t handle,
1380 const GEOSWKBWriter* writer);
1381 extern void GEOS_DLL GEOSWKBWriter_setIncludeSRID_r(GEOSContextHandle_t handle,
1382 GEOSWKBWriter* writer, const char writeSRID);
1386 * Free buffers returned by stuff like GEOSWKBWriter_write(),
1387 * GEOSWKBWriter_writeHEX() and GEOSWKTWriter_write().
1389 extern void GEOS_DLL GEOSFree(void *buffer);
1390 extern void GEOS_DLL GEOSFree_r(GEOSContextHandle_t handle, void *buffer);
1392 #ifdef __cplusplus
1393 } // extern "C"
1394 #endif
1396 #endif /* #ifndef GEOS_C_H_INCLUDED */