HotPixel: do not invalidate reference to original point. Fixes #498.
[geos.git] / capi / geos_c.h.in
blob05b8376f241f31b6efee75328a5b18c978fa0998
1 /************************************************************************
3 * $Id$
5 * C-Wrapper for GEOS library
7 * Copyright (C) 2010 2011 Sandro Santilli <strk@keybit.net>
8 * Copyright (C) 2005 Refractions Research Inc.
10 * This is free software; you can redistribute and/or modify it under
11 * the terms of the GNU Lesser General Public Licence as published
12 * by the Free Software Foundation.
13 * See the COPYING file for more information.
15 * Author: Sandro Santilli <strk@refractions.net>
17 ***********************************************************************
19 * GENERAL NOTES:
21 * - Remember to call initGEOS() before any use of this library's
22 * functions, and call finishGEOS() when done.
24 * - Currently you have to explicitly GEOSGeom_destroy() all
25 * GEOSGeom objects to avoid memory leaks, and to GEOSFree()
26 * all returned char * (unless const).
28 ***********************************************************************/
30 #ifndef GEOS_C_H_INCLUDED
31 #define GEOS_C_H_INCLUDED
33 #ifndef __cplusplus
34 # include <stddef.h> /* for size_t definition */
35 #else
36 # include <cstddef>
37 using std::size_t;
38 #endif
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
44 /************************************************************************
46 * Version
48 ***********************************************************************/
51 * Following 'ifdef' hack fixes problem with generating geos_c.h on Windows,
52 * when building with Visual C++ compiler.
55 #if defined(_MSC_VER)
56 #include <geos/version.h>
57 #define GEOS_CAPI_VERSION_MAJOR 1
58 #define GEOS_CAPI_VERSION_MINOR 6
59 #define GEOS_CAPI_VERSION_PATCH 1
60 #define GEOS_CAPI_VERSION "3.3.0-CAPI-1.7.0"
61 #else
62 #ifndef GEOS_VERSION_MAJOR
63 #define GEOS_VERSION_MAJOR @VERSION_MAJOR@
64 #endif
65 #ifndef GEOS_VERSION_MINOR
66 #define GEOS_VERSION_MINOR @VERSION_MINOR@
67 #endif
68 #ifndef GEOS_VERSION_PATCH
69 #define GEOS_VERSION_PATCH @VERSION_PATCH@
70 #endif
71 #ifndef GEOS_VERSION
72 #define GEOS_VERSION "@VERSION@"
73 #endif
74 #ifndef GEOS_JTS_PORT
75 #define GEOS_JTS_PORT "@JTS_PORT@"
76 #endif
78 #define GEOS_CAPI_VERSION_MAJOR @CAPI_VERSION_MAJOR@
79 #define GEOS_CAPI_VERSION_MINOR @CAPI_VERSION_MINOR@
80 #define GEOS_CAPI_VERSION_PATCH @CAPI_VERSION_PATCH@
81 #define GEOS_CAPI_VERSION "@VERSION@-CAPI-@CAPI_VERSION@"
82 #endif
84 #define GEOS_CAPI_FIRST_INTERFACE GEOS_CAPI_VERSION_MAJOR
85 #define GEOS_CAPI_LAST_INTERFACE (GEOS_CAPI_VERSION_MAJOR+GEOS_CAPI_VERSION_MINOR)
87 /************************************************************************
89 * (Abstract) type definitions
91 ************************************************************************/
93 typedef void (*GEOSMessageHandler)(const char *fmt, ...);
95 /* When we're included by geos_c.cpp, those are #defined to the original
96 * JTS definitions via preprocessor. We don't touch them to allow the
97 * compiler to cross-check the declarations. However, for all "normal"
98 * C-API users, we need to define them as "opaque" struct pointers, as
99 * those clients don't have access to the original C++ headers, by design.
101 #ifndef GEOSGeometry
102 typedef struct GEOSGeom_t GEOSGeometry;
103 typedef struct GEOSPrepGeom_t GEOSPreparedGeometry;
104 typedef struct GEOSCoordSeq_t GEOSCoordSequence;
105 typedef struct GEOSSTRtree_t GEOSSTRtree;
106 typedef struct GEOSBufParams_t GEOSBufferParams;
107 #endif
109 /* Those are compatibility definitions for source compatibility
110 * with GEOS 2.X clients relying on that type.
112 typedef GEOSGeometry* GEOSGeom;
113 typedef GEOSCoordSequence* GEOSCoordSeq;
115 /* Supported geometry types
116 * This was renamed from GEOSGeomTypeId in GEOS 2.2.X, which might
117 * break compatibility, this issue is still under investigation.
120 enum GEOSGeomTypes {
121 GEOS_POINT,
122 GEOS_LINESTRING,
123 GEOS_LINEARRING,
124 GEOS_POLYGON,
125 GEOS_MULTIPOINT,
126 GEOS_MULTILINESTRING,
127 GEOS_MULTIPOLYGON,
128 GEOS_GEOMETRYCOLLECTION
131 /* Byte oders exposed via the c api */
132 enum GEOSByteOrders {
133 GEOS_WKB_XDR = 0, /* Big Endian */
134 GEOS_WKB_NDR = 1 /* Little Endian */
137 typedef struct GEOSContextHandle_HS *GEOSContextHandle_t;
139 typedef void (*GEOSQueryCallback)(void *item, void *userdata);
141 /************************************************************************
143 * Initialization, cleanup, version
145 ***********************************************************************/
147 #include <geos/export.h>
149 extern void GEOS_DLL initGEOS(GEOSMessageHandler notice_function,
150 GEOSMessageHandler error_function);
151 extern void GEOS_DLL finishGEOS(void);
153 extern GEOSContextHandle_t GEOS_DLL initGEOS_r(
154 GEOSMessageHandler notice_function,
155 GEOSMessageHandler error_function);
156 extern void GEOS_DLL finishGEOS_r(GEOSContextHandle_t handle);
158 extern GEOSMessageHandler GEOS_DLL GEOSContext_setNoticeHandler_r(GEOSContextHandle_t extHandle,
159 GEOSMessageHandler nf);
160 extern GEOSMessageHandler GEOS_DLL GEOSContext_setErrorHandler_r(GEOSContextHandle_t extHandle,
161 GEOSMessageHandler nf);
163 extern const char GEOS_DLL *GEOSversion();
166 /************************************************************************
168 * NOTE - These functions are DEPRECATED. Please use the new Reader and
169 * writer APIS!
171 ***********************************************************************/
173 extern GEOSGeometry GEOS_DLL *GEOSGeomFromWKT(const char *wkt);
174 extern char GEOS_DLL *GEOSGeomToWKT(const GEOSGeometry* g);
176 extern GEOSGeometry GEOS_DLL *GEOSGeomFromWKT_r(GEOSContextHandle_t handle,
177 const char *wkt);
178 extern char GEOS_DLL *GEOSGeomToWKT_r(GEOSContextHandle_t handle,
179 const GEOSGeometry* g);
182 * Specify whether output WKB should be 2d or 3d.
183 * Return previously set number of dimensions.
185 extern int GEOS_DLL GEOS_getWKBOutputDims();
186 extern int GEOS_DLL GEOS_setWKBOutputDims(int newDims);
188 extern int GEOS_DLL GEOS_getWKBOutputDims_r(GEOSContextHandle_t handle);
189 extern int GEOS_DLL GEOS_setWKBOutputDims_r(GEOSContextHandle_t handle,
190 int newDims);
193 * Specify whether the WKB byte order is big or little endian.
194 * The return value is the previous byte order.
196 extern int GEOS_DLL GEOS_getWKBByteOrder();
197 extern int GEOS_DLL GEOS_setWKBByteOrder(int byteOrder);
199 extern GEOSGeometry GEOS_DLL *GEOSGeomFromWKB_buf(const unsigned char *wkb, size_t size);
200 extern unsigned char GEOS_DLL *GEOSGeomToWKB_buf(const GEOSGeometry* g, size_t *size);
202 extern GEOSGeometry GEOS_DLL *GEOSGeomFromHEX_buf(const unsigned char *hex, size_t size);
203 extern unsigned char GEOS_DLL *GEOSGeomToHEX_buf(const GEOSGeometry* g, size_t *size);
205 extern int GEOS_DLL GEOS_getWKBByteOrder_r(GEOSContextHandle_t handle);
206 extern int GEOS_DLL GEOS_setWKBByteOrder_r(GEOSContextHandle_t handle,
207 int byteOrder);
209 extern GEOSGeometry GEOS_DLL *GEOSGeomFromWKB_buf_r(GEOSContextHandle_t handle,
210 const unsigned char *wkb,
211 size_t size);
212 extern unsigned char GEOS_DLL *GEOSGeomToWKB_buf_r(GEOSContextHandle_t handle,
213 const GEOSGeometry* g,
214 size_t *size);
216 extern GEOSGeometry GEOS_DLL *GEOSGeomFromHEX_buf_r(GEOSContextHandle_t handle,
217 const unsigned char *hex,
218 size_t size);
219 extern unsigned char GEOS_DLL *GEOSGeomToHEX_buf_r(GEOSContextHandle_t handle,
220 const GEOSGeometry* g,
221 size_t *size);
223 /************************************************************************
225 * Coordinate Sequence functions
227 ***********************************************************************/
230 * Create a Coordinate sequence with ``size'' coordinates
231 * of ``dims'' dimensions.
232 * Return NULL on exception.
234 extern GEOSCoordSequence GEOS_DLL *GEOSCoordSeq_create(unsigned int size, unsigned int dims);
236 extern GEOSCoordSequence GEOS_DLL *GEOSCoordSeq_create_r(
237 GEOSContextHandle_t handle,
238 unsigned int size,
239 unsigned int dims);
242 * Clone a Coordinate Sequence.
243 * Return NULL on exception.
245 extern GEOSCoordSequence GEOS_DLL *GEOSCoordSeq_clone(const GEOSCoordSequence* s);
247 extern GEOSCoordSequence GEOS_DLL *GEOSCoordSeq_clone_r(
248 GEOSContextHandle_t handle,
249 const GEOSCoordSequence* s);
252 * Destroy a Coordinate Sequence.
254 extern void GEOS_DLL GEOSCoordSeq_destroy(GEOSCoordSequence* s);
256 extern void GEOS_DLL GEOSCoordSeq_destroy_r(GEOSContextHandle_t handle,
257 GEOSCoordSequence* s);
260 * Set ordinate values in a Coordinate Sequence.
261 * Return 0 on exception.
263 extern int GEOS_DLL GEOSCoordSeq_setX(GEOSCoordSequence* s,
264 unsigned int idx, double val);
265 extern int GEOS_DLL GEOSCoordSeq_setY(GEOSCoordSequence* s,
266 unsigned int idx, double val);
267 extern int GEOS_DLL GEOSCoordSeq_setZ(GEOSCoordSequence* s,
268 unsigned int idx, double val);
269 extern int GEOS_DLL GEOSCoordSeq_setOrdinate(GEOSCoordSequence* s,
270 unsigned int idx, unsigned int dim, double val);
272 extern int GEOS_DLL GEOSCoordSeq_setX_r(GEOSContextHandle_t handle,
273 GEOSCoordSequence* s, unsigned int idx,
274 double val);
275 extern int GEOS_DLL GEOSCoordSeq_setY_r(GEOSContextHandle_t handle,
276 GEOSCoordSequence* s, unsigned int idx,
277 double val);
278 extern int GEOS_DLL GEOSCoordSeq_setZ_r(GEOSContextHandle_t handle,
279 GEOSCoordSequence* s, unsigned int idx,
280 double val);
281 extern int GEOS_DLL GEOSCoordSeq_setOrdinate_r(GEOSContextHandle_t handle,
282 GEOSCoordSequence* s,
283 unsigned int idx,
284 unsigned int dim, double val);
287 * Get ordinate values from a Coordinate Sequence.
288 * Return 0 on exception.
290 extern int GEOS_DLL GEOSCoordSeq_getX(const GEOSCoordSequence* s,
291 unsigned int idx, double *val);
292 extern int GEOS_DLL GEOSCoordSeq_getY(const GEOSCoordSequence* s,
293 unsigned int idx, double *val);
294 extern int GEOS_DLL GEOSCoordSeq_getZ(const GEOSCoordSequence* s,
295 unsigned int idx, double *val);
296 extern int GEOS_DLL GEOSCoordSeq_getOrdinate(const GEOSCoordSequence* s,
297 unsigned int idx, unsigned int dim, double *val);
299 extern int GEOS_DLL GEOSCoordSeq_getX_r(GEOSContextHandle_t handle,
300 const GEOSCoordSequence* s,
301 unsigned int idx, double *val);
302 extern int GEOS_DLL GEOSCoordSeq_getY_r(GEOSContextHandle_t handle,
303 const GEOSCoordSequence* s,
304 unsigned int idx, double *val);
305 extern int GEOS_DLL GEOSCoordSeq_getZ_r(GEOSContextHandle_t handle,
306 const GEOSCoordSequence* s,
307 unsigned int idx, double *val);
308 extern int GEOS_DLL GEOSCoordSeq_getOrdinate_r(GEOSContextHandle_t handle,
309 const GEOSCoordSequence* s,
310 unsigned int idx,
311 unsigned int dim, double *val);
313 * Get size and dimensions info from a Coordinate Sequence.
314 * Return 0 on exception.
316 extern int GEOS_DLL GEOSCoordSeq_getSize(const GEOSCoordSequence* s,
317 unsigned int *size);
318 extern int GEOS_DLL GEOSCoordSeq_getDimensions(const GEOSCoordSequence* s,
319 unsigned int *dims);
321 extern int GEOS_DLL GEOSCoordSeq_getSize_r(GEOSContextHandle_t handle,
322 const GEOSCoordSequence* s,
323 unsigned int *size);
324 extern int GEOS_DLL GEOSCoordSeq_getDimensions_r(GEOSContextHandle_t handle,
325 const GEOSCoordSequence* s,
326 unsigned int *dims);
328 /************************************************************************
330 * Linearref functions -- there are more, but these two are probably
331 * sufficient for most purposes
333 ***********************************************************************/
336 * GEOSGeometry ownership is retained by caller
340 /* Return distance of point 'p' projected on 'g' from origin
341 * of 'g'. Geometry 'g' must be a lineal geometry */
342 extern double GEOS_DLL GEOSProject(const GEOSGeometry *g,
343 const GEOSGeometry* p);
344 extern double GEOS_DLL GEOSProject_r(GEOSContextHandle_t handle,
345 const GEOSGeometry *g,
346 const GEOSGeometry *p);
348 /* Return closest point to given distance within geometry
349 * Geometry must be a LineString */
350 extern GEOSGeometry GEOS_DLL *GEOSInterpolate(const GEOSGeometry *g,
351 double d);
352 extern GEOSGeometry GEOS_DLL *GEOSInterpolate_r(GEOSContextHandle_t handle,
353 const GEOSGeometry *g,
354 double d);
356 extern double GEOS_DLL GEOSProjectNormalized(const GEOSGeometry *g,
357 const GEOSGeometry* p);
358 extern double GEOS_DLL GEOSProjectNormalized_r(GEOSContextHandle_t handle,
359 const GEOSGeometry *g,
360 const GEOSGeometry *p);
362 extern GEOSGeometry GEOS_DLL *GEOSInterpolateNormalized(const GEOSGeometry *g,
363 double d);
364 extern GEOSGeometry GEOS_DLL *GEOSInterpolateNormalized_r(
365 GEOSContextHandle_t handle,
366 const GEOSGeometry *g,
367 double d);
369 /************************************************************************
371 * Buffer related functions
373 ***********************************************************************/
375 enum GEOSBufCapStyles {
376 GEOSBUF_CAP_ROUND=1,
377 GEOSBUF_CAP_FLAT=2,
378 GEOSBUF_CAP_SQUARE=3
381 enum GEOSBufJoinStyles {
382 GEOSBUF_JOIN_ROUND=1,
383 GEOSBUF_JOIN_MITRE=2,
384 GEOSBUF_JOIN_BEVEL=3
387 /* @return 0 on exception */
388 extern GEOSBufferParams GEOS_DLL *GEOSBufferParams_create();
389 extern GEOSBufferParams GEOS_DLL *GEOSBufferParams_create_r(
390 GEOSContextHandle_t handle);
391 extern void GEOS_DLL GEOSBufferParams_destroy(GEOSBufferParams* parms);
392 extern void GEOS_DLL GEOSBufferParams_destroy_r(
393 GEOSContextHandle_t handle,
394 GEOSBufferParams* parms);
396 /* @return 0 on exception */
397 extern int GEOS_DLL GEOSBufferParams_setEndCapStyle(
398 GEOSBufferParams* p,
399 int style);
400 extern int GEOS_DLL GEOSBufferParams_setEndCapStyle_r(
401 GEOSContextHandle_t handle,
402 GEOSBufferParams* p,
403 int style);
405 /* @return 0 on exception */
406 extern int GEOS_DLL GEOSBufferParams_setJoinStyle(
407 GEOSBufferParams* p,
408 int joinStyle);
409 extern int GEOS_DLL GEOSBufferParams_setJoinStyle_r(
410 GEOSContextHandle_t handle,
411 GEOSBufferParams* p,
412 int joinStyle);
414 /* @return 0 on exception */
415 extern int GEOS_DLL GEOSBufferParams_setMitreLimit(
416 GEOSBufferParams* p,
417 double mitreLimit);
418 extern int GEOS_DLL GEOSBufferParams_setMitreLimit_r(
419 GEOSContextHandle_t handle,
420 GEOSBufferParams* p,
421 double mitreLimit);
423 /* @return 0 on exception */
424 extern int GEOS_DLL GEOSBufferParams_setQuadrantSegments(
425 GEOSBufferParams* p,
426 int quadSegs);
427 extern int GEOS_DLL GEOSBufferParams_setQuadrantSegments_r(
428 GEOSContextHandle_t handle,
429 GEOSBufferParams* p,
430 int quadSegs);
432 /* @param singleSided: 1 for single sided, 0 otherwise */
433 /* @return 0 on exception */
434 extern int GEOS_DLL GEOSBufferParams_setSingleSided(
435 GEOSBufferParams* p,
436 int singleSided);
437 extern int GEOS_DLL GEOSBufferParams_setSingleSided_r(
438 GEOSContextHandle_t handle,
439 GEOSBufferParams* p,
440 int singleSided);
442 /* @return NULL on exception. */
443 extern GEOSGeometry GEOS_DLL *GEOSBufferWithParams(
444 const GEOSGeometry* g1,
445 const GEOSBufferParams* p,
446 double width);
447 extern GEOSGeometry GEOS_DLL *GEOSBufferWithParams_r(
448 GEOSContextHandle_t handle,
449 const GEOSGeometry* g1,
450 const GEOSBufferParams* p,
451 double width);
453 /* These functions return NULL on exception. */
454 extern GEOSGeometry GEOS_DLL *GEOSBuffer(const GEOSGeometry* g1,
455 double width, int quadsegs);
456 extern GEOSGeometry GEOS_DLL *GEOSBuffer_r(GEOSContextHandle_t handle,
457 const GEOSGeometry* g1,
458 double width, int quadsegs);
460 /* These functions return NULL on exception. */
461 extern GEOSGeometry GEOS_DLL *GEOSBufferWithStyle(const GEOSGeometry* g1,
462 double width, int quadsegs, int endCapStyle, int joinStyle,
463 double mitreLimit);
464 extern GEOSGeometry GEOS_DLL *GEOSBufferWithStyle_r(GEOSContextHandle_t handle,
465 const GEOSGeometry* g1, double width, int quadsegs, int endCapStyle,
466 int joinStyle, double mitreLimit);
468 /* These functions return NULL on exception. Only LINESTRINGs are accepted. */
469 /* @deprecated in 3.3.0: use GEOSOffsetCurve instead */
470 extern GEOSGeometry GEOS_DLL *GEOSSingleSidedBuffer(const GEOSGeometry* g1,
471 double width, int quadsegs, int joinStyle, double mitreLimit,
472 int leftSide);
473 extern GEOSGeometry GEOS_DLL *GEOSSingleSidedBuffer_r(
474 GEOSContextHandle_t handle,
475 const GEOSGeometry* g1, double width, int quadsegs,
476 int joinStyle, double mitreLimit, int leftSide);
479 * Only LINESTRINGs are accepted.
480 * @param width : offset distance.
481 * negative for right side offset.
482 * positive for left side offset.
483 * @return NULL on exception
485 extern GEOSGeometry GEOS_DLL *GEOSOffsetCurve(const GEOSGeometry* g1,
486 double width, int quadsegs, int joinStyle, double mitreLimit);
487 extern GEOSGeometry GEOS_DLL *GEOSOffsetCurve_r(GEOSContextHandle_t handle,
488 const GEOSGeometry* g1, double width, int quadsegs,
489 int joinStyle, double mitreLimit);
492 /************************************************************************
494 * Geometry Constructors.
495 * GEOSCoordSequence* arguments will become ownership of the returned object.
496 * All functions return NULL on exception.
498 ***********************************************************************/
500 extern GEOSGeometry GEOS_DLL *GEOSGeom_createPoint(GEOSCoordSequence* s);
501 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyPoint();
502 extern GEOSGeometry GEOS_DLL *GEOSGeom_createLinearRing(GEOSCoordSequence* s);
503 extern GEOSGeometry GEOS_DLL *GEOSGeom_createLineString(GEOSCoordSequence* s);
504 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyLineString();
506 extern GEOSGeometry GEOS_DLL *GEOSGeom_createPoint_r(
507 GEOSContextHandle_t handle,
508 GEOSCoordSequence* s);
509 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyPoint_r(
510 GEOSContextHandle_t handle);
511 extern GEOSGeometry GEOS_DLL *GEOSGeom_createLinearRing_r(
512 GEOSContextHandle_t handle,
513 GEOSCoordSequence* s);
514 extern GEOSGeometry GEOS_DLL *GEOSGeom_createLineString_r(
515 GEOSContextHandle_t handle,
516 GEOSCoordSequence* s);
517 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyLineString_r(
518 GEOSContextHandle_t handle);
521 * Second argument is an array of GEOSGeometry* objects.
522 * The caller remains owner of the array, but pointed-to
523 * objects become ownership of the returned GEOSGeometry.
525 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyPolygon();
526 extern GEOSGeometry GEOS_DLL *GEOSGeom_createPolygon(GEOSGeometry* shell,
527 GEOSGeometry** holes, unsigned int nholes);
528 extern GEOSGeometry GEOS_DLL *GEOSGeom_createCollection(int type,
529 GEOSGeometry* *geoms, unsigned int ngeoms);
530 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyCollection(int type);
532 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyPolygon_r(
533 GEOSContextHandle_t handle);
534 extern GEOSGeometry GEOS_DLL *GEOSGeom_createPolygon_r(
535 GEOSContextHandle_t handle,
536 GEOSGeometry* shell,
537 GEOSGeometry** holes,
538 unsigned int nholes);
539 extern GEOSGeometry GEOS_DLL *GEOSGeom_createCollection_r(
540 GEOSContextHandle_t handle, int type,
541 GEOSGeometry* *geoms,
542 unsigned int ngeoms);
543 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyCollection_r(
544 GEOSContextHandle_t handle, int type);
546 extern GEOSGeometry GEOS_DLL *GEOSGeom_clone(const GEOSGeometry* g);
548 extern GEOSGeometry GEOS_DLL *GEOSGeom_clone_r(GEOSContextHandle_t handle,
549 const GEOSGeometry* g);
551 /************************************************************************
553 * Memory management
555 ***********************************************************************/
557 extern void GEOS_DLL GEOSGeom_destroy(GEOSGeometry* g);
559 extern void GEOS_DLL GEOSGeom_destroy_r(GEOSContextHandle_t handle,
560 GEOSGeometry* g);
562 /************************************************************************
564 * Topology operations - return NULL on exception.
566 ***********************************************************************/
568 extern GEOSGeometry GEOS_DLL *GEOSEnvelope(const GEOSGeometry* g1);
569 extern GEOSGeometry GEOS_DLL *GEOSIntersection(const GEOSGeometry* g1, const GEOSGeometry* g2);
570 extern GEOSGeometry GEOS_DLL *GEOSConvexHull(const GEOSGeometry* g1);
571 extern GEOSGeometry GEOS_DLL *GEOSDifference(const GEOSGeometry* g1, const GEOSGeometry* g2);
572 extern GEOSGeometry GEOS_DLL *GEOSSymDifference(const GEOSGeometry* g1,
573 const GEOSGeometry* g2);
574 extern GEOSGeometry GEOS_DLL *GEOSBoundary(const GEOSGeometry* g1);
575 extern GEOSGeometry GEOS_DLL *GEOSUnion(const GEOSGeometry* g1, const GEOSGeometry* g2);
576 extern GEOSGeometry GEOS_DLL *GEOSUnaryUnion(const GEOSGeometry* g1);
578 /* @deprecated in 3.3.0: use GEOSUnaryUnion instead */
579 extern GEOSGeometry GEOS_DLL *GEOSUnionCascaded(const GEOSGeometry* g1);
580 extern GEOSGeometry GEOS_DLL *GEOSUnionCascaded_r(GEOSContextHandle_t handle, const GEOSGeometry* g1);
582 extern GEOSGeometry GEOS_DLL *GEOSPointOnSurface(const GEOSGeometry* g1);
583 extern GEOSGeometry GEOS_DLL *GEOSGetCentroid(const GEOSGeometry* g);
585 extern GEOSGeometry GEOS_DLL *GEOSEnvelope_r(GEOSContextHandle_t handle,
586 const GEOSGeometry* g1);
587 extern GEOSGeometry GEOS_DLL *GEOSIntersection_r(GEOSContextHandle_t handle,
588 const GEOSGeometry* g1,
589 const GEOSGeometry* g2);
590 extern GEOSGeometry GEOS_DLL *GEOSConvexHull_r(GEOSContextHandle_t handle,
591 const GEOSGeometry* g1);
592 extern GEOSGeometry GEOS_DLL *GEOSDifference_r(GEOSContextHandle_t handle,
593 const GEOSGeometry* g1,
594 const GEOSGeometry* g2);
595 extern GEOSGeometry GEOS_DLL *GEOSSymDifference_r(GEOSContextHandle_t handle,
596 const GEOSGeometry* g1,
597 const GEOSGeometry* g2);
598 extern GEOSGeometry GEOS_DLL *GEOSBoundary_r(GEOSContextHandle_t handle,
599 const GEOSGeometry* g1);
600 extern GEOSGeometry GEOS_DLL *GEOSUnion_r(GEOSContextHandle_t handle,
601 const GEOSGeometry* g1,
602 const GEOSGeometry* g2);
603 extern GEOSGeometry GEOS_DLL *GEOSUnaryUnion_r(GEOSContextHandle_t handle,
604 const GEOSGeometry* g);
605 extern GEOSGeometry GEOS_DLL *GEOSPointOnSurface_r(GEOSContextHandle_t handle,
606 const GEOSGeometry* g1);
607 extern GEOSGeometry GEOS_DLL *GEOSGetCentroid_r(GEOSContextHandle_t handle,
608 const GEOSGeometry* g);
611 * all arguments remain ownership of the caller
612 * (both Geometries and pointers)
614 extern GEOSGeometry GEOS_DLL *GEOSPolygonize(const GEOSGeometry * const geoms[], unsigned int ngeoms);
615 extern GEOSGeometry GEOS_DLL *GEOSPolygonizer_getCutEdges(const GEOSGeometry * const geoms[], unsigned int ngeoms);
617 * Polygonizes a set of Geometrys which contain linework that
618 * represents the edges of a planar graph.
620 * Any dimension of Geometry is handled - the constituent linework
621 * is extracted to form the edges.
623 * The edges must be correctly noded; that is, they must only meet
624 * at their endpoints.
625 * The Polygonizer will still run on incorrectly noded input
626 * but will not form polygons from incorrected noded edges.
628 * The Polygonizer reports the follow kinds of errors:
630 * - Dangles - edges which have one or both ends which are
631 * not incident on another edge endpoint
632 * - Cut Edges - edges which are connected at both ends but
633 * which do not form part of polygon
634 * - Invalid Ring Lines - edges which form rings which are invalid
635 * (e.g. the component lines contain a self-intersection)
637 * Errors are reported to output parameters "cuts", "dangles" and
638 * "invalid" (if not-null). Formed polygons are returned as a
639 * collection. NULL is returned on exception. All returned
640 * geometries must be destroyed by caller.
643 extern GEOSGeometry GEOS_DLL *GEOSPolygonize_full(const GEOSGeometry* input,
644 GEOSGeometry** cuts, GEOSGeometry** dangles, GEOSGeometry** invalid);
646 extern GEOSGeometry GEOS_DLL *GEOSLineMerge(const GEOSGeometry* g);
647 extern GEOSGeometry GEOS_DLL *GEOSSimplify(const GEOSGeometry* g1, double tolerance);
648 extern GEOSGeometry GEOS_DLL *GEOSTopologyPreserveSimplify(const GEOSGeometry* g1,
649 double tolerance);
651 extern GEOSGeometry GEOS_DLL *GEOSPolygonize_r(GEOSContextHandle_t handle,
652 const GEOSGeometry *const geoms[],
653 unsigned int ngeoms);
654 extern GEOSGeometry GEOS_DLL *GEOSPolygonizer_getCutEdges_r(
655 GEOSContextHandle_t handle,
656 const GEOSGeometry * const geoms[],
657 unsigned int ngeoms);
658 extern GEOSGeometry GEOS_DLL *GEOSPolygonize_full_r(GEOSContextHandle_t handle,
659 const GEOSGeometry* input, GEOSGeometry** cuts,
660 GEOSGeometry** dangles, GEOSGeometry** invalidRings);
662 extern GEOSGeometry GEOS_DLL *GEOSLineMerge_r(GEOSContextHandle_t handle,
663 const GEOSGeometry* g);
664 extern GEOSGeometry GEOS_DLL *GEOSSimplify_r(GEOSContextHandle_t handle,
665 const GEOSGeometry* g1,
666 double tolerance);
667 extern GEOSGeometry GEOS_DLL *GEOSTopologyPreserveSimplify_r(
668 GEOSContextHandle_t handle,
669 const GEOSGeometry* g1, double tolerance);
672 * Return all distinct vertices of input geometry as a MULTIPOINT.
673 * Note that only 2 dimensions of the vertices are considered when
674 * testing for equality.
676 extern GEOSGeometry GEOS_DLL *GEOSGeom_extractUniquePoints(
677 const GEOSGeometry* g);
678 extern GEOSGeometry GEOS_DLL *GEOSGeom_extractUniquePoints_r(
679 GEOSContextHandle_t handle,
680 const GEOSGeometry* g);
683 * Find paths shared between the two given lineal geometries.
685 * Returns a GEOMETRYCOLLECTION having two elements:
686 * - first element is a MULTILINESTRING containing shared paths
687 * having the _same_ direction on both inputs
688 * - second element is a MULTILINESTRING containing shared paths
689 * having the _opposite_ direction on the two inputs
691 * Returns NULL on exception
693 extern GEOSGeometry GEOS_DLL *GEOSSharedPaths(const GEOSGeometry* g1,
694 const GEOSGeometry* g2);
695 extern GEOSGeometry GEOS_DLL *GEOSSharedPaths_r(GEOSContextHandle_t handle,
696 const GEOSGeometry* g1, const GEOSGeometry* g2);
699 * Snap first geometry on to second with given tolerance
700 * Returns a newly allocated geometry, or NULL on exception
702 extern GEOSGeometry GEOS_DLL *GEOSSnap(const GEOSGeometry* g1,
703 const GEOSGeometry* g2, double tolerance);
704 extern GEOSGeometry GEOS_DLL *GEOSSnap_r(GEOSContextHandle_t handle,
705 const GEOSGeometry* g1, const GEOSGeometry* g2, double tolerance);
707 /************************************************************************
709 * Binary predicates - return 2 on exception, 1 on true, 0 on false
711 ***********************************************************************/
713 extern char GEOS_DLL GEOSDisjoint(const GEOSGeometry* g1, const GEOSGeometry* g2);
714 extern char GEOS_DLL GEOSTouches(const GEOSGeometry* g1, const GEOSGeometry* g2);
715 extern char GEOS_DLL GEOSIntersects(const GEOSGeometry* g1, const GEOSGeometry* g2);
716 extern char GEOS_DLL GEOSCrosses(const GEOSGeometry* g1, const GEOSGeometry* g2);
717 extern char GEOS_DLL GEOSWithin(const GEOSGeometry* g1, const GEOSGeometry* g2);
718 extern char GEOS_DLL GEOSContains(const GEOSGeometry* g1, const GEOSGeometry* g2);
719 extern char GEOS_DLL GEOSOverlaps(const GEOSGeometry* g1, const GEOSGeometry* g2);
720 extern char GEOS_DLL GEOSEquals(const GEOSGeometry* g1, const GEOSGeometry* g2);
721 extern char GEOS_DLL GEOSEqualsExact(const GEOSGeometry* g1, const GEOSGeometry* g2, double tolerance);
722 extern char GEOS_DLL GEOSCovers(const GEOSGeometry* g1, const GEOSGeometry* g2);
723 extern char GEOS_DLL GEOSCoveredBy(const GEOSGeometry* g1, const GEOSGeometry* g2);
725 extern char GEOS_DLL GEOSDisjoint_r(GEOSContextHandle_t handle,
726 const GEOSGeometry* g1,
727 const GEOSGeometry* g2);
728 extern char GEOS_DLL GEOSTouches_r(GEOSContextHandle_t handle,
729 const GEOSGeometry* g1,
730 const GEOSGeometry* g2);
731 extern char GEOS_DLL GEOSIntersects_r(GEOSContextHandle_t handle,
732 const GEOSGeometry* g1,
733 const GEOSGeometry* g2);
734 extern char GEOS_DLL GEOSCrosses_r(GEOSContextHandle_t handle,
735 const GEOSGeometry* g1,
736 const GEOSGeometry* g2);
737 extern char GEOS_DLL GEOSWithin_r(GEOSContextHandle_t handle,
738 const GEOSGeometry* g1,
739 const GEOSGeometry* g2);
740 extern char GEOS_DLL GEOSContains_r(GEOSContextHandle_t handle,
741 const GEOSGeometry* g1,
742 const GEOSGeometry* g2);
743 extern char GEOS_DLL GEOSOverlaps_r(GEOSContextHandle_t handle,
744 const GEOSGeometry* g1,
745 const GEOSGeometry* g2);
746 extern char GEOS_DLL GEOSEquals_r(GEOSContextHandle_t handle,
747 const GEOSGeometry* g1,
748 const GEOSGeometry* g2);
749 extern char GEOS_DLL GEOSEqualsExact_r(GEOSContextHandle_t handle,
750 const GEOSGeometry* g1,
751 const GEOSGeometry* g2,
752 double tolerance);
753 extern char GEOS_DLL GEOSCovers_r(GEOSContextHandle_t handle,
754 const GEOSGeometry* g1,
755 const GEOSGeometry* g2);
756 extern char GEOS_DLL GEOSCoveredBy_r(GEOSContextHandle_t handle,
757 const GEOSGeometry* g1,
758 const GEOSGeometry* g2);
760 /************************************************************************
762 * Prepared Geometry Binary predicates - return 2 on exception, 1 on true, 0 on false
764 ***********************************************************************/
767 * GEOSGeometry ownership is retained by caller
769 extern const GEOSPreparedGeometry GEOS_DLL *GEOSPrepare(const GEOSGeometry* g);
771 extern void GEOS_DLL GEOSPreparedGeom_destroy(const GEOSPreparedGeometry* g);
773 extern char GEOS_DLL GEOSPreparedContains(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
774 extern char GEOS_DLL GEOSPreparedContainsProperly(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
775 extern char GEOS_DLL GEOSPreparedCoveredBy(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
776 extern char GEOS_DLL GEOSPreparedCovers(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
777 extern char GEOS_DLL GEOSPreparedCrosses(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
778 extern char GEOS_DLL GEOSPreparedDisjoint(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
779 extern char GEOS_DLL GEOSPreparedIntersects(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
780 extern char GEOS_DLL GEOSPreparedOverlaps(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
781 extern char GEOS_DLL GEOSPreparedTouches(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
782 extern char GEOS_DLL GEOSPreparedWithin(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
785 * GEOSGeometry ownership is retained by caller
787 extern const GEOSPreparedGeometry GEOS_DLL *GEOSPrepare_r(
788 GEOSContextHandle_t handle,
789 const GEOSGeometry* g);
791 extern void GEOS_DLL GEOSPreparedGeom_destroy_r(GEOSContextHandle_t handle,
792 const GEOSPreparedGeometry* g);
794 extern char GEOS_DLL GEOSPreparedContains_r(GEOSContextHandle_t handle,
795 const GEOSPreparedGeometry* pg1,
796 const GEOSGeometry* g2);
797 extern char GEOS_DLL GEOSPreparedContainsProperly_r(GEOSContextHandle_t handle,
798 const GEOSPreparedGeometry* pg1,
799 const GEOSGeometry* g2);
800 extern char GEOS_DLL GEOSPreparedCoveredBy_r(GEOSContextHandle_t handle,
801 const GEOSPreparedGeometry* pg1,
802 const GEOSGeometry* g2);
803 extern char GEOS_DLL GEOSPreparedCovers_r(GEOSContextHandle_t handle,
804 const GEOSPreparedGeometry* pg1,
805 const GEOSGeometry* g2);
806 extern char GEOS_DLL GEOSPreparedCrosses_r(GEOSContextHandle_t handle,
807 const GEOSPreparedGeometry* pg1,
808 const GEOSGeometry* g2);
809 extern char GEOS_DLL GEOSPreparedDisjoint_r(GEOSContextHandle_t handle,
810 const GEOSPreparedGeometry* pg1,
811 const GEOSGeometry* g2);
812 extern char GEOS_DLL GEOSPreparedIntersects_r(GEOSContextHandle_t handle,
813 const GEOSPreparedGeometry* pg1,
814 const GEOSGeometry* g2);
815 extern char GEOS_DLL GEOSPreparedOverlaps_r(GEOSContextHandle_t handle,
816 const GEOSPreparedGeometry* pg1,
817 const GEOSGeometry* g2);
818 extern char GEOS_DLL GEOSPreparedTouches_r(GEOSContextHandle_t handle,
819 const GEOSPreparedGeometry* pg1,
820 const GEOSGeometry* g2);
821 extern char GEOS_DLL GEOSPreparedWithin_r(GEOSContextHandle_t handle,
822 const GEOSPreparedGeometry* pg1,
823 const GEOSGeometry* g2);
825 /************************************************************************
827 * STRtree functions
829 ***********************************************************************/
832 * GEOSGeometry ownership is retained by caller
835 extern GEOSSTRtree GEOS_DLL *GEOSSTRtree_create(size_t nodeCapacity);
836 extern void GEOS_DLL GEOSSTRtree_insert(GEOSSTRtree *tree,
837 const GEOSGeometry *g,
838 void *item);
839 extern void GEOS_DLL GEOSSTRtree_query(GEOSSTRtree *tree,
840 const GEOSGeometry *g,
841 GEOSQueryCallback callback,
842 void *userdata);
843 extern void GEOS_DLL GEOSSTRtree_iterate(GEOSSTRtree *tree,
844 GEOSQueryCallback callback,
845 void *userdata);
846 extern char GEOS_DLL GEOSSTRtree_remove(GEOSSTRtree *tree,
847 const GEOSGeometry *g,
848 void *item);
849 extern void GEOS_DLL GEOSSTRtree_destroy(GEOSSTRtree *tree);
852 extern GEOSSTRtree GEOS_DLL *GEOSSTRtree_create_r(
853 GEOSContextHandle_t handle,
854 size_t nodeCapacity);
855 extern void GEOS_DLL GEOSSTRtree_insert_r(GEOSContextHandle_t handle,
856 GEOSSTRtree *tree,
857 const GEOSGeometry *g,
858 void *item);
859 extern void GEOS_DLL GEOSSTRtree_query_r(GEOSContextHandle_t handle,
860 GEOSSTRtree *tree,
861 const GEOSGeometry *g,
862 GEOSQueryCallback callback,
863 void *userdata);
864 extern void GEOS_DLL GEOSSTRtree_iterate_r(GEOSContextHandle_t handle,
865 GEOSSTRtree *tree,
866 GEOSQueryCallback callback,
867 void *userdata);
868 extern char GEOS_DLL GEOSSTRtree_remove_r(GEOSContextHandle_t handle,
869 GEOSSTRtree *tree,
870 const GEOSGeometry *g,
871 void *item);
872 extern void GEOS_DLL GEOSSTRtree_destroy_r(GEOSContextHandle_t handle,
873 GEOSSTRtree *tree);
876 /************************************************************************
878 * Unary predicate - return 2 on exception, 1 on true, 0 on false
880 ***********************************************************************/
882 extern char GEOS_DLL GEOSisEmpty(const GEOSGeometry* g1);
883 extern char GEOS_DLL GEOSisSimple(const GEOSGeometry* g1);
884 extern char GEOS_DLL GEOSisRing(const GEOSGeometry* g1);
885 extern char GEOS_DLL GEOSHasZ(const GEOSGeometry* g1);
886 extern char GEOS_DLL GEOSisClosed(const GEOSGeometry *g1);
888 extern char GEOS_DLL GEOSisEmpty_r(GEOSContextHandle_t handle,
889 const GEOSGeometry* g1);
890 extern char GEOS_DLL GEOSisSimple_r(GEOSContextHandle_t handle,
891 const GEOSGeometry* g1);
892 extern char GEOS_DLL GEOSisRing_r(GEOSContextHandle_t handle,
893 const GEOSGeometry* g1);
894 extern char GEOS_DLL GEOSHasZ_r(GEOSContextHandle_t handle,
895 const GEOSGeometry* g1);
896 extern char GEOS_DLL GEOSisClosed_r(GEOSContextHandle_t handle,
897 const GEOSGeometry *g1);
899 /************************************************************************
901 * Dimensionally Extended 9 Intersection Model related
903 ***********************************************************************/
905 /* These are for use with GEOSRelateBoundaryNodeRule (flags param) */
906 enum GEOSRelateBoundaryNodeRules {
907 /* MOD2 and OGC are the same rule, and is the default
908 * used by GEOSRelatePattern
910 GEOSRELATE_BNR_MOD2=1,
911 GEOSRELATE_BNR_OGC=1,
912 GEOSRELATE_BNR_ENDPOINT=2,
913 GEOSRELATE_BNR_MULTIVALENT_ENDPOINT=3,
914 GEOSRELATE_BNR_MONOVALENT_ENDPOINT=4
917 /* return 2 on exception, 1 on true, 0 on false */
918 extern char GEOS_DLL GEOSRelatePattern(const GEOSGeometry* g1, const GEOSGeometry* g2, const char *pat);
919 extern char GEOS_DLL GEOSRelatePattern_r(GEOSContextHandle_t handle,
920 const GEOSGeometry* g1,
921 const GEOSGeometry* g2,
922 const char *pat);
924 /* return NULL on exception, a string to GEOSFree otherwise */
925 extern char GEOS_DLL *GEOSRelate(const GEOSGeometry* g1, const GEOSGeometry* g2);
926 extern char GEOS_DLL *GEOSRelate_r(GEOSContextHandle_t handle,
927 const GEOSGeometry* g1,
928 const GEOSGeometry* g2);
930 /* return 2 on exception, 1 on true, 0 on false */
931 extern char GEOS_DLL GEOSRelatePatternMatch(const char* mat, const char *pat);
932 extern char GEOS_DLL GEOSRelatePatternMatch_r(GEOSContextHandle_t handle,
933 const char* mat,
934 const char *pat);
936 /* return NULL on exception, a string to GEOSFree otherwise */
937 extern char GEOS_DLL *GEOSRelateBoundaryNodeRule(const GEOSGeometry* g1,
938 const GEOSGeometry* g2,
939 int bnr);
940 extern char GEOS_DLL *GEOSRelateBoundaryNodeRule_r(GEOSContextHandle_t handle,
941 const GEOSGeometry* g1,
942 const GEOSGeometry* g2,
943 int bnr);
945 /************************************************************************
947 * Validity checking
949 ***********************************************************************/
951 /* These are for use with GEOSisValidDetail (flags param) */
952 enum GEOSValidFlags {
953 GEOSVALID_ALLOW_SELFTOUCHING_RING_FORMING_HOLE=1
956 /* return 2 on exception, 1 on true, 0 on false */
957 extern char GEOS_DLL GEOSisValid(const GEOSGeometry* g1);
958 extern char GEOS_DLL GEOSisValid_r(GEOSContextHandle_t handle,
959 const GEOSGeometry* g1);
961 /* return NULL on exception, a string to GEOSFree otherwise */
962 extern char GEOS_DLL *GEOSisValidReason(const GEOSGeometry *g1);
963 extern char GEOS_DLL *GEOSisValidReason_r(GEOSContextHandle_t handle,
964 const GEOSGeometry* g1);
967 * Caller has the responsibility to destroy 'reason' (GEOSFree)
968 * and 'location' (GEOSGeom_destroy) params
969 * return 2 on exception, 1 when valid, 0 when invalid
971 extern char GEOS_DLL GEOSisValidDetail(const GEOSGeometry* g,
972 int flags,
973 char** reason, GEOSGeometry** location);
974 extern char GEOS_DLL GEOSisValidDetail_r(GEOSContextHandle_t handle,
975 const GEOSGeometry* g,
976 int flags,
977 char** reason,
978 GEOSGeometry** location);
980 /************************************************************************
982 * Geometry info
984 ***********************************************************************/
986 /* Return NULL on exception, result must be freed by caller. */
987 extern char GEOS_DLL *GEOSGeomType(const GEOSGeometry* g1);
989 extern char GEOS_DLL *GEOSGeomType_r(GEOSContextHandle_t handle,
990 const GEOSGeometry* g1);
992 /* Return -1 on exception */
993 extern int GEOS_DLL GEOSGeomTypeId(const GEOSGeometry* g1);
995 extern int GEOS_DLL GEOSGeomTypeId_r(GEOSContextHandle_t handle,
996 const GEOSGeometry* g1);
998 /* Return 0 on exception */
999 extern int GEOS_DLL GEOSGetSRID(const GEOSGeometry* g);
1000 extern int GEOS_DLL GEOSGetSRID_r(GEOSContextHandle_t handle,
1001 const GEOSGeometry* g);
1003 extern void GEOS_DLL GEOSSetSRID(GEOSGeometry* g, int SRID);
1004 extern void GEOS_DLL GEOSSetSRID_r(GEOSContextHandle_t handle,
1005 GEOSGeometry* g, int SRID);
1007 /* May be called on all geometries in GEOS 3.x, returns -1 on error and 1
1008 * for non-multi geometries. Older GEOS versions only accept
1009 * GeometryCollections or Multi* geometries here, and are likely to crash
1010 * when feeded simple geometries, so beware if you need compatibility with
1011 * old GEOS versions.
1013 extern int GEOS_DLL GEOSGetNumGeometries(const GEOSGeometry* g);
1015 extern int GEOS_DLL GEOSGetNumGeometries_r(GEOSContextHandle_t handle,
1016 const GEOSGeometry* g);
1019 * Return NULL on exception.
1020 * Returned object is a pointer to internal storage:
1021 * it must NOT be destroyed directly.
1022 * Up to GEOS 3.2.0 the input geometry must be a Collection, in
1023 * later version it doesn't matter (getGeometryN(0) for a single will
1024 * return the input).
1026 extern const GEOSGeometry GEOS_DLL *GEOSGetGeometryN(const GEOSGeometry* g, int n);
1028 extern const GEOSGeometry GEOS_DLL *GEOSGetGeometryN_r(
1029 GEOSContextHandle_t handle,
1030 const GEOSGeometry* g, int n);
1032 /* Return -1 on exception */
1033 extern int GEOS_DLL GEOSNormalize(GEOSGeometry* g1);
1035 extern int GEOS_DLL GEOSNormalize_r(GEOSContextHandle_t handle,
1036 GEOSGeometry* g1);
1038 /* Return -1 on exception */
1039 extern int GEOS_DLL GEOSGetNumInteriorRings(const GEOSGeometry* g1);
1041 extern int GEOS_DLL GEOSGetNumInteriorRings_r(GEOSContextHandle_t handle,
1042 const GEOSGeometry* g1);
1044 /* Return -1 on exception, Geometry must be a LineString. */
1045 extern int GEOS_DLL GEOSGeomGetNumPoints(const GEOSGeometry* g1);
1047 extern int GEOS_DLL GEOSGeomGetNumPoints_r(GEOSContextHandle_t handle,
1048 const GEOSGeometry* g1);
1050 /* Return -1 on exception, Geometry must be a Point. */
1051 extern int GEOS_DLL GEOSGeomGetX(const GEOSGeometry *g1, double *x);
1052 extern int GEOS_DLL GEOSGeomGetY(const GEOSGeometry *g1, double *y);
1054 extern int GEOS_DLL GEOSGeomGetX_r(GEOSContextHandle_t handle, const GEOSGeometry *g1, double *x);
1055 extern int GEOS_DLL GEOSGeomGetY_r(GEOSContextHandle_t handle, const GEOSGeometry *g1, double *y);
1058 * Return NULL on exception, Geometry must be a Polygon.
1059 * Returned object is a pointer to internal storage:
1060 * it must NOT be destroyed directly.
1062 extern const GEOSGeometry GEOS_DLL *GEOSGetInteriorRingN(const GEOSGeometry* g, int n);
1064 extern const GEOSGeometry GEOS_DLL *GEOSGetInteriorRingN_r(
1065 GEOSContextHandle_t handle,
1066 const GEOSGeometry* g, int n);
1069 * Return NULL on exception, Geometry must be a Polygon.
1070 * Returned object is a pointer to internal storage:
1071 * it must NOT be destroyed directly.
1073 extern const GEOSGeometry GEOS_DLL *GEOSGetExteriorRing(const GEOSGeometry* g);
1075 extern const GEOSGeometry GEOS_DLL *GEOSGetExteriorRing_r(
1076 GEOSContextHandle_t handle,
1077 const GEOSGeometry* g);
1079 /* Return -1 on exception */
1080 extern int GEOS_DLL GEOSGetNumCoordinates(const GEOSGeometry* g1);
1082 extern int GEOS_DLL GEOSGetNumCoordinates_r(GEOSContextHandle_t handle,
1083 const GEOSGeometry* g1);
1086 * Return NULL on exception.
1087 * Geometry must be a LineString, LinearRing or Point.
1089 extern const GEOSCoordSequence GEOS_DLL *GEOSGeom_getCoordSeq(const GEOSGeometry* g);
1091 extern const GEOSCoordSequence GEOS_DLL *GEOSGeom_getCoordSeq_r(
1092 GEOSContextHandle_t handle,
1093 const GEOSGeometry* g);
1096 * Return 0 on exception (or empty geometry)
1098 extern int GEOS_DLL GEOSGeom_getDimensions(const GEOSGeometry* g);
1100 extern int GEOS_DLL GEOSGeom_getDimensions_r(GEOSContextHandle_t handle,
1101 const GEOSGeometry* g);
1104 * Return 2 or 3.
1106 extern int GEOS_DLL GEOSGeom_getCoordinateDimension(const GEOSGeometry* g);
1108 extern int GEOS_DLL GEOSGeom_getCoordinateDimension_r(GEOSContextHandle_t handle,
1109 const GEOSGeometry* g);
1112 * Return NULL on exception.
1113 * Must be LineString and must be freed by called.
1115 extern GEOSGeometry GEOS_DLL *GEOSGeomGetPointN(const GEOSGeometry *g1, int n);
1116 extern GEOSGeometry GEOS_DLL *GEOSGeomGetStartPoint(const GEOSGeometry *g1);
1117 extern GEOSGeometry GEOS_DLL *GEOSGeomGetEndPoint(const GEOSGeometry *g1);
1119 extern GEOSGeometry GEOS_DLL *GEOSGeomGetPointN_r(GEOSContextHandle_t handle, const GEOSGeometry *g1, int n);
1120 extern GEOSGeometry GEOS_DLL *GEOSGeomGetStartPoint_r(GEOSContextHandle_t handle, const GEOSGeometry *g1);
1121 extern GEOSGeometry GEOS_DLL *GEOSGeomGetEndPoint_r(GEOSContextHandle_t handle, const GEOSGeometry *g1);
1123 /************************************************************************
1125 * Misc functions
1127 ***********************************************************************/
1129 /* Return 0 on exception, 1 otherwise */
1130 extern int GEOS_DLL GEOSArea(const GEOSGeometry* g1, double *area);
1131 extern int GEOS_DLL GEOSLength(const GEOSGeometry* g1, double *length);
1132 extern int GEOS_DLL GEOSDistance(const GEOSGeometry* g1, const GEOSGeometry* g2,
1133 double *dist);
1134 extern int GEOS_DLL GEOSHausdorffDistance(const GEOSGeometry *g1,
1135 const GEOSGeometry *g2, double *dist);
1136 extern int GEOS_DLL GEOSHausdorffDistanceDensify(const GEOSGeometry *g1,
1137 const GEOSGeometry *g2, double densifyFrac, double *dist);
1138 extern int GEOS_DLL GEOSGeomGetLength(const GEOSGeometry *g1, double *length);
1139 extern int GEOS_DLL GEOSArea_r(GEOSContextHandle_t handle,
1140 const GEOSGeometry* g1, double *area);
1141 extern int GEOS_DLL GEOSLength_r(GEOSContextHandle_t handle,
1142 const GEOSGeometry* g1, double *length);
1143 extern int GEOS_DLL GEOSDistance_r(GEOSContextHandle_t handle,
1144 const GEOSGeometry* g1,
1145 const GEOSGeometry* g2, double *dist);
1146 extern int GEOS_DLL GEOSHausdorffDistance_r(GEOSContextHandle_t handle,
1147 const GEOSGeometry *g1,
1148 const GEOSGeometry *g2,
1149 double *dist);
1150 extern int GEOS_DLL GEOSHausdorffDistanceDensify_r(GEOSContextHandle_t handle,
1151 const GEOSGeometry *g1,
1152 const GEOSGeometry *g2,
1153 double densifyFrac, double *dist);
1154 extern int GEOS_DLL GEOSGeomGetLength_r(GEOSContextHandle_t handle,
1155 const GEOSGeometry *g1, double *length);
1157 /************************************************************************
1159 * Algorithms
1161 ***********************************************************************/
1163 /* Walking from A to B:
1164 * return -1 if reaching P takes a counter-clockwise (left) turn
1165 * return 1 if reaching P takes a clockwise (right) turn
1166 * return 0 if P is collinear with A-B
1168 * On exceptions, return 2.
1171 extern int GEOS_DLL GEOSOrientationIndex(double Ax, double Ay, double Bx, double By,
1172 double Px, double Py);
1173 extern int GEOS_DLL GEOSOrientationIndex_r(GEOSContextHandle_t handle,
1174 double Ax, double Ay, double Bx, double By, double Px, double Py);
1177 /************************************************************************
1179 * Reader and Writer APIs
1181 ***********************************************************************/
1183 typedef struct GEOSWKTReader_t GEOSWKTReader;
1184 typedef struct GEOSWKTWriter_t GEOSWKTWriter;
1185 typedef struct GEOSWKBReader_t GEOSWKBReader;
1186 typedef struct GEOSWKBWriter_t GEOSWKBWriter;
1189 /* WKT Reader */
1190 extern GEOSWKTReader GEOS_DLL *GEOSWKTReader_create();
1191 extern void GEOS_DLL GEOSWKTReader_destroy(GEOSWKTReader* reader);
1192 extern GEOSGeometry GEOS_DLL *GEOSWKTReader_read(GEOSWKTReader* reader, const char *wkt);
1194 extern GEOSWKTReader GEOS_DLL *GEOSWKTReader_create_r(
1195 GEOSContextHandle_t handle);
1196 extern void GEOS_DLL GEOSWKTReader_destroy_r(GEOSContextHandle_t handle,
1197 GEOSWKTReader* reader);
1198 extern GEOSGeometry GEOS_DLL *GEOSWKTReader_read_r(GEOSContextHandle_t handle,
1199 GEOSWKTReader* reader,
1200 const char *wkt);
1202 /* WKT Writer */
1203 extern GEOSWKTWriter GEOS_DLL *GEOSWKTWriter_create();
1204 extern void GEOS_DLL GEOSWKTWriter_destroy(GEOSWKTWriter* writer);
1205 extern char GEOS_DLL *GEOSWKTWriter_write(GEOSWKTWriter* reader, const GEOSGeometry* g);
1206 extern void GEOS_DLL GEOSWKTWriter_setTrim(GEOSWKTWriter *writer, char trim);
1207 extern void GEOS_DLL GEOSWKTWriter_setRoundingPrecision(GEOSWKTWriter *writer, int precision);
1208 extern void GEOS_DLL GEOSWKTWriter_setOutputDimension(GEOSWKTWriter *writer, int dim);
1209 extern int GEOS_DLL GEOSWKTWriter_getOutputDimension(GEOSWKTWriter *writer);
1210 extern void GEOS_DLL GEOSWKTWriter_setOld3D(GEOSWKTWriter *writer, int useOld3D);
1212 extern GEOSWKTWriter GEOS_DLL *GEOSWKTWriter_create_r(
1213 GEOSContextHandle_t handle);
1214 extern void GEOS_DLL GEOSWKTWriter_destroy_r(GEOSContextHandle_t handle,
1215 GEOSWKTWriter* writer);
1216 extern char GEOS_DLL *GEOSWKTWriter_write_r(GEOSContextHandle_t handle,
1217 GEOSWKTWriter* reader,
1218 const GEOSGeometry* g);
1219 extern void GEOS_DLL GEOSWKTWriter_setTrim_r(GEOSContextHandle_t handle,
1220 GEOSWKTWriter *writer,
1221 char trim);
1222 extern void GEOS_DLL GEOSWKTWriter_setRoundingPrecision_r(GEOSContextHandle_t handle,
1223 GEOSWKTWriter *writer,
1224 int precision);
1225 extern void GEOS_DLL GEOSWKTWriter_setOutputDimension_r(GEOSContextHandle_t handle,
1226 GEOSWKTWriter *writer,
1227 int dim);
1228 extern int GEOS_DLL GEOSWKTWriter_getOutputDimension_r(GEOSContextHandle_t handle,
1229 GEOSWKTWriter *writer);
1230 extern void GEOS_DLL GEOSWKTWriter_setOld3D_r(GEOSContextHandle_t handle,
1231 GEOSWKTWriter *writer,
1232 int useOld3D);
1234 /* WKB Reader */
1235 extern GEOSWKBReader GEOS_DLL *GEOSWKBReader_create();
1236 extern void GEOS_DLL GEOSWKBReader_destroy(GEOSWKBReader* reader);
1237 extern GEOSGeometry GEOS_DLL *GEOSWKBReader_read(GEOSWKBReader* reader, const unsigned char *wkb, size_t size);
1238 extern GEOSGeometry GEOS_DLL *GEOSWKBReader_readHEX(GEOSWKBReader* reader, const unsigned char *hex, size_t size);
1240 extern GEOSWKBReader GEOS_DLL *GEOSWKBReader_create_r(
1241 GEOSContextHandle_t handle);
1242 extern void GEOS_DLL GEOSWKBReader_destroy_r(GEOSContextHandle_t handle,
1243 GEOSWKBReader* reader);
1244 extern GEOSGeometry GEOS_DLL *GEOSWKBReader_read_r(GEOSContextHandle_t handle,
1245 GEOSWKBReader* reader,
1246 const unsigned char *wkb,
1247 size_t size);
1248 extern GEOSGeometry GEOS_DLL *GEOSWKBReader_readHEX_r(
1249 GEOSContextHandle_t handle,
1250 GEOSWKBReader* reader,
1251 const unsigned char *hex,
1252 size_t size);
1254 /* WKB Writer */
1255 extern GEOSWKBWriter GEOS_DLL *GEOSWKBWriter_create();
1256 extern void GEOS_DLL GEOSWKBWriter_destroy(GEOSWKBWriter* writer);
1258 extern GEOSWKBWriter GEOS_DLL *GEOSWKBWriter_create_r(
1259 GEOSContextHandle_t handle);
1260 extern void GEOS_DLL GEOSWKBWriter_destroy_r(GEOSContextHandle_t handle,
1261 GEOSWKBWriter* writer);
1263 /* The caller owns the results for these two methods! */
1264 extern unsigned char GEOS_DLL *GEOSWKBWriter_write(GEOSWKBWriter* writer, const GEOSGeometry* g, size_t *size);
1265 extern unsigned char GEOS_DLL *GEOSWKBWriter_writeHEX(GEOSWKBWriter* writer, const GEOSGeometry* g, size_t *size);
1267 extern unsigned char GEOS_DLL *GEOSWKBWriter_write_r(
1268 GEOSContextHandle_t handle,
1269 GEOSWKBWriter* writer,
1270 const GEOSGeometry* g,
1271 size_t *size);
1272 extern unsigned char GEOS_DLL *GEOSWKBWriter_writeHEX_r(
1273 GEOSContextHandle_t handle,
1274 GEOSWKBWriter* writer,
1275 const GEOSGeometry* g,
1276 size_t *size);
1279 * Specify whether output WKB should be 2d or 3d.
1280 * Return previously set number of dimensions.
1282 extern int GEOS_DLL GEOSWKBWriter_getOutputDimension(const GEOSWKBWriter* writer);
1283 extern void GEOS_DLL GEOSWKBWriter_setOutputDimension(GEOSWKBWriter* writer, int newDimension);
1285 extern int GEOS_DLL GEOSWKBWriter_getOutputDimension_r(
1286 GEOSContextHandle_t handle,
1287 const GEOSWKBWriter* writer);
1288 extern void GEOS_DLL GEOSWKBWriter_setOutputDimension_r(
1289 GEOSContextHandle_t handle,
1290 GEOSWKBWriter* writer, int newDimension);
1293 * Specify whether the WKB byte order is big or little endian.
1294 * The return value is the previous byte order.
1296 extern int GEOS_DLL GEOSWKBWriter_getByteOrder(const GEOSWKBWriter* writer);
1297 extern void GEOS_DLL GEOSWKBWriter_setByteOrder(GEOSWKBWriter* writer, int byteOrder);
1299 extern int GEOS_DLL GEOSWKBWriter_getByteOrder_r(GEOSContextHandle_t handle,
1300 const GEOSWKBWriter* writer);
1301 extern void GEOS_DLL GEOSWKBWriter_setByteOrder_r(GEOSContextHandle_t handle,
1302 GEOSWKBWriter* writer,
1303 int byteOrder);
1306 * Specify whether SRID values should be output.
1308 extern char GEOS_DLL GEOSWKBWriter_getIncludeSRID(const GEOSWKBWriter* writer);
1309 extern void GEOS_DLL GEOSWKBWriter_setIncludeSRID(GEOSWKBWriter* writer, const char writeSRID);
1311 extern char GEOS_DLL GEOSWKBWriter_getIncludeSRID_r(GEOSContextHandle_t handle,
1312 const GEOSWKBWriter* writer);
1313 extern void GEOS_DLL GEOSWKBWriter_setIncludeSRID_r(GEOSContextHandle_t handle,
1314 GEOSWKBWriter* writer, const char writeSRID);
1318 * Free buffers returned by stuff like GEOSWKBWriter_write(),
1319 * GEOSWKBWriter_writeHEX() and GEOSWKTWriter_write().
1321 extern void GEOS_DLL GEOSFree( void *buffer );
1322 extern void GEOS_DLL GEOSFree_r( GEOSContextHandle_t handle, void *buffer );
1324 #ifdef __cplusplus
1325 } // extern "C"
1326 #endif
1328 #endif /* #ifndef GEOS_C_H_INCLUDED */