GEOS: geos_c.h Source File

GEOS 3.5.0

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

geos_c.h
1 /************************************************************************
2 *
3 *
4 * C-Wrapper for GEOS library
5 *
6 * Copyright (C) 2010 2011 Sandro Santilli <strk@keybit.net>
7 * Copyright (C) 2005 Refractions Research Inc.
8 *
9 * This is free software; you can redistribute and/or modify it under
10 * the terms of the GNU Lesser General Public Licence as published
11 * by the Free Software Foundation.
12 * See the COPYING file for more information.
13 *
14 * Author: Sandro Santilli <strk@keybit.net>
15 *
16 ***********************************************************************
17 *
18 * GENERAL NOTES:
19 *
20 * - Remember to call initGEOS() before any use of this library's
21 * functions, and call finishGEOS() when done.
22 *
23 * - Currently you have to explicitly GEOSGeom_destroy() all
24 * GEOSGeom objects to avoid memory leaks, and to GEOSFree()
25 * all returned char * (unless const).
26 *
27 * - Functions ending with _r are thread safe; see details in RFC 3
28 * http://trac.osgeo.org/geos/wiki/RFC3.
29 * To avoid using by accident non _r functions,
30 * define GEOS_USE_ONLY_R_API before including geos_c.h
31 *
32 ***********************************************************************/
33
34 #ifndef GEOS_C_H_INCLUDED
35 #define GEOS_C_H_INCLUDED
36
37 #ifndef __cplusplus
38 # include <stddef.h> /* for size_t definition */
39 #else
40 # include <cstddef>
41 using std::size_t;
42 #endif
43
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47
48 /************************************************************************
49 *
50 * Version
51 *
52 ***********************************************************************/
53
54 /*
55 * Following 'ifdef' hack fixes problem with generating geos_c.h on Windows,
56 * when building with Visual C++ compiler.
57 *
58 */
59 #if defined(_MSC_VER)
60 #include <geos/version.h>
61 #define GEOS_CAPI_VERSION_MAJOR 1
62 #define GEOS_CAPI_VERSION_MINOR 9
63 #define GEOS_CAPI_VERSION_PATCH 0
64 #define GEOS_CAPI_VERSION "3.5.0-CAPI-1.9.0"
65 #else
66 #ifndef GEOS_VERSION_MAJOR
67 #define GEOS_VERSION_MAJOR 3
68 #endif
69 #ifndef GEOS_VERSION_MINOR
70 #define GEOS_VERSION_MINOR 5
71 #endif
72 #ifndef GEOS_VERSION_PATCH
73 #define GEOS_VERSION_PATCH 0
74 #endif
75 #ifndef GEOS_VERSION
76 #define GEOS_VERSION "3.5.0"
77 #endif
78 #ifndef GEOS_JTS_PORT
79 #define GEOS_JTS_PORT "1.13.0"
80 #endif
81
82 #define GEOS_CAPI_VERSION_MAJOR 1
83 #define GEOS_CAPI_VERSION_MINOR 9
84 #define GEOS_CAPI_VERSION_PATCH 0
85 #define GEOS_CAPI_VERSION "3.5.0-CAPI-1.9.0"
86 #endif
87
88 #define GEOS_CAPI_FIRST_INTERFACE GEOS_CAPI_VERSION_MAJOR
89 #define GEOS_CAPI_LAST_INTERFACE (GEOS_CAPI_VERSION_MAJOR+GEOS_CAPI_VERSION_MINOR)
90
91 /************************************************************************
92 *
93 * (Abstract) type definitions
94 *
95 ************************************************************************/
96
97 typedef struct GEOSContextHandle_HS *GEOSContextHandle_t;
98
99 typedef void (*GEOSMessageHandler)(const char *fmt, ...);
100
101 /*
102 * A GEOS message handler function.
103 *
104 * @param message the message contents
105 * @param userdata the user data pointer that was passed to GEOS when registering this message handler.
106 *
107 *
108 * @see GEOSContext_setErrorMessageHandler
109 * @see GEOSContext_setNoticeMessageHandler
110 */
111 typedef void (*GEOSMessageHandler_r)(const char *message, void *userdata);
112
113 /* When we're included by geos_c.cpp, those are #defined to the original
114 * JTS definitions via preprocessor. We don't touch them to allow the
115 * compiler to cross-check the declarations. However, for all "normal"
116 * C-API users, we need to define them as "opaque" struct pointers, as
117 * those clients don't have access to the original C++ headers, by design.
118 */
119 #ifndef GEOSGeometry
120 typedef struct GEOSGeom_t GEOSGeometry;
121 typedef struct GEOSPrepGeom_t GEOSPreparedGeometry;
122 typedef struct GEOSCoordSeq_t GEOSCoordSequence;
123 typedef struct GEOSSTRtree_t GEOSSTRtree;
124 typedef struct GEOSBufParams_t GEOSBufferParams;
125 #endif
126
127 /* Those are compatibility definitions for source compatibility
128 * with GEOS 2.X clients relying on that type.
129 */
130 typedef GEOSGeometry* GEOSGeom;
131 typedef GEOSCoordSequence* GEOSCoordSeq;
132
133 /* Supported geometry types
134 * This was renamed from GEOSGeomTypeId in GEOS 2.2.X, which might
135 * break compatibility, this issue is still under investigation.
136 */
137
138 enum GEOSGeomTypes {
139 GEOS_POINT,
140 GEOS_LINESTRING,
141 GEOS_LINEARRING,
142 GEOS_POLYGON,
143 GEOS_MULTIPOINT,
144 GEOS_MULTILINESTRING,
145 GEOS_MULTIPOLYGON,
146 GEOS_GEOMETRYCOLLECTION
147 };
148
149 /* Byte oders exposed via the c api */
150 enum GEOSByteOrders {
151 GEOS_WKB_XDR = 0, /* Big Endian */
152 GEOS_WKB_NDR = 1 /* Little Endian */
153 };
154
155 typedef void (*GEOSQueryCallback)(void *item, void *userdata);
156
157 /************************************************************************
158 *
159 * Initialization, cleanup, version
160 *
161 ***********************************************************************/
162
163 #include <geos/export.h>
164
165 /*
166 * Register an interruption checking callback
167 *
168 * The callback will be invoked _before_ checking for
169 * interruption, so can be used to request it.
170 */
171 typedef void (GEOSInterruptCallback)();
172 extern GEOSInterruptCallback GEOS_DLL *GEOS_interruptRegisterCallback(GEOSInterruptCallback* cb);
173 /* Request safe interruption of operations */
174 extern void GEOS_DLL GEOS_interruptRequest();
175 /* Cancel a pending interruption request */
176 extern void GEOS_DLL GEOS_interruptCancel();
177
178 /*
179 * @deprecated in 3.5.0
180 * initialize using GEOS_init_r() and set the message handlers using
181 * GEOSContext_setNoticeHandler_r and/or GEOSContext_setErrorHandler_r
182 */
183 extern GEOSContextHandle_t GEOS_DLL initGEOS_r(
184 GEOSMessageHandler notice_function,
185 GEOSMessageHandler error_function);
186 /*
187 * @deprecated in 3.5.0 replaced by GEOS_finish_r.
188 */
189 extern void GEOS_DLL finishGEOS_r(GEOSContextHandle_t handle);
190
191 extern GEOSContextHandle_t GEOS_DLL GEOS_init_r();
192 extern void GEOS_DLL GEOS_finish_r(GEOSContextHandle_t handle);
193
194
195 extern GEOSMessageHandler GEOS_DLL GEOSContext_setNoticeHandler_r(GEOSContextHandle_t extHandle,
196 GEOSMessageHandler nf);
197 extern GEOSMessageHandler GEOS_DLL GEOSContext_setErrorHandler_r(GEOSContextHandle_t extHandle,
198 GEOSMessageHandler ef);
199
200 /*
201 * Sets a notice message handler on the given GEOS context.
202 *
203 * @param extHandle the GEOS context
204 * @param nf the message handler
205 * @param userData optional user data pointer that will be passed to the message handler
206 *
207 * @return the previously configured message handler or NULL if no message handler was configured
208 */
209 extern GEOSMessageHandler_r GEOS_DLL GEOSContext_setNoticeMessageHandler_r(GEOSContextHandle_t extHandle,
210 GEOSMessageHandler_r nf,
211 void *userData);
212
213 /*
214 * Sets an error message handler on the given GEOS context.
215 *
216 * @param extHandle the GEOS context
217 * @param ef the message handler
218 * @param userData optional user data pointer that will be passed to the message handler
219 *
220 * @return the previously configured message handler or NULL if no message handler was configured
221 */
222 extern GEOSMessageHandler_r GEOS_DLL GEOSContext_setErrorMessageHandler_r(GEOSContextHandle_t extHandle,
223 GEOSMessageHandler_r ef,
224 void *userData);
225
226 extern const char GEOS_DLL *GEOSversion();
227
228
229 /************************************************************************
230 *
231 * NOTE - These functions are DEPRECATED. Please use the new Reader and
232 * writer APIS!
233 *
234 ***********************************************************************/
235
236 extern GEOSGeometry GEOS_DLL *GEOSGeomFromWKT_r(GEOSContextHandle_t handle,
237 const char *wkt);
238 extern char GEOS_DLL *GEOSGeomToWKT_r(GEOSContextHandle_t handle,
239 const GEOSGeometry* g);
240
241 /*
242 * Specify whether output WKB should be 2d or 3d.
243 * Return previously set number of dimensions.
244 */
245
246 extern int GEOS_DLL GEOS_getWKBOutputDims_r(GEOSContextHandle_t handle);
247 extern int GEOS_DLL GEOS_setWKBOutputDims_r(GEOSContextHandle_t handle,
248 int newDims);
249
250 /*
251 * Specify whether the WKB byte order is big or little endian.
252 * The return value is the previous byte order.
253 */
254
255 extern int GEOS_DLL GEOS_getWKBByteOrder_r(GEOSContextHandle_t handle);
256 extern int GEOS_DLL GEOS_setWKBByteOrder_r(GEOSContextHandle_t handle,
257 int byteOrder);
258
259 extern GEOSGeometry GEOS_DLL *GEOSGeomFromWKB_buf_r(GEOSContextHandle_t handle,
260 const unsigned char *wkb,
261 size_t size);
262 extern unsigned char GEOS_DLL *GEOSGeomToWKB_buf_r(GEOSContextHandle_t handle,
263 const GEOSGeometry* g,
264 size_t *size);
265
266 extern GEOSGeometry GEOS_DLL *GEOSGeomFromHEX_buf_r(GEOSContextHandle_t handle,
267 const unsigned char *hex,
268 size_t size);
269 extern unsigned char GEOS_DLL *GEOSGeomToHEX_buf_r(GEOSContextHandle_t handle,
270 const GEOSGeometry* g,
271 size_t *size);
272
273 /************************************************************************
274 *
275 * Coordinate Sequence functions
276 *
277 ***********************************************************************/
278
279 /*
280 * Create a Coordinate sequence with ``size'' coordinates
281 * of ``dims'' dimensions.
282 * Return NULL on exception.
283 */
284 extern GEOSCoordSequence GEOS_DLL *GEOSCoordSeq_create_r(
285 GEOSContextHandle_t handle,
286 unsigned int size,
287 unsigned int dims);
288
289 /*
290 * Clone a Coordinate Sequence.
291 * Return NULL on exception.
292 */
293 extern GEOSCoordSequence GEOS_DLL *GEOSCoordSeq_clone_r(
294 GEOSContextHandle_t handle,
295 const GEOSCoordSequence* s);
296
297 /*
298 * Destroy a Coordinate Sequence.
299 */
300 extern void GEOS_DLL GEOSCoordSeq_destroy_r(GEOSContextHandle_t handle,
301 GEOSCoordSequence* s);
302
303 /*
304 * Set ordinate values in a Coordinate Sequence.
305 * Return 0 on exception.
306 */
307 extern int GEOS_DLL GEOSCoordSeq_setX_r(GEOSContextHandle_t handle,
308 GEOSCoordSequence* s, unsigned int idx,
309 double val);
310 extern int GEOS_DLL GEOSCoordSeq_setY_r(GEOSContextHandle_t handle,
311 GEOSCoordSequence* s, unsigned int idx,
312 double val);
313 extern int GEOS_DLL GEOSCoordSeq_setZ_r(GEOSContextHandle_t handle,
314 GEOSCoordSequence* s, unsigned int idx,
315 double val);
316 extern int GEOS_DLL GEOSCoordSeq_setOrdinate_r(GEOSContextHandle_t handle,
317 GEOSCoordSequence* s,
318 unsigned int idx,
319 unsigned int dim, double val);
320
321 /*
322 * Get ordinate values from a Coordinate Sequence.
323 * Return 0 on exception.
324 */
325 extern int GEOS_DLL GEOSCoordSeq_getX_r(GEOSContextHandle_t handle,
326 const GEOSCoordSequence* s,
327 unsigned int idx, double *val);
328 extern int GEOS_DLL GEOSCoordSeq_getY_r(GEOSContextHandle_t handle,
329 const GEOSCoordSequence* s,
330 unsigned int idx, double *val);
331 extern int GEOS_DLL GEOSCoordSeq_getZ_r(GEOSContextHandle_t handle,
332 const GEOSCoordSequence* s,
333 unsigned int idx, double *val);
334 extern int GEOS_DLL GEOSCoordSeq_getOrdinate_r(GEOSContextHandle_t handle,
335 const GEOSCoordSequence* s,
336 unsigned int idx,
337 unsigned int dim, double *val);
338 /*
339 * Get size and dimensions info from a Coordinate Sequence.
340 * Return 0 on exception.
341 */
342 extern int GEOS_DLL GEOSCoordSeq_getSize_r(GEOSContextHandle_t handle,
343 const GEOSCoordSequence* s,
344 unsigned int *size);
345 extern int GEOS_DLL GEOSCoordSeq_getDimensions_r(GEOSContextHandle_t handle,
346 const GEOSCoordSequence* s,
347 unsigned int *dims);
348
349 /************************************************************************
350 *
351 * Linear referencing functions -- there are more, but these are
352 * probably sufficient for most purposes
353 *
354 ***********************************************************************/
355
356 /*
357 * GEOSGeometry ownership is retained by caller
358 */
359
360
361 /* Return distance of point 'p' projected on 'g' from origin
362 * of 'g'. Geometry 'g' must be a lineal geometry */
363 extern double GEOS_DLL GEOSProject_r(GEOSContextHandle_t handle,
364 const GEOSGeometry *g,
365 const GEOSGeometry *p);
366
367 /* Return closest point to given distance within geometry
368 * Geometry must be a LineString */
369 extern GEOSGeometry GEOS_DLL *GEOSInterpolate_r(GEOSContextHandle_t handle,
370 const GEOSGeometry *g,
371 double d);
372
373 extern double GEOS_DLL GEOSProjectNormalized_r(GEOSContextHandle_t handle,
374 const GEOSGeometry *g,
375 const GEOSGeometry *p);
376
377 extern GEOSGeometry GEOS_DLL *GEOSInterpolateNormalized_r(
378 GEOSContextHandle_t handle,
379 const GEOSGeometry *g,
380 double d);
381
382 /************************************************************************
383 *
384 * Buffer related functions
385 *
386 ***********************************************************************/
387
388
389 /* @return NULL on exception */
390 extern GEOSGeometry GEOS_DLL *GEOSBuffer_r(GEOSContextHandle_t handle,
391 const GEOSGeometry* g,
392 double width, int quadsegs);
393
394 enum GEOSBufCapStyles {
395 GEOSBUF_CAP_ROUND=1,
396 GEOSBUF_CAP_FLAT=2,
397 GEOSBUF_CAP_SQUARE=3
398 };
399
400 enum GEOSBufJoinStyles {
401 GEOSBUF_JOIN_ROUND=1,
402 GEOSBUF_JOIN_MITRE=2,
403 GEOSBUF_JOIN_BEVEL=3
404 };
405
406 /* @return 0 on exception */
407 extern GEOSBufferParams GEOS_DLL *GEOSBufferParams_create_r(
408 GEOSContextHandle_t handle);
409 extern void GEOS_DLL GEOSBufferParams_destroy_r(
410 GEOSContextHandle_t handle,
411 GEOSBufferParams* parms);
412
413 /* @return 0 on exception */
414 extern int GEOS_DLL GEOSBufferParams_setEndCapStyle_r(
415 GEOSContextHandle_t handle,
416 GEOSBufferParams* p,
417 int style);
418
419 /* @return 0 on exception */
420 extern int GEOS_DLL GEOSBufferParams_setJoinStyle_r(
421 GEOSContextHandle_t handle,
422 GEOSBufferParams* p,
423 int joinStyle);
424
425 /* @return 0 on exception */
426 extern int GEOS_DLL GEOSBufferParams_setMitreLimit_r(
427 GEOSContextHandle_t handle,
428 GEOSBufferParams* p,
429 double mitreLimit);
430
431 /* @return 0 on exception */
432 extern int GEOS_DLL GEOSBufferParams_setQuadrantSegments_r(
433 GEOSContextHandle_t handle,
434 GEOSBufferParams* p,
435 int quadSegs);
436
437 /* @param singleSided: 1 for single sided, 0 otherwise */
438 /* @return 0 on exception */
439 extern int GEOS_DLL GEOSBufferParams_setSingleSided_r(
440 GEOSContextHandle_t handle,
441 GEOSBufferParams* p,
442 int singleSided);
443
444 /* @return NULL on exception */
445 extern GEOSGeometry GEOS_DLL *GEOSBufferWithParams_r(
446 GEOSContextHandle_t handle,
447 const GEOSGeometry* g,
448 const GEOSBufferParams* p,
449 double width);
450
451 /* These functions return NULL on exception. */
452 extern GEOSGeometry GEOS_DLL *GEOSBufferWithStyle_r(GEOSContextHandle_t handle,
453 const GEOSGeometry* g, double width, int quadsegs, int endCapStyle,
454 int joinStyle, double mitreLimit);
455
456 /* These functions return NULL on exception. Only LINESTRINGs are accepted. */
457 /* @deprecated in 3.3.0: use GEOSOffsetCurve instead */
458 extern GEOSGeometry GEOS_DLL *GEOSSingleSidedBuffer_r(
459 GEOSContextHandle_t handle,
460 const GEOSGeometry* g, double width, int quadsegs,
461 int joinStyle, double mitreLimit, int leftSide);
462
463 /*
464 * Only LINESTRINGs are accepted.
465 * @param width : offset distance.
466 * negative for right side offset.
467 * positive for left side offset.
468 * @return NULL on exception
469 */
470 extern GEOSGeometry GEOS_DLL *GEOSOffsetCurve_r(GEOSContextHandle_t handle,
471 const GEOSGeometry* g, double width, int quadsegs,
472 int joinStyle, double mitreLimit);
473
474
475 /************************************************************************
476 *
477 * Geometry Constructors.
478 * GEOSCoordSequence* arguments will become ownership of the returned object.
479 * All functions return NULL on exception.
480 *
481 ***********************************************************************/
482
483 extern GEOSGeometry GEOS_DLL *GEOSGeom_createPoint_r(
484 GEOSContextHandle_t handle,
485 GEOSCoordSequence* s);
486 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyPoint_r(
487 GEOSContextHandle_t handle);
488 extern GEOSGeometry GEOS_DLL *GEOSGeom_createLinearRing_r(
489 GEOSContextHandle_t handle,
490 GEOSCoordSequence* s);
491 extern GEOSGeometry GEOS_DLL *GEOSGeom_createLineString_r(
492 GEOSContextHandle_t handle,
493 GEOSCoordSequence* s);
494 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyLineString_r(
495 GEOSContextHandle_t handle);
496
497 /*
498 * Second argument is an array of GEOSGeometry* objects.
499 * The caller remains owner of the array, but pointed-to
500 * objects become ownership of the returned GEOSGeometry.
501 */
502 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyPolygon_r(
503 GEOSContextHandle_t handle);
504 extern GEOSGeometry GEOS_DLL *GEOSGeom_createPolygon_r(
505 GEOSContextHandle_t handle,
506 GEOSGeometry* shell,
507 GEOSGeometry** holes,
508 unsigned int nholes);
509 extern GEOSGeometry GEOS_DLL *GEOSGeom_createCollection_r(
510 GEOSContextHandle_t handle, int type,
511 GEOSGeometry* *geoms,
512 unsigned int ngeoms);
513 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyCollection_r(
514 GEOSContextHandle_t handle, int type);
515
516 extern GEOSGeometry GEOS_DLL *GEOSGeom_clone_r(GEOSContextHandle_t handle,
517 const GEOSGeometry* g);
518
519 /************************************************************************
520 *
521 * Memory management
522 *
523 ***********************************************************************/
524
525 extern void GEOS_DLL GEOSGeom_destroy_r(GEOSContextHandle_t handle,
526 GEOSGeometry* g);
527
528 /************************************************************************
529 *
530 * Topology operations - return NULL on exception.
531 *
532 ***********************************************************************/
533
534 extern GEOSGeometry GEOS_DLL *GEOSEnvelope_r(GEOSContextHandle_t handle,
535 const GEOSGeometry* g);
536 extern GEOSGeometry GEOS_DLL *GEOSIntersection_r(GEOSContextHandle_t handle,
537 const GEOSGeometry* g1,
538 const GEOSGeometry* g2);
539 extern GEOSGeometry GEOS_DLL *GEOSConvexHull_r(GEOSContextHandle_t handle,
540 const GEOSGeometry* g);
541 extern GEOSGeometry GEOS_DLL *GEOSDifference_r(GEOSContextHandle_t handle,
542 const GEOSGeometry* g1,
543 const GEOSGeometry* g2);
544 extern GEOSGeometry GEOS_DLL *GEOSSymDifference_r(GEOSContextHandle_t handle,
545 const GEOSGeometry* g1,
546 const GEOSGeometry* g2);
547 extern GEOSGeometry GEOS_DLL *GEOSBoundary_r(GEOSContextHandle_t handle,
548 const GEOSGeometry* g);
549 extern GEOSGeometry GEOS_DLL *GEOSUnion_r(GEOSContextHandle_t handle,
550 const GEOSGeometry* g1,
551 const GEOSGeometry* g2);
552 extern GEOSGeometry GEOS_DLL *GEOSUnaryUnion_r(GEOSContextHandle_t handle,
553 const GEOSGeometry* g);
554 /* @deprecated in 3.3.0: use GEOSUnaryUnion_r instead */
555 extern GEOSGeometry GEOS_DLL *GEOSUnionCascaded_r(GEOSContextHandle_t handle,
556 const GEOSGeometry* g);
557 extern GEOSGeometry GEOS_DLL *GEOSPointOnSurface_r(GEOSContextHandle_t handle,
558 const GEOSGeometry* g);
559 extern GEOSGeometry GEOS_DLL *GEOSGetCentroid_r(GEOSContextHandle_t handle,
560 const GEOSGeometry* g);
561 extern GEOSGeometry GEOS_DLL *GEOSNode_r(GEOSContextHandle_t handle,
562 const GEOSGeometry* g);
563 /* Fast, non-robust intersection between an arbitrary geometry and
564 * a rectangle. The returned geometry may be invalid. */
565 extern GEOSGeometry GEOS_DLL *GEOSClipByRect_r(GEOSContextHandle_t handle,
566 const GEOSGeometry* g,
567 double xmin, double ymin,
568 double xmax, double ymax);
569
570 /*
571 * all arguments remain ownership of the caller
572 * (both Geometries and pointers)
573 */
574 /*
575 * Polygonizes a set of Geometries which contain linework that
576 * represents the edges of a planar graph.
577 *
578 * Any dimension of Geometry is handled - the constituent linework
579 * is extracted to form the edges.
580 *
581 * The edges must be correctly noded; that is, they must only meet
582 * at their endpoints.
583 * The Polygonizer will still run on incorrectly noded input
584 * but will not form polygons from incorrectly noded edges.
585 *
586 * The Polygonizer reports the follow kinds of errors:
587 *
588 * - Dangles - edges which have one or both ends which are
589 * not incident on another edge endpoint
590 * - Cut Edges - edges which are connected at both ends but
591 * which do not form part of polygon
592 * - Invalid Ring Lines - edges which form rings which are invalid
593 * (e.g. the component lines contain a self-intersection)
594 *
595 * Errors are reported to output parameters "cuts", "dangles" and
596 * "invalid" (if not-null). Formed polygons are returned as a
597 * collection. NULL is returned on exception. All returned
598 * geometries must be destroyed by caller.
599 *
600 */
601
602 extern GEOSGeometry GEOS_DLL *GEOSPolygonize_r(GEOSContextHandle_t handle,
603 const GEOSGeometry *const geoms[],
604 unsigned int ngeoms);
605 extern GEOSGeometry GEOS_DLL *GEOSPolygonizer_getCutEdges_r(
606 GEOSContextHandle_t handle,
607 const GEOSGeometry * const geoms[],
608 unsigned int ngeoms);
609 extern GEOSGeometry GEOS_DLL *GEOSPolygonize_full_r(GEOSContextHandle_t handle,
610 const GEOSGeometry* input, GEOSGeometry** cuts,
611 GEOSGeometry** dangles, GEOSGeometry** invalidRings);
612
613 extern GEOSGeometry GEOS_DLL *GEOSLineMerge_r(GEOSContextHandle_t handle,
614 const GEOSGeometry* g);
615 extern GEOSGeometry GEOS_DLL *GEOSSimplify_r(GEOSContextHandle_t handle,
616 const GEOSGeometry* g,
617 double tolerance);
618 extern GEOSGeometry GEOS_DLL *GEOSTopologyPreserveSimplify_r(
619 GEOSContextHandle_t handle,
620 const GEOSGeometry* g, double tolerance);
621
622 /*
623 * Return all distinct vertices of input geometry as a MULTIPOINT.
624 * Note that only 2 dimensions of the vertices are considered when
625 * testing for equality.
626 */
627 extern GEOSGeometry GEOS_DLL *GEOSGeom_extractUniquePoints_r(
628 GEOSContextHandle_t handle,
629 const GEOSGeometry* g);
630
631 /*
632 * Find paths shared between the two given lineal geometries.
633 *
634 * Returns a GEOMETRYCOLLECTION having two elements:
635 * - first element is a MULTILINESTRING containing shared paths
636 * having the _same_ direction on both inputs
637 * - second element is a MULTILINESTRING containing shared paths
638 * having the _opposite_ direction on the two inputs
639 *
640 * Returns NULL on exception
641 */
642 extern GEOSGeometry GEOS_DLL *GEOSSharedPaths_r(GEOSContextHandle_t handle,
643 const GEOSGeometry* g1, const GEOSGeometry* g2);
644
645 /*
646 * Snap first geometry on to second with given tolerance
647 * Returns a newly allocated geometry, or NULL on exception
648 */
649 extern GEOSGeometry GEOS_DLL *GEOSSnap_r(GEOSContextHandle_t handle,
650 const GEOSGeometry* g1, const GEOSGeometry* g2, double tolerance);
651
652 /*
653 * Return a Delaunay triangulation of the vertex of the given geometry
654 *
655 * @param g the input geometry whose vertex will be used as "sites"
656 * @param tolerance optional snapping tolerance to use for improved robustness
657 * @param onlyEdges if non-zero will return a MULTILINESTRING, otherwise it will
658 * return a GEOMETRYCOLLECTION containing triangular POLYGONs.
659 *
660 * @return a newly allocated geometry, or NULL on exception
661 */
662 extern GEOSGeometry GEOS_DLL * GEOSDelaunayTriangulation_r(
663 GEOSContextHandle_t handle,
664 const GEOSGeometry *g,
665 double tolerance,
666 int onlyEdges);
667
668 /*
669 * Returns the Voronoi polygons of a set of Vertices given as input
670 *
671 * @param g the input geometry whose vertex will be used as sites.
672 * @param tolerance snapping tolerance to use for improved robustness
673 * @param onlyEdges whether to return only edges of the voronoi cells
674 * @param env clipping envelope for the returned diagram, automatically
675 * determined if NULL.
676 * The diagram will be clipped to the larger
677 * of this envelope or an envelope surrounding the sites.
678 *
679 * @return a newly allocated geometry, or NULL on exception.
680 */
681 extern GEOSGeometry GEOS_DLL * GEOSVoronoiDiagram_r(
682 GEOSContextHandle_t extHandle,
683 const GEOSGeometry *g,
684 const GEOSGeometry *env,
685 double tolerance,
686 int onlyEdges);
687
688
689 /************************************************************************
690 *
691 * Binary predicates - return 2 on exception, 1 on true, 0 on false
692 *
693 ***********************************************************************/
694
695 extern char GEOS_DLL GEOSDisjoint_r(GEOSContextHandle_t handle,
696 const GEOSGeometry* g1,
697 const GEOSGeometry* g2);
698 extern char GEOS_DLL GEOSTouches_r(GEOSContextHandle_t handle,
699 const GEOSGeometry* g1,
700 const GEOSGeometry* g2);
701 extern char GEOS_DLL GEOSIntersects_r(GEOSContextHandle_t handle,
702 const GEOSGeometry* g1,
703 const GEOSGeometry* g2);
704 extern char GEOS_DLL GEOSCrosses_r(GEOSContextHandle_t handle,
705 const GEOSGeometry* g1,
706 const GEOSGeometry* g2);
707 extern char GEOS_DLL GEOSWithin_r(GEOSContextHandle_t handle,
708 const GEOSGeometry* g1,
709 const GEOSGeometry* g2);
710 extern char GEOS_DLL GEOSContains_r(GEOSContextHandle_t handle,
711 const GEOSGeometry* g1,
712 const GEOSGeometry* g2);
713 extern char GEOS_DLL GEOSOverlaps_r(GEOSContextHandle_t handle,
714 const GEOSGeometry* g1,
715 const GEOSGeometry* g2);
716 extern char GEOS_DLL GEOSEquals_r(GEOSContextHandle_t handle,
717 const GEOSGeometry* g1,
718 const GEOSGeometry* g2);
719 extern char GEOS_DLL GEOSEqualsExact_r(GEOSContextHandle_t handle,
720 const GEOSGeometry* g1,
721 const GEOSGeometry* g2,
722 double tolerance);
723 extern char GEOS_DLL GEOSCovers_r(GEOSContextHandle_t handle,
724 const GEOSGeometry* g1,
725 const GEOSGeometry* g2);
726 extern char GEOS_DLL GEOSCoveredBy_r(GEOSContextHandle_t handle,
727 const GEOSGeometry* g1,
728 const GEOSGeometry* g2);
729
730 /************************************************************************
731 *
732 * Prepared Geometry Binary predicates - return 2 on exception, 1 on true, 0 on false
733 *
734 ***********************************************************************/
735
736 /*
737 * GEOSGeometry ownership is retained by caller
738 */
739 extern const GEOSPreparedGeometry GEOS_DLL *GEOSPrepare_r(
740 GEOSContextHandle_t handle,
741 const GEOSGeometry* g);
742
743 extern void GEOS_DLL GEOSPreparedGeom_destroy_r(GEOSContextHandle_t handle,
744 const GEOSPreparedGeometry* g);
745
746 extern char GEOS_DLL GEOSPreparedContains_r(GEOSContextHandle_t handle,
747 const GEOSPreparedGeometry* pg1,
748 const GEOSGeometry* g2);
749 extern char GEOS_DLL GEOSPreparedContainsProperly_r(GEOSContextHandle_t handle,
750 const GEOSPreparedGeometry* pg1,
751 const GEOSGeometry* g2);
752 extern char GEOS_DLL GEOSPreparedCoveredBy_r(GEOSContextHandle_t handle,
753 const GEOSPreparedGeometry* pg1,
754 const GEOSGeometry* g2);
755 extern char GEOS_DLL GEOSPreparedCovers_r(GEOSContextHandle_t handle,
756 const GEOSPreparedGeometry* pg1,
757 const GEOSGeometry* g2);
758 extern char GEOS_DLL GEOSPreparedCrosses_r(GEOSContextHandle_t handle,
759 const GEOSPreparedGeometry* pg1,
760 const GEOSGeometry* g2);
761 extern char GEOS_DLL GEOSPreparedDisjoint_r(GEOSContextHandle_t handle,
762 const GEOSPreparedGeometry* pg1,
763 const GEOSGeometry* g2);
764 extern char GEOS_DLL GEOSPreparedIntersects_r(GEOSContextHandle_t handle,
765 const GEOSPreparedGeometry* pg1,
766 const GEOSGeometry* g2);
767 extern char GEOS_DLL GEOSPreparedOverlaps_r(GEOSContextHandle_t handle,
768 const GEOSPreparedGeometry* pg1,
769 const GEOSGeometry* g2);
770 extern char GEOS_DLL GEOSPreparedTouches_r(GEOSContextHandle_t handle,
771 const GEOSPreparedGeometry* pg1,
772 const GEOSGeometry* g2);
773 extern char GEOS_DLL GEOSPreparedWithin_r(GEOSContextHandle_t handle,
774 const GEOSPreparedGeometry* pg1,
775 const GEOSGeometry* g2);
776
777 /************************************************************************
778 *
779 * STRtree functions
780 *
781 ***********************************************************************/
782
783 /*
784 * GEOSGeometry ownership is retained by caller
785 */
786
787 extern GEOSSTRtree GEOS_DLL *GEOSSTRtree_create_r(
788 GEOSContextHandle_t handle,
789 size_t nodeCapacity);
790 extern void GEOS_DLL GEOSSTRtree_insert_r(GEOSContextHandle_t handle,
791 GEOSSTRtree *tree,
792 const GEOSGeometry *g,
793 void *item);
794 extern void GEOS_DLL GEOSSTRtree_query_r(GEOSContextHandle_t handle,
795 GEOSSTRtree *tree,
796 const GEOSGeometry *g,
797 GEOSQueryCallback callback,
798 void *userdata);
799 extern void GEOS_DLL GEOSSTRtree_iterate_r(GEOSContextHandle_t handle,
800 GEOSSTRtree *tree,
801 GEOSQueryCallback callback,
802 void *userdata);
803 extern char GEOS_DLL GEOSSTRtree_remove_r(GEOSContextHandle_t handle,
804 GEOSSTRtree *tree,
805 const GEOSGeometry *g,
806 void *item);
807 extern void GEOS_DLL GEOSSTRtree_destroy_r(GEOSContextHandle_t handle,
808 GEOSSTRtree *tree);
809
810
811 /************************************************************************
812 *
813 * Unary predicate - return 2 on exception, 1 on true, 0 on false
814 *
815 ***********************************************************************/
816
817 extern char GEOS_DLL GEOSisEmpty_r(GEOSContextHandle_t handle,
818 const GEOSGeometry* g);
819 extern char GEOS_DLL GEOSisSimple_r(GEOSContextHandle_t handle,
820 const GEOSGeometry* g);
821 extern char GEOS_DLL GEOSisRing_r(GEOSContextHandle_t handle,
822 const GEOSGeometry* g);
823 extern char GEOS_DLL GEOSHasZ_r(GEOSContextHandle_t handle,
824 const GEOSGeometry* g);
825 extern char GEOS_DLL GEOSisClosed_r(GEOSContextHandle_t handle,
826 const GEOSGeometry *g);
827
828 /************************************************************************
829 *
830 * Dimensionally Extended 9 Intersection Model related
831 *
832 ***********************************************************************/
833
834 /* These are for use with GEOSRelateBoundaryNodeRule (flags param) */
835 enum GEOSRelateBoundaryNodeRules {
836 /* MOD2 and OGC are the same rule, and is the default
837 * used by GEOSRelatePattern
838 */
839 GEOSRELATE_BNR_MOD2=1,
840 GEOSRELATE_BNR_OGC=1,
841 GEOSRELATE_BNR_ENDPOINT=2,
842 GEOSRELATE_BNR_MULTIVALENT_ENDPOINT=3,
843 GEOSRELATE_BNR_MONOVALENT_ENDPOINT=4
844 };
845
846 /* return 2 on exception, 1 on true, 0 on false */
847 extern char GEOS_DLL GEOSRelatePattern_r(GEOSContextHandle_t handle,
848 const GEOSGeometry* g1,
849 const GEOSGeometry* g2,
850 const char *pat);
851
852 /* return NULL on exception, a string to GEOSFree otherwise */
853 extern char GEOS_DLL *GEOSRelate_r(GEOSContextHandle_t handle,
854 const GEOSGeometry* g1,
855 const GEOSGeometry* g2);
856
857 /* return 2 on exception, 1 on true, 0 on false */
858 extern char GEOS_DLL GEOSRelatePatternMatch_r(GEOSContextHandle_t handle,
859 const char *mat,
860 const char *pat);
861
862 /* return NULL on exception, a string to GEOSFree otherwise */
863 extern char GEOS_DLL *GEOSRelateBoundaryNodeRule_r(GEOSContextHandle_t handle,
864 const GEOSGeometry* g1,
865 const GEOSGeometry* g2,
866 int bnr);
867
868 /************************************************************************
869 *
870 * Validity checking
871 *
872 ***********************************************************************/
873
874 /* These are for use with GEOSisValidDetail (flags param) */
875 enum GEOSValidFlags {
876 GEOSVALID_ALLOW_SELFTOUCHING_RING_FORMING_HOLE=1
877 };
878
879 /* return 2 on exception, 1 on true, 0 on false */
880 extern char GEOS_DLL GEOSisValid_r(GEOSContextHandle_t handle,
881 const GEOSGeometry* g);
882
883 /* return NULL on exception, a string to GEOSFree otherwise */
884 extern char GEOS_DLL *GEOSisValidReason_r(GEOSContextHandle_t handle,
885 const GEOSGeometry* g);
886
887 /*
888 * Caller has the responsibility to destroy 'reason' (GEOSFree)
889 * and 'location' (GEOSGeom_destroy) params
890 * return 2 on exception, 1 when valid, 0 when invalid
891 */
892 extern char GEOS_DLL GEOSisValidDetail_r(GEOSContextHandle_t handle,
893 const GEOSGeometry* g,
894 int flags,
895 char** reason,
896 GEOSGeometry** location);
897
898 /************************************************************************
899 *
900 * Geometry info
901 *
902 ***********************************************************************/
903
904 /* Return NULL on exception, result must be freed by caller. */
905 extern char GEOS_DLL *GEOSGeomType_r(GEOSContextHandle_t handle,
906 const GEOSGeometry* g);
907
908 /* Return -1 on exception */
909 extern int GEOS_DLL GEOSGeomTypeId_r(GEOSContextHandle_t handle,
910 const GEOSGeometry* g);
911
912 /* Return 0 on exception */
913 extern int GEOS_DLL GEOSGetSRID_r(GEOSContextHandle_t handle,
914 const GEOSGeometry* g);
915
916 extern void GEOS_DLL GEOSSetSRID_r(GEOSContextHandle_t handle,
917 GEOSGeometry* g, int SRID);
918
919 /* May be called on all geometries in GEOS 3.x, returns -1 on error and 1
920 * for non-multi geometries. Older GEOS versions only accept
921 * GeometryCollections or Multi* geometries here, and are likely to crash
922 * when fed simple geometries, so beware if you need compatibility with
923 * old GEOS versions.
924 */
925 extern int GEOS_DLL GEOSGetNumGeometries_r(GEOSContextHandle_t handle,
926 const GEOSGeometry* g);
927
928 /*
929 * Return NULL on exception.
930 * Returned object is a pointer to internal storage:
931 * it must NOT be destroyed directly.
932 * Up to GEOS 3.2.0 the input geometry must be a Collection, in
933 * later version it doesn't matter (getGeometryN(0) for a single will
934 * return the input).
935 */
936 extern const GEOSGeometry GEOS_DLL *GEOSGetGeometryN_r(
937 GEOSContextHandle_t handle,
938 const GEOSGeometry* g, int n);
939
940 /* Return -1 on exception */
941 extern int GEOS_DLL GEOSNormalize_r(GEOSContextHandle_t handle,
942 GEOSGeometry* g);
943
944 /* Return -1 on exception */
945 extern int GEOS_DLL GEOSGetNumInteriorRings_r(GEOSContextHandle_t handle,
946 const GEOSGeometry* g);
947
948 /* Return -1 on exception, Geometry must be a LineString. */
949 extern int GEOS_DLL GEOSGeomGetNumPoints_r(GEOSContextHandle_t handle,
950 const GEOSGeometry* g);
951
952 /* Return -1 on exception, Geometry must be a Point. */
953 extern int GEOS_DLL GEOSGeomGetX_r(GEOSContextHandle_t handle, const GEOSGeometry *g, double *x);
954 extern int GEOS_DLL GEOSGeomGetY_r(GEOSContextHandle_t handle, const GEOSGeometry *g, double *y);
955
956 /*
957 * Return NULL on exception, Geometry must be a Polygon.
958 * Returned object is a pointer to internal storage:
959 * it must NOT be destroyed directly.
960 */
961 extern const GEOSGeometry GEOS_DLL *GEOSGetInteriorRingN_r(
962 GEOSContextHandle_t handle,
963 const GEOSGeometry* g, int n);
964
965 /*
966 * Return NULL on exception, Geometry must be a Polygon.
967 * Returned object is a pointer to internal storage:
968 * it must NOT be destroyed directly.
969 */
970 extern const GEOSGeometry GEOS_DLL *GEOSGetExteriorRing_r(
971 GEOSContextHandle_t handle,
972 const GEOSGeometry* g);
973
974 /* Return -1 on exception */
975 extern int GEOS_DLL GEOSGetNumCoordinates_r(GEOSContextHandle_t handle,
976 const GEOSGeometry* g);
977
978 /*
979 * Return NULL on exception.
980 * Geometry must be a LineString, LinearRing or Point.
981 */
982 extern const GEOSCoordSequence GEOS_DLL *GEOSGeom_getCoordSeq_r(
983 GEOSContextHandle_t handle,
984 const GEOSGeometry* g);
985
986 /*
987 * Return 0 on exception (or empty geometry)
988 */
989 extern int GEOS_DLL GEOSGeom_getDimensions_r(GEOSContextHandle_t handle,
990 const GEOSGeometry* g);
991
992 /*
993 * Return 2 or 3.
994 */
995 extern int GEOS_DLL GEOSGeom_getCoordinateDimension_r(GEOSContextHandle_t handle,
996 const GEOSGeometry* g);
997
998 /*
999 * Return NULL on exception.
1000 * Must be LineString and must be freed by called.
1001 */
1002 extern GEOSGeometry GEOS_DLL *GEOSGeomGetPointN_r(GEOSContextHandle_t handle, const GEOSGeometry *g, int n);
1003 extern GEOSGeometry GEOS_DLL *GEOSGeomGetStartPoint_r(GEOSContextHandle_t handle, const GEOSGeometry *g);
1004 extern GEOSGeometry GEOS_DLL *GEOSGeomGetEndPoint_r(GEOSContextHandle_t handle, const GEOSGeometry *g);
1005
1006 /************************************************************************
1007 *
1008 * Misc functions
1009 *
1010 ***********************************************************************/
1011
1012 /* Return 0 on exception, 1 otherwise */
1013 extern int GEOS_DLL GEOSArea_r(GEOSContextHandle_t handle,
1014 const GEOSGeometry* g, double *area);
1015 extern int GEOS_DLL GEOSLength_r(GEOSContextHandle_t handle,
1016 const GEOSGeometry* g, double *length);
1017 extern int GEOS_DLL GEOSDistance_r(GEOSContextHandle_t handle,
1018 const GEOSGeometry* g1,
1019 const GEOSGeometry* g2, double *dist);
1020 extern int GEOS_DLL GEOSHausdorffDistance_r(GEOSContextHandle_t handle,
1021 const GEOSGeometry *g1,
1022 const GEOSGeometry *g2,
1023 double *dist);
1024 extern int GEOS_DLL GEOSHausdorffDistanceDensify_r(GEOSContextHandle_t handle,
1025 const GEOSGeometry *g1,
1026 const GEOSGeometry *g2,
1027 double densifyFrac, double *dist);
1028 extern int GEOS_DLL GEOSGeomGetLength_r(GEOSContextHandle_t handle,
1029 const GEOSGeometry *g, double *length);
1030
1031 /* Return 0 on exception, the closest points of the two geometries otherwise.
1032 * The first point comes from g1 geometry and the second point comes from g2.
1033 */
1034 extern GEOSCoordSequence GEOS_DLL *GEOSNearestPoints_r(
1035 GEOSContextHandle_t handle, const GEOSGeometry* g1, const GEOSGeometry* g2);
1036
1037
1038 /************************************************************************
1039 *
1040 * Algorithms
1041 *
1042 ***********************************************************************/
1043
1044 /* Walking from A to B:
1045 * return -1 if reaching P takes a counter-clockwise (left) turn
1046 * return 1 if reaching P takes a clockwise (right) turn
1047 * return 0 if P is collinear with A-B
1048 *
1049 * On exceptions, return 2.
1050 *
1051 */
1052 extern int GEOS_DLL GEOSOrientationIndex_r(GEOSContextHandle_t handle,
1053 double Ax, double Ay, double Bx, double By, double Px, double Py);
1054
1055
1056 /************************************************************************
1057 *
1058 * Reader and Writer APIs
1059 *
1060 ***********************************************************************/
1061
1062 typedef struct GEOSWKTReader_t GEOSWKTReader;
1063 typedef struct GEOSWKTWriter_t GEOSWKTWriter;
1064 typedef struct GEOSWKBReader_t GEOSWKBReader;
1065 typedef struct GEOSWKBWriter_t GEOSWKBWriter;
1066
1067
1068 /* WKT Reader */
1069 extern GEOSWKTReader GEOS_DLL *GEOSWKTReader_create_r(
1070 GEOSContextHandle_t handle);
1071 extern void GEOS_DLL GEOSWKTReader_destroy_r(GEOSContextHandle_t handle,
1072 GEOSWKTReader* reader);
1073 extern GEOSGeometry GEOS_DLL *GEOSWKTReader_read_r(GEOSContextHandle_t handle,
1074 GEOSWKTReader* reader,
1075 const char *wkt);
1076
1077 /* WKT Writer */
1078 extern GEOSWKTWriter GEOS_DLL *GEOSWKTWriter_create_r(
1079 GEOSContextHandle_t handle);
1080 extern void GEOS_DLL GEOSWKTWriter_destroy_r(GEOSContextHandle_t handle,
1081 GEOSWKTWriter* writer);
1082 extern char GEOS_DLL *GEOSWKTWriter_write_r(GEOSContextHandle_t handle,
1083 GEOSWKTWriter* writer,
1084 const GEOSGeometry* g);
1085 extern void GEOS_DLL GEOSWKTWriter_setTrim_r(GEOSContextHandle_t handle,
1086 GEOSWKTWriter *writer,
1087 char trim);
1088 extern void GEOS_DLL GEOSWKTWriter_setRoundingPrecision_r(GEOSContextHandle_t handle,
1089 GEOSWKTWriter *writer,
1090 int precision);
1091 extern void GEOS_DLL GEOSWKTWriter_setOutputDimension_r(GEOSContextHandle_t handle,
1092 GEOSWKTWriter *writer,
1093 int dim);
1094 extern int GEOS_DLL GEOSWKTWriter_getOutputDimension_r(GEOSContextHandle_t handle,
1095 GEOSWKTWriter *writer);
1096 extern void GEOS_DLL GEOSWKTWriter_setOld3D_r(GEOSContextHandle_t handle,
1097 GEOSWKTWriter *writer,
1098 int useOld3D);
1099
1100 /* WKB Reader */
1101 extern GEOSWKBReader GEOS_DLL *GEOSWKBReader_create_r(
1102 GEOSContextHandle_t handle);
1103 extern void GEOS_DLL GEOSWKBReader_destroy_r(GEOSContextHandle_t handle,
1104 GEOSWKBReader* reader);
1105 extern GEOSGeometry GEOS_DLL *GEOSWKBReader_read_r(GEOSContextHandle_t handle,
1106 GEOSWKBReader* reader,
1107 const unsigned char *wkb,
1108 size_t size);
1109 extern GEOSGeometry GEOS_DLL *GEOSWKBReader_readHEX_r(
1110 GEOSContextHandle_t handle,
1111 GEOSWKBReader* reader,
1112 const unsigned char *hex,
1113 size_t size);
1114
1115 /* WKB Writer */
1116 extern GEOSWKBWriter GEOS_DLL *GEOSWKBWriter_create_r(
1117 GEOSContextHandle_t handle);
1118 extern void GEOS_DLL GEOSWKBWriter_destroy_r(GEOSContextHandle_t handle,
1119 GEOSWKBWriter* writer);
1120
1121 /* The caller owns the results for these two methods! */
1122 extern unsigned char GEOS_DLL *GEOSWKBWriter_write_r(
1123 GEOSContextHandle_t handle,
1124 GEOSWKBWriter* writer,
1125 const GEOSGeometry* g,
1126 size_t *size);
1127 extern unsigned char GEOS_DLL *GEOSWKBWriter_writeHEX_r(
1128 GEOSContextHandle_t handle,
1129 GEOSWKBWriter* writer,
1130 const GEOSGeometry* g,
1131 size_t *size);
1132
1133 /*
1134 * Specify whether output WKB should be 2d or 3d.
1135 * Return previously set number of dimensions.
1136 */
1137 extern int GEOS_DLL GEOSWKBWriter_getOutputDimension_r(
1138 GEOSContextHandle_t handle,
1139 const GEOSWKBWriter* writer);
1140 extern void GEOS_DLL GEOSWKBWriter_setOutputDimension_r(
1141 GEOSContextHandle_t handle,
1142 GEOSWKBWriter* writer, int newDimension);
1143
1144 /*
1145 * Specify whether the WKB byte order is big or little endian.
1146 * The return value is the previous byte order.
1147 */
1148 extern int GEOS_DLL GEOSWKBWriter_getByteOrder_r(GEOSContextHandle_t handle,
1149 const GEOSWKBWriter* writer);
1150 extern void GEOS_DLL GEOSWKBWriter_setByteOrder_r(GEOSContextHandle_t handle,
1151 GEOSWKBWriter* writer,
1152 int byteOrder);
1153
1154 /*
1155 * Specify whether SRID values should be output.
1156 */
1157 extern char GEOS_DLL GEOSWKBWriter_getIncludeSRID_r(GEOSContextHandle_t handle,
1158 const GEOSWKBWriter* writer);
1159 extern void GEOS_DLL GEOSWKBWriter_setIncludeSRID_r(GEOSContextHandle_t handle,
1160 GEOSWKBWriter* writer, const char writeSRID);
1161
1162
1163 /*
1164 * Free buffers returned by stuff like GEOSWKBWriter_write(),
1165 * GEOSWKBWriter_writeHEX() and GEOSWKTWriter_write().
1166 */
1167 extern void GEOS_DLL GEOSFree_r(GEOSContextHandle_t handle, void *buffer);
1168
1169
1170 /* External code to GEOS can define GEOS_USE_ONLY_R_API to avoid the */
1171 /* non _r API to be available */
1172 #ifndef GEOS_USE_ONLY_R_API
1173
1174 /************************************************************************
1175 *
1176 * Initialization, cleanup, version
1177 *
1178 ***********************************************************************/
1179
1180 extern void GEOS_DLL initGEOS(GEOSMessageHandler notice_function,
1181 GEOSMessageHandler error_function);
1182 extern void GEOS_DLL finishGEOS(void);
1183
1184 /************************************************************************
1185 *
1186 * NOTE - These functions are DEPRECATED. Please use the new Reader and
1187 * writer APIS!
1188 *
1189 ***********************************************************************/
1190
1191 extern GEOSGeometry GEOS_DLL *GEOSGeomFromWKT(const char *wkt);
1192 extern char GEOS_DLL *GEOSGeomToWKT(const GEOSGeometry* g);
1193
1194 /*
1195 * Specify whether output WKB should be 2d or 3d.
1196 * Return previously set number of dimensions.
1197 */
1198 extern int GEOS_DLL GEOS_getWKBOutputDims();
1199 extern int GEOS_DLL GEOS_setWKBOutputDims(int newDims);
1200
1201 /*
1202 * Specify whether the WKB byte order is big or little endian.
1203 * The return value is the previous byte order.
1204 */
1205 extern int GEOS_DLL GEOS_getWKBByteOrder();
1206 extern int GEOS_DLL GEOS_setWKBByteOrder(int byteOrder);
1207
1208 extern GEOSGeometry GEOS_DLL *GEOSGeomFromWKB_buf(const unsigned char *wkb, size_t size);
1209 extern unsigned char GEOS_DLL *GEOSGeomToWKB_buf(const GEOSGeometry* g, size_t *size);
1210
1211 extern GEOSGeometry GEOS_DLL *GEOSGeomFromHEX_buf(const unsigned char *hex, size_t size);
1212 extern unsigned char GEOS_DLL *GEOSGeomToHEX_buf(const GEOSGeometry* g, size_t *size);
1213
1214 /************************************************************************
1215 *
1216 * Coordinate Sequence functions
1217 *
1218 ***********************************************************************/
1219
1220 /*
1221 * Create a Coordinate sequence with ``size'' coordinates
1222 * of ``dims'' dimensions.
1223 * Return NULL on exception.
1224 */
1225 extern GEOSCoordSequence GEOS_DLL *GEOSCoordSeq_create(unsigned int size, unsigned int dims);
1226
1227 /*
1228 * Clone a Coordinate Sequence.
1229 * Return NULL on exception.
1230 */
1231 extern GEOSCoordSequence GEOS_DLL *GEOSCoordSeq_clone(const GEOSCoordSequence* s);
1232
1233 /*
1234 * Destroy a Coordinate Sequence.
1235 */
1236 extern void GEOS_DLL GEOSCoordSeq_destroy(GEOSCoordSequence* s);
1237
1238 /*
1239 * Set ordinate values in a Coordinate Sequence.
1240 * Return 0 on exception.
1241 */
1242 extern int GEOS_DLL GEOSCoordSeq_setX(GEOSCoordSequence* s,
1243 unsigned int idx, double val);
1244 extern int GEOS_DLL GEOSCoordSeq_setY(GEOSCoordSequence* s,
1245 unsigned int idx, double val);
1246 extern int GEOS_DLL GEOSCoordSeq_setZ(GEOSCoordSequence* s,
1247 unsigned int idx, double val);
1248 extern int GEOS_DLL GEOSCoordSeq_setOrdinate(GEOSCoordSequence* s,
1249 unsigned int idx, unsigned int dim, double val);
1250
1251 /*
1252 * Get ordinate values from a Coordinate Sequence.
1253 * Return 0 on exception.
1254 */
1255 extern int GEOS_DLL GEOSCoordSeq_getX(const GEOSCoordSequence* s,
1256 unsigned int idx, double *val);
1257 extern int GEOS_DLL GEOSCoordSeq_getY(const GEOSCoordSequence* s,
1258 unsigned int idx, double *val);
1259 extern int GEOS_DLL GEOSCoordSeq_getZ(const GEOSCoordSequence* s,
1260 unsigned int idx, double *val);
1261 extern int GEOS_DLL GEOSCoordSeq_getOrdinate(const GEOSCoordSequence* s,
1262 unsigned int idx, unsigned int dim, double *val);
1263 /*
1264 * Get size and dimensions info from a Coordinate Sequence.
1265 * Return 0 on exception.
1266 */
1267 extern int GEOS_DLL GEOSCoordSeq_getSize(const GEOSCoordSequence* s,
1268 unsigned int *size);
1269 extern int GEOS_DLL GEOSCoordSeq_getDimensions(const GEOSCoordSequence* s,
1270 unsigned int *dims);
1271
1272 /************************************************************************
1273 *
1274 * Linear referencing functions -- there are more, but these are
1275 * probably sufficient for most purposes
1276 *
1277 ***********************************************************************/
1278
1279 /*
1280 * GEOSGeometry ownership is retained by caller
1281 */
1282
1283
1284 /* Return distance of point 'p' projected on 'g' from origin
1285 * of 'g'. Geometry 'g' must be a lineal geometry */
1286 extern double GEOS_DLL GEOSProject(const GEOSGeometry *g,
1287 const GEOSGeometry* p);
1288
1289 /* Return closest point to given distance within geometry
1290 * Geometry must be a LineString */
1291 extern GEOSGeometry GEOS_DLL *GEOSInterpolate(const GEOSGeometry *g,
1292 double d);
1293
1294 extern double GEOS_DLL GEOSProjectNormalized(const GEOSGeometry *g,
1295 const GEOSGeometry* p);
1296
1297 extern GEOSGeometry GEOS_DLL *GEOSInterpolateNormalized(const GEOSGeometry *g,
1298 double d);
1299
1300 /************************************************************************
1301 *
1302 * Buffer related functions
1303 *
1304 ***********************************************************************/
1305
1306
1307 /* @return NULL on exception */
1308 extern GEOSGeometry GEOS_DLL *GEOSBuffer(const GEOSGeometry* g,
1309 double width, int quadsegs);
1310
1311 /* @return 0 on exception */
1312 extern GEOSBufferParams GEOS_DLL *GEOSBufferParams_create();
1313 extern void GEOS_DLL GEOSBufferParams_destroy(GEOSBufferParams* parms);
1314
1315 /* @return 0 on exception */
1316 extern int GEOS_DLL GEOSBufferParams_setEndCapStyle(
1317 GEOSBufferParams* p,
1318 int style);
1319
1320 /* @return 0 on exception */
1321 extern int GEOS_DLL GEOSBufferParams_setJoinStyle(
1322 GEOSBufferParams* p,
1323 int joinStyle);
1324
1325 /* @return 0 on exception */
1326 extern int GEOS_DLL GEOSBufferParams_setMitreLimit(
1327 GEOSBufferParams* p,
1328 double mitreLimit);
1329
1330 /* @return 0 on exception */
1331 extern int GEOS_DLL GEOSBufferParams_setQuadrantSegments(
1332 GEOSBufferParams* p,
1333 int quadSegs);
1334
1335 /* @param singleSided: 1 for single sided, 0 otherwise */
1336 /* @return 0 on exception */
1337 extern int GEOS_DLL GEOSBufferParams_setSingleSided(
1338 GEOSBufferParams* p,
1339 int singleSided);
1340
1341 /* @return NULL on exception */
1342 extern GEOSGeometry GEOS_DLL *GEOSBufferWithParams(
1343 const GEOSGeometry* g,
1344 const GEOSBufferParams* p,
1345 double width);
1346
1347 /* These functions return NULL on exception. */
1348 extern GEOSGeometry GEOS_DLL *GEOSBufferWithStyle(const GEOSGeometry* g,
1349 double width, int quadsegs, int endCapStyle, int joinStyle,
1350 double mitreLimit);
1351
1352 /* These functions return NULL on exception. Only LINESTRINGs are accepted. */
1353 /* @deprecated in 3.3.0: use GEOSOffsetCurve instead */
1354 extern GEOSGeometry GEOS_DLL *GEOSSingleSidedBuffer(const GEOSGeometry* g,
1355 double width, int quadsegs, int joinStyle, double mitreLimit,
1356 int leftSide);
1357
1358 /*
1359 * Only LINESTRINGs are accepted.
1360 * @param width : offset distance.
1361 * negative for right side offset.
1362 * positive for left side offset.
1363 * @return NULL on exception
1364 */
1365 extern GEOSGeometry GEOS_DLL *GEOSOffsetCurve(const GEOSGeometry* g,
1366 double width, int quadsegs, int joinStyle, double mitreLimit);
1367
1368 /************************************************************************
1369 *
1370 * Geometry Constructors.
1371 * GEOSCoordSequence* arguments will become ownership of the returned object.
1372 * All functions return NULL on exception.
1373 *
1374 ***********************************************************************/
1375
1376 extern GEOSGeometry GEOS_DLL *GEOSGeom_createPoint(GEOSCoordSequence* s);
1377 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyPoint();
1378 extern GEOSGeometry GEOS_DLL *GEOSGeom_createLinearRing(GEOSCoordSequence* s);
1379 extern GEOSGeometry GEOS_DLL *GEOSGeom_createLineString(GEOSCoordSequence* s);
1380 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyLineString();
1381
1382 /*
1383 * Second argument is an array of GEOSGeometry* objects.
1384 * The caller remains owner of the array, but pointed-to
1385 * objects become ownership of the returned GEOSGeometry.
1386 */
1387 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyPolygon();
1388 extern GEOSGeometry GEOS_DLL *GEOSGeom_createPolygon(GEOSGeometry* shell,
1389 GEOSGeometry** holes, unsigned int nholes);
1390 extern GEOSGeometry GEOS_DLL *GEOSGeom_createCollection(int type,
1391 GEOSGeometry* *geoms, unsigned int ngeoms);
1392 extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyCollection(int type);
1393
1394 extern GEOSGeometry GEOS_DLL *GEOSGeom_clone(const GEOSGeometry* g);
1395
1396 /************************************************************************
1397 *
1398 * Memory management
1399 *
1400 ***********************************************************************/
1401
1402 extern void GEOS_DLL GEOSGeom_destroy(GEOSGeometry* g);
1403
1404 /************************************************************************
1405 *
1406 * Topology operations - return NULL on exception.
1407 *
1408 ***********************************************************************/
1409
1410 extern GEOSGeometry GEOS_DLL *GEOSEnvelope(const GEOSGeometry* g);
1411 extern GEOSGeometry GEOS_DLL *GEOSIntersection(const GEOSGeometry* g1, const GEOSGeometry* g2);
1412 extern GEOSGeometry GEOS_DLL *GEOSConvexHull(const GEOSGeometry* g);
1413 extern GEOSGeometry GEOS_DLL *GEOSDifference(const GEOSGeometry* g1, const GEOSGeometry* g2);
1414 extern GEOSGeometry GEOS_DLL *GEOSSymDifference(const GEOSGeometry* g1, const GEOSGeometry* g2);
1415 extern GEOSGeometry GEOS_DLL *GEOSBoundary(const GEOSGeometry* g);
1416 extern GEOSGeometry GEOS_DLL *GEOSUnion(const GEOSGeometry* g1, const GEOSGeometry* g2);
1417 extern GEOSGeometry GEOS_DLL *GEOSUnaryUnion(const GEOSGeometry* g);
1418
1419 /* @deprecated in 3.3.0: use GEOSUnaryUnion instead */
1420 extern GEOSGeometry GEOS_DLL *GEOSUnionCascaded(const GEOSGeometry* g);
1421 extern GEOSGeometry GEOS_DLL *GEOSPointOnSurface(const GEOSGeometry* g);
1422 extern GEOSGeometry GEOS_DLL *GEOSGetCentroid(const GEOSGeometry* g);
1423 extern GEOSGeometry GEOS_DLL *GEOSNode(const GEOSGeometry* g);
1424 extern GEOSGeometry GEOS_DLL *GEOSClipByRect(const GEOSGeometry* g, double xmin, double ymin, double xmax, double ymax);
1425
1426 /*
1427 * all arguments remain ownership of the caller
1428 * (both Geometries and pointers)
1429 */
1430 extern GEOSGeometry GEOS_DLL *GEOSPolygonize(const GEOSGeometry * const geoms[], unsigned int ngeoms);
1431 extern GEOSGeometry GEOS_DLL *GEOSPolygonizer_getCutEdges(const GEOSGeometry * const geoms[], unsigned int ngeoms);
1432 /*
1433 * Polygonizes a set of Geometries which contain linework that
1434 * represents the edges of a planar graph.
1435 *
1436 * Any dimension of Geometry is handled - the constituent linework
1437 * is extracted to form the edges.
1438 *
1439 * The edges must be correctly noded; that is, they must only meet
1440 * at their endpoints.
1441 * The Polygonizer will still run on incorrectly noded input
1442 * but will not form polygons from incorrectly noded edges.
1443 *
1444 * The Polygonizer reports the follow kinds of errors:
1445 *
1446 * - Dangles - edges which have one or both ends which are
1447 * not incident on another edge endpoint
1448 * - Cut Edges - edges which are connected at both ends but
1449 * which do not form part of polygon
1450 * - Invalid Ring Lines - edges which form rings which are invalid
1451 * (e.g. the component lines contain a self-intersection)
1452 *
1453 * Errors are reported to output parameters "cuts", "dangles" and
1454 * "invalid" (if not-null). Formed polygons are returned as a
1455 * collection. NULL is returned on exception. All returned
1456 * geometries must be destroyed by caller.
1457 *
1458 */
1459 extern GEOSGeometry GEOS_DLL *GEOSPolygonize_full(const GEOSGeometry* input,
1460 GEOSGeometry** cuts, GEOSGeometry** dangles, GEOSGeometry** invalid);
1461
1462 extern GEOSGeometry GEOS_DLL *GEOSLineMerge(const GEOSGeometry* g);
1463 extern GEOSGeometry GEOS_DLL *GEOSSimplify(const GEOSGeometry* g, double tolerance);
1464 extern GEOSGeometry GEOS_DLL *GEOSTopologyPreserveSimplify(const GEOSGeometry* g,
1465 double tolerance);
1466
1467 /*
1468 * Return all distinct vertices of input geometry as a MULTIPOINT.
1469 * Note that only 2 dimensions of the vertices are considered when
1470 * testing for equality.
1471 */
1472 extern GEOSGeometry GEOS_DLL *GEOSGeom_extractUniquePoints(
1473 const GEOSGeometry* g);
1474
1475 /*
1476 * Find paths shared between the two given lineal geometries.
1477 *
1478 * Returns a GEOMETRYCOLLECTION having two elements:
1479 * - first element is a MULTILINESTRING containing shared paths
1480 * having the _same_ direction on both inputs
1481 * - second element is a MULTILINESTRING containing shared paths
1482 * having the _opposite_ direction on the two inputs
1483 *
1484 * Returns NULL on exception
1485 */
1486 extern GEOSGeometry GEOS_DLL *GEOSSharedPaths(const GEOSGeometry* g1,
1487 const GEOSGeometry* g2);
1488
1489 /*
1490 * Snap first geometry on to second with given tolerance
1491 * Returns a newly allocated geometry, or NULL on exception
1492 */
1493 extern GEOSGeometry GEOS_DLL *GEOSSnap(const GEOSGeometry* g1,
1494 const GEOSGeometry* g2, double tolerance);
1495
1496 /*
1497 * Return a Delaunay triangulation of the vertex of the given geometry
1498 *
1499 * @param g the input geometry whose vertex will be used as "sites"
1500 * @param tolerance optional snapping tolerance to use for improved robustness
1501 * @param onlyEdges if non-zero will return a MULTILINESTRING, otherwise it will
1502 * return a GEOMETRYCOLLECTION containing triangular POLYGONs.
1503 *
1504 * @return a newly allocated geometry, or NULL on exception
1505 */
1506 extern GEOSGeometry GEOS_DLL * GEOSDelaunayTriangulation(
1507 const GEOSGeometry *g,
1508 double tolerance,
1509 int onlyEdges);
1510
1511 /*
1512 * Returns the Voronoi polygons of a set of Vertices given as input
1513 *
1514 * @param g the input geometry whose vertex will be used as sites.
1515 * @param tolerance snapping tolerance to use for improved robustness
1516 * @param onlyEdges whether to return only edges of the voronoi cells
1517 * @param env clipping envelope for the returned diagram, automatically
1518 * determined if NULL.
1519 * The diagram will be clipped to the larger
1520 * of this envelope or an envelope surrounding the sites.
1521 *
1522 * @return a newly allocated geometry, or NULL on exception.
1523 */
1524 extern GEOSGeometry GEOS_DLL * GEOSVoronoiDiagram(
1525 const GEOSGeometry *g,
1526 const GEOSGeometry *env,
1527 double tolerance,
1528 int onlyEdges);
1529
1530 /************************************************************************
1531 *
1532 * Binary predicates - return 2 on exception, 1 on true, 0 on false
1533 *
1534 ***********************************************************************/
1535
1536 extern char GEOS_DLL GEOSDisjoint(const GEOSGeometry* g1, const GEOSGeometry* g2);
1537 extern char GEOS_DLL GEOSTouches(const GEOSGeometry* g1, const GEOSGeometry* g2);
1538 extern char GEOS_DLL GEOSIntersects(const GEOSGeometry* g1, const GEOSGeometry* g2);
1539 extern char GEOS_DLL GEOSCrosses(const GEOSGeometry* g1, const GEOSGeometry* g2);
1540 extern char GEOS_DLL GEOSWithin(const GEOSGeometry* g1, const GEOSGeometry* g2);
1541 extern char GEOS_DLL GEOSContains(const GEOSGeometry* g1, const GEOSGeometry* g2);
1542 extern char GEOS_DLL GEOSOverlaps(const GEOSGeometry* g1, const GEOSGeometry* g2);
1543 extern char GEOS_DLL GEOSEquals(const GEOSGeometry* g1, const GEOSGeometry* g2);
1544 extern char GEOS_DLL GEOSEqualsExact(const GEOSGeometry* g1, const GEOSGeometry* g2, double tolerance);
1545 extern char GEOS_DLL GEOSCovers(const GEOSGeometry* g1, const GEOSGeometry* g2);
1546 extern char GEOS_DLL GEOSCoveredBy(const GEOSGeometry* g1, const GEOSGeometry* g2);
1547
1548 /************************************************************************
1549 *
1550 * Prepared Geometry Binary predicates - return 2 on exception, 1 on true, 0 on false
1551 *
1552 ***********************************************************************/
1553
1554 /*
1555 * GEOSGeometry ownership is retained by caller
1556 */
1557 extern const GEOSPreparedGeometry GEOS_DLL *GEOSPrepare(const GEOSGeometry* g);
1558
1559 extern void GEOS_DLL GEOSPreparedGeom_destroy(const GEOSPreparedGeometry* g);
1560
1561 extern char GEOS_DLL GEOSPreparedContains(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
1562 extern char GEOS_DLL GEOSPreparedContainsProperly(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
1563 extern char GEOS_DLL GEOSPreparedCoveredBy(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
1564 extern char GEOS_DLL GEOSPreparedCovers(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
1565 extern char GEOS_DLL GEOSPreparedCrosses(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
1566 extern char GEOS_DLL GEOSPreparedDisjoint(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
1567 extern char GEOS_DLL GEOSPreparedIntersects(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
1568 extern char GEOS_DLL GEOSPreparedOverlaps(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
1569 extern char GEOS_DLL GEOSPreparedTouches(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
1570 extern char GEOS_DLL GEOSPreparedWithin(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
1571
1572 /************************************************************************
1573 *
1574 * STRtree functions
1575 *
1576 ***********************************************************************/
1577
1578 /*
1579 * GEOSGeometry ownership is retained by caller
1580 */
1581
1582 extern GEOSSTRtree GEOS_DLL *GEOSSTRtree_create(size_t nodeCapacity);
1583 extern void GEOS_DLL GEOSSTRtree_insert(GEOSSTRtree *tree,
1584 const GEOSGeometry *g,
1585 void *item);
1586 extern void GEOS_DLL GEOSSTRtree_query(GEOSSTRtree *tree,
1587 const GEOSGeometry *g,
1588 GEOSQueryCallback callback,
1589 void *userdata);
1590 extern void GEOS_DLL GEOSSTRtree_iterate(GEOSSTRtree *tree,
1591 GEOSQueryCallback callback,
1592 void *userdata);
1593 extern char GEOS_DLL GEOSSTRtree_remove(GEOSSTRtree *tree,
1594 const GEOSGeometry *g,
1595 void *item);
1596 extern void GEOS_DLL GEOSSTRtree_destroy(GEOSSTRtree *tree);
1597
1598
1599 /************************************************************************
1600 *
1601 * Unary predicate - return 2 on exception, 1 on true, 0 on false
1602 *
1603 ***********************************************************************/
1604
1605 extern char GEOS_DLL GEOSisEmpty(const GEOSGeometry* g);
1606 extern char GEOS_DLL GEOSisSimple(const GEOSGeometry* g);
1607 extern char GEOS_DLL GEOSisRing(const GEOSGeometry* g);
1608 extern char GEOS_DLL GEOSHasZ(const GEOSGeometry* g);
1609 extern char GEOS_DLL GEOSisClosed(const GEOSGeometry *g);
1610
1611 /************************************************************************
1612 *
1613 * Dimensionally Extended 9 Intersection Model related
1614 *
1615 ***********************************************************************/
1616
1617 /* return 2 on exception, 1 on true, 0 on false */
1618 extern char GEOS_DLL GEOSRelatePattern(const GEOSGeometry* g1, const GEOSGeometry* g2, const char *pat);
1619
1620 /* return NULL on exception, a string to GEOSFree otherwise */
1621 extern char GEOS_DLL *GEOSRelate(const GEOSGeometry* g1, const GEOSGeometry* g2);
1622
1623 /* return 2 on exception, 1 on true, 0 on false */
1624 extern char GEOS_DLL GEOSRelatePatternMatch(const char *mat, const char *pat);
1625
1626 /* return NULL on exception, a string to GEOSFree otherwise */
1627 extern char GEOS_DLL *GEOSRelateBoundaryNodeRule(const GEOSGeometry* g1,
1628 const GEOSGeometry* g2,
1629 int bnr);
1630
1631 /************************************************************************
1632 *
1633 * Validity checking
1634 *
1635 ***********************************************************************/
1636
1637 /* return 2 on exception, 1 on true, 0 on false */
1638 extern char GEOS_DLL GEOSisValid(const GEOSGeometry* g);
1639
1640 /* return NULL on exception, a string to GEOSFree otherwise */
1641 extern char GEOS_DLL *GEOSisValidReason(const GEOSGeometry *g);
1642 /*
1643 * Caller has the responsibility to destroy 'reason' (GEOSFree)
1644 * and 'location' (GEOSGeom_destroy) params
1645 * return 2 on exception, 1 when valid, 0 when invalid
1646 * Use enum GEOSValidFlags values for the flags param.
1647 */
1648 extern char GEOS_DLL GEOSisValidDetail(const GEOSGeometry* g,
1649 int flags,
1650 char** reason, GEOSGeometry** location);
1651
1652 /************************************************************************
1653 *
1654 * Geometry info
1655 *
1656 ***********************************************************************/
1657
1658 /* Return NULL on exception, result must be freed by caller. */
1659 extern char GEOS_DLL *GEOSGeomType(const GEOSGeometry* g);
1660
1661 /* Return -1 on exception */
1662 extern int GEOS_DLL GEOSGeomTypeId(const GEOSGeometry* g);
1663
1664 /* Return 0 on exception */
1665 extern int GEOS_DLL GEOSGetSRID(const GEOSGeometry* g);
1666
1667 extern void GEOS_DLL GEOSSetSRID(GEOSGeometry* g, int SRID);
1668
1669 /* May be called on all geometries in GEOS 3.x, returns -1 on error and 1
1670 * for non-multi geometries. Older GEOS versions only accept
1671 * GeometryCollections or Multi* geometries here, and are likely to crash
1672 * when fed simple geometries, so beware if you need compatibility with
1673 * old GEOS versions.
1674 */
1675 extern int GEOS_DLL GEOSGetNumGeometries(const GEOSGeometry* g);
1676
1677 /*
1678 * Return NULL on exception.
1679 * Returned object is a pointer to internal storage:
1680 * it must NOT be destroyed directly.
1681 * Up to GEOS 3.2.0 the input geometry must be a Collection, in
1682 * later version it doesn't matter (getGeometryN(0) for a single will
1683 * return the input).
1684 */
1685 extern const GEOSGeometry GEOS_DLL *GEOSGetGeometryN(const GEOSGeometry* g, int n);
1686
1687 /* Return -1 on exception */
1688 extern int GEOS_DLL GEOSNormalize(GEOSGeometry* g);
1689
1690 /* Return -1 on exception */
1691 extern int GEOS_DLL GEOSGetNumInteriorRings(const GEOSGeometry* g);
1692
1693 /* Return -1 on exception, Geometry must be a LineString. */
1694 extern int GEOS_DLL GEOSGeomGetNumPoints(const GEOSGeometry* g);
1695
1696 /* Return -1 on exception, Geometry must be a Point. */
1697 extern int GEOS_DLL GEOSGeomGetX(const GEOSGeometry *g, double *x);
1698 extern int GEOS_DLL GEOSGeomGetY(const GEOSGeometry *g, double *y);
1699
1700 /*
1701 * Return NULL on exception, Geometry must be a Polygon.
1702 * Returned object is a pointer to internal storage:
1703 * it must NOT be destroyed directly.
1704 */
1705 extern const GEOSGeometry GEOS_DLL *GEOSGetInteriorRingN(const GEOSGeometry* g, int n);
1706
1707 /*
1708 * Return NULL on exception, Geometry must be a Polygon.
1709 * Returned object is a pointer to internal storage:
1710 * it must NOT be destroyed directly.
1711 */
1712 extern const GEOSGeometry GEOS_DLL *GEOSGetExteriorRing(const GEOSGeometry* g);
1713
1714 /* Return -1 on exception */
1715 extern int GEOS_DLL GEOSGetNumCoordinates(const GEOSGeometry* g);
1716
1717 /*
1718 * Return NULL on exception.
1719 * Geometry must be a LineString, LinearRing or Point.
1720 */
1721 extern const GEOSCoordSequence GEOS_DLL *GEOSGeom_getCoordSeq(const GEOSGeometry* g);
1722
1723 /*
1724 * Return 0 on exception (or empty geometry)
1725 */
1726 extern int GEOS_DLL GEOSGeom_getDimensions(const GEOSGeometry* g);
1727
1728 /*
1729 * Return 2 or 3.
1730 */
1731 extern int GEOS_DLL GEOSGeom_getCoordinateDimension(const GEOSGeometry* g);
1732
1733 /*
1734 * Return NULL on exception.
1735 * Must be LineString and must be freed by called.
1736 */
1737 extern GEOSGeometry GEOS_DLL *GEOSGeomGetPointN(const GEOSGeometry *g, int n);
1738 extern GEOSGeometry GEOS_DLL *GEOSGeomGetStartPoint(const GEOSGeometry *g);
1739 extern GEOSGeometry GEOS_DLL *GEOSGeomGetEndPoint(const GEOSGeometry *g);
1740
1741 /************************************************************************
1742 *
1743 * Misc functions
1744 *
1745 ***********************************************************************/
1746
1747 /* Return 0 on exception, 1 otherwise */
1748 extern int GEOS_DLL GEOSArea(const GEOSGeometry* g, double *area);
1749 extern int GEOS_DLL GEOSLength(const GEOSGeometry* g, double *length);
1750 extern int GEOS_DLL GEOSDistance(const GEOSGeometry* g1, const GEOSGeometry* g2,
1751 double *dist);
1752 extern int GEOS_DLL GEOSHausdorffDistance(const GEOSGeometry *g1,
1753 const GEOSGeometry *g2, double *dist);
1754 extern int GEOS_DLL GEOSHausdorffDistanceDensify(const GEOSGeometry *g1,
1755 const GEOSGeometry *g2, double densifyFrac, double *dist);
1756 extern int GEOS_DLL GEOSGeomGetLength(const GEOSGeometry *g, double *length);
1757
1758 /* Return 0 on exception, the closest points of the two geometries otherwise.
1759 * The first point comes from g1 geometry and the second point comes from g2.
1760 */
1761 extern GEOSCoordSequence GEOS_DLL *GEOSNearestPoints(
1762 const GEOSGeometry* g1, const GEOSGeometry* g2);
1763
1764
1765 /************************************************************************
1766 *
1767 * Algorithms
1768 *
1769 ***********************************************************************/
1770
1771 /* Walking from A to B:
1772 * return -1 if reaching P takes a counter-clockwise (left) turn
1773 * return 1 if reaching P takes a clockwise (right) turn
1774 * return 0 if P is collinear with A-B
1775 *
1776 * On exceptions, return 2.
1777 *
1778 */
1779 extern int GEOS_DLL GEOSOrientationIndex(double Ax, double Ay, double Bx, double By,
1780 double Px, double Py);
1781
1782 /************************************************************************
1783 *
1784 * Reader and Writer APIs
1785 *
1786 ***********************************************************************/
1787
1788 /* WKT Reader */
1789 extern GEOSWKTReader GEOS_DLL *GEOSWKTReader_create();
1790 extern void GEOS_DLL GEOSWKTReader_destroy(GEOSWKTReader* reader);
1791 extern GEOSGeometry GEOS_DLL *GEOSWKTReader_read(GEOSWKTReader* reader, const char *wkt);
1792
1793 /* WKT Writer */
1794 extern GEOSWKTWriter GEOS_DLL *GEOSWKTWriter_create();
1795 extern void GEOS_DLL GEOSWKTWriter_destroy(GEOSWKTWriter* writer);
1796 extern char GEOS_DLL *GEOSWKTWriter_write(GEOSWKTWriter* writer, const GEOSGeometry* g);
1797 extern void GEOS_DLL GEOSWKTWriter_setTrim(GEOSWKTWriter *writer, char trim);
1798 extern void GEOS_DLL GEOSWKTWriter_setRoundingPrecision(GEOSWKTWriter *writer, int precision);
1799 extern void GEOS_DLL GEOSWKTWriter_setOutputDimension(GEOSWKTWriter *writer, int dim);
1800 extern int GEOS_DLL GEOSWKTWriter_getOutputDimension(GEOSWKTWriter *writer);
1801 extern void GEOS_DLL GEOSWKTWriter_setOld3D(GEOSWKTWriter *writer, int useOld3D);
1802
1803 /* WKB Reader */
1804 extern GEOSWKBReader GEOS_DLL *GEOSWKBReader_create();
1805 extern void GEOS_DLL GEOSWKBReader_destroy(GEOSWKBReader* reader);
1806 extern GEOSGeometry GEOS_DLL *GEOSWKBReader_read(GEOSWKBReader* reader, const unsigned char *wkb, size_t size);
1807 extern GEOSGeometry GEOS_DLL *GEOSWKBReader_readHEX(GEOSWKBReader* reader, const unsigned char *hex, size_t size);
1808
1809 /* WKB Writer */
1810 extern GEOSWKBWriter GEOS_DLL *GEOSWKBWriter_create();
1811 extern void GEOS_DLL GEOSWKBWriter_destroy(GEOSWKBWriter* writer);
1812
1813 /* The caller owns the results for these two methods! */
1814 extern unsigned char GEOS_DLL *GEOSWKBWriter_write(GEOSWKBWriter* writer, const GEOSGeometry* g, size_t *size);
1815 extern unsigned char GEOS_DLL *GEOSWKBWriter_writeHEX(GEOSWKBWriter* writer, const GEOSGeometry* g, size_t *size);
1816
1817 /*
1818 * Specify whether output WKB should be 2d or 3d.
1819 * Return previously set number of dimensions.
1820 */
1821 extern int GEOS_DLL GEOSWKBWriter_getOutputDimension(const GEOSWKBWriter* writer);
1822 extern void GEOS_DLL GEOSWKBWriter_setOutputDimension(GEOSWKBWriter* writer, int newDimension);
1823
1824 /*
1825 * Specify whether the WKB byte order is big or little endian.
1826 * The return value is the previous byte order.
1827 */
1828 extern int GEOS_DLL GEOSWKBWriter_getByteOrder(const GEOSWKBWriter* writer);
1829 extern void GEOS_DLL GEOSWKBWriter_setByteOrder(GEOSWKBWriter* writer, int byteOrder);
1830
1831 /*
1832 * Specify whether SRID values should be output.
1833 */
1834 extern char GEOS_DLL GEOSWKBWriter_getIncludeSRID(const GEOSWKBWriter* writer);
1835 extern void GEOS_DLL GEOSWKBWriter_setIncludeSRID(GEOSWKBWriter* writer, const char writeSRID);
1836
1837 /*
1838 * Free buffers returned by stuff like GEOSWKBWriter_write(),
1839 * GEOSWKBWriter_writeHEX() and GEOSWKTWriter_write().
1840 */
1841 extern void GEOS_DLL GEOSFree(void *buffer);
1842
1843 #endif /* #ifndef GEOS_USE_ONLY_R_API */
1844
1845
1846 #ifdef __cplusplus
1847 } // extern "C"
1848 #endif
1849
1850 #endif /* #ifndef GEOS_C_H_INCLUDED */
geos::geom::GEOS_LINESTRING
a linestring
Definition: Geometry.h:69
geos::geom::GEOS_GEOMETRYCOLLECTION
a collection of heterogeneus geometries
Definition: Geometry.h:81
geos::geom::GEOS_MULTILINESTRING
a collection of linestrings
Definition: Geometry.h:77
geos::geom::GEOS_MULTIPOINT
a collection of points
Definition: Geometry.h:75
geos::geom::GEOS_POLYGON
a polygon
Definition: Geometry.h:73
geos::geom::GEOS_LINEARRING
a linear ring (linestring with 1st point == last point)
Definition: Geometry.h:71
geos::geom::GEOS_POINT
a point
Definition: Geometry.h:67
geos::geom::GEOS_MULTIPOLYGON
a collection of polygons
Definition: Geometry.h:79