forked from libgeos/geos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeos_c.h.in
1398 lines (1207 loc) · 63.2 KB
/
geos_c.h.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/************************************************************************
*
*
* C-Wrapper for GEOS library
*
* Copyright (C) 2010 2011 Sandro Santilli <[email protected]>
* Copyright (C) 2005 Refractions Research Inc.
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU Lesser General Public Licence as published
* by the Free Software Foundation.
* See the COPYING file for more information.
*
* Author: Sandro Santilli <[email protected]>
*
***********************************************************************
*
* GENERAL NOTES:
*
* - Remember to call initGEOS() before any use of this library's
* functions, and call finishGEOS() when done.
*
* - Currently you have to explicitly GEOSGeom_destroy() all
* GEOSGeom objects to avoid memory leaks, and to GEOSFree()
* all returned char * (unless const).
*
* - Functions ending with _r are thread safe; see details in RFC 3
* http://trac.osgeo.org/geos/wiki/RFC3
*
***********************************************************************/
#ifndef GEOS_C_H_INCLUDED
#define GEOS_C_H_INCLUDED
#ifndef __cplusplus
# include <stddef.h> /* for size_t definition */
#else
# include <cstddef>
using std::size_t;
#endif
#ifdef __cplusplus
extern "C" {
#endif
/************************************************************************
*
* Version
*
***********************************************************************/
/*
* Following 'ifdef' hack fixes problem with generating geos_c.h on Windows,
* when building with Visual C++ compiler.
*
*/
#if defined(_MSC_VER)
#include <geos/version.h>
#define GEOS_CAPI_VERSION_MAJOR 1
#define GEOS_CAPI_VERSION_MINOR 9
#define GEOS_CAPI_VERSION_PATCH 0
#define GEOS_CAPI_VERSION "3.5.0-CAPI-1.9.0"
#else
#ifndef GEOS_VERSION_MAJOR
#define GEOS_VERSION_MAJOR @VERSION_MAJOR@
#endif
#ifndef GEOS_VERSION_MINOR
#define GEOS_VERSION_MINOR @VERSION_MINOR@
#endif
#ifndef GEOS_VERSION_PATCH
#define GEOS_VERSION_PATCH @VERSION_PATCH@
#endif
#ifndef GEOS_VERSION
#define GEOS_VERSION "@VERSION@"
#endif
#ifndef GEOS_JTS_PORT
#define GEOS_JTS_PORT "@JTS_PORT@"
#endif
#define GEOS_CAPI_VERSION_MAJOR @CAPI_VERSION_MAJOR@
#define GEOS_CAPI_VERSION_MINOR @CAPI_VERSION_MINOR@
#define GEOS_CAPI_VERSION_PATCH @CAPI_VERSION_PATCH@
#define GEOS_CAPI_VERSION "@VERSION@-CAPI-@CAPI_VERSION@"
#endif
#define GEOS_CAPI_FIRST_INTERFACE GEOS_CAPI_VERSION_MAJOR
#define GEOS_CAPI_LAST_INTERFACE (GEOS_CAPI_VERSION_MAJOR+GEOS_CAPI_VERSION_MINOR)
/************************************************************************
*
* (Abstract) type definitions
*
************************************************************************/
typedef void (*GEOSMessageHandler)(const char *fmt, ...);
/* When we're included by geos_c.cpp, those are #defined to the original
* JTS definitions via preprocessor. We don't touch them to allow the
* compiler to cross-check the declarations. However, for all "normal"
* C-API users, we need to define them as "opaque" struct pointers, as
* those clients don't have access to the original C++ headers, by design.
*/
#ifndef GEOSGeometry
typedef struct GEOSGeom_t GEOSGeometry;
typedef struct GEOSPrepGeom_t GEOSPreparedGeometry;
typedef struct GEOSCoordSeq_t GEOSCoordSequence;
typedef struct GEOSSTRtree_t GEOSSTRtree;
typedef struct GEOSBufParams_t GEOSBufferParams;
#endif
/* Those are compatibility definitions for source compatibility
* with GEOS 2.X clients relying on that type.
*/
typedef GEOSGeometry* GEOSGeom;
typedef GEOSCoordSequence* GEOSCoordSeq;
/* Supported geometry types
* This was renamed from GEOSGeomTypeId in GEOS 2.2.X, which might
* break compatibility, this issue is still under investigation.
*/
enum GEOSGeomTypes {
GEOS_POINT,
GEOS_LINESTRING,
GEOS_LINEARRING,
GEOS_POLYGON,
GEOS_MULTIPOINT,
GEOS_MULTILINESTRING,
GEOS_MULTIPOLYGON,
GEOS_GEOMETRYCOLLECTION
};
/* Byte oders exposed via the c api */
enum GEOSByteOrders {
GEOS_WKB_XDR = 0, /* Big Endian */
GEOS_WKB_NDR = 1 /* Little Endian */
};
typedef struct GEOSContextHandle_HS *GEOSContextHandle_t;
typedef void (*GEOSQueryCallback)(void *item, void *userdata);
/************************************************************************
*
* Initialization, cleanup, version
*
***********************************************************************/
#include <geos/export.h>
extern void GEOS_DLL initGEOS(GEOSMessageHandler notice_function,
GEOSMessageHandler error_function);
extern void GEOS_DLL finishGEOS(void);
/*
* Register an interruption checking callback
*
* The callback will be invoked _before_ checking for
* interruption, so can be used to request it.
*/
typedef void (GEOSInterruptCallback)();
extern GEOSInterruptCallback GEOS_DLL *GEOS_interruptRegisterCallback(GEOSInterruptCallback* cb);
/* Request safe interruption of operations */
extern void GEOS_DLL GEOS_interruptRequest();
/* Cancel a pending interruption request */
extern void GEOS_DLL GEOS_interruptCancel();
extern GEOSContextHandle_t GEOS_DLL initGEOS_r(
GEOSMessageHandler notice_function,
GEOSMessageHandler error_function);
extern void GEOS_DLL finishGEOS_r(GEOSContextHandle_t handle);
extern GEOSMessageHandler GEOS_DLL GEOSContext_setNoticeHandler_r(GEOSContextHandle_t extHandle,
GEOSMessageHandler nf);
extern GEOSMessageHandler GEOS_DLL GEOSContext_setErrorHandler_r(GEOSContextHandle_t extHandle,
GEOSMessageHandler ef);
extern const char GEOS_DLL *GEOSversion();
/************************************************************************
*
* NOTE - These functions are DEPRECATED. Please use the new Reader and
* writer APIS!
*
***********************************************************************/
extern GEOSGeometry GEOS_DLL *GEOSGeomFromWKT(const char *wkt);
extern char GEOS_DLL *GEOSGeomToWKT(const GEOSGeometry* g);
extern GEOSGeometry GEOS_DLL *GEOSGeomFromWKT_r(GEOSContextHandle_t handle,
const char *wkt);
extern char GEOS_DLL *GEOSGeomToWKT_r(GEOSContextHandle_t handle,
const GEOSGeometry* g);
/*
* Specify whether output WKB should be 2d or 3d.
* Return previously set number of dimensions.
*/
extern int GEOS_DLL GEOS_getWKBOutputDims();
extern int GEOS_DLL GEOS_setWKBOutputDims(int newDims);
extern int GEOS_DLL GEOS_getWKBOutputDims_r(GEOSContextHandle_t handle);
extern int GEOS_DLL GEOS_setWKBOutputDims_r(GEOSContextHandle_t handle,
int newDims);
/*
* Specify whether the WKB byte order is big or little endian.
* The return value is the previous byte order.
*/
extern int GEOS_DLL GEOS_getWKBByteOrder();
extern int GEOS_DLL GEOS_setWKBByteOrder(int byteOrder);
extern GEOSGeometry GEOS_DLL *GEOSGeomFromWKB_buf(const unsigned char *wkb, size_t size);
extern unsigned char GEOS_DLL *GEOSGeomToWKB_buf(const GEOSGeometry* g, size_t *size);
extern GEOSGeometry GEOS_DLL *GEOSGeomFromHEX_buf(const unsigned char *hex, size_t size);
extern unsigned char GEOS_DLL *GEOSGeomToHEX_buf(const GEOSGeometry* g, size_t *size);
extern int GEOS_DLL GEOS_getWKBByteOrder_r(GEOSContextHandle_t handle);
extern int GEOS_DLL GEOS_setWKBByteOrder_r(GEOSContextHandle_t handle,
int byteOrder);
extern GEOSGeometry GEOS_DLL *GEOSGeomFromWKB_buf_r(GEOSContextHandle_t handle,
const unsigned char *wkb,
size_t size);
extern unsigned char GEOS_DLL *GEOSGeomToWKB_buf_r(GEOSContextHandle_t handle,
const GEOSGeometry* g,
size_t *size);
extern GEOSGeometry GEOS_DLL *GEOSGeomFromHEX_buf_r(GEOSContextHandle_t handle,
const unsigned char *hex,
size_t size);
extern unsigned char GEOS_DLL *GEOSGeomToHEX_buf_r(GEOSContextHandle_t handle,
const GEOSGeometry* g,
size_t *size);
/************************************************************************
*
* Coordinate Sequence functions
*
***********************************************************************/
/*
* Create a Coordinate sequence with ``size'' coordinates
* of ``dims'' dimensions.
* Return NULL on exception.
*/
extern GEOSCoordSequence GEOS_DLL *GEOSCoordSeq_create(unsigned int size, unsigned int dims);
extern GEOSCoordSequence GEOS_DLL *GEOSCoordSeq_create_r(
GEOSContextHandle_t handle,
unsigned int size,
unsigned int dims);
/*
* Clone a Coordinate Sequence.
* Return NULL on exception.
*/
extern GEOSCoordSequence GEOS_DLL *GEOSCoordSeq_clone(const GEOSCoordSequence* s);
extern GEOSCoordSequence GEOS_DLL *GEOSCoordSeq_clone_r(
GEOSContextHandle_t handle,
const GEOSCoordSequence* s);
/*
* Destroy a Coordinate Sequence.
*/
extern void GEOS_DLL GEOSCoordSeq_destroy(GEOSCoordSequence* s);
extern void GEOS_DLL GEOSCoordSeq_destroy_r(GEOSContextHandle_t handle,
GEOSCoordSequence* s);
/*
* Set ordinate values in a Coordinate Sequence.
* Return 0 on exception.
*/
extern int GEOS_DLL GEOSCoordSeq_setX(GEOSCoordSequence* s,
unsigned int idx, double val);
extern int GEOS_DLL GEOSCoordSeq_setY(GEOSCoordSequence* s,
unsigned int idx, double val);
extern int GEOS_DLL GEOSCoordSeq_setZ(GEOSCoordSequence* s,
unsigned int idx, double val);
extern int GEOS_DLL GEOSCoordSeq_setOrdinate(GEOSCoordSequence* s,
unsigned int idx, unsigned int dim, double val);
extern int GEOS_DLL GEOSCoordSeq_setX_r(GEOSContextHandle_t handle,
GEOSCoordSequence* s, unsigned int idx,
double val);
extern int GEOS_DLL GEOSCoordSeq_setY_r(GEOSContextHandle_t handle,
GEOSCoordSequence* s, unsigned int idx,
double val);
extern int GEOS_DLL GEOSCoordSeq_setZ_r(GEOSContextHandle_t handle,
GEOSCoordSequence* s, unsigned int idx,
double val);
extern int GEOS_DLL GEOSCoordSeq_setOrdinate_r(GEOSContextHandle_t handle,
GEOSCoordSequence* s,
unsigned int idx,
unsigned int dim, double val);
/*
* Get ordinate values from a Coordinate Sequence.
* Return 0 on exception.
*/
extern int GEOS_DLL GEOSCoordSeq_getX(const GEOSCoordSequence* s,
unsigned int idx, double *val);
extern int GEOS_DLL GEOSCoordSeq_getY(const GEOSCoordSequence* s,
unsigned int idx, double *val);
extern int GEOS_DLL GEOSCoordSeq_getZ(const GEOSCoordSequence* s,
unsigned int idx, double *val);
extern int GEOS_DLL GEOSCoordSeq_getOrdinate(const GEOSCoordSequence* s,
unsigned int idx, unsigned int dim, double *val);
extern int GEOS_DLL GEOSCoordSeq_getX_r(GEOSContextHandle_t handle,
const GEOSCoordSequence* s,
unsigned int idx, double *val);
extern int GEOS_DLL GEOSCoordSeq_getY_r(GEOSContextHandle_t handle,
const GEOSCoordSequence* s,
unsigned int idx, double *val);
extern int GEOS_DLL GEOSCoordSeq_getZ_r(GEOSContextHandle_t handle,
const GEOSCoordSequence* s,
unsigned int idx, double *val);
extern int GEOS_DLL GEOSCoordSeq_getOrdinate_r(GEOSContextHandle_t handle,
const GEOSCoordSequence* s,
unsigned int idx,
unsigned int dim, double *val);
/*
* Get size and dimensions info from a Coordinate Sequence.
* Return 0 on exception.
*/
extern int GEOS_DLL GEOSCoordSeq_getSize(const GEOSCoordSequence* s,
unsigned int *size);
extern int GEOS_DLL GEOSCoordSeq_getDimensions(const GEOSCoordSequence* s,
unsigned int *dims);
extern int GEOS_DLL GEOSCoordSeq_getSize_r(GEOSContextHandle_t handle,
const GEOSCoordSequence* s,
unsigned int *size);
extern int GEOS_DLL GEOSCoordSeq_getDimensions_r(GEOSContextHandle_t handle,
const GEOSCoordSequence* s,
unsigned int *dims);
/************************************************************************
*
* Linear referencing functions -- there are more, but these are
* probably sufficient for most purposes
*
***********************************************************************/
/*
* GEOSGeometry ownership is retained by caller
*/
/* Return distance of point 'p' projected on 'g' from origin
* of 'g'. Geometry 'g' must be a lineal geometry */
extern double GEOS_DLL GEOSProject(const GEOSGeometry *g,
const GEOSGeometry* p);
extern double GEOS_DLL GEOSProject_r(GEOSContextHandle_t handle,
const GEOSGeometry *g,
const GEOSGeometry *p);
/* Return closest point to given distance within geometry
* Geometry must be a LineString */
extern GEOSGeometry GEOS_DLL *GEOSInterpolate(const GEOSGeometry *g,
double d);
extern GEOSGeometry GEOS_DLL *GEOSInterpolate_r(GEOSContextHandle_t handle,
const GEOSGeometry *g,
double d);
extern double GEOS_DLL GEOSProjectNormalized(const GEOSGeometry *g,
const GEOSGeometry* p);
extern double GEOS_DLL GEOSProjectNormalized_r(GEOSContextHandle_t handle,
const GEOSGeometry *g,
const GEOSGeometry *p);
extern GEOSGeometry GEOS_DLL *GEOSInterpolateNormalized(const GEOSGeometry *g,
double d);
extern GEOSGeometry GEOS_DLL *GEOSInterpolateNormalized_r(
GEOSContextHandle_t handle,
const GEOSGeometry *g,
double d);
/************************************************************************
*
* Buffer related functions
*
***********************************************************************/
/* @return NULL on exception */
extern GEOSGeometry GEOS_DLL *GEOSBuffer(const GEOSGeometry* g,
double width, int quadsegs);
extern GEOSGeometry GEOS_DLL *GEOSBuffer_r(GEOSContextHandle_t handle,
const GEOSGeometry* g,
double width, int quadsegs);
enum GEOSBufCapStyles {
GEOSBUF_CAP_ROUND=1,
GEOSBUF_CAP_FLAT=2,
GEOSBUF_CAP_SQUARE=3
};
enum GEOSBufJoinStyles {
GEOSBUF_JOIN_ROUND=1,
GEOSBUF_JOIN_MITRE=2,
GEOSBUF_JOIN_BEVEL=3
};
/* @return 0 on exception */
extern GEOSBufferParams GEOS_DLL *GEOSBufferParams_create();
extern GEOSBufferParams GEOS_DLL *GEOSBufferParams_create_r(
GEOSContextHandle_t handle);
extern void GEOS_DLL GEOSBufferParams_destroy(GEOSBufferParams* parms);
extern void GEOS_DLL GEOSBufferParams_destroy_r(
GEOSContextHandle_t handle,
GEOSBufferParams* parms);
/* @return 0 on exception */
extern int GEOS_DLL GEOSBufferParams_setEndCapStyle(
GEOSBufferParams* p,
int style);
extern int GEOS_DLL GEOSBufferParams_setEndCapStyle_r(
GEOSContextHandle_t handle,
GEOSBufferParams* p,
int style);
/* @return 0 on exception */
extern int GEOS_DLL GEOSBufferParams_setJoinStyle(
GEOSBufferParams* p,
int joinStyle);
extern int GEOS_DLL GEOSBufferParams_setJoinStyle_r(
GEOSContextHandle_t handle,
GEOSBufferParams* p,
int joinStyle);
/* @return 0 on exception */
extern int GEOS_DLL GEOSBufferParams_setMitreLimit(
GEOSBufferParams* p,
double mitreLimit);
extern int GEOS_DLL GEOSBufferParams_setMitreLimit_r(
GEOSContextHandle_t handle,
GEOSBufferParams* p,
double mitreLimit);
/* @return 0 on exception */
extern int GEOS_DLL GEOSBufferParams_setQuadrantSegments(
GEOSBufferParams* p,
int quadSegs);
extern int GEOS_DLL GEOSBufferParams_setQuadrantSegments_r(
GEOSContextHandle_t handle,
GEOSBufferParams* p,
int quadSegs);
/* @param singleSided: 1 for single sided, 0 otherwise */
/* @return 0 on exception */
extern int GEOS_DLL GEOSBufferParams_setSingleSided(
GEOSBufferParams* p,
int singleSided);
extern int GEOS_DLL GEOSBufferParams_setSingleSided_r(
GEOSContextHandle_t handle,
GEOSBufferParams* p,
int singleSided);
/* @return NULL on exception */
extern GEOSGeometry GEOS_DLL *GEOSBufferWithParams(
const GEOSGeometry* g,
const GEOSBufferParams* p,
double width);
extern GEOSGeometry GEOS_DLL *GEOSBufferWithParams_r(
GEOSContextHandle_t handle,
const GEOSGeometry* g,
const GEOSBufferParams* p,
double width);
/* These functions return NULL on exception. */
extern GEOSGeometry GEOS_DLL *GEOSBufferWithStyle(const GEOSGeometry* g,
double width, int quadsegs, int endCapStyle, int joinStyle,
double mitreLimit);
extern GEOSGeometry GEOS_DLL *GEOSBufferWithStyle_r(GEOSContextHandle_t handle,
const GEOSGeometry* g, double width, int quadsegs, int endCapStyle,
int joinStyle, double mitreLimit);
/* These functions return NULL on exception. Only LINESTRINGs are accepted. */
/* @deprecated in 3.3.0: use GEOSOffsetCurve instead */
extern GEOSGeometry GEOS_DLL *GEOSSingleSidedBuffer(const GEOSGeometry* g,
double width, int quadsegs, int joinStyle, double mitreLimit,
int leftSide);
extern GEOSGeometry GEOS_DLL *GEOSSingleSidedBuffer_r(
GEOSContextHandle_t handle,
const GEOSGeometry* g, double width, int quadsegs,
int joinStyle, double mitreLimit, int leftSide);
/*
* Only LINESTRINGs are accepted.
* @param width : offset distance.
* negative for right side offset.
* positive for left side offset.
* @return NULL on exception
*/
extern GEOSGeometry GEOS_DLL *GEOSOffsetCurve(const GEOSGeometry* g,
double width, int quadsegs, int joinStyle, double mitreLimit);
extern GEOSGeometry GEOS_DLL *GEOSOffsetCurve_r(GEOSContextHandle_t handle,
const GEOSGeometry* g, double width, int quadsegs,
int joinStyle, double mitreLimit);
/************************************************************************
*
* Geometry Constructors.
* GEOSCoordSequence* arguments will become ownership of the returned object.
* All functions return NULL on exception.
*
***********************************************************************/
extern GEOSGeometry GEOS_DLL *GEOSGeom_createPoint(GEOSCoordSequence* s);
extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyPoint();
extern GEOSGeometry GEOS_DLL *GEOSGeom_createLinearRing(GEOSCoordSequence* s);
extern GEOSGeometry GEOS_DLL *GEOSGeom_createLineString(GEOSCoordSequence* s);
extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyLineString();
extern GEOSGeometry GEOS_DLL *GEOSGeom_createPoint_r(
GEOSContextHandle_t handle,
GEOSCoordSequence* s);
extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyPoint_r(
GEOSContextHandle_t handle);
extern GEOSGeometry GEOS_DLL *GEOSGeom_createLinearRing_r(
GEOSContextHandle_t handle,
GEOSCoordSequence* s);
extern GEOSGeometry GEOS_DLL *GEOSGeom_createLineString_r(
GEOSContextHandle_t handle,
GEOSCoordSequence* s);
extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyLineString_r(
GEOSContextHandle_t handle);
/*
* Second argument is an array of GEOSGeometry* objects.
* The caller remains owner of the array, but pointed-to
* objects become ownership of the returned GEOSGeometry.
*/
extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyPolygon();
extern GEOSGeometry GEOS_DLL *GEOSGeom_createPolygon(GEOSGeometry* shell,
GEOSGeometry** holes, unsigned int nholes);
extern GEOSGeometry GEOS_DLL *GEOSGeom_createCollection(int type,
GEOSGeometry* *geoms, unsigned int ngeoms);
extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyCollection(int type);
extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyPolygon_r(
GEOSContextHandle_t handle);
extern GEOSGeometry GEOS_DLL *GEOSGeom_createPolygon_r(
GEOSContextHandle_t handle,
GEOSGeometry* shell,
GEOSGeometry** holes,
unsigned int nholes);
extern GEOSGeometry GEOS_DLL *GEOSGeom_createCollection_r(
GEOSContextHandle_t handle, int type,
GEOSGeometry* *geoms,
unsigned int ngeoms);
extern GEOSGeometry GEOS_DLL *GEOSGeom_createEmptyCollection_r(
GEOSContextHandle_t handle, int type);
extern GEOSGeometry GEOS_DLL *GEOSGeom_clone(const GEOSGeometry* g);
extern GEOSGeometry GEOS_DLL *GEOSGeom_clone_r(GEOSContextHandle_t handle,
const GEOSGeometry* g);
/************************************************************************
*
* Memory management
*
***********************************************************************/
extern void GEOS_DLL GEOSGeom_destroy(GEOSGeometry* g);
extern void GEOS_DLL GEOSGeom_destroy_r(GEOSContextHandle_t handle,
GEOSGeometry* g);
/************************************************************************
*
* Topology operations - return NULL on exception.
*
***********************************************************************/
extern GEOSGeometry GEOS_DLL *GEOSEnvelope(const GEOSGeometry* g);
extern GEOSGeometry GEOS_DLL *GEOSIntersection(const GEOSGeometry* g1, const GEOSGeometry* g2);
extern GEOSGeometry GEOS_DLL *GEOSConvexHull(const GEOSGeometry* g);
extern GEOSGeometry GEOS_DLL *GEOSDifference(const GEOSGeometry* g1, const GEOSGeometry* g2);
extern GEOSGeometry GEOS_DLL *GEOSSymDifference(const GEOSGeometry* g1, const GEOSGeometry* g2);
extern GEOSGeometry GEOS_DLL *GEOSBoundary(const GEOSGeometry* g);
extern GEOSGeometry GEOS_DLL *GEOSUnion(const GEOSGeometry* g1, const GEOSGeometry* g2);
extern GEOSGeometry GEOS_DLL *GEOSUnaryUnion(const GEOSGeometry* g);
/* @deprecated in 3.3.0: use GEOSUnaryUnion instead */
extern GEOSGeometry GEOS_DLL *GEOSUnionCascaded(const GEOSGeometry* g);
extern GEOSGeometry GEOS_DLL *GEOSPointOnSurface(const GEOSGeometry* g);
extern GEOSGeometry GEOS_DLL *GEOSGetCentroid(const GEOSGeometry* g);
extern GEOSGeometry GEOS_DLL *GEOSNode(const GEOSGeometry* g);
extern GEOSGeometry GEOS_DLL *GEOSEnvelope_r(GEOSContextHandle_t handle,
const GEOSGeometry* g);
extern GEOSGeometry GEOS_DLL *GEOSIntersection_r(GEOSContextHandle_t handle,
const GEOSGeometry* g1,
const GEOSGeometry* g2);
extern GEOSGeometry GEOS_DLL *GEOSConvexHull_r(GEOSContextHandle_t handle,
const GEOSGeometry* g);
extern GEOSGeometry GEOS_DLL *GEOSDifference_r(GEOSContextHandle_t handle,
const GEOSGeometry* g1,
const GEOSGeometry* g2);
extern GEOSGeometry GEOS_DLL *GEOSSymDifference_r(GEOSContextHandle_t handle,
const GEOSGeometry* g1,
const GEOSGeometry* g2);
extern GEOSGeometry GEOS_DLL *GEOSBoundary_r(GEOSContextHandle_t handle,
const GEOSGeometry* g);
extern GEOSGeometry GEOS_DLL *GEOSUnion_r(GEOSContextHandle_t handle,
const GEOSGeometry* g1,
const GEOSGeometry* g2);
extern GEOSGeometry GEOS_DLL *GEOSUnaryUnion_r(GEOSContextHandle_t handle,
const GEOSGeometry* g);
extern GEOSGeometry GEOS_DLL *GEOSUnionCascaded_r(GEOSContextHandle_t handle,
const GEOSGeometry* g);
extern GEOSGeometry GEOS_DLL *GEOSPointOnSurface_r(GEOSContextHandle_t handle,
const GEOSGeometry* g);
extern GEOSGeometry GEOS_DLL *GEOSGetCentroid_r(GEOSContextHandle_t handle,
const GEOSGeometry* g);
extern GEOSGeometry GEOS_DLL *GEOSNode_r(GEOSContextHandle_t handle,
const GEOSGeometry* g);
/*
* all arguments remain ownership of the caller
* (both Geometries and pointers)
*/
extern GEOSGeometry GEOS_DLL *GEOSPolygonize(const GEOSGeometry * const geoms[], unsigned int ngeoms);
extern GEOSGeometry GEOS_DLL *GEOSPolygonizer_getCutEdges(const GEOSGeometry * const geoms[], unsigned int ngeoms);
/*
* Polygonizes a set of Geometries which contain linework that
* represents the edges of a planar graph.
*
* Any dimension of Geometry is handled - the constituent linework
* is extracted to form the edges.
*
* The edges must be correctly noded; that is, they must only meet
* at their endpoints.
* The Polygonizer will still run on incorrectly noded input
* but will not form polygons from incorrectly noded edges.
*
* The Polygonizer reports the follow kinds of errors:
*
* - Dangles - edges which have one or both ends which are
* not incident on another edge endpoint
* - Cut Edges - edges which are connected at both ends but
* which do not form part of polygon
* - Invalid Ring Lines - edges which form rings which are invalid
* (e.g. the component lines contain a self-intersection)
*
* Errors are reported to output parameters "cuts", "dangles" and
* "invalid" (if not-null). Formed polygons are returned as a
* collection. NULL is returned on exception. All returned
* geometries must be destroyed by caller.
*
*/
extern GEOSGeometry GEOS_DLL *GEOSPolygonize_full(const GEOSGeometry* input,
GEOSGeometry** cuts, GEOSGeometry** dangles, GEOSGeometry** invalid);
extern GEOSGeometry GEOS_DLL *GEOSLineMerge(const GEOSGeometry* g);
extern GEOSGeometry GEOS_DLL *GEOSSimplify(const GEOSGeometry* g, double tolerance);
extern GEOSGeometry GEOS_DLL *GEOSTopologyPreserveSimplify(const GEOSGeometry* g,
double tolerance);
extern GEOSGeometry GEOS_DLL *GEOSPolygonize_r(GEOSContextHandle_t handle,
const GEOSGeometry *const geoms[],
unsigned int ngeoms);
extern GEOSGeometry GEOS_DLL *GEOSPolygonizer_getCutEdges_r(
GEOSContextHandle_t handle,
const GEOSGeometry * const geoms[],
unsigned int ngeoms);
extern GEOSGeometry GEOS_DLL *GEOSPolygonize_full_r(GEOSContextHandle_t handle,
const GEOSGeometry* input, GEOSGeometry** cuts,
GEOSGeometry** dangles, GEOSGeometry** invalidRings);
extern GEOSGeometry GEOS_DLL *GEOSLineMerge_r(GEOSContextHandle_t handle,
const GEOSGeometry* g);
extern GEOSGeometry GEOS_DLL *GEOSSimplify_r(GEOSContextHandle_t handle,
const GEOSGeometry* g,
double tolerance);
extern GEOSGeometry GEOS_DLL *GEOSTopologyPreserveSimplify_r(
GEOSContextHandle_t handle,
const GEOSGeometry* g, double tolerance);
/*
* Return all distinct vertices of input geometry as a MULTIPOINT.
* Note that only 2 dimensions of the vertices are considered when
* testing for equality.
*/
extern GEOSGeometry GEOS_DLL *GEOSGeom_extractUniquePoints(
const GEOSGeometry* g);
extern GEOSGeometry GEOS_DLL *GEOSGeom_extractUniquePoints_r(
GEOSContextHandle_t handle,
const GEOSGeometry* g);
/*
* Find paths shared between the two given lineal geometries.
*
* Returns a GEOMETRYCOLLECTION having two elements:
* - first element is a MULTILINESTRING containing shared paths
* having the _same_ direction on both inputs
* - second element is a MULTILINESTRING containing shared paths
* having the _opposite_ direction on the two inputs
*
* Returns NULL on exception
*/
extern GEOSGeometry GEOS_DLL *GEOSSharedPaths(const GEOSGeometry* g1,
const GEOSGeometry* g2);
extern GEOSGeometry GEOS_DLL *GEOSSharedPaths_r(GEOSContextHandle_t handle,
const GEOSGeometry* g1, const GEOSGeometry* g2);
/*
* Snap first geometry on to second with given tolerance
* Returns a newly allocated geometry, or NULL on exception
*/
extern GEOSGeometry GEOS_DLL *GEOSSnap(const GEOSGeometry* g1,
const GEOSGeometry* g2, double tolerance);
extern GEOSGeometry GEOS_DLL *GEOSSnap_r(GEOSContextHandle_t handle,
const GEOSGeometry* g1, const GEOSGeometry* g2, double tolerance);
/*
* Return a Delaunay triangulation of the vertex of the given geometry
*
* @param g the input geometry whose vertex will be used as "sites"
* @param tolerance optional snapping tolerance to use for improved robustness
* @param onlyEdges if non-zero will return a MULTILINESTRING, otherwise it will
* return a GEOMETRYCOLLECTION containing triangular POLYGONs.
*
* @return a newly allocated geometry, or NULL on exception
*/
extern GEOSGeometry GEOS_DLL * GEOSDelaunayTriangulation(
const GEOSGeometry *g,
double tolerance,
int onlyEdges);
extern GEOSGeometry GEOS_DLL * GEOSDelaunayTriangulation_r(
GEOSContextHandle_t handle,
const GEOSGeometry *g,
double tolerance,
int onlyEdges);
/*
* Returns the Voronoi polygons of a set of Vertices given as input
*
* @param g the input geometry whose vertex will be used as sites.
* @param tolerance optional snapping tolerance to use for improved robustness
*
* @return a newly allocated geometry, or NULL on exception.
*/
extern GEOSGeometry GEOS_DLL * GEOSVoronoiDiagram(
const GEOSGeometry *g,
double tolerance,
int onlyEdges);
extern GEOSGeometry GEOS_DLL * GEOSVoronoiDiagram_r(
GEOSContextHandle_t extHandle,
const GEOSGeometry *g1,
double tolerance,
int onlyEdges);
/************************************************************************
*
* Binary predicates - return 2 on exception, 1 on true, 0 on false
*
***********************************************************************/
extern char GEOS_DLL GEOSDisjoint(const GEOSGeometry* g1, const GEOSGeometry* g2);
extern char GEOS_DLL GEOSTouches(const GEOSGeometry* g1, const GEOSGeometry* g2);
extern char GEOS_DLL GEOSIntersects(const GEOSGeometry* g1, const GEOSGeometry* g2);
extern char GEOS_DLL GEOSCrosses(const GEOSGeometry* g1, const GEOSGeometry* g2);
extern char GEOS_DLL GEOSWithin(const GEOSGeometry* g1, const GEOSGeometry* g2);
extern char GEOS_DLL GEOSContains(const GEOSGeometry* g1, const GEOSGeometry* g2);
extern char GEOS_DLL GEOSOverlaps(const GEOSGeometry* g1, const GEOSGeometry* g2);
extern char GEOS_DLL GEOSEquals(const GEOSGeometry* g1, const GEOSGeometry* g2);
extern char GEOS_DLL GEOSEqualsExact(const GEOSGeometry* g1, const GEOSGeometry* g2, double tolerance);
extern char GEOS_DLL GEOSCovers(const GEOSGeometry* g1, const GEOSGeometry* g2);
extern char GEOS_DLL GEOSCoveredBy(const GEOSGeometry* g1, const GEOSGeometry* g2);
extern char GEOS_DLL GEOSDisjoint_r(GEOSContextHandle_t handle,
const GEOSGeometry* g1,
const GEOSGeometry* g2);
extern char GEOS_DLL GEOSTouches_r(GEOSContextHandle_t handle,
const GEOSGeometry* g1,
const GEOSGeometry* g2);
extern char GEOS_DLL GEOSIntersects_r(GEOSContextHandle_t handle,
const GEOSGeometry* g1,
const GEOSGeometry* g2);
extern char GEOS_DLL GEOSCrosses_r(GEOSContextHandle_t handle,
const GEOSGeometry* g1,
const GEOSGeometry* g2);
extern char GEOS_DLL GEOSWithin_r(GEOSContextHandle_t handle,
const GEOSGeometry* g1,
const GEOSGeometry* g2);
extern char GEOS_DLL GEOSContains_r(GEOSContextHandle_t handle,
const GEOSGeometry* g1,
const GEOSGeometry* g2);
extern char GEOS_DLL GEOSOverlaps_r(GEOSContextHandle_t handle,
const GEOSGeometry* g1,
const GEOSGeometry* g2);
extern char GEOS_DLL GEOSEquals_r(GEOSContextHandle_t handle,
const GEOSGeometry* g1,
const GEOSGeometry* g2);
extern char GEOS_DLL GEOSEqualsExact_r(GEOSContextHandle_t handle,
const GEOSGeometry* g1,
const GEOSGeometry* g2,
double tolerance);
extern char GEOS_DLL GEOSCovers_r(GEOSContextHandle_t handle,
const GEOSGeometry* g1,
const GEOSGeometry* g2);
extern char GEOS_DLL GEOSCoveredBy_r(GEOSContextHandle_t handle,
const GEOSGeometry* g1,
const GEOSGeometry* g2);
/************************************************************************
*
* Prepared Geometry Binary predicates - return 2 on exception, 1 on true, 0 on false
*
***********************************************************************/
/*
* GEOSGeometry ownership is retained by caller
*/
extern const GEOSPreparedGeometry GEOS_DLL *GEOSPrepare(const GEOSGeometry* g);
extern void GEOS_DLL GEOSPreparedGeom_destroy(const GEOSPreparedGeometry* g);
extern char GEOS_DLL GEOSPreparedContains(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
extern char GEOS_DLL GEOSPreparedContainsProperly(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
extern char GEOS_DLL GEOSPreparedCoveredBy(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
extern char GEOS_DLL GEOSPreparedCovers(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
extern char GEOS_DLL GEOSPreparedCrosses(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
extern char GEOS_DLL GEOSPreparedDisjoint(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
extern char GEOS_DLL GEOSPreparedIntersects(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
extern char GEOS_DLL GEOSPreparedOverlaps(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
extern char GEOS_DLL GEOSPreparedTouches(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
extern char GEOS_DLL GEOSPreparedWithin(const GEOSPreparedGeometry* pg1, const GEOSGeometry* g2);
/*
* GEOSGeometry ownership is retained by caller
*/
extern const GEOSPreparedGeometry GEOS_DLL *GEOSPrepare_r(
GEOSContextHandle_t handle,
const GEOSGeometry* g);
extern void GEOS_DLL GEOSPreparedGeom_destroy_r(GEOSContextHandle_t handle,
const GEOSPreparedGeometry* g);
extern char GEOS_DLL GEOSPreparedContains_r(GEOSContextHandle_t handle,
const GEOSPreparedGeometry* pg1,
const GEOSGeometry* g2);
extern char GEOS_DLL GEOSPreparedContainsProperly_r(GEOSContextHandle_t handle,
const GEOSPreparedGeometry* pg1,
const GEOSGeometry* g2);
extern char GEOS_DLL GEOSPreparedCoveredBy_r(GEOSContextHandle_t handle,
const GEOSPreparedGeometry* pg1,
const GEOSGeometry* g2);
extern char GEOS_DLL GEOSPreparedCovers_r(GEOSContextHandle_t handle,
const GEOSPreparedGeometry* pg1,
const GEOSGeometry* g2);
extern char GEOS_DLL GEOSPreparedCrosses_r(GEOSContextHandle_t handle,
const GEOSPreparedGeometry* pg1,
const GEOSGeometry* g2);
extern char GEOS_DLL GEOSPreparedDisjoint_r(GEOSContextHandle_t handle,
const GEOSPreparedGeometry* pg1,
const GEOSGeometry* g2);
extern char GEOS_DLL GEOSPreparedIntersects_r(GEOSContextHandle_t handle,
const GEOSPreparedGeometry* pg1,
const GEOSGeometry* g2);
extern char GEOS_DLL GEOSPreparedOverlaps_r(GEOSContextHandle_t handle,
const GEOSPreparedGeometry* pg1,
const GEOSGeometry* g2);
extern char GEOS_DLL GEOSPreparedTouches_r(GEOSContextHandle_t handle,
const GEOSPreparedGeometry* pg1,
const GEOSGeometry* g2);
extern char GEOS_DLL GEOSPreparedWithin_r(GEOSContextHandle_t handle,
const GEOSPreparedGeometry* pg1,
const GEOSGeometry* g2);
/************************************************************************
*
* STRtree functions
*
***********************************************************************/
/*
* GEOSGeometry ownership is retained by caller
*/
extern GEOSSTRtree GEOS_DLL *GEOSSTRtree_create(size_t nodeCapacity);
extern void GEOS_DLL GEOSSTRtree_insert(GEOSSTRtree *tree,
const GEOSGeometry *g,
void *item);
extern void GEOS_DLL GEOSSTRtree_query(GEOSSTRtree *tree,
const GEOSGeometry *g,
GEOSQueryCallback callback,
void *userdata);
extern void GEOS_DLL GEOSSTRtree_iterate(GEOSSTRtree *tree,
GEOSQueryCallback callback,
void *userdata);
extern char GEOS_DLL GEOSSTRtree_remove(GEOSSTRtree *tree,
const GEOSGeometry *g,
void *item);
extern void GEOS_DLL GEOSSTRtree_destroy(GEOSSTRtree *tree);
extern GEOSSTRtree GEOS_DLL *GEOSSTRtree_create_r(
GEOSContextHandle_t handle,
size_t nodeCapacity);
extern void GEOS_DLL GEOSSTRtree_insert_r(GEOSContextHandle_t handle,
GEOSSTRtree *tree,
const GEOSGeometry *g,
void *item);
extern void GEOS_DLL GEOSSTRtree_query_r(GEOSContextHandle_t handle,
GEOSSTRtree *tree,
const GEOSGeometry *g,
GEOSQueryCallback callback,
void *userdata);
extern void GEOS_DLL GEOSSTRtree_iterate_r(GEOSContextHandle_t handle,
GEOSSTRtree *tree,
GEOSQueryCallback callback,
void *userdata);
extern char GEOS_DLL GEOSSTRtree_remove_r(GEOSContextHandle_t handle,
GEOSSTRtree *tree,
const GEOSGeometry *g,
void *item);
extern void GEOS_DLL GEOSSTRtree_destroy_r(GEOSContextHandle_t handle,
GEOSSTRtree *tree);
/************************************************************************
*
* Unary predicate - return 2 on exception, 1 on true, 0 on false
*
***********************************************************************/
extern char GEOS_DLL GEOSisEmpty(const GEOSGeometry* g);
extern char GEOS_DLL GEOSisSimple(const GEOSGeometry* g);
extern char GEOS_DLL GEOSisRing(const GEOSGeometry* g);
extern char GEOS_DLL GEOSHasZ(const GEOSGeometry* g);
extern char GEOS_DLL GEOSisClosed(const GEOSGeometry *g);
extern char GEOS_DLL GEOSisEmpty_r(GEOSContextHandle_t handle,
const GEOSGeometry* g);
extern char GEOS_DLL GEOSisSimple_r(GEOSContextHandle_t handle,
const GEOSGeometry* g);
extern char GEOS_DLL GEOSisRing_r(GEOSContextHandle_t handle,
const GEOSGeometry* g);
extern char GEOS_DLL GEOSHasZ_r(GEOSContextHandle_t handle,
const GEOSGeometry* g);
extern char GEOS_DLL GEOSisClosed_r(GEOSContextHandle_t handle,
const GEOSGeometry *g);
/************************************************************************
*
* Dimensionally Extended 9 Intersection Model related
*
***********************************************************************/
/* These are for use with GEOSRelateBoundaryNodeRule (flags param) */
enum GEOSRelateBoundaryNodeRules {
/* MOD2 and OGC are the same rule, and is the default
* used by GEOSRelatePattern
*/
GEOSRELATE_BNR_MOD2=1,
GEOSRELATE_BNR_OGC=1,
GEOSRELATE_BNR_ENDPOINT=2,
GEOSRELATE_BNR_MULTIVALENT_ENDPOINT=3,
GEOSRELATE_BNR_MONOVALENT_ENDPOINT=4
};
/* return 2 on exception, 1 on true, 0 on false */
extern char GEOS_DLL GEOSRelatePattern(const GEOSGeometry* g1, const GEOSGeometry* g2, const char *pat);
extern char GEOS_DLL GEOSRelatePattern_r(GEOSContextHandle_t handle,
const GEOSGeometry* g1,
const GEOSGeometry* g2,
const char *pat);
/* return NULL on exception, a string to GEOSFree otherwise */
extern char GEOS_DLL *GEOSRelate(const GEOSGeometry* g1, const GEOSGeometry* g2);
extern char GEOS_DLL *GEOSRelate_r(GEOSContextHandle_t handle,
const GEOSGeometry* g1,
const GEOSGeometry* g2);
/* return 2 on exception, 1 on true, 0 on false */
extern char GEOS_DLL GEOSRelatePatternMatch(const char *mat, const char *pat);
extern char GEOS_DLL GEOSRelatePatternMatch_r(GEOSContextHandle_t handle,
const char *mat,
const char *pat);
/* return NULL on exception, a string to GEOSFree otherwise */
extern char GEOS_DLL *GEOSRelateBoundaryNodeRule(const GEOSGeometry* g1,
const GEOSGeometry* g2,
int bnr);
extern char GEOS_DLL *GEOSRelateBoundaryNodeRule_r(GEOSContextHandle_t handle,