GEOS 3.4.2

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