-
Notifications
You must be signed in to change notification settings - Fork 420
Expand file tree
/
Copy pathgeos_c.cpp
More file actions
2075 lines (1731 loc) · 51.3 KB
/
Copy pathgeos_c.cpp
File metadata and controls
2075 lines (1731 loc) · 51.3 KB
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 <strk@kbt.io>
* Copyright (C) 2005-2006 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 <strk@kbt.io>
*
***********************************************************************/
#include <geos/geom/prep/PreparedGeometryFactory.h>
#include <geos/index/strtree/TemplateSTRtree.h>
#include <geos/io/WKTReader.h>
#include <geos/io/WKBReader.h>
#include <geos/io/WKTWriter.h>
#include <geos/io/WKBWriter.h>
#include <geos/io/GeoJSONReader.h>
#include <geos/io/GeoJSONWriter.h>
#include <geos/operation/buffer/BufferParameters.h>
#include <geos/operation/cluster/Clusters.h>
#include <geos/util/Interrupt.h>
#include <stdexcept>
#include <new>
#ifdef _MSC_VER
#pragma warning(disable : 4099)
#endif
// Some extra magic to make type declarations in geos_c.h work -
// for cross-checking of types in header.
// NOTE: the below defines or struct definition must be kept in exact
// sync between geos_c.cpp and geos_ts_c.cpp to avoid C++ One Definition Rule
// violations.
#define GEOSGeometry geos::geom::Geometry
#define GEOSPreparedGeometry geos::geom::prep::PreparedGeometry
#define GEOSClusterInfo geos::operation::cluster::Clusters
#define GEOSCoordSequence geos::geom::CoordinateSequence
#define GEOSBufferParams geos::operation::buffer::BufferParameters
#define GEOSSTRtree geos::index::strtree::TemplateSTRtree<void*>
#define GEOSWKTReader geos::io::WKTReader
#define GEOSWKTWriter geos::io::WKTWriter
#define GEOSWKBReader geos::io::WKBReader
#define GEOSWKBWriter geos::io::WKBWriter
#define GEOSGeoJSONReader geos::io::GeoJSONReader
#define GEOSGeoJSONWriter geos::io::GeoJSONWriter
// Implementation struct for the GEOSCoverageCleanParams object
typedef struct {
double snappingDistance;
int overlapMergeStrategy;
double gapMaximumWidth;
} GEOSCoverageCleanParams;
// Implementation struct for the GEOSMakeValidParams object
typedef struct {
int method;
int keepCollapsed;
} GEOSMakeValidParams;
#include "geos_c.h"
/// Define this if you want operations triggering Exceptions to
/// be printed (will use the NOTIFY channel - only implemented for GEOSUnion so far)
///
#undef VERBOSE_EXCEPTIONS
#include <geos/export.h>
/*
#if defined(_MSC_VER)
# define GEOS_DLL __declspec(dllexport)
#else
# define GEOS_DLL
#endif
*/
// import the most frequently used definitions globally
using geos::geom::Geometry;
using geos::geom::LineString;
using geos::geom::Polygon;
using geos::geom::CoordinateSequence;
using geos::geom::GeometryFactory;
using geos::io::WKTReader;
using geos::io::WKTWriter;
using geos::io::WKBReader;
using geos::io::WKBWriter;
using geos::io::GeoJSONReader;
using geos::io::GeoJSONWriter;
typedef std::unique_ptr<Geometry> GeomPtr;
//## GLOBALS ################################################
// NOTE: SRID will have to be changed after geometry creation
GEOSContextHandle_t handle = NULL;
extern "C" {
void
initGEOS(GEOSMessageHandler nf, GEOSMessageHandler ef)
{
if(! handle) {
handle = initGEOS_r(nf, ef);
}
else {
GEOSContext_setNoticeHandler_r(handle, nf);
GEOSContext_setErrorHandler_r(handle, ef);
}
geos::util::Interrupt::cancel();
}
void
finishGEOS()
{
if(handle != NULL) {
finishGEOS_r(handle);
handle = NULL;
}
}
GEOSInterruptCallback*
GEOS_interruptRegisterCallback(GEOSInterruptCallback* cb)
{
return geos::util::Interrupt::registerCallback(cb);
}
void
GEOS_interruptRequest()
{
geos::util::Interrupt::request();
}
void
GEOS_interruptCancel()
{
geos::util::Interrupt::cancel();
}
void
GEOSFree(void* buffer)
{
GEOSFree_r(handle, buffer);
}
/****************************************************************
** relate()-related functions
** return 0 = false, 1 = true, 2 = error occurred
**
*/
char
GEOSDisjoint(const Geometry* g1, const Geometry* g2)
{
return GEOSDisjoint_r(handle, g1, g2);
}
char
GEOSTouches(const Geometry* g1, const Geometry* g2)
{
return GEOSTouches_r(handle, g1, g2);
}
char
GEOSIntersects(const Geometry* g1, const Geometry* g2)
{
return GEOSIntersects_r(handle, g1, g2);
}
char
GEOSCrosses(const Geometry* g1, const Geometry* g2)
{
return GEOSCrosses_r(handle, g1, g2);
}
char
GEOSWithin(const Geometry* g1, const Geometry* g2)
{
return GEOSWithin_r(handle, g1, g2);
}
// call g1->contains(g2)
// returns 0 = false
// 1 = true
// 2 = error was trapped
char
GEOSContains(const Geometry* g1, const Geometry* g2)
{
return GEOSContains_r(handle, g1, g2);
}
char
GEOSOverlaps(const Geometry* g1, const Geometry* g2)
{
return GEOSOverlaps_r(handle, g1, g2);
}
char
GEOSCovers(const Geometry* g1, const Geometry* g2)
{
return GEOSCovers_r(handle, g1, g2);
}
char
GEOSCoveredBy(const Geometry* g1, const Geometry* g2)
{
return GEOSCoveredBy_r(handle, g1, g2);
}
//-------------------------------------------------------------------
// low-level relate functions
//------------------------------------------------------------------
char
GEOSRelatePattern(const Geometry* g1, const Geometry* g2, const char* imPattern)
{
return GEOSRelatePattern_r(handle, g1, g2, imPattern);
}
char
GEOSRelatePatternMatch(const char* intMatrix, const char* imPattern)
{
return GEOSRelatePatternMatch_r(handle, intMatrix, imPattern);
}
char*
GEOSRelate(const Geometry* g1, const Geometry* g2)
{
return GEOSRelate_r(handle, g1, g2);
}
char*
GEOSRelateBoundaryNodeRule(const Geometry* g1, const Geometry* g2, int bnr)
{
return GEOSRelateBoundaryNodeRule_r(handle, g1, g2, bnr);
}
//-----------------------------------------------------------------
// isValid
//-----------------------------------------------------------------
char
GEOSisValid(const Geometry* g)
{
return GEOSisValid_r(handle, g);
}
char*
GEOSisValidReason(const Geometry* g)
{
return GEOSisValidReason_r(handle, g);
}
char
GEOSisValidDetail(const Geometry* g, int flags,
char** reason, Geometry** location)
{
return GEOSisValidDetail_r(handle, g, flags, reason, location);
}
//-----------------------------------------------------------------
// general purpose
//-----------------------------------------------------------------
char
GEOSEquals(const Geometry* g1, const Geometry* g2)
{
return GEOSEquals_r(handle, g1, g2);
}
char
GEOSEqualsExact(const Geometry* g1, const Geometry* g2, double tolerance)
{
return GEOSEqualsExact_r(handle, g1, g2, tolerance);
}
char
GEOSEqualsIdentical(const Geometry* g1, const Geometry* g2)
{
return GEOSEqualsIdentical_r(handle, g1, g2);
}
int
GEOSDistance(const Geometry* g1, const Geometry* g2, double* dist)
{
return GEOSDistance_r(handle, g1, g2, dist);
}
char
GEOSDistanceWithin(const Geometry* g1, const Geometry* g2, double dist)
{
return GEOSDistanceWithin_r(handle, g1, g2, dist);
}
int
GEOSDistanceIndexed(const Geometry* g1, const Geometry* g2, double* dist)
{
return GEOSDistanceIndexed_r(handle, g1, g2, dist);
}
int
GEOSHausdorffDistance(const Geometry* g1, const Geometry* g2, double* dist)
{
return GEOSHausdorffDistance_r(handle, g1, g2, dist);
}
int
GEOSHausdorffDistanceDensify(const Geometry* g1, const Geometry* g2, double densifyFrac, double* dist)
{
return GEOSHausdorffDistanceDensify_r(handle, g1, g2, densifyFrac, dist);
}
int
GEOSFrechetDistance(const Geometry* g1, const Geometry* g2, double* dist)
{
return GEOSFrechetDistance_r(handle, g1, g2, dist);
}
int
GEOSFrechetDistanceDensify(const Geometry* g1, const Geometry* g2, double densifyFrac, double* dist)
{
return GEOSFrechetDistanceDensify_r(handle, g1, g2, densifyFrac, dist);
}
int
GEOSArea(const Geometry* g, double* area)
{
return GEOSArea_r(handle, g, area);
}
int
GEOSLength(const Geometry* g, double* length)
{
return GEOSLength_r(handle, g, length);
}
CoordinateSequence*
GEOSNearestPoints(const Geometry* g1, const Geometry* g2)
{
return GEOSNearestPoints_r(handle, g1, g2);
}
GEOSClusterInfo*
GEOSClusterDBSCAN(const GEOSGeometry* g, double eps, unsigned minPoints)
{
return GEOSClusterDBSCAN_r(handle, g, eps, minPoints);
}
GEOSClusterInfo*
GEOSClusterGeometryDistance(const GEOSGeometry* g, double d)
{
return GEOSClusterGeometryDistance_r(handle, g, d);
}
GEOSClusterInfo*
GEOSClusterGeometryIntersects(const GEOSGeometry* g)
{
return GEOSClusterGeometryIntersects_r(handle, g);
}
GEOSClusterInfo*
GEOSClusterEnvelopeDistance(const GEOSGeometry* g, double d)
{
return GEOSClusterEnvelopeDistance_r(handle, g, d);
}
GEOSClusterInfo*
GEOSClusterEnvelopeIntersects(const GEOSGeometry* g)
{
return GEOSClusterEnvelopeIntersects_r(handle, g);
}
std::size_t GEOSClusterInfo_getNumClusters(const GEOSClusterInfo* clusters)
{
return GEOSClusterInfo_getNumClusters_r(handle, clusters);
}
std::size_t GEOSClusterInfo_getClusterSize(const GEOSClusterInfo* clusters, size_t i)
{
return GEOSClusterInfo_getClusterSize_r(handle, clusters, i);
}
const std::size_t* GEOSClusterInfo_getInputsForClusterN(const GEOSClusterInfo* clusters, size_t i)
{
return GEOSClusterInfo_getInputsForClusterN_r(handle, clusters, i);
}
std::size_t* GEOSClusterInfo_getClustersForInputs(const GEOSClusterInfo* clusters)
{
return GEOSClusterInfo_getClustersForInputs_r(handle, clusters);
}
void GEOSClusterInfo_destroy(GEOSClusterInfo* info)
{
GEOSClusterInfo_destroy_r(handle, info);
}
Geometry*
GEOSGeomFromWKT(const char* wkt)
{
return GEOSGeomFromWKT_r(handle, wkt);
}
char*
GEOSGeomToWKT(const Geometry* g)
{
return GEOSGeomToWKT_r(handle, g);
}
// Remember to free the result!
unsigned char*
GEOSGeomToWKB_buf(const Geometry* g, std::size_t* size)
{
return GEOSGeomToWKB_buf_r(handle, g, size);
}
Geometry*
GEOSGeomFromWKB_buf(const unsigned char* wkb, std::size_t size)
{
return GEOSGeomFromWKB_buf_r(handle, wkb, size);
}
/* Read/write wkb hex values. Returned geometries are
owned by the caller.*/
unsigned char*
GEOSGeomToHEX_buf(const Geometry* g, std::size_t* size)
{
return GEOSGeomToHEX_buf_r(handle, g, size);
}
Geometry*
GEOSGeomFromHEX_buf(const unsigned char* hex, std::size_t size)
{
return GEOSGeomFromHEX_buf_r(handle, hex, size);
}
char
GEOSisEmpty(const Geometry* g)
{
return GEOSisEmpty_r(handle, g);
}
char
GEOSisSimple(const Geometry* g)
{
return GEOSisSimple_r(handle, g);
}
char
GEOSisRing(const Geometry* g)
{
return GEOSisRing_r(handle, g);
}
//free the result of this
char*
GEOSGeomType(const Geometry* g)
{
return GEOSGeomType_r(handle, g);
}
// Return postgis geometry type index
int
GEOSGeomTypeId(const Geometry* g)
{
return GEOSGeomTypeId_r(handle, g);
}
//-------------------------------------------------------------------
// GEOS functions that return geometries
//-------------------------------------------------------------------
Geometry*
GEOSEnvelope(const Geometry* g)
{
return GEOSEnvelope_r(handle, g);
}
Geometry*
GEOSIntersection(const Geometry* g1, const Geometry* g2)
{
return GEOSIntersection_r(handle, g1, g2);
}
Geometry*
GEOSIntersectionPrec(const Geometry* g1, const Geometry* g2, double gridSize)
{
return GEOSIntersectionPrec_r(handle, g1, g2, gridSize);
}
Geometry*
GEOSBuffer(const Geometry* g, double width, int quadrantsegments)
{
return GEOSBuffer_r(handle, g, width, quadrantsegments);
}
Geometry*
GEOSBufferWithStyle(const Geometry* g, double width, int quadsegs,
int endCapStyle, int joinStyle, double mitreLimit)
{
return GEOSBufferWithStyle_r(handle, g, width, quadsegs, endCapStyle,
joinStyle, mitreLimit);
}
Geometry*
GEOSDensify(const Geometry* g, double tolerance)
{
return GEOSDensify_r(handle, g, tolerance);
}
Geometry*
GEOSSingleSidedBuffer(const Geometry* g, double width, int quadsegs,
int joinStyle, double mitreLimit, int leftSide)
{
return GEOSSingleSidedBuffer_r(handle, g, width, quadsegs,
joinStyle, mitreLimit, leftSide);
}
Geometry*
GEOSOffsetCurve(const Geometry* g, double width, int quadsegs,
int joinStyle, double mitreLimit)
{
return GEOSOffsetCurve_r(handle, g, width, quadsegs,
joinStyle, mitreLimit);
}
Geometry*
GEOSConvexHull(const Geometry* g)
{
return GEOSConvexHull_r(handle, g);
}
Geometry*
GEOSConcaveHull(const Geometry* g,
double ratio,
unsigned int allowHoles)
{
return GEOSConcaveHull_r(handle, g, ratio, allowHoles);
}
Geometry*
GEOSConcaveHullByLength(const Geometry* g,
double length,
unsigned int allowHoles)
{
return GEOSConcaveHullByLength_r(handle, g, length, allowHoles);
}
Geometry*
GEOSPolygonHullSimplify(const Geometry* g,
unsigned int isOuter,
double vertexNumFraction)
{
return GEOSPolygonHullSimplify_r(handle, g, isOuter, vertexNumFraction);
}
Geometry*
GEOSPolygonHullSimplifyMode(const Geometry* g,
unsigned int isOuter,
unsigned int parameterMode,
double parameter)
{
return GEOSPolygonHullSimplifyMode_r(handle, g, isOuter, parameterMode, parameter);
}
Geometry*
GEOSConcaveHullOfPolygons(const Geometry* g,
double lengthRatio,
unsigned int isTight,
unsigned int isHolesAllowed)
{
return GEOSConcaveHullOfPolygons_r(handle,
g, lengthRatio, isTight, isHolesAllowed);
}
Geometry*
GEOSMinimumRotatedRectangle(const Geometry* g)
{
return GEOSMinimumRotatedRectangle_r(handle, g);
}
Geometry*
GEOSMaximumInscribedCircle(const Geometry* g, double tolerance)
{
return GEOSMaximumInscribedCircle_r(handle, g, tolerance);
}
Geometry*
GEOSLargestEmptyCircle(const Geometry* g, const Geometry* boundary, double tolerance)
{
return GEOSLargestEmptyCircle_r(handle, g, boundary, tolerance);
}
Geometry*
GEOSMinimumWidth(const Geometry* g)
{
return GEOSMinimumWidth_r(handle, g);
}
Geometry*
GEOSMinimumClearanceLine(const Geometry* g)
{
return GEOSMinimumClearanceLine_r(handle, g);
}
int
GEOSMinimumClearance(const Geometry* g, double* d)
{
return GEOSMinimumClearance_r(handle, g, d);
}
Geometry*
GEOSDifference(const Geometry* g1, const Geometry* g2)
{
return GEOSDifference_r(handle, g1, g2);
}
Geometry*
GEOSDifferencePrec(const Geometry* g1, const Geometry* g2, double gridSize)
{
return GEOSDifferencePrec_r(handle, g1, g2, gridSize);
}
Geometry*
GEOSBoundary(const Geometry* g)
{
return GEOSBoundary_r(handle, g);
}
Geometry*
GEOSSymDifference(const Geometry* g1, const Geometry* g2)
{
return GEOSSymDifference_r(handle, g1, g2);
}
Geometry*
GEOSSymDifferencePrec(const Geometry* g1, const Geometry* g2, double gridSize)
{
return GEOSSymDifferencePrec_r(handle, g1, g2, gridSize);
}
Geometry*
GEOSUnion(const Geometry* g1, const Geometry* g2)
{
return GEOSUnion_r(handle, g1, g2);
}
Geometry*
GEOSUnionPrec(const Geometry* g1, const Geometry* g2, double gridSize)
{
return GEOSUnionPrec_r(handle, g1, g2, gridSize);
}
Geometry*
GEOSUnaryUnion(const Geometry* g)
{
return GEOSUnaryUnion_r(handle, g);
}
Geometry*
GEOSUnaryUnionPrec(const Geometry* g, double gridSize)
{
return GEOSUnaryUnionPrec_r(handle, g, gridSize);
}
Geometry*
GEOSCoverageUnion(const Geometry* g)
{
return GEOSCoverageUnion_r(handle, g);
}
Geometry*
GEOSDisjointSubsetUnion(const Geometry* g)
{
return GEOSDisjointSubsetUnion_r(handle, g);
}
Geometry*
GEOSNode(const Geometry* g)
{
return GEOSNode_r(handle, g);
}
Geometry*
GEOSUnionCascaded(const Geometry* g)
{
return GEOSUnionCascaded_r(handle, g);
}
Geometry*
GEOSPointOnSurface(const Geometry* g)
{
return GEOSPointOnSurface_r(handle, g);
}
Geometry*
GEOSClipByRect(const Geometry* g, double xmin, double ymin, double xmax, double ymax)
{
return GEOSClipByRect_r(handle, g, xmin, ymin, xmax, ymax);
}
Geometry*
GEOSGeom_transformXY(const GEOSGeometry* g, GEOSTransformXYCallback callback, void* userdata) {
return GEOSGeom_transformXY_r(handle, g, callback, userdata);
}
Geometry*
GEOSGeom_transformXYZ(const GEOSGeometry* g, GEOSTransformXYZCallback callback, void* userdata) {
return GEOSGeom_transformXYZ_r(handle, g, callback, userdata);
}
//-------------------------------------------------------------------
// memory management functions
//------------------------------------------------------------------
void
GEOSGeom_destroy(Geometry* a)
{
return GEOSGeom_destroy_r(handle, a);
}
int
GEOSGetNumCoordinates(const Geometry* g)
{
return GEOSGetNumCoordinates_r(handle, g);
}
/*
* Return -1 on exception, 0 otherwise.
* Converts Geometry to normal form (or canonical form).
*/
int
GEOSNormalize(Geometry* g)
{
return GEOSNormalize_r(handle, g);
}
int
GEOSOrientPolygons(Geometry* g, int exteriorCW)
{
return GEOSOrientPolygons_r(handle, g, exteriorCW);
}
int
GEOSGetNumInteriorRings(const Geometry* g)
{
return GEOSGetNumInteriorRings_r(handle, g);
}
// returns -1 on error and 1 for non-multi geometries
int
GEOSGetNumGeometries(const Geometry* g)
{
return GEOSGetNumGeometries_r(handle, g);
}
/*
* Call only on GEOMETRYCOLLECTION or MULTI*.
* Return a pointer to the internal Geometry.
*/
const Geometry*
GEOSGetGeometryN(const Geometry* g, int n)
{
return GEOSGetGeometryN_r(handle, g, n);
}
/*
* Call only on LINESTRING
* Returns NULL on exception
*/
Geometry*
GEOSGeomGetPointN(const Geometry* g, int n)
{
return GEOSGeomGetPointN_r(handle, g, n);
}
/*
* Call only on LINESTRING
*/
Geometry*
GEOSGeomGetStartPoint(const Geometry* g)
{
return GEOSGeomGetStartPoint_r(handle, g);
}
/*
* Call only on LINESTRING
*/
Geometry*
GEOSGeomGetEndPoint(const Geometry* g)
{
return GEOSGeomGetEndPoint_r(handle, g);
}
/*
* Call only on LINESTRING
* return 2 on exception, 1 on true, 0 on false
*/
char
GEOSisClosed(const Geometry* g)
{
return GEOSisClosed_r(handle, g);
}
/*
* Call only on LINESTRING
* returns 0 on exception, otherwise 1
*/
int
GEOSGeomGetLength(const Geometry* g, double* length)
{
return GEOSGeomGetLength_r(handle, g, length);
}
/*
* Call only on LINESTRING
* returns -1 on exception
*/
int
GEOSGeomGetNumPoints(const Geometry* g)
{
return GEOSGeomGetNumPoints_r(handle, g);
}
/*
* For POINT
* returns 0 on exception, otherwise 1
*/
int
GEOSGeomGetX(const Geometry* g, double* x)
{
return GEOSGeomGetX_r(handle, g, x);
}
/*
* For POINT
* returns 0 on exception, otherwise 1
*/
int
GEOSGeomGetY(const Geometry* g, double* y)
{
return GEOSGeomGetY_r(handle, g, y);
}
/*
* For POINT
* returns 0 on exception, otherwise 1
*/
int
GEOSGeomGetZ(const Geometry* g1, double* z)
{
return GEOSGeomGetZ_r(handle, g1, z);
}
/*
* For POINT
* returns 0 on exception, otherwise 1
*/
int
GEOSGeomGetM(const Geometry* g1, double* m)
{
return GEOSGeomGetM_r(handle, g1, m);
}
/*
* Call only on polygon
* Return a copy of the internal Geometry.
*/
const Geometry*
GEOSGetExteriorRing(const Geometry* g)
{
return GEOSGetExteriorRing_r(handle, g);
}
/*
* Call only on polygon
* Return a pointer to internal storage, do not destroy it.
*/
const Geometry*
GEOSGetInteriorRingN(const Geometry* g, int n)
{
return GEOSGetInteriorRingN_r(handle, g, n);
}
Geometry*
GEOSGetCentroid(const Geometry* g)
{
return GEOSGetCentroid_r(handle, g);
}
int
GEOSHilbertCode(const GEOSGeometry *geom, const GEOSGeometry* extent,
unsigned int level, unsigned int *code)
{
return GEOSHilbertCode_r(handle, geom, extent, level, code);
}
Geometry*
GEOSMinimumBoundingCircle(const Geometry* g, double* radius, Geometry** center)
{
return GEOSMinimumBoundingCircle_r(handle, g, radius, center);
}
Geometry*
GEOSGeom_createCollection(int type, Geometry** geoms, unsigned int ngeoms)
{
return GEOSGeom_createCollection_r(handle, type, geoms, ngeoms);
}
Geometry**
GEOSGeom_releaseCollection(Geometry* collection, unsigned int * ngeoms)
{
return GEOSGeom_releaseCollection_r(handle, collection, ngeoms);
}
Geometry*
GEOSPolygonize(const Geometry* const* g, unsigned int ngeoms)
{
return GEOSPolygonize_r(handle, g, ngeoms);
}
Geometry*
GEOSPolygonize_valid(const Geometry* const* g, unsigned int ngeoms)
{
return GEOSPolygonize_valid_r(handle, g, ngeoms);
}
Geometry*
GEOSPolygonizer_getCutEdges(const Geometry* const* g, unsigned int ngeoms)
{
return GEOSPolygonizer_getCutEdges_r(handle, g, ngeoms);
}
GEOSGeometry*
GEOSPolygonize_full(const GEOSGeometry* input,
GEOSGeometry** cuts, GEOSGeometry** dangles, GEOSGeometry** invalid)
{
return GEOSPolygonize_full_r(handle, input, cuts, dangles, invalid);
}
Geometry*
GEOSBuildArea(const Geometry* g)
{
return GEOSBuildArea_r(handle, g);
}
Geometry*
GEOSMakeValid(const Geometry* g)
{
return GEOSMakeValid_r(handle, g);
}
GEOSMakeValidParams*
GEOSMakeValidParams_create()
{
return GEOSMakeValidParams_create_r(handle);
}
void
GEOSMakeValidParams_destroy(GEOSMakeValidParams* parms)
{
return GEOSMakeValidParams_destroy_r(handle, parms);
}
int
GEOSMakeValidParams_setMethod(
GEOSMakeValidParams* p,
GEOSMakeValidMethods method)
{
return GEOSMakeValidParams_setMethod_r(handle, p, method);
}