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 ***********************************************************************
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 ***********************************************************************/
29 #ifndef GEOS_C_H_INCLUDED
30 #define GEOS_C_H_INCLUDED
33 # include <stddef.h> /* for size_t definition */
43 /************************************************************************
47 ***********************************************************************/
50 * Following 'ifdef' hack fixes problem with generating geos_c.h on Windows,
51 * when building with Visual C++ compiler.
55 #include <geos/version.h>
56 #define GEOS_CAPI_VERSION_MAJOR 1
57 #define GEOS_CAPI_VERSION_MINOR 8
58 #define GEOS_CAPI_VERSION_PATCH 0
59 #define GEOS_CAPI_VERSION "3.4.0-CAPI-1.8.0"
61 #ifndef GEOS_VERSION_MAJOR
62 #define GEOS_VERSION_MAJOR @VERSION_MAJOR@
64 #ifndef GEOS_VERSION_MINOR
65 #define GEOS_VERSION_MINOR @VERSION_MINOR@
67 #ifndef GEOS_VERSION_PATCH
68 #define GEOS_VERSION_PATCH @VERSION_PATCH@
71 #define GEOS_VERSION "@VERSION@"
74 #define GEOS_JTS_PORT "@JTS_PORT@"
77 #define GEOS_CAPI_VERSION_MAJOR @CAPI_VERSION_MAJOR@
78 #define GEOS_CAPI_VERSION_MINOR @CAPI_VERSION_MINOR@
79 #define GEOS_CAPI_VERSION_PATCH @CAPI_VERSION_PATCH@
80 #define GEOS_CAPI_VERSION "@VERSION@-CAPI-@CAPI_VERSION@"
83 #define GEOS_CAPI_FIRST_INTERFACE GEOS_CAPI_VERSION_MAJOR
84 #define GEOS_CAPI_LAST_INTERFACE (GEOS_CAPI_VERSION_MAJOR+GEOS_CAPI_VERSION_MINOR)
86 /************************************************************************
88 * (Abstract) type definitions
90 ************************************************************************/
92 typedef void (*GEOSMessageHandler
)(const char *fmt
, ...);
94 /* When we're included by geos_c.cpp, those are #defined to the original
95 * JTS definitions via preprocessor. We don't touch them to allow the
96 * compiler to cross-check the declarations. However, for all "normal"
97 * C-API users, we need to define them as "opaque" struct pointers, as
98 * those clients don't have access to the original C++ headers, by design.
101 typedef struct GEOSGeom_t GEOSGeometry
;
102 typedef struct GEOSPrepGeom_t GEOSPreparedGeometry
;
103 typedef struct GEOSCoordSeq_t GEOSCoordSequence
;
104 typedef struct GEOSSTRtree_t GEOSSTRtree
;
105 typedef struct GEOSBufParams_t GEOSBufferParams
;
108 /* Those are compatibility definitions for source compatibility
109 * with GEOS 2.X clients relying on that type.
111 typedef GEOSGeometry
* GEOSGeom
;
112 typedef GEOSCoordSequence
* GEOSCoordSeq
;
114 /* Supported geometry types
115 * This was renamed from GEOSGeomTypeId in GEOS 2.2.X, which might
116 * break compatibility, this issue is still under investigation.
125 GEOS_MULTILINESTRING
,
127 GEOS_GEOMETRYCOLLECTION
130 /* Byte oders exposed via the c api */
131 enum GEOSByteOrders
{
132 GEOS_WKB_XDR
= 0, /* Big Endian */
133 GEOS_WKB_NDR
= 1 /* Little Endian */
136 typedef struct GEOSContextHandle_HS
*GEOSContextHandle_t
;
138 typedef void (*GEOSQueryCallback
)(void *item
, void *userdata
);
140 /************************************************************************
142 * Initialization, cleanup, version
144 ***********************************************************************/
146 #include <geos/export.h>
148 extern void GEOS_DLL
initGEOS(GEOSMessageHandler notice_function
,
149 GEOSMessageHandler error_function
);
150 extern void GEOS_DLL
finishGEOS(void);
153 * Register an interruption checking callback
155 * The callback will be invoked _before_ checking for
156 * interruption, so can be used to request it.
158 typedef void (GEOSInterruptCallback
)();
159 extern GEOSInterruptCallback GEOS_DLL
*GEOS_interruptRegisterCallback(GEOSInterruptCallback
* cb
);
160 /* Request safe interruption of operations */
161 extern void GEOS_DLL
GEOS_interruptRequest();
162 /* Cancel a pending interruption request */
163 extern void GEOS_DLL
GEOS_interruptCancel();
166 extern GEOSContextHandle_t GEOS_DLL
initGEOS_r(
167 GEOSMessageHandler notice_function
,
168 GEOSMessageHandler error_function
);
169 extern void GEOS_DLL
finishGEOS_r(GEOSContextHandle_t handle
);
171 extern GEOSMessageHandler GEOS_DLL
GEOSContext_setNoticeHandler_r(GEOSContextHandle_t extHandle
,
172 GEOSMessageHandler nf
);
173 extern GEOSMessageHandler GEOS_DLL
GEOSContext_setErrorHandler_r(GEOSContextHandle_t extHandle
,
174 GEOSMessageHandler nf
);
176 extern const char GEOS_DLL
*GEOSversion();
179 /************************************************************************
181 * NOTE - These functions are DEPRECATED. Please use the new Reader and
184 ***********************************************************************/
186 extern GEOSGeometry GEOS_DLL
*GEOSGeomFromWKT(const char *wkt
);
187 extern char GEOS_DLL
*GEOSGeomToWKT(const GEOSGeometry
* g
);
189 extern GEOSGeometry GEOS_DLL
*GEOSGeomFromWKT_r(GEOSContextHandle_t handle
,
191 extern char GEOS_DLL
*GEOSGeomToWKT_r(GEOSContextHandle_t handle
,
192 const GEOSGeometry
* g
);
195 * Specify whether output WKB should be 2d or 3d.
196 * Return previously set number of dimensions.
198 extern int GEOS_DLL
GEOS_getWKBOutputDims();
199 extern int GEOS_DLL
GEOS_setWKBOutputDims(int newDims
);
201 extern int GEOS_DLL
GEOS_getWKBOutputDims_r(GEOSContextHandle_t handle
);
202 extern int GEOS_DLL
GEOS_setWKBOutputDims_r(GEOSContextHandle_t handle
,
206 * Specify whether the WKB byte order is big or little endian.
207 * The return value is the previous byte order.
209 extern int GEOS_DLL
GEOS_getWKBByteOrder();
210 extern int GEOS_DLL
GEOS_setWKBByteOrder(int byteOrder
);
212 extern GEOSGeometry GEOS_DLL
*GEOSGeomFromWKB_buf(const unsigned char *wkb
, size_t size
);
213 extern unsigned char GEOS_DLL
*GEOSGeomToWKB_buf(const GEOSGeometry
* g
, size_t *size
);
215 extern GEOSGeometry GEOS_DLL
*GEOSGeomFromHEX_buf(const unsigned char *hex
, size_t size
);
216 extern unsigned char GEOS_DLL
*GEOSGeomToHEX_buf(const GEOSGeometry
* g
, size_t *size
);
218 extern int GEOS_DLL
GEOS_getWKBByteOrder_r(GEOSContextHandle_t handle
);
219 extern int GEOS_DLL
GEOS_setWKBByteOrder_r(GEOSContextHandle_t handle
,
222 extern GEOSGeometry GEOS_DLL
*GEOSGeomFromWKB_buf_r(GEOSContextHandle_t handle
,
223 const unsigned char *wkb
,
225 extern unsigned char GEOS_DLL
*GEOSGeomToWKB_buf_r(GEOSContextHandle_t handle
,
226 const GEOSGeometry
* g
,
229 extern GEOSGeometry GEOS_DLL
*GEOSGeomFromHEX_buf_r(GEOSContextHandle_t handle
,
230 const unsigned char *hex
,
232 extern unsigned char GEOS_DLL
*GEOSGeomToHEX_buf_r(GEOSContextHandle_t handle
,
233 const GEOSGeometry
* g
,
236 /************************************************************************
238 * Coordinate Sequence functions
240 ***********************************************************************/
243 * Create a Coordinate sequence with ``size'' coordinates
244 * of ``dims'' dimensions.
245 * Return NULL on exception.
247 extern GEOSCoordSequence GEOS_DLL
*GEOSCoordSeq_create(unsigned int size
, unsigned int dims
);
249 extern GEOSCoordSequence GEOS_DLL
*GEOSCoordSeq_create_r(
250 GEOSContextHandle_t handle
,
255 * Clone a Coordinate Sequence.
256 * Return NULL on exception.
258 extern GEOSCoordSequence GEOS_DLL
*GEOSCoordSeq_clone(const GEOSCoordSequence
* s
);
260 extern GEOSCoordSequence GEOS_DLL
*GEOSCoordSeq_clone_r(
261 GEOSContextHandle_t handle
,
262 const GEOSCoordSequence
* s
);
265 * Destroy a Coordinate Sequence.
267 extern void GEOS_DLL
GEOSCoordSeq_destroy(GEOSCoordSequence
* s
);
269 extern void GEOS_DLL
GEOSCoordSeq_destroy_r(GEOSContextHandle_t handle
,
270 GEOSCoordSequence
* s
);
273 * Set ordinate values in a Coordinate Sequence.
274 * Return 0 on exception.
276 extern int GEOS_DLL
GEOSCoordSeq_setX(GEOSCoordSequence
* s
,
277 unsigned int idx
, double val
);
278 extern int GEOS_DLL
GEOSCoordSeq_setY(GEOSCoordSequence
* s
,
279 unsigned int idx
, double val
);
280 extern int GEOS_DLL
GEOSCoordSeq_setZ(GEOSCoordSequence
* s
,
281 unsigned int idx
, double val
);
282 extern int GEOS_DLL
GEOSCoordSeq_setOrdinate(GEOSCoordSequence
* s
,
283 unsigned int idx
, unsigned int dim
, double val
);
285 extern int GEOS_DLL
GEOSCoordSeq_setX_r(GEOSContextHandle_t handle
,
286 GEOSCoordSequence
* s
, unsigned int idx
,
288 extern int GEOS_DLL
GEOSCoordSeq_setY_r(GEOSContextHandle_t handle
,
289 GEOSCoordSequence
* s
, unsigned int idx
,
291 extern int GEOS_DLL
GEOSCoordSeq_setZ_r(GEOSContextHandle_t handle
,
292 GEOSCoordSequence
* s
, unsigned int idx
,
294 extern int GEOS_DLL
GEOSCoordSeq_setOrdinate_r(GEOSContextHandle_t handle
,
295 GEOSCoordSequence
* s
,
297 unsigned int dim
, double val
);
300 * Get ordinate values from a Coordinate Sequence.
301 * Return 0 on exception.
303 extern int GEOS_DLL
GEOSCoordSeq_getX(const GEOSCoordSequence
* s
,
304 unsigned int idx
, double *val
);
305 extern int GEOS_DLL
GEOSCoordSeq_getY(const GEOSCoordSequence
* s
,
306 unsigned int idx
, double *val
);
307 extern int GEOS_DLL
GEOSCoordSeq_getZ(const GEOSCoordSequence
* s
,
308 unsigned int idx
, double *val
);
309 extern int GEOS_DLL
GEOSCoordSeq_getOrdinate(const GEOSCoordSequence
* s
,
310 unsigned int idx
, unsigned int dim
, double *val
);
312 extern int GEOS_DLL
GEOSCoordSeq_getX_r(GEOSContextHandle_t handle
,
313 const GEOSCoordSequence
* s
,
314 unsigned int idx
, double *val
);
315 extern int GEOS_DLL
GEOSCoordSeq_getY_r(GEOSContextHandle_t handle
,
316 const GEOSCoordSequence
* s
,
317 unsigned int idx
, double *val
);
318 extern int GEOS_DLL
GEOSCoordSeq_getZ_r(GEOSContextHandle_t handle
,
319 const GEOSCoordSequence
* s
,
320 unsigned int idx
, double *val
);
321 extern int GEOS_DLL
GEOSCoordSeq_getOrdinate_r(GEOSContextHandle_t handle
,
322 const GEOSCoordSequence
* s
,
324 unsigned int dim
, double *val
);
326 * Get size and dimensions info from a Coordinate Sequence.
327 * Return 0 on exception.
329 extern int GEOS_DLL
GEOSCoordSeq_getSize(const GEOSCoordSequence
* s
,
331 extern int GEOS_DLL
GEOSCoordSeq_getDimensions(const GEOSCoordSequence
* s
,
334 extern int GEOS_DLL
GEOSCoordSeq_getSize_r(GEOSContextHandle_t handle
,
335 const GEOSCoordSequence
* s
,
337 extern int GEOS_DLL
GEOSCoordSeq_getDimensions_r(GEOSContextHandle_t handle
,
338 const GEOSCoordSequence
* s
,
341 /************************************************************************
343 * Linearref functions -- there are more, but these two are probably
344 * sufficient for most purposes
346 ***********************************************************************/
349 * GEOSGeometry ownership is retained by caller
353 /* Return distance of point 'p' projected on 'g' from origin
354 * of 'g'. Geometry 'g' must be a lineal geometry */
355 extern double GEOS_DLL
GEOSProject(const GEOSGeometry
*g
,
356 const GEOSGeometry
* p
);
357 extern double GEOS_DLL
GEOSProject_r(GEOSContextHandle_t handle
,
358 const GEOSGeometry
*g
,
359 const GEOSGeometry
*p
);
361 /* Return closest point to given distance within geometry
362 * Geometry must be a LineString */
363 extern GEOSGeometry GEOS_DLL
*GEOSInterpolate(const GEOSGeometry
*g
,
365 extern GEOSGeometry GEOS_DLL
*GEOSInterpolate_r(GEOSContextHandle_t handle
,
366 const GEOSGeometry
*g
,
369 extern double GEOS_DLL
GEOSProjectNormalized(const GEOSGeometry
*g
,
370 const GEOSGeometry
* p
);
371 extern double GEOS_DLL
GEOSProjectNormalized_r(GEOSContextHandle_t handle
,
372 const GEOSGeometry
*g
,
373 const GEOSGeometry
*p
);
375 extern GEOSGeometry GEOS_DLL
*GEOSInterpolateNormalized(const GEOSGeometry
*g
,
377 extern GEOSGeometry GEOS_DLL
*GEOSInterpolateNormalized_r(
378 GEOSContextHandle_t handle
,
379 const GEOSGeometry
*g
,
382 /************************************************************************
384 * Buffer related functions
386 ***********************************************************************/
388 enum GEOSBufCapStyles
{
394 enum GEOSBufJoinStyles
{
395 GEOSBUF_JOIN_ROUND
=1,
396 GEOSBUF_JOIN_MITRE
=2,
400 /* @return 0 on exception */
401 extern GEOSBufferParams GEOS_DLL
*GEOSBufferParams_create();
402 extern GEOSBufferParams GEOS_DLL
*GEOSBufferParams_create_r(
403 GEOSContextHandle_t handle
);
404 extern void GEOS_DLL
GEOSBufferParams_destroy(GEOSBufferParams
* parms
);
405 extern void GEOS_DLL
GEOSBufferParams_destroy_r(
406 GEOSContextHandle_t handle
,
407 GEOSBufferParams
* parms
);
409 /* @return 0 on exception */
410 extern int GEOS_DLL
GEOSBufferParams_setEndCapStyle(
413 extern int GEOS_DLL
GEOSBufferParams_setEndCapStyle_r(
414 GEOSContextHandle_t handle
,
418 /* @return 0 on exception */
419 extern int GEOS_DLL
GEOSBufferParams_setJoinStyle(
422 extern int GEOS_DLL
GEOSBufferParams_setJoinStyle_r(
423 GEOSContextHandle_t handle
,
427 /* @return 0 on exception */
428 extern int GEOS_DLL
GEOSBufferParams_setMitreLimit(
431 extern int GEOS_DLL
GEOSBufferParams_setMitreLimit_r(
432 GEOSContextHandle_t handle
,
436 /* @return 0 on exception */
437 extern int GEOS_DLL
GEOSBufferParams_setQuadrantSegments(
440 extern int GEOS_DLL
GEOSBufferParams_setQuadrantSegments_r(
441 GEOSContextHandle_t handle
,
445 /* @param singleSided: 1 for single sided, 0 otherwise */
446 /* @return 0 on exception */
447 extern int GEOS_DLL
GEOSBufferParams_setSingleSided(
450 extern int GEOS_DLL
GEOSBufferParams_setSingleSided_r(
451 GEOSContextHandle_t handle
,
455 /* @return NULL on exception. */
456 extern GEOSGeometry GEOS_DLL
*GEOSBufferWithParams(
457 const GEOSGeometry
* g1
,
458 const GEOSBufferParams
* p
,
460 extern GEOSGeometry GEOS_DLL
*GEOSBufferWithParams_r(
461 GEOSContextHandle_t handle
,
462 const GEOSGeometry
* g1
,
463 const GEOSBufferParams
* p
,
466 /* These functions return NULL on exception. */
467 extern GEOSGeometry GEOS_DLL
*GEOSBuffer(const GEOSGeometry
* g1
,
468 double width
, int quadsegs
);
469 extern GEOSGeometry GEOS_DLL
*GEOSBuffer_r(GEOSContextHandle_t handle
,
470 const GEOSGeometry
* g1
,
471 double width
, int quadsegs
);
473 /* These functions return NULL on exception. */
474 extern GEOSGeometry GEOS_DLL
*GEOSBufferWithStyle(const GEOSGeometry
* g1
,
475 double width
, int quadsegs
, int endCapStyle
, int joinStyle
,
477 extern GEOSGeometry GEOS_DLL
*GEOSBufferWithStyle_r(GEOSContextHandle_t handle
,
478 const GEOSGeometry
* g1
, double width
, int quadsegs
, int endCapStyle
,
479 int joinStyle
, double mitreLimit
);
481 /* These functions return NULL on exception. Only LINESTRINGs are accepted. */
482 /* @deprecated in 3.3.0: use GEOSOffsetCurve instead */
483 extern GEOSGeometry GEOS_DLL
*GEOSSingleSidedBuffer(const GEOSGeometry
* g1
,
484 double width
, int quadsegs
, int joinStyle
, double mitreLimit
,
486 extern GEOSGeometry GEOS_DLL
*GEOSSingleSidedBuffer_r(
487 GEOSContextHandle_t handle
,
488 const GEOSGeometry
* g1
, double width
, int quadsegs
,
489 int joinStyle
, double mitreLimit
, int leftSide
);
492 * Only LINESTRINGs are accepted.
493 * @param width : offset distance.
494 * negative for right side offset.
495 * positive for left side offset.
496 * @return NULL on exception
498 extern GEOSGeometry GEOS_DLL
*GEOSOffsetCurve(const GEOSGeometry
* g1
,
499 double width
, int quadsegs
, int joinStyle
, double mitreLimit
);
500 extern GEOSGeometry GEOS_DLL
*GEOSOffsetCurve_r(GEOSContextHandle_t handle
,
501 const GEOSGeometry
* g1
, double width
, int quadsegs
,
502 int joinStyle
, double mitreLimit
);
505 /************************************************************************
507 * Geometry Constructors.
508 * GEOSCoordSequence* arguments will become ownership of the returned object.
509 * All functions return NULL on exception.
511 ***********************************************************************/
513 extern GEOSGeometry GEOS_DLL
*GEOSGeom_createPoint(GEOSCoordSequence
* s
);
514 extern GEOSGeometry GEOS_DLL
*GEOSGeom_createEmptyPoint();
515 extern GEOSGeometry GEOS_DLL
*GEOSGeom_createLinearRing(GEOSCoordSequence
* s
);
516 extern GEOSGeometry GEOS_DLL
*GEOSGeom_createLineString(GEOSCoordSequence
* s
);
517 extern GEOSGeometry GEOS_DLL
*GEOSGeom_createEmptyLineString();
519 extern GEOSGeometry GEOS_DLL
*GEOSGeom_createPoint_r(
520 GEOSContextHandle_t handle
,
521 GEOSCoordSequence
* s
);
522 extern GEOSGeometry GEOS_DLL
*GEOSGeom_createEmptyPoint_r(
523 GEOSContextHandle_t handle
);
524 extern GEOSGeometry GEOS_DLL
*GEOSGeom_createLinearRing_r(
525 GEOSContextHandle_t handle
,
526 GEOSCoordSequence
* s
);
527 extern GEOSGeometry GEOS_DLL
*GEOSGeom_createLineString_r(
528 GEOSContextHandle_t handle
,
529 GEOSCoordSequence
* s
);
530 extern GEOSGeometry GEOS_DLL
*GEOSGeom_createEmptyLineString_r(
531 GEOSContextHandle_t handle
);
534 * Second argument is an array of GEOSGeometry* objects.
535 * The caller remains owner of the array, but pointed-to
536 * objects become ownership of the returned GEOSGeometry.
538 extern GEOSGeometry GEOS_DLL
*GEOSGeom_createEmptyPolygon();
539 extern GEOSGeometry GEOS_DLL
*GEOSGeom_createPolygon(GEOSGeometry
* shell
,
540 GEOSGeometry
** holes
, unsigned int nholes
);
541 extern GEOSGeometry GEOS_DLL
*GEOSGeom_createCollection(int type
,
542 GEOSGeometry
* *geoms
, unsigned int ngeoms
);
543 extern GEOSGeometry GEOS_DLL
*GEOSGeom_createEmptyCollection(int type
);
545 extern GEOSGeometry GEOS_DLL
*GEOSGeom_createEmptyPolygon_r(
546 GEOSContextHandle_t handle
);
547 extern GEOSGeometry GEOS_DLL
*GEOSGeom_createPolygon_r(
548 GEOSContextHandle_t handle
,
550 GEOSGeometry
** holes
,
551 unsigned int nholes
);
552 extern GEOSGeometry GEOS_DLL
*GEOSGeom_createCollection_r(
553 GEOSContextHandle_t handle
, int type
,
554 GEOSGeometry
* *geoms
,
555 unsigned int ngeoms
);
556 extern GEOSGeometry GEOS_DLL
*GEOSGeom_createEmptyCollection_r(
557 GEOSContextHandle_t handle
, int type
);
559 extern GEOSGeometry GEOS_DLL
*GEOSGeom_clone(const GEOSGeometry
* g
);
561 extern GEOSGeometry GEOS_DLL
*GEOSGeom_clone_r(GEOSContextHandle_t handle
,
562 const GEOSGeometry
* g
);
564 /************************************************************************
568 ***********************************************************************/
570 extern void GEOS_DLL
GEOSGeom_destroy(GEOSGeometry
* g
);
572 extern void GEOS_DLL
GEOSGeom_destroy_r(GEOSContextHandle_t handle
,
575 /************************************************************************
577 * Topology operations - return NULL on exception.
579 ***********************************************************************/
581 extern GEOSGeometry GEOS_DLL
*GEOSEnvelope(const GEOSGeometry
* g1
);
582 extern GEOSGeometry GEOS_DLL
*GEOSIntersection(const GEOSGeometry
* g1
, const GEOSGeometry
* g2
);
583 extern GEOSGeometry GEOS_DLL
*GEOSConvexHull(const GEOSGeometry
* g1
);
584 extern GEOSGeometry GEOS_DLL
*GEOSDifference(const GEOSGeometry
* g1
, const GEOSGeometry
* g2
);
585 extern GEOSGeometry GEOS_DLL
*GEOSSymDifference(const GEOSGeometry
* g1
,
586 const GEOSGeometry
* g2
);
587 extern GEOSGeometry GEOS_DLL
*GEOSBoundary(const GEOSGeometry
* g1
);
588 extern GEOSGeometry GEOS_DLL
*GEOSUnion(const GEOSGeometry
* g1
, const GEOSGeometry
* g2
);
589 extern GEOSGeometry GEOS_DLL
*GEOSUnaryUnion(const GEOSGeometry
* g1
);
590 extern GEOSGeometry GEOS_DLL
*GEOSNode(const GEOSGeometry
* g
);
592 /* @deprecated in 3.3.0: use GEOSUnaryUnion instead */
593 extern GEOSGeometry GEOS_DLL
*GEOSUnionCascaded(const GEOSGeometry
* g1
);
594 extern GEOSGeometry GEOS_DLL
*GEOSUnionCascaded_r(GEOSContextHandle_t handle
, const GEOSGeometry
* g1
);
596 extern GEOSGeometry GEOS_DLL
*GEOSPointOnSurface(const GEOSGeometry
* g1
);
597 extern GEOSGeometry GEOS_DLL
*GEOSGetCentroid(const GEOSGeometry
* g
);
599 extern GEOSGeometry GEOS_DLL
*GEOSEnvelope_r(GEOSContextHandle_t handle
,
600 const GEOSGeometry
* g1
);
601 extern GEOSGeometry GEOS_DLL
*GEOSIntersection_r(GEOSContextHandle_t handle
,
602 const GEOSGeometry
* g1
,
603 const GEOSGeometry
* g2
);
604 extern GEOSGeometry GEOS_DLL
*GEOSConvexHull_r(GEOSContextHandle_t handle
,
605 const GEOSGeometry
* g1
);
606 extern GEOSGeometry GEOS_DLL
*GEOSDifference_r(GEOSContextHandle_t handle
,
607 const GEOSGeometry
* g1
,
608 const GEOSGeometry
* g2
);
609 extern GEOSGeometry GEOS_DLL
*GEOSSymDifference_r(GEOSContextHandle_t handle
,
610 const GEOSGeometry
* g1
,
611 const GEOSGeometry
* g2
);
612 extern GEOSGeometry GEOS_DLL
*GEOSBoundary_r(GEOSContextHandle_t handle
,
613 const GEOSGeometry
* g1
);
614 extern GEOSGeometry GEOS_DLL
*GEOSUnion_r(GEOSContextHandle_t handle
,
615 const GEOSGeometry
* g1
,
616 const GEOSGeometry
* g2
);
617 extern GEOSGeometry GEOS_DLL
*GEOSUnaryUnion_r(GEOSContextHandle_t handle
,
618 const GEOSGeometry
* g
);
619 extern GEOSGeometry GEOS_DLL
*GEOSPointOnSurface_r(GEOSContextHandle_t handle
,
620 const GEOSGeometry
* g1
);
621 extern GEOSGeometry GEOS_DLL
*GEOSGetCentroid_r(GEOSContextHandle_t handle
,
622 const GEOSGeometry
* g
);
623 extern GEOSGeometry GEOS_DLL
*GEOSNode_r(GEOSContextHandle_t handle
,
624 const GEOSGeometry
* g
);
627 * all arguments remain ownership of the caller
628 * (both Geometries and pointers)
630 extern GEOSGeometry GEOS_DLL
*GEOSPolygonize(const GEOSGeometry
* const geoms
[], unsigned int ngeoms
);
631 extern GEOSGeometry GEOS_DLL
*GEOSPolygonizer_getCutEdges(const GEOSGeometry
* const geoms
[], unsigned int ngeoms
);
633 * Polygonizes a set of Geometrys which contain linework that
634 * represents the edges of a planar graph.
636 * Any dimension of Geometry is handled - the constituent linework
637 * is extracted to form the edges.
639 * The edges must be correctly noded; that is, they must only meet
640 * at their endpoints.
641 * The Polygonizer will still run on incorrectly noded input
642 * but will not form polygons from incorrected noded edges.
644 * The Polygonizer reports the follow kinds of errors:
646 * - Dangles - edges which have one or both ends which are
647 * not incident on another edge endpoint
648 * - Cut Edges - edges which are connected at both ends but
649 * which do not form part of polygon
650 * - Invalid Ring Lines - edges which form rings which are invalid
651 * (e.g. the component lines contain a self-intersection)
653 * Errors are reported to output parameters "cuts", "dangles" and
654 * "invalid" (if not-null). Formed polygons are returned as a
655 * collection. NULL is returned on exception. All returned
656 * geometries must be destroyed by caller.
659 extern GEOSGeometry GEOS_DLL
*GEOSPolygonize_full(const GEOSGeometry
* input
,
660 GEOSGeometry
** cuts
, GEOSGeometry
** dangles
, GEOSGeometry
** invalid
);
662 extern GEOSGeometry GEOS_DLL
*GEOSLineMerge(const GEOSGeometry
* g
);
663 extern GEOSGeometry GEOS_DLL
*GEOSSimplify(const GEOSGeometry
* g1
, double tolerance
);
664 extern GEOSGeometry GEOS_DLL
*GEOSTopologyPreserveSimplify(const GEOSGeometry
* g1
,
667 extern GEOSGeometry GEOS_DLL
*GEOSPolygonize_r(GEOSContextHandle_t handle
,
668 const GEOSGeometry
*const geoms
[],
669 unsigned int ngeoms
);
670 extern GEOSGeometry GEOS_DLL
*GEOSPolygonizer_getCutEdges_r(
671 GEOSContextHandle_t handle
,
672 const GEOSGeometry
* const geoms
[],
673 unsigned int ngeoms
);
674 extern GEOSGeometry GEOS_DLL
*GEOSPolygonize_full_r(GEOSContextHandle_t handle
,
675 const GEOSGeometry
* input
, GEOSGeometry
** cuts
,
676 GEOSGeometry
** dangles
, GEOSGeometry
** invalidRings
);
678 extern GEOSGeometry GEOS_DLL
*GEOSLineMerge_r(GEOSContextHandle_t handle
,
679 const GEOSGeometry
* g
);
680 extern GEOSGeometry GEOS_DLL
*GEOSSimplify_r(GEOSContextHandle_t handle
,
681 const GEOSGeometry
* g1
,
683 extern GEOSGeometry GEOS_DLL
*GEOSTopologyPreserveSimplify_r(
684 GEOSContextHandle_t handle
,
685 const GEOSGeometry
* g1
, double tolerance
);
688 * Return all distinct vertices of input geometry as a MULTIPOINT.
689 * Note that only 2 dimensions of the vertices are considered when
690 * testing for equality.
692 extern GEOSGeometry GEOS_DLL
*GEOSGeom_extractUniquePoints(
693 const GEOSGeometry
* g
);
694 extern GEOSGeometry GEOS_DLL
*GEOSGeom_extractUniquePoints_r(
695 GEOSContextHandle_t handle
,
696 const GEOSGeometry
* g
);
699 * Find paths shared between the two given lineal geometries.
701 * Returns a GEOMETRYCOLLECTION having two elements:
702 * - first element is a MULTILINESTRING containing shared paths
703 * having the _same_ direction on both inputs
704 * - second element is a MULTILINESTRING containing shared paths
705 * having the _opposite_ direction on the two inputs
707 * Returns NULL on exception
709 extern GEOSGeometry GEOS_DLL
*GEOSSharedPaths(const GEOSGeometry
* g1
,
710 const GEOSGeometry
* g2
);
711 extern GEOSGeometry GEOS_DLL
*GEOSSharedPaths_r(GEOSContextHandle_t handle
,
712 const GEOSGeometry
* g1
, const GEOSGeometry
* g2
);
715 * Snap first geometry on to second with given tolerance
716 * Returns a newly allocated geometry, or NULL on exception
718 extern GEOSGeometry GEOS_DLL
*GEOSSnap(const GEOSGeometry
* g1
,
719 const GEOSGeometry
* g2
, double tolerance
);
720 extern GEOSGeometry GEOS_DLL
*GEOSSnap_r(GEOSContextHandle_t handle
,
721 const GEOSGeometry
* g1
, const GEOSGeometry
* g2
, double tolerance
);
724 * Return a Delaunay triangulation of the vertex of the given geometry
726 * @param g the input geometry whose vertex will be used as "sites"
727 * @param tolerance optional snapping tolerance to use for improved robustness
728 * @param onlyEdges if non-zero will return a MULTILINESTRING, otherwise it will
729 * return a GEOMETRYCOLLECTION containing triangular POLYGONs.
731 * @return a newly allocated geometry, or NULL on exception
733 extern GEOSGeometry GEOS_DLL
* GEOSDelaunayTriangulation(
734 const GEOSGeometry
*g
,
738 extern GEOSGeometry GEOS_DLL
* GEOSDelaunayTriangulation_r(
739 GEOSContextHandle_t handle
,
740 const GEOSGeometry
*g
,
744 /************************************************************************
746 * Binary predicates - return 2 on exception, 1 on true, 0 on false
748 ***********************************************************************/
750 extern char GEOS_DLL
GEOSDisjoint(const GEOSGeometry
* g1
, const GEOSGeometry
* g2
);
751 extern char GEOS_DLL
GEOSTouches(const GEOSGeometry
* g1
, const GEOSGeometry
* g2
);
752 extern char GEOS_DLL
GEOSIntersects(const GEOSGeometry
* g1
, const GEOSGeometry
* g2
);
753 extern char GEOS_DLL
GEOSCrosses(const GEOSGeometry
* g1
, const GEOSGeometry
* g2
);
754 extern char GEOS_DLL
GEOSWithin(const GEOSGeometry
* g1
, const GEOSGeometry
* g2
);
755 extern char GEOS_DLL
GEOSContains(const GEOSGeometry
* g1
, const GEOSGeometry
* g2
);
756 extern char GEOS_DLL
GEOSOverlaps(const GEOSGeometry
* g1
, const GEOSGeometry
* g2
);
757 extern char GEOS_DLL
GEOSEquals(const GEOSGeometry
* g1
, const GEOSGeometry
* g2
);
758 extern char GEOS_DLL
GEOSEqualsExact(const GEOSGeometry
* g1
, const GEOSGeometry
* g2
, double tolerance
);
759 extern char GEOS_DLL
GEOSCovers(const GEOSGeometry
* g1
, const GEOSGeometry
* g2
);
760 extern char GEOS_DLL
GEOSCoveredBy(const GEOSGeometry
* g1
, const GEOSGeometry
* g2
);
762 extern char GEOS_DLL
GEOSDisjoint_r(GEOSContextHandle_t handle
,
763 const GEOSGeometry
* g1
,
764 const GEOSGeometry
* g2
);
765 extern char GEOS_DLL
GEOSTouches_r(GEOSContextHandle_t handle
,
766 const GEOSGeometry
* g1
,
767 const GEOSGeometry
* g2
);
768 extern char GEOS_DLL
GEOSIntersects_r(GEOSContextHandle_t handle
,
769 const GEOSGeometry
* g1
,
770 const GEOSGeometry
* g2
);
771 extern char GEOS_DLL
GEOSCrosses_r(GEOSContextHandle_t handle
,
772 const GEOSGeometry
* g1
,
773 const GEOSGeometry
* g2
);
774 extern char GEOS_DLL
GEOSWithin_r(GEOSContextHandle_t handle
,
775 const GEOSGeometry
* g1
,
776 const GEOSGeometry
* g2
);
777 extern char GEOS_DLL
GEOSContains_r(GEOSContextHandle_t handle
,
778 const GEOSGeometry
* g1
,
779 const GEOSGeometry
* g2
);
780 extern char GEOS_DLL
GEOSOverlaps_r(GEOSContextHandle_t handle
,
781 const GEOSGeometry
* g1
,
782 const GEOSGeometry
* g2
);
783 extern char GEOS_DLL
GEOSEquals_r(GEOSContextHandle_t handle
,
784 const GEOSGeometry
* g1
,
785 const GEOSGeometry
* g2
);
786 extern char GEOS_DLL
GEOSEqualsExact_r(GEOSContextHandle_t handle
,
787 const GEOSGeometry
* g1
,
788 const GEOSGeometry
* g2
,
790 extern char GEOS_DLL
GEOSCovers_r(GEOSContextHandle_t handle
,
791 const GEOSGeometry
* g1
,
792 const GEOSGeometry
* g2
);
793 extern char GEOS_DLL
GEOSCoveredBy_r(GEOSContextHandle_t handle
,
794 const GEOSGeometry
* g1
,
795 const GEOSGeometry
* g2
);
797 /************************************************************************
799 * Prepared Geometry Binary predicates - return 2 on exception, 1 on true, 0 on false
801 ***********************************************************************/
804 * GEOSGeometry ownership is retained by caller
806 extern const GEOSPreparedGeometry GEOS_DLL
*GEOSPrepare(const GEOSGeometry
* g
);
808 extern void GEOS_DLL
GEOSPreparedGeom_destroy(const GEOSPreparedGeometry
* g
);
810 extern char GEOS_DLL
GEOSPreparedContains(const GEOSPreparedGeometry
* pg1
, const GEOSGeometry
* g2
);
811 extern char GEOS_DLL
GEOSPreparedContainsProperly(const GEOSPreparedGeometry
* pg1
, const GEOSGeometry
* g2
);
812 extern char GEOS_DLL
GEOSPreparedCoveredBy(const GEOSPreparedGeometry
* pg1
, const GEOSGeometry
* g2
);
813 extern char GEOS_DLL
GEOSPreparedCovers(const GEOSPreparedGeometry
* pg1
, const GEOSGeometry
* g2
);
814 extern char GEOS_DLL
GEOSPreparedCrosses(const GEOSPreparedGeometry
* pg1
, const GEOSGeometry
* g2
);
815 extern char GEOS_DLL
GEOSPreparedDisjoint(const GEOSPreparedGeometry
* pg1
, const GEOSGeometry
* g2
);
816 extern char GEOS_DLL
GEOSPreparedIntersects(const GEOSPreparedGeometry
* pg1
, const GEOSGeometry
* g2
);
817 extern char GEOS_DLL
GEOSPreparedOverlaps(const GEOSPreparedGeometry
* pg1
, const GEOSGeometry
* g2
);
818 extern char GEOS_DLL
GEOSPreparedTouches(const GEOSPreparedGeometry
* pg1
, const GEOSGeometry
* g2
);
819 extern char GEOS_DLL
GEOSPreparedWithin(const GEOSPreparedGeometry
* pg1
, const GEOSGeometry
* g2
);
822 * GEOSGeometry ownership is retained by caller
824 extern const GEOSPreparedGeometry GEOS_DLL
*GEOSPrepare_r(
825 GEOSContextHandle_t handle
,
826 const GEOSGeometry
* g
);
828 extern void GEOS_DLL
GEOSPreparedGeom_destroy_r(GEOSContextHandle_t handle
,
829 const GEOSPreparedGeometry
* g
);
831 extern char GEOS_DLL
GEOSPreparedContains_r(GEOSContextHandle_t handle
,
832 const GEOSPreparedGeometry
* pg1
,
833 const GEOSGeometry
* g2
);
834 extern char GEOS_DLL
GEOSPreparedContainsProperly_r(GEOSContextHandle_t handle
,
835 const GEOSPreparedGeometry
* pg1
,
836 const GEOSGeometry
* g2
);
837 extern char GEOS_DLL
GEOSPreparedCoveredBy_r(GEOSContextHandle_t handle
,
838 const GEOSPreparedGeometry
* pg1
,
839 const GEOSGeometry
* g2
);
840 extern char GEOS_DLL
GEOSPreparedCovers_r(GEOSContextHandle_t handle
,
841 const GEOSPreparedGeometry
* pg1
,
842 const GEOSGeometry
* g2
);
843 extern char GEOS_DLL
GEOSPreparedCrosses_r(GEOSContextHandle_t handle
,
844 const GEOSPreparedGeometry
* pg1
,
845 const GEOSGeometry
* g2
);
846 extern char GEOS_DLL
GEOSPreparedDisjoint_r(GEOSContextHandle_t handle
,
847 const GEOSPreparedGeometry
* pg1
,
848 const GEOSGeometry
* g2
);
849 extern char GEOS_DLL
GEOSPreparedIntersects_r(GEOSContextHandle_t handle
,
850 const GEOSPreparedGeometry
* pg1
,
851 const GEOSGeometry
* g2
);
852 extern char GEOS_DLL
GEOSPreparedOverlaps_r(GEOSContextHandle_t handle
,
853 const GEOSPreparedGeometry
* pg1
,
854 const GEOSGeometry
* g2
);
855 extern char GEOS_DLL
GEOSPreparedTouches_r(GEOSContextHandle_t handle
,
856 const GEOSPreparedGeometry
* pg1
,
857 const GEOSGeometry
* g2
);
858 extern char GEOS_DLL
GEOSPreparedWithin_r(GEOSContextHandle_t handle
,
859 const GEOSPreparedGeometry
* pg1
,
860 const GEOSGeometry
* g2
);
862 /************************************************************************
866 ***********************************************************************/
869 * GEOSGeometry ownership is retained by caller
872 extern GEOSSTRtree GEOS_DLL
*GEOSSTRtree_create(size_t nodeCapacity
);
873 extern void GEOS_DLL
GEOSSTRtree_insert(GEOSSTRtree
*tree
,
874 const GEOSGeometry
*g
,
876 extern void GEOS_DLL
GEOSSTRtree_query(GEOSSTRtree
*tree
,
877 const GEOSGeometry
*g
,
878 GEOSQueryCallback callback
,
880 extern void GEOS_DLL
GEOSSTRtree_iterate(GEOSSTRtree
*tree
,
881 GEOSQueryCallback callback
,
883 extern char GEOS_DLL
GEOSSTRtree_remove(GEOSSTRtree
*tree
,
884 const GEOSGeometry
*g
,
886 extern void GEOS_DLL
GEOSSTRtree_destroy(GEOSSTRtree
*tree
);
889 extern GEOSSTRtree GEOS_DLL
*GEOSSTRtree_create_r(
890 GEOSContextHandle_t handle
,
891 size_t nodeCapacity
);
892 extern void GEOS_DLL
GEOSSTRtree_insert_r(GEOSContextHandle_t handle
,
894 const GEOSGeometry
*g
,
896 extern void GEOS_DLL
GEOSSTRtree_query_r(GEOSContextHandle_t handle
,
898 const GEOSGeometry
*g
,
899 GEOSQueryCallback callback
,
901 extern void GEOS_DLL
GEOSSTRtree_iterate_r(GEOSContextHandle_t handle
,
903 GEOSQueryCallback callback
,
905 extern char GEOS_DLL
GEOSSTRtree_remove_r(GEOSContextHandle_t handle
,
907 const GEOSGeometry
*g
,
909 extern void GEOS_DLL
GEOSSTRtree_destroy_r(GEOSContextHandle_t handle
,
913 /************************************************************************
915 * Unary predicate - return 2 on exception, 1 on true, 0 on false
917 ***********************************************************************/
919 extern char GEOS_DLL
GEOSisEmpty(const GEOSGeometry
* g1
);
920 extern char GEOS_DLL
GEOSisSimple(const GEOSGeometry
* g1
);
921 extern char GEOS_DLL
GEOSisRing(const GEOSGeometry
* g1
);
922 extern char GEOS_DLL
GEOSHasZ(const GEOSGeometry
* g1
);
923 extern char GEOS_DLL
GEOSisClosed(const GEOSGeometry
*g1
);
925 extern char GEOS_DLL
GEOSisEmpty_r(GEOSContextHandle_t handle
,
926 const GEOSGeometry
* g1
);
927 extern char GEOS_DLL
GEOSisSimple_r(GEOSContextHandle_t handle
,
928 const GEOSGeometry
* g1
);
929 extern char GEOS_DLL
GEOSisRing_r(GEOSContextHandle_t handle
,
930 const GEOSGeometry
* g1
);
931 extern char GEOS_DLL
GEOSHasZ_r(GEOSContextHandle_t handle
,
932 const GEOSGeometry
* g1
);
933 extern char GEOS_DLL
GEOSisClosed_r(GEOSContextHandle_t handle
,
934 const GEOSGeometry
*g1
);
936 /************************************************************************
938 * Dimensionally Extended 9 Intersection Model related
940 ***********************************************************************/
942 /* These are for use with GEOSRelateBoundaryNodeRule (flags param) */
943 enum GEOSRelateBoundaryNodeRules
{
944 /* MOD2 and OGC are the same rule, and is the default
945 * used by GEOSRelatePattern
947 GEOSRELATE_BNR_MOD2
=1,
948 GEOSRELATE_BNR_OGC
=1,
949 GEOSRELATE_BNR_ENDPOINT
=2,
950 GEOSRELATE_BNR_MULTIVALENT_ENDPOINT
=3,
951 GEOSRELATE_BNR_MONOVALENT_ENDPOINT
=4
954 /* return 2 on exception, 1 on true, 0 on false */
955 extern char GEOS_DLL
GEOSRelatePattern(const GEOSGeometry
* g1
, const GEOSGeometry
* g2
, const char *pat
);
956 extern char GEOS_DLL
GEOSRelatePattern_r(GEOSContextHandle_t handle
,
957 const GEOSGeometry
* g1
,
958 const GEOSGeometry
* g2
,
961 /* return NULL on exception, a string to GEOSFree otherwise */
962 extern char GEOS_DLL
*GEOSRelate(const GEOSGeometry
* g1
, const GEOSGeometry
* g2
);
963 extern char GEOS_DLL
*GEOSRelate_r(GEOSContextHandle_t handle
,
964 const GEOSGeometry
* g1
,
965 const GEOSGeometry
* g2
);
967 /* return 2 on exception, 1 on true, 0 on false */
968 extern char GEOS_DLL
GEOSRelatePatternMatch(const char* mat
, const char *pat
);
969 extern char GEOS_DLL
GEOSRelatePatternMatch_r(GEOSContextHandle_t handle
,
973 /* return NULL on exception, a string to GEOSFree otherwise */
974 extern char GEOS_DLL
*GEOSRelateBoundaryNodeRule(const GEOSGeometry
* g1
,
975 const GEOSGeometry
* g2
,
977 extern char GEOS_DLL
*GEOSRelateBoundaryNodeRule_r(GEOSContextHandle_t handle
,
978 const GEOSGeometry
* g1
,
979 const GEOSGeometry
* g2
,
982 /************************************************************************
986 ***********************************************************************/
988 /* These are for use with GEOSisValidDetail (flags param) */
989 enum GEOSValidFlags
{
990 GEOSVALID_ALLOW_SELFTOUCHING_RING_FORMING_HOLE
=1
993 /* return 2 on exception, 1 on true, 0 on false */
994 extern char GEOS_DLL
GEOSisValid(const GEOSGeometry
* g1
);
995 extern char GEOS_DLL
GEOSisValid_r(GEOSContextHandle_t handle
,
996 const GEOSGeometry
* g1
);
998 /* return NULL on exception, a string to GEOSFree otherwise */
999 extern char GEOS_DLL
*GEOSisValidReason(const GEOSGeometry
*g1
);
1000 extern char GEOS_DLL
*GEOSisValidReason_r(GEOSContextHandle_t handle
,
1001 const GEOSGeometry
* g1
);
1004 * Caller has the responsibility to destroy 'reason' (GEOSFree)
1005 * and 'location' (GEOSGeom_destroy) params
1006 * return 2 on exception, 1 when valid, 0 when invalid
1008 extern char GEOS_DLL
GEOSisValidDetail(const GEOSGeometry
* g
,
1010 char** reason
, GEOSGeometry
** location
);
1011 extern char GEOS_DLL
GEOSisValidDetail_r(GEOSContextHandle_t handle
,
1012 const GEOSGeometry
* g
,
1015 GEOSGeometry
** location
);
1017 /************************************************************************
1021 ***********************************************************************/
1023 /* Return NULL on exception, result must be freed by caller. */
1024 extern char GEOS_DLL
*GEOSGeomType(const GEOSGeometry
* g1
);
1026 extern char GEOS_DLL
*GEOSGeomType_r(GEOSContextHandle_t handle
,
1027 const GEOSGeometry
* g1
);
1029 /* Return -1 on exception */
1030 extern int GEOS_DLL
GEOSGeomTypeId(const GEOSGeometry
* g1
);
1032 extern int GEOS_DLL
GEOSGeomTypeId_r(GEOSContextHandle_t handle
,
1033 const GEOSGeometry
* g1
);
1035 /* Return 0 on exception */
1036 extern int GEOS_DLL
GEOSGetSRID(const GEOSGeometry
* g
);
1037 extern int GEOS_DLL
GEOSGetSRID_r(GEOSContextHandle_t handle
,
1038 const GEOSGeometry
* g
);
1040 extern void GEOS_DLL
GEOSSetSRID(GEOSGeometry
* g
, int SRID
);
1041 extern void GEOS_DLL
GEOSSetSRID_r(GEOSContextHandle_t handle
,
1042 GEOSGeometry
* g
, int SRID
);
1044 /* May be called on all geometries in GEOS 3.x, returns -1 on error and 1
1045 * for non-multi geometries. Older GEOS versions only accept
1046 * GeometryCollections or Multi* geometries here, and are likely to crash
1047 * when feeded simple geometries, so beware if you need compatibility with
1048 * old GEOS versions.
1050 extern int GEOS_DLL
GEOSGetNumGeometries(const GEOSGeometry
* g
);
1052 extern int GEOS_DLL
GEOSGetNumGeometries_r(GEOSContextHandle_t handle
,
1053 const GEOSGeometry
* g
);
1056 * Return NULL on exception.
1057 * Returned object is a pointer to internal storage:
1058 * it must NOT be destroyed directly.
1059 * Up to GEOS 3.2.0 the input geometry must be a Collection, in
1060 * later version it doesn't matter (getGeometryN(0) for a single will
1061 * return the input).
1063 extern const GEOSGeometry GEOS_DLL
*GEOSGetGeometryN(const GEOSGeometry
* g
, int n
);
1065 extern const GEOSGeometry GEOS_DLL
*GEOSGetGeometryN_r(
1066 GEOSContextHandle_t handle
,
1067 const GEOSGeometry
* g
, int n
);
1069 /* Return -1 on exception */
1070 extern int GEOS_DLL
GEOSNormalize(GEOSGeometry
* g1
);
1072 extern int GEOS_DLL
GEOSNormalize_r(GEOSContextHandle_t handle
,
1075 /* Return -1 on exception */
1076 extern int GEOS_DLL
GEOSGetNumInteriorRings(const GEOSGeometry
* g1
);
1078 extern int GEOS_DLL
GEOSGetNumInteriorRings_r(GEOSContextHandle_t handle
,
1079 const GEOSGeometry
* g1
);
1081 /* Return -1 on exception, Geometry must be a LineString. */
1082 extern int GEOS_DLL
GEOSGeomGetNumPoints(const GEOSGeometry
* g1
);
1084 extern int GEOS_DLL
GEOSGeomGetNumPoints_r(GEOSContextHandle_t handle
,
1085 const GEOSGeometry
* g1
);
1087 /* Return -1 on exception, Geometry must be a Point. */
1088 extern int GEOS_DLL
GEOSGeomGetX(const GEOSGeometry
*g1
, double *x
);
1089 extern int GEOS_DLL
GEOSGeomGetY(const GEOSGeometry
*g1
, double *y
);
1091 extern int GEOS_DLL
GEOSGeomGetX_r(GEOSContextHandle_t handle
, const GEOSGeometry
*g1
, double *x
);
1092 extern int GEOS_DLL
GEOSGeomGetY_r(GEOSContextHandle_t handle
, const GEOSGeometry
*g1
, double *y
);
1095 * Return NULL on exception, Geometry must be a Polygon.
1096 * Returned object is a pointer to internal storage:
1097 * it must NOT be destroyed directly.
1099 extern const GEOSGeometry GEOS_DLL
*GEOSGetInteriorRingN(const GEOSGeometry
* g
, int n
);
1101 extern const GEOSGeometry GEOS_DLL
*GEOSGetInteriorRingN_r(
1102 GEOSContextHandle_t handle
,
1103 const GEOSGeometry
* g
, int n
);
1106 * Return NULL on exception, Geometry must be a Polygon.
1107 * Returned object is a pointer to internal storage:
1108 * it must NOT be destroyed directly.
1110 extern const GEOSGeometry GEOS_DLL
*GEOSGetExteriorRing(const GEOSGeometry
* g
);
1112 extern const GEOSGeometry GEOS_DLL
*GEOSGetExteriorRing_r(
1113 GEOSContextHandle_t handle
,
1114 const GEOSGeometry
* g
);
1116 /* Return -1 on exception */
1117 extern int GEOS_DLL
GEOSGetNumCoordinates(const GEOSGeometry
* g1
);
1119 extern int GEOS_DLL
GEOSGetNumCoordinates_r(GEOSContextHandle_t handle
,
1120 const GEOSGeometry
* g1
);
1123 * Return NULL on exception.
1124 * Geometry must be a LineString, LinearRing or Point.
1126 extern const GEOSCoordSequence GEOS_DLL
*GEOSGeom_getCoordSeq(const GEOSGeometry
* g
);
1128 extern const GEOSCoordSequence GEOS_DLL
*GEOSGeom_getCoordSeq_r(
1129 GEOSContextHandle_t handle
,
1130 const GEOSGeometry
* g
);
1133 * Return 0 on exception (or empty geometry)
1135 extern int GEOS_DLL
GEOSGeom_getDimensions(const GEOSGeometry
* g
);
1137 extern int GEOS_DLL
GEOSGeom_getDimensions_r(GEOSContextHandle_t handle
,
1138 const GEOSGeometry
* g
);
1143 extern int GEOS_DLL
GEOSGeom_getCoordinateDimension(const GEOSGeometry
* g
);
1145 extern int GEOS_DLL
GEOSGeom_getCoordinateDimension_r(GEOSContextHandle_t handle
,
1146 const GEOSGeometry
* g
);
1149 * Return NULL on exception.
1150 * Must be LineString and must be freed by called.
1152 extern GEOSGeometry GEOS_DLL
*GEOSGeomGetPointN(const GEOSGeometry
*g1
, int n
);
1153 extern GEOSGeometry GEOS_DLL
*GEOSGeomGetStartPoint(const GEOSGeometry
*g1
);
1154 extern GEOSGeometry GEOS_DLL
*GEOSGeomGetEndPoint(const GEOSGeometry
*g1
);
1156 extern GEOSGeometry GEOS_DLL
*GEOSGeomGetPointN_r(GEOSContextHandle_t handle
, const GEOSGeometry
*g1
, int n
);
1157 extern GEOSGeometry GEOS_DLL
*GEOSGeomGetStartPoint_r(GEOSContextHandle_t handle
, const GEOSGeometry
*g1
);
1158 extern GEOSGeometry GEOS_DLL
*GEOSGeomGetEndPoint_r(GEOSContextHandle_t handle
, const GEOSGeometry
*g1
);
1160 /************************************************************************
1164 ***********************************************************************/
1166 /* Return 0 on exception, 1 otherwise */
1167 extern int GEOS_DLL
GEOSArea(const GEOSGeometry
* g1
, double *area
);
1168 extern int GEOS_DLL
GEOSLength(const GEOSGeometry
* g1
, double *length
);
1169 extern int GEOS_DLL
GEOSDistance(const GEOSGeometry
* g1
, const GEOSGeometry
* g2
,
1171 extern int GEOS_DLL
GEOSHausdorffDistance(const GEOSGeometry
*g1
,
1172 const GEOSGeometry
*g2
, double *dist
);
1173 extern int GEOS_DLL
GEOSHausdorffDistanceDensify(const GEOSGeometry
*g1
,
1174 const GEOSGeometry
*g2
, double densifyFrac
, double *dist
);
1175 extern int GEOS_DLL
GEOSGeomGetLength(const GEOSGeometry
*g1
, double *length
);
1176 extern int GEOS_DLL
GEOSArea_r(GEOSContextHandle_t handle
,
1177 const GEOSGeometry
* g1
, double *area
);
1178 extern int GEOS_DLL
GEOSLength_r(GEOSContextHandle_t handle
,
1179 const GEOSGeometry
* g1
, double *length
);
1180 extern int GEOS_DLL
GEOSDistance_r(GEOSContextHandle_t handle
,
1181 const GEOSGeometry
* g1
,
1182 const GEOSGeometry
* g2
, double *dist
);
1183 extern int GEOS_DLL
GEOSHausdorffDistance_r(GEOSContextHandle_t handle
,
1184 const GEOSGeometry
*g1
,
1185 const GEOSGeometry
*g2
,
1187 extern int GEOS_DLL
GEOSHausdorffDistanceDensify_r(GEOSContextHandle_t handle
,
1188 const GEOSGeometry
*g1
,
1189 const GEOSGeometry
*g2
,
1190 double densifyFrac
, double *dist
);
1191 extern int GEOS_DLL
GEOSGeomGetLength_r(GEOSContextHandle_t handle
,
1192 const GEOSGeometry
*g1
, double *length
);
1194 /************************************************************************
1198 ***********************************************************************/
1200 /* Walking from A to B:
1201 * return -1 if reaching P takes a counter-clockwise (left) turn
1202 * return 1 if reaching P takes a clockwise (right) turn
1203 * return 0 if P is collinear with A-B
1205 * On exceptions, return 2.
1208 extern int GEOS_DLL
GEOSOrientationIndex(double Ax
, double Ay
, double Bx
, double By
,
1209 double Px
, double Py
);
1210 extern int GEOS_DLL
GEOSOrientationIndex_r(GEOSContextHandle_t handle
,
1211 double Ax
, double Ay
, double Bx
, double By
, double Px
, double Py
);
1214 /************************************************************************
1216 * Reader and Writer APIs
1218 ***********************************************************************/
1220 typedef struct GEOSWKTReader_t GEOSWKTReader
;
1221 typedef struct GEOSWKTWriter_t GEOSWKTWriter
;
1222 typedef struct GEOSWKBReader_t GEOSWKBReader
;
1223 typedef struct GEOSWKBWriter_t GEOSWKBWriter
;
1227 extern GEOSWKTReader GEOS_DLL
*GEOSWKTReader_create();
1228 extern void GEOS_DLL
GEOSWKTReader_destroy(GEOSWKTReader
* reader
);
1229 extern GEOSGeometry GEOS_DLL
*GEOSWKTReader_read(GEOSWKTReader
* reader
, const char *wkt
);
1231 extern GEOSWKTReader GEOS_DLL
*GEOSWKTReader_create_r(
1232 GEOSContextHandle_t handle
);
1233 extern void GEOS_DLL
GEOSWKTReader_destroy_r(GEOSContextHandle_t handle
,
1234 GEOSWKTReader
* reader
);
1235 extern GEOSGeometry GEOS_DLL
*GEOSWKTReader_read_r(GEOSContextHandle_t handle
,
1236 GEOSWKTReader
* reader
,
1240 extern GEOSWKTWriter GEOS_DLL
*GEOSWKTWriter_create();
1241 extern void GEOS_DLL
GEOSWKTWriter_destroy(GEOSWKTWriter
* writer
);
1242 extern char GEOS_DLL
*GEOSWKTWriter_write(GEOSWKTWriter
* reader
, const GEOSGeometry
* g
);
1243 extern void GEOS_DLL
GEOSWKTWriter_setTrim(GEOSWKTWriter
*writer
, char trim
);
1244 extern void GEOS_DLL
GEOSWKTWriter_setRoundingPrecision(GEOSWKTWriter
*writer
, int precision
);
1245 extern void GEOS_DLL
GEOSWKTWriter_setOutputDimension(GEOSWKTWriter
*writer
, int dim
);
1246 extern int GEOS_DLL
GEOSWKTWriter_getOutputDimension(GEOSWKTWriter
*writer
);
1247 extern void GEOS_DLL
GEOSWKTWriter_setOld3D(GEOSWKTWriter
*writer
, int useOld3D
);
1249 extern GEOSWKTWriter GEOS_DLL
*GEOSWKTWriter_create_r(
1250 GEOSContextHandle_t handle
);
1251 extern void GEOS_DLL
GEOSWKTWriter_destroy_r(GEOSContextHandle_t handle
,
1252 GEOSWKTWriter
* writer
);
1253 extern char GEOS_DLL
*GEOSWKTWriter_write_r(GEOSContextHandle_t handle
,
1254 GEOSWKTWriter
* reader
,
1255 const GEOSGeometry
* g
);
1256 extern void GEOS_DLL
GEOSWKTWriter_setTrim_r(GEOSContextHandle_t handle
,
1257 GEOSWKTWriter
*writer
,
1259 extern void GEOS_DLL
GEOSWKTWriter_setRoundingPrecision_r(GEOSContextHandle_t handle
,
1260 GEOSWKTWriter
*writer
,
1262 extern void GEOS_DLL
GEOSWKTWriter_setOutputDimension_r(GEOSContextHandle_t handle
,
1263 GEOSWKTWriter
*writer
,
1265 extern int GEOS_DLL
GEOSWKTWriter_getOutputDimension_r(GEOSContextHandle_t handle
,
1266 GEOSWKTWriter
*writer
);
1267 extern void GEOS_DLL
GEOSWKTWriter_setOld3D_r(GEOSContextHandle_t handle
,
1268 GEOSWKTWriter
*writer
,
1272 extern GEOSWKBReader GEOS_DLL
*GEOSWKBReader_create();
1273 extern void GEOS_DLL
GEOSWKBReader_destroy(GEOSWKBReader
* reader
);
1274 extern GEOSGeometry GEOS_DLL
*GEOSWKBReader_read(GEOSWKBReader
* reader
, const unsigned char *wkb
, size_t size
);
1275 extern GEOSGeometry GEOS_DLL
*GEOSWKBReader_readHEX(GEOSWKBReader
* reader
, const unsigned char *hex
, size_t size
);
1277 extern GEOSWKBReader GEOS_DLL
*GEOSWKBReader_create_r(
1278 GEOSContextHandle_t handle
);
1279 extern void GEOS_DLL
GEOSWKBReader_destroy_r(GEOSContextHandle_t handle
,
1280 GEOSWKBReader
* reader
);
1281 extern GEOSGeometry GEOS_DLL
*GEOSWKBReader_read_r(GEOSContextHandle_t handle
,
1282 GEOSWKBReader
* reader
,
1283 const unsigned char *wkb
,
1285 extern GEOSGeometry GEOS_DLL
*GEOSWKBReader_readHEX_r(
1286 GEOSContextHandle_t handle
,
1287 GEOSWKBReader
* reader
,
1288 const unsigned char *hex
,
1292 extern GEOSWKBWriter GEOS_DLL
*GEOSWKBWriter_create();
1293 extern void GEOS_DLL
GEOSWKBWriter_destroy(GEOSWKBWriter
* writer
);
1295 extern GEOSWKBWriter GEOS_DLL
*GEOSWKBWriter_create_r(
1296 GEOSContextHandle_t handle
);
1297 extern void GEOS_DLL
GEOSWKBWriter_destroy_r(GEOSContextHandle_t handle
,
1298 GEOSWKBWriter
* writer
);
1300 /* The caller owns the results for these two methods! */
1301 extern unsigned char GEOS_DLL
*GEOSWKBWriter_write(GEOSWKBWriter
* writer
, const GEOSGeometry
* g
, size_t *size
);
1302 extern unsigned char GEOS_DLL
*GEOSWKBWriter_writeHEX(GEOSWKBWriter
* writer
, const GEOSGeometry
* g
, size_t *size
);
1304 extern unsigned char GEOS_DLL
*GEOSWKBWriter_write_r(
1305 GEOSContextHandle_t handle
,
1306 GEOSWKBWriter
* writer
,
1307 const GEOSGeometry
* g
,
1309 extern unsigned char GEOS_DLL
*GEOSWKBWriter_writeHEX_r(
1310 GEOSContextHandle_t handle
,
1311 GEOSWKBWriter
* writer
,
1312 const GEOSGeometry
* g
,
1316 * Specify whether output WKB should be 2d or 3d.
1317 * Return previously set number of dimensions.
1319 extern int GEOS_DLL
GEOSWKBWriter_getOutputDimension(const GEOSWKBWriter
* writer
);
1320 extern void GEOS_DLL
GEOSWKBWriter_setOutputDimension(GEOSWKBWriter
* writer
, int newDimension
);
1322 extern int GEOS_DLL
GEOSWKBWriter_getOutputDimension_r(
1323 GEOSContextHandle_t handle
,
1324 const GEOSWKBWriter
* writer
);
1325 extern void GEOS_DLL
GEOSWKBWriter_setOutputDimension_r(
1326 GEOSContextHandle_t handle
,
1327 GEOSWKBWriter
* writer
, int newDimension
);
1330 * Specify whether the WKB byte order is big or little endian.
1331 * The return value is the previous byte order.
1333 extern int GEOS_DLL
GEOSWKBWriter_getByteOrder(const GEOSWKBWriter
* writer
);
1334 extern void GEOS_DLL
GEOSWKBWriter_setByteOrder(GEOSWKBWriter
* writer
, int byteOrder
);
1336 extern int GEOS_DLL
GEOSWKBWriter_getByteOrder_r(GEOSContextHandle_t handle
,
1337 const GEOSWKBWriter
* writer
);
1338 extern void GEOS_DLL
GEOSWKBWriter_setByteOrder_r(GEOSContextHandle_t handle
,
1339 GEOSWKBWriter
* writer
,
1343 * Specify whether SRID values should be output.
1345 extern char GEOS_DLL
GEOSWKBWriter_getIncludeSRID(const GEOSWKBWriter
* writer
);
1346 extern void GEOS_DLL
GEOSWKBWriter_setIncludeSRID(GEOSWKBWriter
* writer
, const char writeSRID
);
1348 extern char GEOS_DLL
GEOSWKBWriter_getIncludeSRID_r(GEOSContextHandle_t handle
,
1349 const GEOSWKBWriter
* writer
);
1350 extern void GEOS_DLL
GEOSWKBWriter_setIncludeSRID_r(GEOSContextHandle_t handle
,
1351 GEOSWKBWriter
* writer
, const char writeSRID
);
1355 * Free buffers returned by stuff like GEOSWKBWriter_write(),
1356 * GEOSWKBWriter_writeHEX() and GEOSWKTWriter_write().
1358 extern void GEOS_DLL
GEOSFree( void *buffer
);
1359 extern void GEOS_DLL
GEOSFree_r( GEOSContextHandle_t handle
, void *buffer
);
1365 #endif /* #ifndef GEOS_C_H_INCLUDED */