GEOS 3.3.4

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

- File List

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