Coverage Report

Created: 2025-08-25 06:57

/src/geos/capi/geos_ts_c.cpp
Line
Count
Source (jump to first uncovered line)
1
/************************************************************************
2
 *
3
 *
4
 * C-Wrapper for GEOS library
5
 *
6
 * Copyright (C) 2005-2006 Refractions Research Inc.
7
 * Copyright (C) 2010-2012 Sandro Santilli <strk@kbt.io>
8
 * Copyright (C) 2016-2021 Daniel Baston <dbaston@gmail.com>
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@kbt.io>
16
 * Thread Safety modifications: Chuck Thibert <charles.thibert@ingres.com>
17
 *
18
 ***********************************************************************/
19
20
#include <geos/algorithm/BoundaryNodeRule.h>
21
#include <geos/algorithm/MinimumBoundingCircle.h>
22
#include <geos/algorithm/MinimumDiameter.h>
23
#include <geos/algorithm/MinimumAreaRectangle.h>
24
#include <geos/algorithm/Orientation.h>
25
#include <geos/algorithm/construct/MaximumInscribedCircle.h>
26
#include <geos/algorithm/construct/LargestEmptyCircle.h>
27
#include <geos/algorithm/distance/DiscreteHausdorffDistance.h>
28
#include <geos/algorithm/distance/DiscreteFrechetDistance.h>
29
#include <geos/algorithm/hull/ConcaveHull.h>
30
#include <geos/algorithm/hull/ConcaveHullOfPolygons.h>
31
#include <geos/coverage/CoverageCleaner.h>
32
#include <geos/coverage/CoverageSimplifier.h>
33
#include <geos/coverage/CoverageUnion.h>
34
#include <geos/coverage/CoverageValidator.h>
35
#include <geos/geom/CircularString.h>
36
#include <geos/geom/CompoundCurve.h>
37
#include <geos/geom/Coordinate.h>
38
#include <geos/geom/CoordinateSequence.h>
39
#include <geos/geom/Curve.h>
40
#include <geos/geom/CurvePolygon.h>
41
#include <geos/geom/Envelope.h>
42
#include <geos/geom/Geometry.h>
43
#include <geos/geom/GeometryCollection.h>
44
#include <geos/geom/GeometryFactory.h>
45
#include <geos/geom/IntersectionMatrix.h>
46
#include <geos/geom/LinearRing.h>
47
#include <geos/geom/LineSegment.h>
48
#include <geos/geom/LineString.h>
49
#include <geos/geom/MultiCurve.h>
50
#include <geos/geom/MultiLineString.h>
51
#include <geos/geom/MultiPoint.h>
52
#include <geos/geom/MultiPolygon.h>
53
#include <geos/geom/MultiSurface.h>
54
#include <geos/geom/Point.h>
55
#include <geos/geom/Polygon.h>
56
#include <geos/geom/PrecisionModel.h>
57
#include <geos/geom/SimpleCurve.h>
58
#include <geos/geom/prep/PreparedGeometry.h>
59
#include <geos/geom/prep/PreparedGeometryFactory.h>
60
#include <geos/geom/util/Densifier.h>
61
#include <geos/geom/util/GeometryFixer.h>
62
#include <geos/index/ItemVisitor.h>
63
#include <geos/index/strtree/TemplateSTRtree.h>
64
#include <geos/io/WKBReader.h>
65
#include <geos/io/WKBWriter.h>
66
#include <geos/io/WKTReader.h>
67
#include <geos/io/WKTWriter.h>
68
#include <geos/io/GeoJSONReader.h>
69
#include <geos/io/GeoJSONWriter.h>
70
#include <geos/linearref/LengthIndexedLine.h>
71
#include <geos/noding/GeometryNoder.h>
72
#include <geos/noding/Noder.h>
73
#include <geos/operation/buffer/BufferBuilder.h>
74
#include <geos/operation/buffer/BufferOp.h>
75
#include <geos/operation/buffer/BufferParameters.h>
76
#include <geos/operation/buffer/OffsetCurve.h>
77
#include <geos/operation/cluster/DBSCANClusterFinder.h>
78
#include <geos/operation/cluster/EnvelopeDistanceClusterFinder.h>
79
#include <geos/operation/cluster/EnvelopeIntersectsClusterFinder.h>
80
#include <geos/operation/cluster/GeometryDistanceClusterFinder.h>
81
#include <geos/operation/cluster/GeometryIntersectsClusterFinder.h>
82
#include <geos/operation/distance/DistanceOp.h>
83
#include <geos/operation/distance/IndexedFacetDistance.h>
84
#include <geos/operation/grid/Grid.h>
85
#include <geos/operation/grid/GridIntersection.h>
86
#include <geos/operation/linemerge/LineMerger.h>
87
#include <geos/operation/intersection/Rectangle.h>
88
#include <geos/operation/intersection/RectangleIntersection.h>
89
#include <geos/operation/overlay/snap/GeometrySnapper.h>
90
#include <geos/operation/overlayng/PrecisionReducer.h>
91
#include <geos/operation/overlayng/OverlayNG.h>
92
#include <geos/operation/overlayng/OverlayNGRobust.h>
93
#include <geos/operation/overlayng/UnaryUnionNG.h>
94
#include <geos/operation/polygonize/Polygonizer.h>
95
#include <geos/operation/polygonize/BuildArea.h>
96
#include <geos/operation/relate/RelateOp.h>
97
#include <geos/operation/sharedpaths/SharedPathsOp.h>
98
#include <geos/operation/union/CascadedPolygonUnion.h>
99
#include <geos/operation/union/DisjointSubsetUnion.h>
100
#include <geos/operation/valid/IsSimpleOp.h>
101
#include <geos/operation/valid/IsValidOp.h>
102
#include <geos/operation/valid/MakeValid.h>
103
#include <geos/operation/valid/RepeatedPointRemover.h>
104
105
#include <geos/operation/relateng/RelateNG.h>
106
107
#include <geos/precision/GeometryPrecisionReducer.h>
108
#include <geos/shape/fractal/HilbertEncoder.h>
109
#include <geos/simplify/DouglasPeuckerSimplifier.h>
110
#include <geos/simplify/PolygonHullSimplifier.h>
111
#include <geos/simplify/TopologyPreservingSimplifier.h>
112
#include <geos/triangulate/DelaunayTriangulationBuilder.h>
113
#include <geos/triangulate/VoronoiDiagramBuilder.h>
114
#include <geos/triangulate/polygon/ConstrainedDelaunayTriangulator.h>
115
#include <geos/util.h>
116
#include <geos/util/IllegalArgumentException.h>
117
#include <geos/util/Interrupt.h>
118
#include <geos/util/UniqueCoordinateArrayFilter.h>
119
#include <geos/util/Machine.h>
120
#include <geos/version.h>
121
122
// This should go away
123
#include <cmath> // finite
124
#include <cstdarg>
125
#include <cstddef>
126
#include <cstdio>
127
#include <cstdlib>
128
#include <cstring>
129
#include <fstream>
130
#include <iostream>
131
#include <sstream>
132
#include <string>
133
#include <memory>
134
135
#ifdef _MSC_VER
136
#pragma warning(disable : 4099)
137
#endif
138
139
// Some extra magic to make type declarations in geos_c.h work -
140
// for cross-checking of types in header.
141
// NOTE: the below defines or struct definition must be kept in exact
142
// sync between geos_c.cpp and geos_ts_c.cpp to avoid C++ One Definition Rule
143
// violations.
144
#define GEOSGeometry geos::geom::Geometry
145
#define GEOSPreparedGeometry geos::geom::prep::PreparedGeometry
146
#define GEOSClusterInfo geos::operation::cluster::Clusters
147
#define GEOSCoordSequence geos::geom::CoordinateSequence
148
#define GEOSBufferParams geos::operation::buffer::BufferParameters
149
0
#define GEOSSTRtree geos::index::strtree::TemplateSTRtree<void*>
150
#define GEOSWKTReader geos::io::WKTReader
151
#define GEOSWKTWriter geos::io::WKTWriter
152
#define GEOSWKBReader geos::io::WKBReader
153
#define GEOSWKBWriter geos::io::WKBWriter
154
#define GEOSGeoJSONReader geos::io::GeoJSONReader
155
#define GEOSGeoJSONWriter geos::io::GeoJSONWriter
156
157
// Implementation struct for the GEOSCoverageCleanParams object
158
typedef struct {
159
    double snappingDistance;
160
    int    overlapMergeStrategy;
161
    double gapMaximumWidth;
162
} GEOSCoverageCleanParams;
163
164
// Implementation struct for the GEOSMakeValidParams object
165
typedef struct {
166
    int method;
167
    int keepCollapsed;
168
} GEOSMakeValidParams;
169
170
#include "geos_c.h"
171
172
// Intentional, to allow non-standard C elements like C99 functions to be
173
// imported through C++ headers of C library, like <cmath>.
174
using namespace std;
175
176
/// Define this if you want operations triggering Exceptions to
177
/// be printed.
178
/// (will use the NOTIFY channel - only implemented for GEOSUnion so far)
179
///
180
#undef VERBOSE_EXCEPTIONS
181
182
#include <geos/export.h>
183
#include <geos/precision/MinimumClearance.h>
184
185
186
// import the most frequently used definitions globally
187
using geos::geom::Coordinate;
188
using geos::geom::CoordinateXY;
189
using geos::geom::CoordinateXYM;
190
using geos::geom::CoordinateXYZM;
191
using geos::geom::CoordinateSequence;
192
using geos::geom::Curve;
193
using geos::geom::Envelope;
194
using geos::geom::Geometry;
195
using geos::geom::GeometryCollection;
196
using geos::geom::GeometryFactory;
197
using geos::geom::LineString;
198
using geos::geom::LinearRing;
199
using geos::geom::MultiCurve;
200
using geos::geom::MultiLineString;
201
using geos::geom::MultiPolygon;
202
using geos::geom::Point;
203
using geos::geom::Polygon;
204
using geos::geom::PrecisionModel;
205
using geos::geom::SimpleCurve;
206
using geos::geom::Surface;
207
208
using geos::geom::prep::PreparedGeometry;
209
210
using geos::io::WKTReader;
211
using geos::io::WKTWriter;
212
using geos::io::WKBReader;
213
using geos::io::WKBWriter;
214
using geos::io::GeoJSONReader;
215
using geos::io::GeoJSONWriter;
216
217
using geos::algorithm::distance::DiscreteFrechetDistance;
218
using geos::algorithm::distance::DiscreteHausdorffDistance;
219
using geos::algorithm::hull::ConcaveHull;
220
using geos::algorithm::hull::ConcaveHullOfPolygons;
221
222
using geos::operation::buffer::BufferBuilder;
223
using geos::operation::buffer::BufferParameters;
224
using geos::operation::buffer::OffsetCurve;
225
using geos::operation::cluster::Clusters;
226
using geos::operation::distance::IndexedFacetDistance;
227
using geos::operation::geounion::CascadedPolygonUnion;
228
using geos::operation::overlayng::OverlayNG;
229
using geos::operation::overlayng::UnaryUnionNG;
230
using geos::operation::overlayng::OverlayNGRobust;
231
using geos::operation::relateng::RelateNG;
232
using geos::operation::valid::TopologyValidationError;
233
234
using geos::precision::GeometryPrecisionReducer;
235
236
using geos::simplify::PolygonHullSimplifier;
237
238
using geos::util::IllegalArgumentException;
239
240
typedef struct GEOSContextHandle_HS {
241
    const GeometryFactory* geomFactory;
242
    char msgBuffer[1024];
243
    GEOSMessageHandler noticeMessageOld;
244
    GEOSMessageHandler_r noticeMessageNew;
245
    void* noticeData;
246
    GEOSMessageHandler errorMessageOld;
247
    GEOSMessageHandler_r errorMessageNew;
248
    GEOSContextInterruptCallback* interrupt_cb;
249
    void* interrupt_cb_data;
250
    void* errorData;
251
    uint8_t WKBOutputDims;
252
    int WKBByteOrder;
253
    int initialized;
254
    std::unique_ptr<Point> point2d;
255
256
    GEOSContextHandle_HS()
257
        :
258
1
        geomFactory(nullptr),
259
1
        noticeMessageOld(nullptr),
260
1
        noticeMessageNew(nullptr),
261
1
        noticeData(nullptr),
262
1
        errorMessageOld(nullptr),
263
1
        errorMessageNew(nullptr),
264
1
        interrupt_cb(nullptr),
265
1
        interrupt_cb_data(nullptr),
266
1
        errorData(nullptr),
267
1
        point2d(nullptr)
268
1
    {
269
1
        memset(msgBuffer, 0, sizeof(msgBuffer));
270
1
        geomFactory = GeometryFactory::getDefaultInstance();
271
1
        point2d = geomFactory->createPoint(CoordinateXY{0, 0});
272
1
        WKBOutputDims = 2;
273
1
        WKBByteOrder = getMachineByteOrder();
274
1
        setNoticeHandler(nullptr);
275
1
        setErrorHandler(nullptr);
276
1
        initialized = 1;
277
1
    }
278
279
    GEOSMessageHandler
280
    setNoticeHandler(GEOSMessageHandler nf)
281
2
    {
282
2
        GEOSMessageHandler f = noticeMessageOld;
283
2
        noticeMessageOld = nf;
284
2
        noticeMessageNew = nullptr;
285
2
        noticeData = nullptr;
286
287
2
        return f;
288
2
    }
289
290
    GEOSMessageHandler
291
    setErrorHandler(GEOSMessageHandler nf)
292
2
    {
293
2
        GEOSMessageHandler f = errorMessageOld;
294
2
        errorMessageOld = nf;
295
2
        errorMessageNew = nullptr;
296
2
        errorData = nullptr;
297
298
2
        return f;
299
2
    }
300
301
    GEOSMessageHandler_r
302
    setNoticeHandler(GEOSMessageHandler_r nf, void* userData)
303
0
    {
304
0
        GEOSMessageHandler_r f = noticeMessageNew;
305
0
        noticeMessageOld = nullptr;
306
0
        noticeMessageNew = nf;
307
0
        noticeData = userData;
308
309
0
        return f;
310
0
    }
311
312
    GEOSMessageHandler_r
313
    setErrorHandler(GEOSMessageHandler_r ef, void* userData)
314
0
    {
315
0
        GEOSMessageHandler_r f = errorMessageNew;
316
0
        errorMessageOld = nullptr;
317
0
        errorMessageNew = ef;
318
0
        errorData = userData;
319
320
0
        return f;
321
0
    }
322
323
    GEOSContextInterruptCallback*
324
    setInterruptHandler(GEOSContextInterruptCallback* cb, void* userData)
325
0
    {
326
0
        auto old = interrupt_cb;
327
0
        interrupt_cb = cb;
328
0
        interrupt_cb_data = userData;
329
0
        return old;
330
0
    }
331
332
    void
333
    NOTICE_MESSAGE(GEOS_PRINTF_FORMAT const char *fmt, ...) GEOS_PRINTF_FORMAT_ATTR(2, 3)
334
0
    {
335
0
        if(nullptr == noticeMessageOld && nullptr == noticeMessageNew) {
336
0
            return;
337
0
        }
338
339
0
        va_list args;
340
0
        va_start(args, fmt);
341
        #ifdef __MINGW32__
342
        #pragma GCC diagnostic push
343
        #pragma GCC diagnostic ignored "-Wsuggest-attribute=format"
344
        #endif
345
0
        int result = vsnprintf(msgBuffer, sizeof(msgBuffer) - 1, fmt, args);
346
        #ifdef __MINGW32__
347
        #pragma GCC diagnostic pop
348
        #endif
349
0
        va_end(args);
350
351
0
        if(result > 0) {
352
0
            if(noticeMessageOld) {
353
0
                noticeMessageOld("%s", msgBuffer);
354
0
            }
355
0
            else {
356
0
                noticeMessageNew(msgBuffer, noticeData);
357
0
            }
358
0
        }
359
0
    }
360
361
    void
362
    ERROR_MESSAGE(GEOS_PRINTF_FORMAT const char *fmt, ...) GEOS_PRINTF_FORMAT_ATTR(2, 3)
363
6.10k
    {
364
6.10k
        if(nullptr == errorMessageOld && nullptr == errorMessageNew) {
365
0
            return;
366
0
        }
367
368
6.10k
        va_list args;
369
6.10k
        va_start(args, fmt);
370
        #ifdef __MINGW32__
371
        #pragma GCC diagnostic push
372
        #pragma GCC diagnostic ignored "-Wsuggest-attribute=format"
373
        #endif
374
6.10k
        int result = vsnprintf(msgBuffer, sizeof(msgBuffer) - 1, fmt, args);
375
        #ifdef __MINGW32__
376
        #pragma GCC diagnostic pop
377
        #endif
378
6.10k
        va_end(args);
379
380
6.10k
        if(result > 0) {
381
6.10k
            if(errorMessageOld) {
382
6.10k
                errorMessageOld("%s", msgBuffer);
383
6.10k
            }
384
0
            else {
385
0
                errorMessageNew(msgBuffer, errorData);
386
0
            }
387
6.10k
        }
388
6.10k
    }
389
} GEOSContextHandleInternal_t;
390
391
// CAPI_ItemVisitor is used internally by the CAPI STRtree
392
// wrappers. It's defined here just to keep it out of the
393
// extern "C" block.
394
class CAPI_ItemVisitor : public geos::index::ItemVisitor {
395
    GEOSQueryCallback callback;
396
    void* userdata;
397
public:
398
    CAPI_ItemVisitor(GEOSQueryCallback cb, void* ud)
399
0
        : ItemVisitor(), callback(cb), userdata(ud) {}
400
401
0
    void operator()(void* item) {
402
0
        callback(item, userdata);
403
0
    }
404
405
    void
406
    visitItem(void* item) override
407
0
    {
408
0
        callback(item, userdata);
409
0
    }
410
};
411
412
413
//## PROTOTYPES #############################################
414
415
extern "C" const char GEOS_DLL* GEOSjtsport();
416
extern "C" char GEOS_DLL* GEOSasText(Geometry* g1);
417
418
419
namespace { // anonymous
420
421
char*
422
gstrdup_s(const char* str, const std::size_t size)
423
4.91k
{
424
4.91k
    char* out = static_cast<char*>(malloc(size + 1));
425
4.91k
    if(nullptr != out) {
426
        // as no strlen call necessary, memcpy may be faster than strcpy
427
4.91k
        std::memcpy(out, str, size + 1);
428
4.91k
    }
429
430
4.91k
    assert(nullptr != out);
431
432
    // we haven't been checking allocation before ticket #371
433
4.91k
    if(nullptr == out) {
434
0
        throw(std::runtime_error("Failed to allocate memory for duplicate string"));
435
0
    }
436
437
4.91k
    return out;
438
4.91k
}
439
440
char*
441
gstrdup(std::string const& str)
442
4.91k
{
443
4.91k
    return gstrdup_s(str.c_str(), str.size());
444
4.91k
}
445
446
struct InterruptManager {
447
    InterruptManager(GEOSContextHandle_t handle) :
448
56.4k
        cb(handle->interrupt_cb),
449
56.4k
        cb_data(handle->interrupt_cb_data) {
450
56.4k
        if (cb) {
451
0
            geos::util::CurrentThreadInterrupt::registerCallback(cb, cb_data);
452
0
        }
453
56.4k
    }
454
455
56.4k
    ~InterruptManager() {
456
56.4k
        if (cb != nullptr) {
457
0
            geos::util::CurrentThreadInterrupt::registerCallback(nullptr, nullptr);
458
0
        }
459
56.4k
    }
460
461
    GEOSContextInterruptCallback* cb;
462
    void* cb_data;
463
};
464
465
struct NotInterruptible {
466
0
    NotInterruptible(GEOSContextHandle_t handle) {
467
0
        (void) handle;
468
0
    }
469
};
470
471
} // namespace anonymous
472
473
// Execute a lambda, using the given context handle to process errors.
474
// Return errval on error.
475
// Errval should be of the type returned by f, unless f returns a bool in which case we promote to char.
476
template<typename InterruptManagerType=InterruptManager, typename F>
477
inline auto execute(
478
        GEOSContextHandle_t extHandle,
479
        typename std::conditional<std::is_same<decltype(std::declval<F>()()),bool>::value,
480
                                  char,
481
                                  decltype(std::declval<F>()())>::type errval,
482
0
        F&& f) -> decltype(errval) {
483
0
    if (extHandle == nullptr) {
484
0
        throw std::runtime_error("GEOS context handle is uninitialized, call initGEOS");
485
0
    }
486
487
0
    GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
488
0
    if (!handle->initialized) {
489
0
        return errval;
490
0
    }
491
492
0
    InterruptManagerType ic(handle);
493
494
0
    try {
495
0
        return f();
496
0
    } catch (const std::exception& e) {
497
0
        handle->ERROR_MESSAGE("%s", e.what());
498
0
    } catch (...) {
499
0
        handle->ERROR_MESSAGE("Unknown exception thrown");
500
0
    }
501
502
0
    return errval;
503
0
}
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ14GEOSDisjoint_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ13GEOSTouches_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ16GEOSIntersects_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ13GEOSCrosses_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ12GEOSWithin_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ14GEOSContains_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ14GEOSOverlaps_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ12GEOSCovers_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ15GEOSCoveredBy_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ12GEOSEquals_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ19GEOSRelatePattern_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ24GEOSRelatePatternMatch_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ13GEOSisValid_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ19GEOSisValidDetail_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ17GEOSEqualsExact_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ21GEOSEqualsIdentical_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ14GEOSDistance_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ20GEOSDistanceWithin_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ21GEOSDistanceIndexed_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ23GEOSHausdorffDistance_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ30GEOSHausdorffDistanceDensify_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ21GEOSFrechetDistance_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ28GEOSFrechetDistanceDensify_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116NotInterruptibleEZ10GEOSArea_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116NotInterruptibleEZ12GEOSLength_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ32GEOSClusterInfo_getNumClusters_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ32GEOSClusterInfo_getClusterSize_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ13GEOSisEmpty_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ14GEOSisSimple_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ20GEOSisSimpleDetail_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ12GEOSisRing_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ16GEOSGeomTypeId_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ22GEOSMinimumClearance_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ31GEOSGridIntersectionFractions_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ23GEOSGetNumCoordinates_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ15GEOSNormalize_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ20GEOSOrientPolygons_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116NotInterruptibleEZ25GEOSGetNumInteriorRings_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116NotInterruptibleEZ22GEOSGetNumGeometries_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ14GEOSisClosed_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ19GEOSGeomGetLength_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ22GEOSGeomGetNumPoints_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ14GEOSGeomGetX_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ14GEOSGeomGetY_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ14GEOSGeomGetZ_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ14GEOSGeomGetM_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ17GEOSHilbertCode_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ38GEOSMakeValidParams_setKeepCollapsed_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ31GEOSMakeValidParams_setMethod_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ13GEOSGetSRID_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ10GEOSHasZ_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ10GEOSHasM_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ23GEOS_getWKBOutputDims_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ23GEOS_setWKBOutputDims_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ22GEOS_getWKBByteOrder_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ22GEOS_setWKBByteOrder_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ27GEOSCoordSeq_copyToArrays_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ27GEOSCoordSeq_copyToBuffer_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ19GEOSCoordSeq_hasZ_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ19GEOSCoordSeq_hasM_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116NotInterruptibleEZ26GEOSCoordSeq_setOrdinate_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116NotInterruptibleEZ20GEOSCoordSeq_setXY_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116NotInterruptibleEZ21GEOSCoordSeq_setXYZ_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116NotInterruptibleEZ26GEOSCoordSeq_getOrdinate_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116NotInterruptibleEZ20GEOSCoordSeq_getXY_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116NotInterruptibleEZ21GEOSCoordSeq_getXYZ_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116NotInterruptibleEZ22GEOSCoordSeq_getSize_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116NotInterruptibleEZ28GEOSCoordSeq_getDimensions_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ20GEOSCoordSeq_isCCW_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ23GEOSGeom_getPrecision_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ24GEOSGeom_getDimensions_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ33GEOSGeom_getCoordinateDimension_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ18GEOSGeom_getXMin_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ18GEOSGeom_getXMax_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ18GEOSGeom_getYMin_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ18GEOSGeom_getYMax_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ20GEOSGeom_getExtent_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ34GEOSWKTWriter_getOutputDimension_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ34GEOSWKBWriter_getOutputDimension_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ28GEOSWKBWriter_getByteOrder_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ30GEOSWKBWriter_getIncludeSRID_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ25GEOSWKBWriter_getFlavor_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ38GEOSGeoJSONWriter_getOutputDimension_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ22GEOSPreparedContains_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ30GEOSPreparedContainsProperly_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ23GEOSPreparedCoveredBy_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ20GEOSPreparedCovers_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ21GEOSPreparedCrosses_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ22GEOSPreparedDisjoint_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ24GEOSPreparedIntersects_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ22GEOSPreparedOverlaps_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ21GEOSPreparedTouches_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ20GEOSPreparedWithin_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ27GEOSPreparedRelatePattern_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ22GEOSPreparedDistance_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ28GEOSPreparedDistanceWithin_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ19GEOSSTRtree_build_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ20GEOSSTRtree_remove_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ13GEOSProject_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ22GEOSOrientationIndex_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ33GEOSBufferParams_setEndCapStyle_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ31GEOSBufferParams_setJoinStyle_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ32GEOSBufferParams_setMitreLimit_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ38GEOSBufferParams_setQuadrantSegments_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ33GEOSBufferParams_setSingleSided_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ25GEOSSegmentIntersection_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ21GEOSCoverageIsValid_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ45GEOSCoverageCleanParams_setSnappingDistance_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ44GEOSCoverageCleanParams_setGapMaximumWidth_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ49GEOSCoverageCleanParams_setOverlapMergeStrategy_rE3$_0EDtfp0_EP20GEOSContextHandle_HSNSt3__111conditionalIXsr3std7is_sameIDTclclsr3stdE7declvalIT0_EEEEbEE5valueEcS9_E4typeEOS8_
504
505
// Execute a lambda, using the given context handle to process errors.
506
// Return nullptr on error.
507
template<typename InterruptManagerType=InterruptManager, typename F, typename std::enable_if<!std::is_void<decltype(std::declval<F>()())>::value, std::nullptr_t>::type = nullptr>
508
33.4k
inline auto execute(GEOSContextHandle_t extHandle, F&& f) -> decltype(f()) {
509
33.4k
    if (extHandle == nullptr) {
510
0
        throw std::runtime_error("context handle is uninitialized, call initGEOS");
511
0
    }
512
513
33.4k
    GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
514
33.4k
    if (!handle->initialized) {
515
0
        return nullptr;
516
0
    }
517
518
33.4k
    InterruptManagerType ic(handle);
519
520
33.4k
    try {
521
33.4k
        return f();
522
33.4k
    } catch (const std::exception& e) {
523
6.10k
        handle->ERROR_MESSAGE("%s", e.what());
524
6.10k
    } catch (...) {
525
0
        handle->ERROR_MESSAGE("Unknown exception thrown");
526
0
    }
527
528
6.10k
    return nullptr;
529
33.4k
}
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ12GEOSRelate_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ28GEOSRelateBoundaryNodeRule_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ19GEOSisValidReason_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ19GEOSNearestPoints_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ19GEOSClusterDBSCAN_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ31GEOSClusterGeometryIntersects_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ31GEOSClusterEnvelopeIntersects_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ29GEOSClusterEnvelopeDistance_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ29GEOSClusterGeometryDistance_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ38GEOSClusterInfo_getInputsForClusterN_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ38GEOSClusterInfo_getClustersForInputs_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ17GEOSGeomFromWKT_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Line
Count
Source
508
5.64k
inline auto execute(GEOSContextHandle_t extHandle, F&& f) -> decltype(f()) {
509
5.64k
    if (extHandle == nullptr) {
510
0
        throw std::runtime_error("context handle is uninitialized, call initGEOS");
511
0
    }
512
513
5.64k
    GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
514
5.64k
    if (!handle->initialized) {
515
0
        return nullptr;
516
0
    }
517
518
5.64k
    InterruptManagerType ic(handle);
519
520
5.64k
    try {
521
5.64k
        return f();
522
5.64k
    } catch (const std::exception& e) {
523
733
        handle->ERROR_MESSAGE("%s", e.what());
524
733
    } catch (...) {
525
0
        handle->ERROR_MESSAGE("Unknown exception thrown");
526
0
    }
527
528
733
    return nullptr;
529
5.64k
}
geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ15GEOSGeomToWKT_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Line
Count
Source
508
4.91k
inline auto execute(GEOSContextHandle_t extHandle, F&& f) -> decltype(f()) {
509
4.91k
    if (extHandle == nullptr) {
510
0
        throw std::runtime_error("context handle is uninitialized, call initGEOS");
511
0
    }
512
513
4.91k
    GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
514
4.91k
    if (!handle->initialized) {
515
0
        return nullptr;
516
0
    }
517
518
4.91k
    InterruptManagerType ic(handle);
519
520
4.91k
    try {
521
4.91k
        return f();
522
4.91k
    } catch (const std::exception& e) {
523
0
        handle->ERROR_MESSAGE("%s", e.what());
524
0
    } catch (...) {
525
0
        handle->ERROR_MESSAGE("Unknown exception thrown");
526
0
    }
527
528
0
    return nullptr;
529
4.91k
}
geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ19GEOSGeomToWKB_buf_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Line
Count
Source
508
4.50k
inline auto execute(GEOSContextHandle_t extHandle, F&& f) -> decltype(f()) {
509
4.50k
    if (extHandle == nullptr) {
510
0
        throw std::runtime_error("context handle is uninitialized, call initGEOS");
511
0
    }
512
513
4.50k
    GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
514
4.50k
    if (!handle->initialized) {
515
0
        return nullptr;
516
0
    }
517
518
4.50k
    InterruptManagerType ic(handle);
519
520
4.50k
    try {
521
4.50k
        return f();
522
4.50k
    } catch (const std::exception& e) {
523
0
        handle->ERROR_MESSAGE("%s", e.what());
524
0
    } catch (...) {
525
0
        handle->ERROR_MESSAGE("Unknown exception thrown");
526
0
    }
527
528
0
    return nullptr;
529
4.50k
}
geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ21GEOSGeomFromWKB_buf_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Line
Count
Source
508
4.91k
inline auto execute(GEOSContextHandle_t extHandle, F&& f) -> decltype(f()) {
509
4.91k
    if (extHandle == nullptr) {
510
0
        throw std::runtime_error("context handle is uninitialized, call initGEOS");
511
0
    }
512
513
4.91k
    GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
514
4.91k
    if (!handle->initialized) {
515
0
        return nullptr;
516
0
    }
517
518
4.91k
    InterruptManagerType ic(handle);
519
520
4.91k
    try {
521
4.91k
        return f();
522
4.91k
    } catch (const std::exception& e) {
523
415
        handle->ERROR_MESSAGE("%s", e.what());
524
415
    } catch (...) {
525
0
        handle->ERROR_MESSAGE("Unknown exception thrown");
526
0
    }
527
528
415
    return nullptr;
529
4.91k
}
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ19GEOSGeomToHEX_buf_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ21GEOSGeomFromHEX_buf_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ14GEOSGeomType_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ14GEOSEnvelope_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ18GEOSIntersection_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Line
Count
Source
508
4.50k
inline auto execute(GEOSContextHandle_t extHandle, F&& f) -> decltype(f()) {
509
4.50k
    if (extHandle == nullptr) {
510
0
        throw std::runtime_error("context handle is uninitialized, call initGEOS");
511
0
    }
512
513
4.50k
    GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
514
4.50k
    if (!handle->initialized) {
515
0
        return nullptr;
516
0
    }
517
518
4.50k
    InterruptManagerType ic(handle);
519
520
4.50k
    try {
521
4.50k
        return f();
522
4.50k
    } catch (const std::exception& e) {
523
1.29k
        handle->ERROR_MESSAGE("%s", e.what());
524
1.29k
    } catch (...) {
525
0
        handle->ERROR_MESSAGE("Unknown exception thrown");
526
0
    }
527
528
1.29k
    return nullptr;
529
4.50k
}
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ22GEOSIntersectionPrec_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ12GEOSBuffer_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ21GEOSBufferWithStyle_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ13GEOSDensify_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ17GEOSOffsetCurve_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ23GEOSSingleSidedBuffer_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ16GEOSConvexHull_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ17GEOSConcaveHull_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ25GEOSConcaveHullByLength_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ25GEOSPolygonHullSimplify_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ29GEOSPolygonHullSimplifyMode_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ27GEOSConcaveHullOfPolygons_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ29GEOSMinimumRotatedRectangle_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ28GEOSMaximumInscribedCircle_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ24GEOSLargestEmptyCircle_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ18GEOSMinimumWidth_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ26GEOSMinimumClearanceLine_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ16GEOSDifference_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Line
Count
Source
508
4.50k
inline auto execute(GEOSContextHandle_t extHandle, F&& f) -> decltype(f()) {
509
4.50k
    if (extHandle == nullptr) {
510
0
        throw std::runtime_error("context handle is uninitialized, call initGEOS");
511
0
    }
512
513
4.50k
    GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
514
4.50k
    if (!handle->initialized) {
515
0
        return nullptr;
516
0
    }
517
518
4.50k
    InterruptManagerType ic(handle);
519
520
4.50k
    try {
521
4.50k
        return f();
522
4.50k
    } catch (const std::exception& e) {
523
1.85k
        handle->ERROR_MESSAGE("%s", e.what());
524
1.85k
    } catch (...) {
525
0
        handle->ERROR_MESSAGE("Unknown exception thrown");
526
0
    }
527
528
1.85k
    return nullptr;
529
4.50k
}
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ20GEOSDifferencePrec_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ14GEOSBoundary_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ19GEOSSymDifference_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ23GEOSSymDifferencePrec_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ11GEOSUnion_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Line
Count
Source
508
4.50k
inline auto execute(GEOSContextHandle_t extHandle, F&& f) -> decltype(f()) {
509
4.50k
    if (extHandle == nullptr) {
510
0
        throw std::runtime_error("context handle is uninitialized, call initGEOS");
511
0
    }
512
513
4.50k
    GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
514
4.50k
    if (!handle->initialized) {
515
0
        return nullptr;
516
0
    }
517
518
4.50k
    InterruptManagerType ic(handle);
519
520
4.50k
    try {
521
4.50k
        return f();
522
4.50k
    } catch (const std::exception& e) {
523
1.80k
        handle->ERROR_MESSAGE("%s", e.what());
524
1.80k
    } catch (...) {
525
0
        handle->ERROR_MESSAGE("Unknown exception thrown");
526
0
    }
527
528
1.80k
    return nullptr;
529
4.50k
}
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ15GEOSUnionPrec_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ19GEOSCoverageUnion_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ25GEOSDisjointSubsetUnion_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ16GEOSUnaryUnion_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ20GEOSUnaryUnionPrec_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ10GEOSNode_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ19GEOSUnionCascaded_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ20GEOSPointOnSurface_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ16GEOSClipByRect_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ22GEOSGeom_transformXY_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ23GEOSGeom_transformXYZ_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116NotInterruptibleEZ18GEOSGetGeometryN_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ19GEOSGeomGetPointN_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ23GEOSGeomGetStartPoint_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ21GEOSGeomGetEndPoint_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116NotInterruptibleEZ21GEOSGetExteriorRing_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116NotInterruptibleEZ22GEOSGetInteriorRingN_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ17GEOSGetCentroid_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ27GEOSMinimumBoundingCircle_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ32GEOSGeom_createEmptyCollection_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ27GEOSGeom_createCollection_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ28GEOSGeom_releaseCollection_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ16GEOSPolygonize_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ22GEOSPolygonize_valid_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ15GEOSBuildArea_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ28GEOSMakeValidParams_create_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ25GEOSMakeValidWithParams_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ25GEOSMakeValidWithParams_rE3$_1TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ26GEOSRemoveRepeatedPoints_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ29GEOSPolygonizer_getCutEdges_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ21GEOSPolygonize_full_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ15GEOSLineMerge_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ23GEOSLineMergeDirected_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ19GEOSLineSubstring_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ13GEOSReverse_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ22GEOSGeom_getUserData_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ21GEOSCoordSeq_create_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ35GEOSCoordSeq_createWithDimensions_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ29GEOSCoordSeq_copyFromBuffer_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ29GEOSCoordSeq_copyFromArrays_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ20GEOSCoordSeq_clone_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ22GEOSGeom_getCoordSeq_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ27GEOSGeom_createEmptyPoint_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ22GEOSGeom_createPoint_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ28GEOSGeom_createPointFromXY_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ27GEOSGeom_createLinearRing_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ32GEOSGeom_createEmptyLineString_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ27GEOSGeom_createLineString_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ29GEOSGeom_createEmptyPolygon_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ24GEOSGeom_createPolygon_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ26GEOSGeom_createRectangle_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ31GEOSGeom_createCircularString_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ36GEOSGeom_createEmptyCircularString_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ30GEOSGeom_createCompoundCurve_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ35GEOSGeom_createEmptyCompoundCurve_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ29GEOSGeom_createCurvePolygon_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ34GEOSGeom_createEmptyCurvePolygon_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ16GEOSGeom_clone_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ23GEOSGeom_setPrecision_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ14GEOSSimplify_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ30GEOSTopologyPreserveSimplify_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ22GEOSWKTReader_create_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ20GEOSWKTReader_read_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ22GEOSWKTWriter_create_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ21GEOSWKTWriter_write_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ22GEOSWKBReader_create_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ20GEOSWKBReader_read_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ23GEOSWKBReader_readHEX_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ22GEOSWKBWriter_create_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ21GEOSWKBWriter_write_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ24GEOSWKBWriter_writeHEX_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ26GEOSGeoJSONReader_create_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ32GEOSGeoJSONReader_readGeometry_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ26GEOSGeoJSONWriter_create_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ33GEOSGeoJSONWriter_writeGeometry_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ13GEOSPrepare_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ20GEOSPreparedRelate_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ27GEOSPreparedNearestPoints_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ20GEOSSTRtree_create_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ29GEOSSTRtree_nearest_generic_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ17GEOSInterpolate_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ30GEOSGeom_extractUniquePoints_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ10GEOSSnap_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ25GEOSBufferParams_create_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ22GEOSBufferWithParams_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ27GEOSDelaunayTriangulation_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ38GEOSConstrainedDelaunayTriangulation_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ20GEOSVoronoiDiagram_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ24GEOSCoverageSimplifyVW_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ32GEOSCoverageCleanParams_create_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ29GEOSCoverageCleanWithParams_rE3$_0TnNSt3__19enable_ifIXntsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEDTclfp0_EEP20GEOSContextHandle_HSOS5_
530
531
// Execute a lambda, using the given context handle to process errors.
532
// No return value.
533
template<typename InterruptManagerType=InterruptManager, typename F, typename std::enable_if<std::is_void<decltype(std::declval<F>()())>::value, std::nullptr_t>::type = nullptr>
534
22.9k
inline void execute(GEOSContextHandle_t extHandle, F&& f) {
535
22.9k
    GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
536
537
22.9k
    if (handle != nullptr) {
538
22.9k
        InterruptManagerType ic(handle);
539
22.9k
    }
540
541
22.9k
    try {
542
22.9k
        f();
543
22.9k
    } catch (const std::exception& e) {
544
0
        handle->ERROR_MESSAGE("%s", e.what());
545
0
    } catch (...) {
546
0
        handle->ERROR_MESSAGE("Unknown exception thrown");
547
0
    }
548
22.9k
}
geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ18GEOSGeom_destroy_rE3$_0TnNSt3__19enable_ifIXsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEvP20GEOSContextHandle_HSOS5_
Line
Count
Source
534
22.9k
inline void execute(GEOSContextHandle_t extHandle, F&& f) {
535
22.9k
    GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
536
537
22.9k
    if (handle != nullptr) {
538
22.9k
        InterruptManagerType ic(handle);
539
22.9k
    }
540
541
22.9k
    try {
542
22.9k
        f();
543
22.9k
    } catch (const std::exception& e) {
544
0
        handle->ERROR_MESSAGE("%s", e.what());
545
0
    } catch (...) {
546
0
        handle->ERROR_MESSAGE("Unknown exception thrown");
547
0
    }
548
22.9k
}
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ22GEOSGeom_setUserData_rE3$_0TnNSt3__19enable_ifIXsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEvP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ13GEOSSetSRID_rE3$_0TnNSt3__19enable_ifIXsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEvP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ22GEOSCoordSeq_destroy_rE3$_0TnNSt3__19enable_ifIXsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEvP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ23GEOSWKTReader_destroy_rE3$_0TnNSt3__19enable_ifIXsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEvP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ31GEOSWKTReader_setFixStructure_rE3$_0TnNSt3__19enable_ifIXsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEvP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ23GEOSWKTWriter_destroy_rE3$_0TnNSt3__19enable_ifIXsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEvP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ23GEOSWKTWriter_setTrim_rE3$_0TnNSt3__19enable_ifIXsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEvP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ36GEOSWKTWriter_setRoundingPrecision_rE3$_0TnNSt3__19enable_ifIXsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEvP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ34GEOSWKTWriter_setOutputDimension_rE3$_0TnNSt3__19enable_ifIXsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEvP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ24GEOSWKTWriter_setOld3D_rE3$_0TnNSt3__19enable_ifIXsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEvP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ23GEOSWKBReader_destroy_rE3$_0TnNSt3__19enable_ifIXsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEvP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ31GEOSWKBReader_setFixStructure_rE3$_0TnNSt3__19enable_ifIXsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEvP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ23GEOSWKBWriter_destroy_rE3$_0TnNSt3__19enable_ifIXsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEvP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ34GEOSWKBWriter_setOutputDimension_rE3$_0TnNSt3__19enable_ifIXsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEvP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ28GEOSWKBWriter_setByteOrder_rE3$_0TnNSt3__19enable_ifIXsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEvP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ30GEOSWKBWriter_setIncludeSRID_rE3$_0TnNSt3__19enable_ifIXsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEvP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ25GEOSWKBWriter_setFlavor_rE3$_0TnNSt3__19enable_ifIXsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEvP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ27GEOSGeoJSONReader_destroy_rE3$_0TnNSt3__19enable_ifIXsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEvP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ27GEOSGeoJSONWriter_destroy_rE3$_0TnNSt3__19enable_ifIXsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEvP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ38GEOSGeoJSONWriter_setOutputDimension_rE3$_0TnNSt3__19enable_ifIXsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEvP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ26GEOSPreparedGeom_destroy_rE3$_0TnNSt3__19enable_ifIXsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEvP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ20GEOSSTRtree_insert_rE3$_0TnNSt3__19enable_ifIXsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEvP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ19GEOSSTRtree_query_rE3$_0TnNSt3__19enable_ifIXsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEvP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ21GEOSSTRtree_iterate_rE3$_0TnNSt3__19enable_ifIXsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEvP20GEOSContextHandle_HSOS5_
Unexecuted instantiation: geos_ts_c.cpp:_Z7executeIN12_GLOBAL__N_116InterruptManagerEZ21GEOSSTRtree_destroy_rE3$_0TnNSt3__19enable_ifIXsr3std7is_voidIDTclclsr3stdE7declvalIT0_EEEEEE5valueEDnE4typeELDn0EEvP20GEOSContextHandle_HSOS5_
549
550
extern "C" {
551
552
    GEOSContextHandle_t
553
    initGEOS_r(GEOSMessageHandler nf, GEOSMessageHandler ef)
554
1
    {
555
1
        GEOSContextHandle_t handle = GEOS_init_r();
556
557
1
        if(nullptr != handle) {
558
1
            GEOSContext_setNoticeHandler_r(handle, nf);
559
1
            GEOSContext_setErrorHandler_r(handle, ef);
560
1
        }
561
562
1
        return handle;
563
1
    }
564
565
    GEOSContextHandle_t
566
    GEOS_init_r()
567
1
    {
568
1
        GEOSContextHandleInternal_t* handle = new GEOSContextHandleInternal_t();
569
570
1
        geos::util::Interrupt::cancel();
571
572
1
        return static_cast<GEOSContextHandle_t>(handle);
573
1
    }
574
575
    GEOSMessageHandler
576
    GEOSContext_setNoticeHandler_r(GEOSContextHandle_t extHandle, GEOSMessageHandler nf)
577
1
    {
578
1
        GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
579
1
        if(0 == handle->initialized) {
580
0
            return nullptr;
581
0
        }
582
583
1
        return handle->setNoticeHandler(nf);
584
1
    }
585
586
    GEOSMessageHandler
587
    GEOSContext_setErrorHandler_r(GEOSContextHandle_t extHandle, GEOSMessageHandler nf)
588
1
    {
589
1
        GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
590
1
        if(0 == handle->initialized) {
591
0
            return nullptr;
592
0
        }
593
594
1
        return handle->setErrorHandler(nf);
595
1
    }
596
597
    GEOSMessageHandler_r
598
    GEOSContext_setNoticeMessageHandler_r(GEOSContextHandle_t extHandle, GEOSMessageHandler_r nf, void* userData)
599
0
    {
600
0
        GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
601
0
        if(0 == handle->initialized) {
602
0
            return nullptr;
603
0
        }
604
605
0
        return handle->setNoticeHandler(nf, userData);
606
0
    }
607
608
    GEOSMessageHandler_r
609
    GEOSContext_setErrorMessageHandler_r(GEOSContextHandle_t extHandle, GEOSMessageHandler_r ef, void* userData)
610
0
    {
611
0
        GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
612
0
        if(0 == handle->initialized) {
613
0
            return nullptr;
614
0
        }
615
616
0
        return handle->setErrorHandler(ef, userData);
617
0
    }
618
619
    GEOSContextInterruptCallback*
620
    GEOSContext_setInterruptCallback_r(GEOSContextHandle_t extHandle, GEOSContextInterruptCallback* cb, void* userData)
621
0
    {
622
0
        GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
623
0
        if(0 == handle->initialized) {
624
0
            return nullptr;
625
0
        }
626
627
0
        return handle->setInterruptHandler(cb, userData);
628
0
    }
629
630
    void
631
    finishGEOS_r(GEOSContextHandle_t extHandle)
632
0
    {
633
        // Fix up freeing handle w.r.t. malloc above
634
0
        delete extHandle;
635
0
        extHandle = nullptr;
636
0
    }
637
638
    void
639
    GEOS_finish_r(GEOSContextHandle_t extHandle)
640
0
    {
641
0
        finishGEOS_r(extHandle);
642
0
    }
643
644
    void
645
    GEOSFree_r(GEOSContextHandle_t extHandle, void* buffer)
646
0
    {
647
0
        assert(nullptr != extHandle);
648
0
        geos::ignore_unused_variable_warning(extHandle);
649
650
0
        free(buffer);
651
0
    }
652
653
//-----------------------------------------------------------
654
// relate()-related functions
655
//  return 0 = false, 1 = true, 2 = error occurred
656
//-----------------------------------------------------------
657
658
    char
659
    GEOSDisjoint_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
660
0
    {
661
0
        return execute(extHandle, 2, [&]() {
662
0
            return g1->disjoint(g2);
663
0
        });
664
0
    }
665
666
    char
667
    GEOSTouches_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
668
0
    {
669
0
        return execute(extHandle, 2, [&]() {
670
0
            return g1->touches(g2);
671
0
        });
672
0
    }
673
674
    char
675
    GEOSIntersects_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
676
0
    {
677
0
        return execute(extHandle, 2, [&]() {
678
0
            return g1->intersects(g2);
679
0
        });
680
0
    }
681
682
    char
683
    GEOSCrosses_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
684
0
    {
685
0
        return execute(extHandle, 2, [&]() {
686
0
            return g1->crosses(g2);
687
0
        });
688
0
    }
689
690
    char
691
    GEOSWithin_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
692
0
    {
693
0
        return execute(extHandle, 2, [&]() {
694
0
            return g1->within(g2);
695
0
        });
696
0
    }
697
698
    char
699
    GEOSContains_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
700
0
    {
701
0
        return execute(extHandle, 2, [&]() {
702
0
            return g1->contains(g2);
703
0
        });
704
0
    }
705
706
    char
707
    GEOSOverlaps_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
708
0
    {
709
0
        return execute(extHandle, 2, [&]() {
710
0
            return g1->overlaps(g2);
711
0
        });
712
0
    }
713
714
    char
715
    GEOSCovers_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
716
0
    {
717
0
        return execute(extHandle, 2, [&]() {
718
0
            return g1->covers(g2);
719
0
        });
720
0
    }
721
722
    char
723
    GEOSCoveredBy_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
724
0
    {
725
0
        return execute(extHandle, 2, [&]() {
726
0
            return g1->coveredBy(g2);
727
0
        });
728
0
    }
729
730
    char
731
    GEOSEquals_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
732
0
    {
733
0
        return execute(extHandle, 2, [&]() {
734
0
            return g1->equals(g2);
735
0
        });
736
0
    }
737
738
739
//-------------------------------------------------------------------
740
// low-level relate functions
741
//------------------------------------------------------------------
742
743
    char
744
    GEOSRelatePattern_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2, const char* imPattern)
745
0
    {
746
0
        return execute(extHandle, 2, [&]() {
747
0
            std::string s(imPattern);
748
0
            return g1->relate(g2, s);
749
0
        });
750
0
    }
751
752
    char
753
    GEOSRelatePatternMatch_r(GEOSContextHandle_t extHandle, const char* intMatrix,
754
                             const char* imPattern)
755
0
    {
756
0
        return execute(extHandle, 2, [&]() {
757
0
            using geos::geom::IntersectionMatrix;
758
759
0
            std::string m(intMatrix);
760
0
            std::string p(imPattern);
761
0
            IntersectionMatrix im(m);
762
763
0
            return im.matches(p);
764
0
        });
765
0
    }
766
767
    char*
768
    GEOSRelate_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
769
0
    {
770
0
        return execute(extHandle, [&]() {
771
0
            using geos::geom::IntersectionMatrix;
772
773
0
            auto im = g1->relate(g2);
774
0
            if(im == nullptr) {
775
0
                return (char*) nullptr;
776
0
            }
777
778
0
            return gstrdup(im->toString());
779
0
        });
780
0
    }
781
782
    char*
783
    GEOSRelateBoundaryNodeRule_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2, int bnr)
784
0
    {
785
0
        using geos::operation::relate::RelateOp;
786
0
        using geos::geom::IntersectionMatrix;
787
0
        using geos::algorithm::BoundaryNodeRule;
788
789
0
        return execute(extHandle, [&]() -> char* {
790
0
            std::unique_ptr<IntersectionMatrix> im;
791
792
0
            switch (bnr) {
793
0
                case GEOSRELATE_BNR_MOD2: /* same as OGC */
794
0
                    im = RelateNG::relate(g1, g2,
795
0
                                          BoundaryNodeRule::getBoundaryRuleMod2());
796
0
                    break;
797
0
                case GEOSRELATE_BNR_ENDPOINT:
798
0
                    im = RelateNG::relate(g1, g2,
799
0
                                          BoundaryNodeRule::getBoundaryEndPoint());
800
0
                    break;
801
0
                case GEOSRELATE_BNR_MULTIVALENT_ENDPOINT:
802
0
                    im = RelateNG::relate(g1, g2,
803
0
                                          BoundaryNodeRule::getBoundaryMultivalentEndPoint());
804
0
                    break;
805
0
                case GEOSRELATE_BNR_MONOVALENT_ENDPOINT:
806
0
                    im = RelateNG::relate(g1, g2,
807
0
                                          BoundaryNodeRule::getBoundaryMonovalentEndPoint());
808
0
                    break;
809
0
                default:
810
0
                    std::ostringstream ss;
811
0
                    ss << "Invalid boundary node rule " << bnr;
812
0
                    throw std::runtime_error(ss.str());
813
0
            }
814
815
0
            if(!im) {
816
0
                return nullptr;
817
0
            }
818
819
0
            char* result = gstrdup(im->toString());
820
821
0
            return result;
822
0
        });
823
0
    }
824
825
826
827
//-----------------------------------------------------------------
828
// isValid
829
//-----------------------------------------------------------------
830
831
832
    char
833
    GEOSisValid_r(GEOSContextHandle_t extHandle, const Geometry* g1)
834
0
    {
835
0
        return execute(extHandle, 2, [&]() {
836
0
            GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
837
838
0
            using geos::operation::valid::IsValidOp;
839
840
0
            IsValidOp ivo(g1);
841
0
            const TopologyValidationError* err = ivo.getValidationError();
842
843
0
            if(err) {
844
0
                handle->NOTICE_MESSAGE("%s", err->toString().c_str());
845
0
                return false;
846
0
            }
847
0
            else {
848
0
                return true;
849
0
            }
850
0
        });
851
0
    }
852
853
    char*
854
    GEOSisValidReason_r(GEOSContextHandle_t extHandle, const Geometry* g1)
855
0
    {
856
0
        return execute(extHandle, [&]() {
857
0
            using geos::operation::valid::IsValidOp;
858
859
0
            char* result = nullptr;
860
0
            char const* const validstr = "Valid Geometry";
861
862
0
            IsValidOp ivo(g1);
863
0
            const TopologyValidationError* err = ivo.getValidationError();
864
865
0
            if(err) {
866
0
                std::ostringstream ss;
867
0
                ss.precision(15);
868
0
                ss << err->getCoordinate();
869
0
                const std::string errloc = ss.str();
870
0
                std::string errmsg(err->getMessage());
871
0
                errmsg += "[" + errloc + "]";
872
0
                result = gstrdup(errmsg);
873
0
            }
874
0
            else {
875
0
                result = gstrdup(std::string(validstr));
876
0
            }
877
878
0
            return result;
879
0
        });
880
0
    }
881
882
    char
883
    GEOSisValidDetail_r(GEOSContextHandle_t extHandle, const Geometry* g,
884
                        int flags, char** reason, Geometry** location)
885
0
    {
886
0
        using geos::operation::valid::IsValidOp;
887
888
0
        return execute(extHandle, 2, [&]() {
889
0
            IsValidOp ivo(g);
890
0
            if(flags & GEOSVALID_ALLOW_SELFTOUCHING_RING_FORMING_HOLE) {
891
0
                ivo.setSelfTouchingRingFormingHoleValid(true);
892
0
            }
893
0
            const TopologyValidationError* err = ivo.getValidationError();
894
0
            if(err != nullptr) {
895
0
                if(location) {
896
0
                    *location = g->getFactory()->createPoint(err->getCoordinate()).release();
897
0
                }
898
0
                if(reason) {
899
0
                    std::string errmsg(err->getMessage());
900
0
                    *reason = gstrdup(errmsg);
901
0
                }
902
0
                return false;
903
0
            }
904
905
0
            if(location) {
906
0
                *location = nullptr;
907
0
            }
908
0
            if(reason) {
909
0
                *reason = nullptr;
910
0
            }
911
0
            return true; /* valid */
912
913
0
        });
914
0
    }
915
916
//-----------------------------------------------------------------
917
// general purpose
918
//-----------------------------------------------------------------
919
920
    char
921
    GEOSEqualsExact_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2, double tolerance)
922
0
    {
923
0
        return execute(extHandle, 2, [&]() {
924
0
            return g1->equalsExact(g2, tolerance);
925
0
        });
926
0
    }
927
928
    char
929
    GEOSEqualsIdentical_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
930
0
    {
931
0
        return execute(extHandle, 2, [&]() {
932
0
            return g1->equalsIdentical(g2);
933
0
        });
934
0
    }
935
936
    int
937
    GEOSDistance_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2, double* dist)
938
0
    {
939
0
        return execute(extHandle, 0, [&]() {
940
0
            *dist = g1->distance(g2);
941
0
            return 1;
942
0
        });
943
0
    }
944
945
    char
946
    GEOSDistanceWithin_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2, double dist)
947
0
    {
948
0
        return execute(extHandle, 2, [&]() {
949
0
            return g1->isWithinDistance(g2, dist);
950
0
        });
951
0
    }
952
953
    int
954
    GEOSDistanceIndexed_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2, double* dist)
955
0
    {
956
0
        return execute(extHandle, 0, [&]() {
957
0
            *dist = IndexedFacetDistance::distance(g1, g2);
958
0
            return 1;
959
0
        });
960
0
    }
961
962
    int
963
    GEOSHausdorffDistance_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2, double* dist)
964
0
    {
965
0
        return execute(extHandle, 0, [&]() {
966
0
            *dist = DiscreteHausdorffDistance::distance(*g1, *g2);
967
0
            return 1;
968
0
        });
969
0
    }
970
971
    int
972
    GEOSHausdorffDistanceDensify_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2,
973
                                   double densifyFrac, double* dist)
974
0
    {
975
0
        return execute(extHandle, 0, [&]() {
976
0
            *dist = DiscreteHausdorffDistance::distance(*g1, *g2, densifyFrac);
977
0
            return 1;
978
0
        });
979
0
    }
980
981
    int
982
    GEOSFrechetDistance_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2, double* dist)
983
0
    {
984
0
        return execute(extHandle, 0, [&]() {
985
0
            *dist = DiscreteFrechetDistance::distance(*g1, *g2);
986
0
            return 1;
987
0
        });
988
0
    }
989
990
    int
991
    GEOSFrechetDistanceDensify_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2, double densifyFrac,
992
                                 double* dist)
993
0
    {
994
0
        return execute(extHandle, 0, [&]() {
995
0
            *dist = DiscreteFrechetDistance::distance(*g1, *g2, densifyFrac);
996
0
            return 1;
997
0
        });
998
0
    }
999
1000
    int
1001
    GEOSArea_r(GEOSContextHandle_t extHandle, const Geometry* g, double* area)
1002
0
    {
1003
0
        return execute<NotInterruptible>(extHandle, 0, [&]() {
1004
0
            *area = g->getArea();
1005
0
            return 1;
1006
0
        });
1007
0
    }
1008
1009
    int
1010
    GEOSLength_r(GEOSContextHandle_t extHandle, const Geometry* g, double* length)
1011
0
    {
1012
0
        return execute<NotInterruptible>(extHandle, 0, [&]() {
1013
0
            *length = g->getLength();
1014
0
            return 1;
1015
0
        });
1016
0
    }
1017
1018
    CoordinateSequence*
1019
    GEOSNearestPoints_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
1020
0
    {
1021
0
        return execute(extHandle, [&]() -> CoordinateSequence* {
1022
0
            if(g1->isEmpty() || g2->isEmpty()) {
1023
0
                return nullptr;
1024
0
            }
1025
0
            return geos::operation::distance::DistanceOp::nearestPoints(g1, g2).release();
1026
0
        });
1027
0
    }
1028
1029
    static Clusters* capi_clusters(const Geometry* g,
1030
                                   geos::operation::cluster::AbstractClusterFinder& finder)
1031
0
    {
1032
0
        std::vector<const Geometry*> input{g->getNumGeometries()};
1033
0
        for (std::size_t i = 0; i < input.size(); i++) {
1034
0
            input[i] = g->getGeometryN(i);
1035
0
        }
1036
1037
0
        return new Clusters(finder.cluster(input));
1038
0
    }
1039
1040
    Clusters*
1041
    GEOSClusterDBSCAN_r(GEOSContextHandle_t extHandle, const Geometry* g, double eps, unsigned minPoints)
1042
0
    {
1043
0
        return execute(extHandle, [&]() {
1044
0
            geos::operation::cluster::DBSCANClusterFinder finder(eps, minPoints);
1045
1046
0
            return capi_clusters(g, finder);
1047
0
        });
1048
0
    }
1049
1050
    Clusters*
1051
    GEOSClusterGeometryIntersects_r(GEOSContextHandle_t extHandle, const Geometry* g)
1052
0
    {
1053
0
        return execute(extHandle, [&]() {
1054
0
            geos::operation::cluster::GeometryIntersectsClusterFinder finder;
1055
0
            return capi_clusters(g, finder);
1056
0
        });
1057
0
    }
1058
1059
    Clusters*
1060
    GEOSClusterEnvelopeIntersects_r(GEOSContextHandle_t extHandle, const Geometry* g)
1061
0
    {
1062
0
        return execute(extHandle, [&]() {
1063
0
            geos::operation::cluster::EnvelopeIntersectsClusterFinder finder;
1064
0
            return capi_clusters(g, finder);
1065
0
        });
1066
0
    }
1067
1068
    Clusters*
1069
    GEOSClusterEnvelopeDistance_r(GEOSContextHandle_t extHandle, const Geometry* g, double d)
1070
0
    {
1071
0
        return execute(extHandle, [&]() {
1072
0
            geos::operation::cluster::EnvelopeDistanceClusterFinder finder(d);
1073
0
            return capi_clusters(g, finder);
1074
0
        });
1075
0
    }
1076
1077
    Clusters*
1078
    GEOSClusterGeometryDistance_r(GEOSContextHandle_t extHandle, const Geometry* g, double d)
1079
0
    {
1080
0
        return execute(extHandle, [&]() {
1081
0
            geos::operation::cluster::GeometryDistanceClusterFinder finder(d);
1082
0
            return capi_clusters(g, finder);
1083
0
        });
1084
0
    }
1085
1086
    std::size_t GEOSClusterInfo_getNumClusters_r(GEOSContextHandle_t extHandle, const Clusters* clusters)
1087
0
    {
1088
0
        return execute(extHandle, 0, [&]() -> std::size_t {
1089
0
            return static_cast<unsigned>(clusters->getNumClusters());
1090
0
        });
1091
0
    }
1092
1093
    std::size_t GEOSClusterInfo_getClusterSize_r(GEOSContextHandle_t extHandle, const Clusters* clusters, std::size_t i)
1094
0
    {
1095
0
        return execute(extHandle, 0, [&]() {
1096
0
            return static_cast<unsigned>(clusters->getSize(i));
1097
0
        });
1098
0
    }
1099
1100
    const std::size_t* GEOSClusterInfo_getInputsForClusterN_r(GEOSContextHandle_t extHandle, const Clusters* clusters, std::size_t i)
1101
0
    {
1102
0
        return execute(extHandle, [&]() {
1103
0
            return &*clusters->begin(i);
1104
0
        });
1105
0
    }
1106
1107
    std::size_t* GEOSClusterInfo_getClustersForInputs_r(GEOSContextHandle_t extHandle, const Clusters* clusters)
1108
0
    {
1109
0
        return execute(extHandle, [&]() {
1110
0
            auto ids = clusters->getClusterIds(GEOS_CLUSTER_NONE);
1111
0
            std::size_t* ids_buf = (size_t*) malloc(ids.size() * sizeof(std::size_t));
1112
0
            std::copy(ids.begin(), ids.end(), ids_buf);
1113
0
            return ids_buf;
1114
0
        });
1115
0
    }
1116
1117
    void GEOSClusterInfo_destroy_r(GEOSContextHandle_t, Clusters* clusters)
1118
0
    {
1119
0
        delete clusters;
1120
0
    }
1121
1122
    Geometry*
1123
    GEOSGeomFromWKT_r(GEOSContextHandle_t extHandle, const char* wkt)
1124
5.64k
    {
1125
5.64k
        return execute(extHandle, [&]() {
1126
5.64k
            GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
1127
1128
5.64k
            const std::string wktstring(wkt);
1129
5.64k
            WKTReader r(static_cast<GeometryFactory const*>(handle->geomFactory));
1130
1131
5.64k
            auto g = r.read(wktstring);
1132
5.64k
            return g.release();
1133
5.64k
        });
1134
5.64k
    }
1135
1136
    char*
1137
    GEOSGeomToWKT_r(GEOSContextHandle_t extHandle, const Geometry* g1)
1138
4.91k
    {
1139
4.91k
        return execute(extHandle, [&]() {
1140
            // Deprecated, show untrimmed 2D output
1141
4.91k
            geos::io::WKTWriter writer;
1142
4.91k
            writer.setTrim(false);
1143
4.91k
            writer.setOutputDimension(2);
1144
4.91k
            char* result = gstrdup(writer.write(g1));
1145
4.91k
            return result;
1146
4.91k
        });
1147
4.91k
    }
1148
1149
    // Remember to free the result!
1150
    unsigned char*
1151
    GEOSGeomToWKB_buf_r(GEOSContextHandle_t extHandle, const Geometry* g, std::size_t* size)
1152
4.50k
    {
1153
4.50k
        using geos::io::WKBWriter;
1154
1155
4.50k
        return execute(extHandle, [&]() {
1156
4.50k
            GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
1157
1158
4.50k
            int byteOrder = handle->WKBByteOrder;
1159
4.50k
            WKBWriter w(handle->WKBOutputDims, byteOrder);
1160
4.50k
            std::ostringstream os(std::ios_base::binary);
1161
4.50k
            w.write(*g, os);
1162
4.50k
            std::string wkbstring(os.str());
1163
4.50k
            const std::size_t len = wkbstring.length();
1164
1165
4.50k
            unsigned char* result = static_cast<unsigned char*>(malloc(len));
1166
4.50k
            if(result) {
1167
4.50k
                std::memcpy(result, wkbstring.c_str(), len);
1168
4.50k
                *size = len;
1169
4.50k
            }
1170
4.50k
            return result;
1171
4.50k
        });
1172
4.50k
    }
1173
1174
    Geometry*
1175
    GEOSGeomFromWKB_buf_r(GEOSContextHandle_t extHandle, const unsigned char* wkb, std::size_t size)
1176
4.91k
    {
1177
4.91k
        using geos::io::WKBReader;
1178
1179
4.91k
        return execute(extHandle, [&]() {
1180
4.91k
            GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
1181
1182
4.91k
            WKBReader r(*(static_cast<GeometryFactory const*>(handle->geomFactory)));
1183
4.91k
            return r.read(wkb, size).release();
1184
4.91k
        });
1185
4.91k
    }
1186
1187
    /* Read/write wkb hex values.  Returned geometries are
1188
       owned by the caller.*/
1189
    unsigned char*
1190
    GEOSGeomToHEX_buf_r(GEOSContextHandle_t extHandle, const Geometry* g, std::size_t* size)
1191
0
    {
1192
0
        using geos::io::WKBWriter;
1193
1194
0
        return execute(extHandle, [&]() {
1195
0
            GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
1196
1197
0
            int byteOrder = handle->WKBByteOrder;
1198
0
            WKBWriter w(handle->WKBOutputDims, byteOrder);
1199
0
            std::ostringstream os(std::ios_base::binary);
1200
0
            w.writeHEX(*g, os);
1201
0
            std::string hexstring(os.str());
1202
1203
0
            char* result = gstrdup(hexstring);
1204
0
            if(result) {
1205
0
                *size = hexstring.length();
1206
0
            }
1207
1208
0
            return reinterpret_cast<unsigned char*>(result);
1209
0
        });
1210
0
    }
1211
1212
    Geometry*
1213
    GEOSGeomFromHEX_buf_r(GEOSContextHandle_t extHandle, const unsigned char* hex, std::size_t size)
1214
0
    {
1215
0
        using geos::io::WKBReader;
1216
1217
0
        return execute(extHandle, [&]() {
1218
0
            GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
1219
0
            std::string hexstring(reinterpret_cast<const char*>(hex), size);
1220
0
            WKBReader r(*(static_cast<GeometryFactory const*>(handle->geomFactory)));
1221
0
            std::istringstream is(std::ios_base::binary);
1222
0
            is.str(hexstring);
1223
0
            is.seekg(0, std::ios::beg); // rewind reader pointer
1224
1225
0
            auto g = r.readHEX(is);
1226
0
            return g.release();
1227
0
        });
1228
0
    }
1229
1230
    char
1231
    GEOSisEmpty_r(GEOSContextHandle_t extHandle, const Geometry* g1)
1232
0
    {
1233
0
        return execute(extHandle, 2, [&]() {
1234
0
            return g1->isEmpty();
1235
0
        });
1236
0
    }
1237
1238
    char
1239
    GEOSisSimple_r(GEOSContextHandle_t extHandle, const Geometry* g1)
1240
0
    {
1241
0
        return execute(extHandle, 2, [&]() {
1242
0
            return g1->isSimple();
1243
0
        });
1244
0
    }
1245
1246
    char
1247
    GEOSisSimpleDetail_r(GEOSContextHandle_t extHandle, const Geometry* g1, int returnAllPoints, Geometry** result)
1248
0
    {
1249
0
        return execute(extHandle, 2, [&]() {
1250
0
            geos::operation::valid::IsSimpleOp iso(g1);
1251
0
            iso.setFindAllLocations(returnAllPoints);
1252
1253
0
            *result = nullptr;
1254
1255
0
            bool simple = iso.isSimple();
1256
0
            if (!simple) {
1257
0
                auto locations = iso.getNonSimpleLocations();
1258
0
                if (locations.size() == 1 || !returnAllPoints) {
1259
0
                    *result = extHandle->geomFactory->createPoint(locations.front()).release();
1260
0
                } else {
1261
0
                    *result = extHandle->geomFactory->createMultiPoint(locations).release();
1262
0
                }
1263
0
            }
1264
1265
0
            return simple;
1266
0
        });
1267
0
    }
1268
1269
    char
1270
    GEOSisRing_r(GEOSContextHandle_t extHandle, const Geometry* g)
1271
0
    {
1272
0
        return execute(extHandle, 2, [&]() {
1273
0
            const Curve* ls = dynamic_cast<const Curve*>(g);
1274
0
            if(ls) {
1275
0
                return ls->isRing();
1276
0
            }
1277
0
            else {
1278
0
                return false;
1279
0
            }
1280
0
        });
1281
0
    }
1282
1283
    //free the result of this
1284
    char*
1285
    GEOSGeomType_r(GEOSContextHandle_t extHandle, const Geometry* g1)
1286
0
    {
1287
0
        return execute(extHandle, [&]() {
1288
0
            std::string s = g1->getGeometryType();
1289
1290
0
            char* result = gstrdup(s);
1291
0
            return result;
1292
0
        });
1293
0
    }
1294
1295
    // Return postgis geometry type index
1296
    int
1297
    GEOSGeomTypeId_r(GEOSContextHandle_t extHandle, const Geometry* g1)
1298
0
    {
1299
0
        return execute(extHandle, -1, [&]() {
1300
0
            return static_cast<int>(g1->getGeometryTypeId());
1301
0
        });
1302
0
    }
1303
1304
//-------------------------------------------------------------------
1305
// GEOS functions that return geometries
1306
//-------------------------------------------------------------------
1307
1308
    Geometry*
1309
    GEOSEnvelope_r(GEOSContextHandle_t extHandle, const Geometry* g1)
1310
0
    {
1311
0
        return execute(extHandle, [&]() {
1312
0
            Geometry* g3 = g1->getEnvelope().release();
1313
0
            g3->setSRID(g1->getSRID());
1314
0
            return g3;
1315
0
        });
1316
0
    }
1317
1318
    Geometry*
1319
    GEOSIntersection_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
1320
4.50k
    {
1321
4.50k
        return execute(extHandle, [&]() {
1322
4.50k
            auto g3 = g1->intersection(g2);
1323
4.50k
            g3->setSRID(g1->getSRID());
1324
4.50k
            return g3.release();
1325
4.50k
        });
1326
4.50k
    }
1327
1328
    Geometry*
1329
    GEOSIntersectionPrec_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2, double gridSize)
1330
0
    {
1331
0
        return execute(extHandle, [&]() {
1332
0
            std::unique_ptr<PrecisionModel> pm;
1333
0
            if(gridSize != 0) {
1334
0
                pm.reset(new PrecisionModel(1.0 / gridSize));
1335
0
            }
1336
0
            else {
1337
0
                pm.reset(new PrecisionModel());
1338
0
            }
1339
0
            auto g3 = gridSize != 0 ?
1340
0
              OverlayNG::overlay(g1, g2, OverlayNG::INTERSECTION, pm.get())
1341
0
              :
1342
0
              OverlayNGRobust::Overlay(g1, g2, OverlayNG::INTERSECTION);
1343
0
            g3->setSRID(g1->getSRID());
1344
0
            return g3.release();
1345
0
        });
1346
0
    }
1347
1348
    Geometry*
1349
    GEOSBuffer_r(GEOSContextHandle_t extHandle, const Geometry* g1, double width, int quadrantsegments)
1350
0
    {
1351
0
        return execute(extHandle, [&]() {
1352
0
            auto g3 = g1->buffer(width, quadrantsegments);
1353
0
            g3->setSRID(g1->getSRID());
1354
0
            return g3.release();
1355
0
        });
1356
0
    }
1357
1358
    Geometry*
1359
    GEOSBufferWithStyle_r(GEOSContextHandle_t extHandle, const Geometry* g1, double width, int quadsegs, int endCapStyle,
1360
                          int joinStyle, double mitreLimit)
1361
0
    {
1362
0
        using geos::operation::buffer::BufferParameters;
1363
0
        using geos::operation::buffer::BufferOp;
1364
0
        using geos::util::IllegalArgumentException;
1365
1366
0
        return execute(extHandle, [&]() {
1367
0
            BufferParameters bp;
1368
0
            bp.setQuadrantSegments(quadsegs);
1369
1370
0
            if(endCapStyle > BufferParameters::CAP_SQUARE) {
1371
0
                throw IllegalArgumentException("Invalid buffer endCap style");
1372
0
            }
1373
0
            bp.setEndCapStyle(
1374
0
                static_cast<BufferParameters::EndCapStyle>(endCapStyle)
1375
0
            );
1376
1377
0
            if(joinStyle > BufferParameters::JOIN_BEVEL) {
1378
0
                throw IllegalArgumentException("Invalid buffer join style");
1379
0
            }
1380
0
            bp.setJoinStyle(
1381
0
                static_cast<BufferParameters::JoinStyle>(joinStyle)
1382
0
            );
1383
0
            bp.setMitreLimit(mitreLimit);
1384
0
            BufferOp op(g1, bp);
1385
0
            std::unique_ptr<Geometry> g3 = op.getResultGeometry(width);
1386
0
            g3->setSRID(g1->getSRID());
1387
0
            return g3.release();
1388
0
        });
1389
0
    }
1390
1391
    Geometry*
1392
    GEOSDensify_r(GEOSContextHandle_t extHandle, const Geometry* g, double tolerance)
1393
0
    {
1394
0
        using geos::geom::util::Densifier;
1395
1396
0
        return execute(extHandle, [&]() {
1397
0
            Densifier densifier(g);
1398
0
            densifier.setDistanceTolerance(tolerance);
1399
0
            auto g3 = densifier.getResultGeometry();
1400
0
            g3->setSRID(g->getSRID());
1401
0
            return g3.release();
1402
0
        });
1403
0
    }
1404
1405
    Geometry*
1406
    GEOSOffsetCurve_r(GEOSContextHandle_t extHandle, const Geometry* g1, double width, int quadsegs, int joinStyle,
1407
                      double mitreLimit)
1408
0
    {
1409
0
        return execute(extHandle, [&]() {
1410
0
            BufferParameters bp;
1411
            //-- use default cap style ROUND
1412
0
            bp.setQuadrantSegments(quadsegs);
1413
1414
0
            if(joinStyle > BufferParameters::JOIN_BEVEL) {
1415
0
                throw IllegalArgumentException("Invalid buffer join style");
1416
0
            }
1417
0
            bp.setJoinStyle(
1418
0
                static_cast<BufferParameters::JoinStyle>(joinStyle)
1419
0
            );
1420
0
            bp.setMitreLimit(mitreLimit);
1421
1422
0
            OffsetCurve oc(*g1, width, bp);
1423
0
            std::unique_ptr<Geometry> g3 = oc.getCurve();
1424
0
            g3->setSRID(g1->getSRID());
1425
0
            return g3.release();
1426
0
        });
1427
0
    }
1428
1429
    /* @deprecated in 3.3.0 */
1430
    Geometry*
1431
    GEOSSingleSidedBuffer_r(GEOSContextHandle_t extHandle, const Geometry* g1, double width, int quadsegs, int joinStyle,
1432
                            double mitreLimit, int leftSide)
1433
0
    {
1434
0
        return execute(extHandle, [&]() {
1435
0
            BufferParameters bp;
1436
0
            bp.setEndCapStyle(BufferParameters::CAP_FLAT);
1437
0
            bp.setQuadrantSegments(quadsegs);
1438
1439
0
            if(joinStyle > BufferParameters::JOIN_BEVEL) {
1440
0
                throw IllegalArgumentException("Invalid buffer join style");
1441
0
            }
1442
0
            bp.setJoinStyle(
1443
0
                static_cast<BufferParameters::JoinStyle>(joinStyle)
1444
0
            );
1445
0
            bp.setMitreLimit(mitreLimit);
1446
1447
0
            bool isLeftSide = leftSide == 0 ? false : true;
1448
0
            BufferBuilder bufBuilder(bp);
1449
0
            std::unique_ptr<Geometry> g3 = bufBuilder.bufferLineSingleSided(g1, width, isLeftSide);
1450
0
            g3->setSRID(g1->getSRID());
1451
0
            return g3.release();
1452
0
        });
1453
0
    }
1454
1455
    Geometry*
1456
    GEOSConvexHull_r(GEOSContextHandle_t extHandle, const Geometry* g1)
1457
0
    {
1458
0
        return execute(extHandle, [&]() {
1459
0
            auto g3 = g1->convexHull();
1460
0
            g3->setSRID(g1->getSRID());
1461
0
            return g3.release();
1462
0
        });
1463
0
    }
1464
1465
    Geometry*
1466
    GEOSConcaveHull_r(GEOSContextHandle_t extHandle,
1467
        const Geometry* g1,
1468
        double ratio,
1469
        unsigned int allowHoles)
1470
0
    {
1471
0
        return execute(extHandle, [&]() {
1472
0
            ConcaveHull hull(g1);
1473
0
            hull.setMaximumEdgeLengthRatio(ratio);
1474
0
            hull.setHolesAllowed(allowHoles);
1475
0
            std::unique_ptr<Geometry> g3 = hull.getHull();
1476
0
            g3->setSRID(g1->getSRID());
1477
0
            return g3.release();
1478
0
        });
1479
0
    }
1480
1481
    Geometry*
1482
    GEOSConcaveHullByLength_r(GEOSContextHandle_t extHandle,
1483
        const Geometry* g1,
1484
        double length,
1485
        unsigned int allowHoles)
1486
0
    {
1487
0
        return execute(extHandle, [&]() {
1488
0
            ConcaveHull hull(g1);
1489
0
            hull.setMaximumEdgeLength(length);
1490
0
            hull.setHolesAllowed(allowHoles);
1491
0
            std::unique_ptr<Geometry> g3 = hull.getHull();
1492
0
            g3->setSRID(g1->getSRID());
1493
0
            return g3.release();
1494
0
        });
1495
0
    }
1496
1497
    Geometry*
1498
    GEOSPolygonHullSimplify_r(GEOSContextHandle_t extHandle,
1499
        const Geometry* g1,
1500
        unsigned int isOuter,
1501
        double vertexNumFraction)
1502
0
    {
1503
0
        return execute(extHandle, [&]() {
1504
0
            std::unique_ptr<Geometry> g3 = PolygonHullSimplifier::hull(g1, isOuter, vertexNumFraction);
1505
0
            g3->setSRID(g1->getSRID());
1506
0
            return g3.release();
1507
0
        });
1508
0
    }
1509
1510
    Geometry*
1511
    GEOSPolygonHullSimplifyMode_r(GEOSContextHandle_t extHandle,
1512
        const Geometry* g1,
1513
        unsigned int isOuter,
1514
        unsigned int parameterMode,
1515
        double parameter)
1516
0
    {
1517
0
        return execute(extHandle, [&]() {
1518
0
            if (parameterMode == GEOSHULL_PARAM_AREA_RATIO) {
1519
0
                std::unique_ptr<Geometry> g3 = PolygonHullSimplifier::hullByAreaDelta(g1, isOuter, parameter);
1520
0
                g3->setSRID(g1->getSRID());
1521
0
                return g3.release();
1522
0
            }
1523
0
            else if (parameterMode == GEOSHULL_PARAM_VERTEX_RATIO) {
1524
0
                std::unique_ptr<Geometry> g3 = PolygonHullSimplifier::hull(g1, isOuter, parameter);
1525
0
                g3->setSRID(g1->getSRID());
1526
0
                return g3.release();
1527
0
            }
1528
0
            else {
1529
0
                throw IllegalArgumentException("GEOSPolygonHullSimplifyMode_r: Unknown parameterMode");
1530
0
            }
1531
0
        });
1532
0
    }
1533
1534
    Geometry*
1535
    GEOSConcaveHullOfPolygons_r(GEOSContextHandle_t extHandle,
1536
        const Geometry* g1,
1537
        double lengthRatio,
1538
        unsigned int isTight,
1539
        unsigned int isHolesAllowed)
1540
0
    {
1541
0
        return execute(extHandle, [&]() {
1542
0
            std::unique_ptr<Geometry> g3 =
1543
0
                ConcaveHullOfPolygons::concaveHullByLengthRatio(
1544
0
                    g1, lengthRatio,
1545
0
                    isTight > 0,
1546
0
                    isHolesAllowed > 0);
1547
0
            g3->setSRID(g1->getSRID());
1548
0
            return g3.release();
1549
0
        });
1550
0
    }
1551
1552
    Geometry*
1553
    GEOSMinimumRotatedRectangle_r(GEOSContextHandle_t extHandle, const Geometry* g)
1554
0
    {
1555
0
        using geos::algorithm::MinimumAreaRectangle;
1556
1557
0
        return execute(extHandle, [&]() {
1558
0
            auto g3 = MinimumAreaRectangle::getMinimumRectangle(g);
1559
0
            g3->setSRID(g->getSRID());
1560
0
            return g3.release();
1561
0
        });
1562
0
    }
1563
1564
    Geometry*
1565
    GEOSMaximumInscribedCircle_r(GEOSContextHandle_t extHandle, const Geometry* g, double tolerance)
1566
0
    {
1567
0
        return execute(extHandle, [&]() {
1568
0
            geos::algorithm::construct::MaximumInscribedCircle mic(g, tolerance);
1569
0
            auto g3 = mic.getRadiusLine();
1570
0
            g3->setSRID(g->getSRID());
1571
0
            return g3.release();
1572
0
        });
1573
0
    }
1574
1575
    Geometry*
1576
    GEOSLargestEmptyCircle_r(GEOSContextHandle_t extHandle, const Geometry* g, const GEOSGeometry* boundary, double tolerance)
1577
0
    {
1578
0
        return execute(extHandle, [&]() {
1579
0
            geos::algorithm::construct::LargestEmptyCircle lec(g, boundary, tolerance);
1580
0
            auto g3 = lec.getRadiusLine();
1581
0
            g3->setSRID(g->getSRID());
1582
0
            return g3.release();
1583
0
        });
1584
0
    }
1585
1586
    Geometry*
1587
    GEOSMinimumWidth_r(GEOSContextHandle_t extHandle, const Geometry* g)
1588
0
    {
1589
0
        return execute(extHandle, [&]() {
1590
0
            geos::algorithm::MinimumDiameter m(g);
1591
0
            auto g3 = m.getDiameter();
1592
0
            g3->setSRID(g->getSRID());
1593
0
            return g3.release();
1594
0
        });
1595
0
    }
1596
1597
    Geometry*
1598
    GEOSMinimumClearanceLine_r(GEOSContextHandle_t extHandle, const Geometry* g)
1599
0
    {
1600
0
        return execute(extHandle, [&]() {
1601
0
            geos::precision::MinimumClearance mc(g);
1602
0
            auto g3 = mc.getLine();
1603
0
            g3->setSRID(g->getSRID());
1604
0
            return g3.release();
1605
0
        });
1606
0
    }
1607
1608
    int
1609
    GEOSMinimumClearance_r(GEOSContextHandle_t extHandle, const Geometry* g, double* d)
1610
0
    {
1611
0
        return execute(extHandle, 2, [&]() {
1612
0
            geos::precision::MinimumClearance mc(g);
1613
0
            double res = mc.getDistance();
1614
0
            *d = res;
1615
0
            return 0;
1616
0
        });
1617
0
    }
1618
1619
1620
    Geometry*
1621
    GEOSDifference_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
1622
4.50k
    {
1623
4.50k
        return execute(extHandle, [&]() {
1624
4.50k
            auto g3 = g1->difference(g2);
1625
4.50k
            g3->setSRID(g1->getSRID());
1626
4.50k
            return g3.release();
1627
4.50k
        });
1628
4.50k
    }
1629
1630
    Geometry*
1631
    GEOSDifferencePrec_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2, double gridSize)
1632
0
    {
1633
0
        return execute(extHandle, [&]() {
1634
1635
0
            std::unique_ptr<PrecisionModel> pm;
1636
0
            if(gridSize != 0) {
1637
0
                pm.reset(new PrecisionModel(1.0 / gridSize));
1638
0
            }
1639
0
            else {
1640
0
                pm.reset(new PrecisionModel());
1641
0
            }
1642
0
            auto g3 = gridSize != 0 ?
1643
0
                OverlayNG::overlay(g1, g2, OverlayNG::DIFFERENCE, pm.get())
1644
0
                :
1645
0
                OverlayNGRobust::Overlay(g1, g2, OverlayNG::DIFFERENCE);
1646
0
            g3->setSRID(g1->getSRID());
1647
0
            return g3.release();
1648
0
        });
1649
0
    }
1650
1651
    Geometry*
1652
    GEOSBoundary_r(GEOSContextHandle_t extHandle, const Geometry* g1)
1653
0
    {
1654
0
        return execute(extHandle, [&]() {
1655
0
            auto g3 = g1->getBoundary();
1656
0
            g3->setSRID(g1->getSRID());
1657
0
            return g3.release();
1658
0
        });
1659
0
    }
1660
1661
    Geometry*
1662
    GEOSSymDifference_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
1663
0
    {
1664
0
        return execute(extHandle, [&]() {
1665
0
            auto g3 = g1->symDifference(g2);
1666
0
            g3->setSRID(g1->getSRID());
1667
0
            return g3.release();
1668
0
        });
1669
0
    }
1670
1671
    Geometry*
1672
    GEOSSymDifferencePrec_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2, double gridSize)
1673
0
    {
1674
0
        return execute(extHandle, [&]() {
1675
1676
0
            std::unique_ptr<PrecisionModel> pm;
1677
0
            if(gridSize != 0) {
1678
0
                pm.reset(new PrecisionModel(1.0 / gridSize));
1679
0
            }
1680
0
            else {
1681
0
                pm.reset(new PrecisionModel());
1682
0
            }
1683
0
            auto g3 = gridSize != 0 ?
1684
0
              OverlayNG::overlay(g1, g2, OverlayNG::SYMDIFFERENCE, pm.get())
1685
0
              :
1686
0
              OverlayNGRobust::Overlay(g1, g2, OverlayNG::SYMDIFFERENCE);
1687
0
            g3->setSRID(g1->getSRID());
1688
0
            return g3.release();
1689
0
        });
1690
0
    }
1691
1692
    Geometry*
1693
    GEOSUnion_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2)
1694
4.50k
    {
1695
4.50k
        return execute(extHandle, [&]() {
1696
4.50k
            auto g3 = g1->Union(g2);
1697
4.50k
            g3->setSRID(g1->getSRID());
1698
4.50k
            return g3.release();
1699
4.50k
        });
1700
4.50k
    }
1701
1702
    Geometry*
1703
    GEOSUnionPrec_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* g2, double gridSize)
1704
0
    {
1705
0
        return execute(extHandle, [&]() {
1706
1707
0
            std::unique_ptr<PrecisionModel> pm;
1708
0
            if(gridSize != 0) {
1709
0
                pm.reset(new PrecisionModel(1.0 / gridSize));
1710
0
            }
1711
0
            else {
1712
0
                pm.reset(new PrecisionModel());
1713
0
            }
1714
0
            auto g3 = gridSize != 0 ?
1715
0
              OverlayNG::overlay(g1, g2, OverlayNG::UNION, pm.get())
1716
0
              :
1717
0
              OverlayNGRobust::Overlay(g1, g2, OverlayNG::UNION);
1718
0
            g3->setSRID(g1->getSRID());
1719
0
            return g3.release();
1720
0
        });
1721
0
    }
1722
1723
    Geometry*
1724
    GEOSCoverageUnion_r(GEOSContextHandle_t extHandle, const Geometry* g)
1725
0
    {
1726
0
        return execute(extHandle, [&]() {
1727
0
            auto g3 = geos::coverage::CoverageUnion::Union(g);
1728
0
            g3->setSRID(g->getSRID());
1729
0
            return g3.release();
1730
0
        });
1731
0
    }
1732
1733
    Geometry*
1734
    GEOSDisjointSubsetUnion_r(GEOSContextHandle_t extHandle, const Geometry* g)
1735
0
    {
1736
0
        return execute(extHandle, [&]() {
1737
0
            auto g3 = geos::operation::geounion::DisjointSubsetUnion::Union(g);
1738
0
            g3->setSRID(g->getSRID());
1739
0
            return g3.release();
1740
0
        });
1741
0
    }
1742
1743
    Geometry*
1744
    GEOSUnaryUnion_r(GEOSContextHandle_t extHandle, const Geometry* g)
1745
0
    {
1746
0
        return execute(extHandle, [&]() {
1747
0
            std::unique_ptr<Geometry> g3(g->Union());
1748
0
            g3->setSRID(g->getSRID());
1749
0
            return g3.release();
1750
0
        });
1751
0
    }
1752
1753
    Geometry*
1754
    GEOSUnaryUnionPrec_r(GEOSContextHandle_t extHandle, const Geometry* g1, double gridSize)
1755
0
    {
1756
0
        return execute(extHandle, [&]() {
1757
1758
0
            std::unique_ptr<PrecisionModel> pm;
1759
0
            if(gridSize != 0) {
1760
0
                pm.reset(new PrecisionModel(1.0 / gridSize));
1761
0
            }
1762
0
            else {
1763
0
                pm.reset(new PrecisionModel());
1764
0
            }
1765
0
            auto g3 = gridSize != 0 ?
1766
0
              UnaryUnionNG::Union(g1, *pm)
1767
0
              :
1768
0
              OverlayNGRobust::Union(g1);
1769
0
            g3->setSRID(g1->getSRID());
1770
0
            return g3.release();
1771
0
        });
1772
0
    }
1773
1774
    Geometry*
1775
    GEOSNode_r(GEOSContextHandle_t extHandle, const Geometry* g)
1776
0
    {
1777
0
        return execute(extHandle, [&]() {
1778
0
            auto g3 = geos::noding::GeometryNoder::node(*g);
1779
0
            g3->setSRID(g->getSRID());
1780
0
            return g3.release();
1781
0
        });
1782
0
    }
1783
1784
    Geometry*
1785
    GEOSUnionCascaded_r(GEOSContextHandle_t extHandle, const Geometry* g1)
1786
0
    {
1787
0
        return execute(extHandle, [&]() {
1788
            // CascadedUnion is the same as UnaryUnion, except that
1789
            // CascadedUnion only works on MultiPolygon, so we just delegate
1790
            // now and retain a check on MultiPolygon type.
1791
0
            const MultiPolygon *p = dynamic_cast<const MultiPolygon *>(g1);
1792
0
            if (!p) {
1793
0
                throw IllegalArgumentException("Invalid argument (must be a MultiPolygon)");
1794
0
            }
1795
0
            return GEOSUnaryUnion_r(extHandle, g1);
1796
0
        });
1797
0
    }
1798
1799
    Geometry*
1800
    GEOSPointOnSurface_r(GEOSContextHandle_t extHandle, const Geometry* g1)
1801
0
    {
1802
0
        return execute(extHandle, [&]() {
1803
0
            auto ret = g1->getInteriorPoint();
1804
0
            ret->setSRID(g1->getSRID());
1805
0
            return ret.release();
1806
0
        });
1807
0
    }
1808
1809
    Geometry*
1810
    GEOSClipByRect_r(GEOSContextHandle_t extHandle, const Geometry* g, double xmin, double ymin, double xmax, double ymax)
1811
0
    {
1812
0
        return execute(extHandle, [&]() {
1813
0
            using geos::operation::intersection::Rectangle;
1814
0
            using geos::operation::intersection::RectangleIntersection;
1815
0
            Rectangle rect(xmin, ymin, xmax, ymax);
1816
0
            std::unique_ptr<Geometry> g3 = RectangleIntersection::clip(*g, rect);
1817
0
            g3->setSRID(g->getSRID());
1818
0
            return g3.release();
1819
0
        });
1820
0
    }
1821
1822
    int
1823
    GEOSGridIntersectionFractions_r(GEOSContextHandle_t extHandle, const Geometry* g, double xmin, double ymin,
1824
                                    double xmax, double ymax, unsigned nx, unsigned ny, float* buf)
1825
0
    {
1826
0
        return execute(extHandle, 0, [&]() {
1827
0
            Envelope env(xmin, xmax, ymin, ymax);
1828
0
            double dx = env.getWidth() / static_cast<double>(nx);
1829
0
            double dy = env.getHeight() / static_cast<double>(ny);
1830
0
            geos::operation::grid::Grid<geos::operation::grid::bounded_extent> grid(env, dx, dy);
1831
1832
            // Matrix wants a shared_ptr, but we don't actually want anything to be freed because
1833
            // buf is externally owned. So we give it an empty deleter.
1834
0
            std::shared_ptr<float[]> bufPtr(buf, [](float*) {});
1835
1836
0
            auto cov = std::make_shared<geos::operation::grid::Matrix<float>>(ny, nx, bufPtr);
1837
0
            geos::operation::grid::GridIntersection isect(grid, *g, cov);
1838
1839
0
            return 1;
1840
0
        });
1841
0
    }
1842
1843
    Geometry*
1844
0
    GEOSGeom_transformXY_r(GEOSContextHandle_t handle, const GEOSGeometry* g, GEOSTransformXYCallback callback, void* userdata) {
1845
1846
0
        struct TransformFilter final: public geos::geom::CoordinateFilter {
1847
0
            TransformFilter(GEOSTransformXYCallback p_callback,
1848
0
                            void* p_userdata) :
1849
0
                            m_callback(p_callback),
1850
0
                            m_userdata(p_userdata) {}
1851
1852
0
            void filter_rw(CoordinateXY* c) const override {
1853
0
                if (!m_callback(&(c->x), &(c->y), m_userdata)) {
1854
0
                    throw std::runtime_error(std::string("Failed to transform coordinates."));
1855
0
                }
1856
0
            }
1857
1858
0
            GEOSTransformXYCallback m_callback;
1859
0
            void* m_userdata;
1860
0
        };
1861
1862
0
        return execute(handle, [&]() {
1863
0
            TransformFilter filter(callback, userdata);
1864
0
            auto ret = g->clone();
1865
0
            ret->apply_rw(&filter);
1866
0
            ret->geometryChanged();
1867
0
            return ret.release();
1868
0
        });
1869
0
    }
1870
1871
1872
    Geometry*
1873
0
    GEOSGeom_transformXYZ_r(GEOSContextHandle_t handle, const GEOSGeometry* g, GEOSTransformXYZCallback callback, void* userdata) {
1874
1875
0
        struct TransformFilter final: public geos::geom::CoordinateFilter {
1876
0
            TransformFilter(GEOSTransformXYZCallback p_callback,
1877
0
                            void* p_userdata) :
1878
0
                            m_callback(p_callback),
1879
0
                            m_userdata(p_userdata) {}
1880
1881
0
            void filter_rw(Coordinate* c) const override {
1882
0
                if (!m_callback(&(c->x), &(c->y), &(c->z), m_userdata)) {
1883
0
                    throw std::runtime_error(std::string("Failed to transform coordinates."));
1884
0
                }
1885
0
            }
1886
1887
0
            GEOSTransformXYZCallback m_callback;
1888
0
            void* m_userdata;
1889
0
        };
1890
1891
0
        return execute(handle, [&]() {
1892
0
            TransformFilter filter(callback, userdata);
1893
0
            auto ret = g->clone();
1894
0
            ret->apply_rw(&filter);
1895
0
            ret->geometryChanged();
1896
0
            return ret.release();
1897
0
        });
1898
0
    }
1899
1900
1901
//-------------------------------------------------------------------
1902
// memory management functions
1903
//------------------------------------------------------------------
1904
1905
    void
1906
    GEOSGeom_destroy_r(GEOSContextHandle_t extHandle, Geometry* a)
1907
22.9k
    {
1908
22.9k
        execute(extHandle, [&]() {
1909
            // FIXME: mloskot: Does this try-catch around delete means that
1910
            // destructors in GEOS may throw? If it does, this is a serious
1911
            // violation of "never throw an exception from a destructor" principle
1912
22.9k
            delete a;
1913
22.9k
        });
1914
22.9k
    }
1915
1916
    void
1917
    GEOSGeom_setUserData_r(GEOSContextHandle_t extHandle, Geometry* g, void* userData)
1918
0
    {
1919
0
        execute(extHandle, [&]() {
1920
0
            g->setUserData(userData);
1921
0
        });
1922
0
    }
1923
1924
    void
1925
    GEOSSetSRID_r(GEOSContextHandle_t extHandle, Geometry* g, int srid)
1926
0
    {
1927
0
        execute(extHandle, [&]() {
1928
0
            g->setSRID(srid);
1929
0
        });
1930
0
    }
1931
1932
1933
    int
1934
    GEOSGetNumCoordinates_r(GEOSContextHandle_t extHandle, const Geometry* g)
1935
0
    {
1936
0
        return execute(extHandle, -1, [&]() {
1937
0
            return static_cast<int>(g->getNumPoints());
1938
0
        });
1939
0
    }
1940
1941
    /*
1942
     * Return -1 on exception, 0 otherwise.
1943
     * Converts Geometry to normal form (or canonical form).
1944
     */
1945
    int
1946
    GEOSNormalize_r(GEOSContextHandle_t extHandle, Geometry* g)
1947
0
    {
1948
0
        return execute(extHandle, -1, [&]() {
1949
0
            g->normalize();
1950
0
            return 0; // SUCCESS
1951
0
        });
1952
0
    }
1953
1954
    int
1955
    GEOSOrientPolygons_r(GEOSContextHandle_t extHandle, Geometry* g, int exteriorCW)
1956
0
    {
1957
0
        return execute(extHandle, -1, [&]() {
1958
0
            class OrientPolygons : public geos::geom::GeometryComponentFilter {
1959
0
            public:
1960
0
                OrientPolygons(bool isExteriorCW) : exteriorCW(isExteriorCW) {}
1961
1962
0
                void filter_rw(Geometry* g) override {
1963
0
                    if (g->getGeometryTypeId() == geos::geom::GeometryTypeId::GEOS_POLYGON) {
1964
0
                        auto p = geos::detail::down_cast<Polygon*>(g);
1965
0
                        p->orientRings(exteriorCW);
1966
0
                    } else if (g->getGeometryTypeId() == geos::geom::GeometryTypeId::GEOS_CURVEPOLYGON) {
1967
0
                        throw geos::util::UnsupportedOperationException("Curved geometries not supported.");
1968
0
                    }
1969
0
                }
1970
1971
0
            private:
1972
0
                bool exteriorCW;
1973
0
            };
1974
1975
0
            OrientPolygons op(exteriorCW);
1976
0
            g->apply_rw(&op);
1977
1978
0
            return 0;
1979
0
        });
1980
0
    }
1981
1982
    int
1983
    GEOSGetNumInteriorRings_r(GEOSContextHandle_t extHandle, const Geometry* g1)
1984
0
    {
1985
0
        return execute<NotInterruptible>(extHandle, -1, [&]() {
1986
0
            const Surface* p = dynamic_cast<const Surface*>(g1);
1987
0
            if(!p) {
1988
0
                throw IllegalArgumentException("Argument is not a Surface");
1989
0
            }
1990
0
            return static_cast<int>(p->getNumInteriorRing());
1991
0
        });
1992
0
    }
1993
1994
1995
    // returns -1 on error and 1 for non-multi geometries
1996
    int
1997
    GEOSGetNumGeometries_r(GEOSContextHandle_t extHandle, const Geometry* g1)
1998
0
    {
1999
0
        return execute<NotInterruptible>(extHandle, -1, [&]() {
2000
0
            return static_cast<int>(g1->getNumGeometries());
2001
0
        });
2002
0
    }
2003
2004
2005
    /*
2006
     * Call only on GEOMETRYCOLLECTION or MULTI*.
2007
     * Return a pointer to the internal Geometry.
2008
     */
2009
    const Geometry*
2010
    GEOSGetGeometryN_r(GEOSContextHandle_t extHandle, const Geometry* g1, int n)
2011
0
    {
2012
0
        return execute<NotInterruptible>(extHandle, [&]() {
2013
0
            if(n < 0) {
2014
0
                throw IllegalArgumentException("Index must be non-negative.");
2015
0
            }
2016
0
            return g1->getGeometryN(static_cast<size_t>(n));
2017
0
        });
2018
0
    }
2019
2020
    /*
2021
     * Call only on LINESTRING
2022
     * Returns NULL on exception
2023
     */
2024
    Geometry*
2025
    GEOSGeomGetPointN_r(GEOSContextHandle_t extHandle, const Geometry* g1, int n)
2026
0
    {
2027
0
        return execute(extHandle, [&]() {
2028
0
            const SimpleCurve* ls = dynamic_cast<const SimpleCurve*>(g1);
2029
0
            if(!ls) {
2030
0
                throw IllegalArgumentException("Argument is not a SimpleCurve");
2031
0
            }
2032
0
            if(n < 0) {
2033
0
                throw IllegalArgumentException("Index must be non-negative.");
2034
0
            }
2035
0
            return ls->getPointN(static_cast<size_t>(n)).release();
2036
0
        });
2037
0
    }
2038
2039
    /*
2040
     * Call only on LINESTRING
2041
     */
2042
    Geometry*
2043
    GEOSGeomGetStartPoint_r(GEOSContextHandle_t extHandle, const Geometry* g1)
2044
0
    {
2045
0
        return execute(extHandle, [&]() {
2046
0
            const SimpleCurve* ls = dynamic_cast<const SimpleCurve*>(g1);
2047
0
            if(!ls) {
2048
0
                throw IllegalArgumentException("Argument is not a SimpleCurve");
2049
0
            }
2050
2051
0
            return ls->getStartPoint().release();
2052
0
        });
2053
0
    }
2054
2055
    /*
2056
     * Call only on LINESTRING
2057
     */
2058
    Geometry*
2059
    GEOSGeomGetEndPoint_r(GEOSContextHandle_t extHandle, const Geometry* g1)
2060
0
    {
2061
0
        return execute(extHandle, [&]() {
2062
0
            const SimpleCurve* ls = dynamic_cast<const SimpleCurve*>(g1);
2063
0
            if(!ls) {
2064
0
                throw IllegalArgumentException("Argument is not a SimpleCurve");
2065
0
            }
2066
0
            return ls->getEndPoint().release();
2067
0
        });
2068
0
    }
2069
2070
    /*
2071
     * Call only on LINESTRING or MULTILINESTRING
2072
     * return 2 on exception, 1 on true, 0 on false
2073
     */
2074
    char
2075
    GEOSisClosed_r(GEOSContextHandle_t extHandle, const Geometry* g1)
2076
0
    {
2077
0
        return execute(extHandle, 2, [&]() {
2078
0
            const Curve* ls = dynamic_cast<const Curve*>(g1);
2079
0
            if(ls) {
2080
0
                return ls->isClosed();
2081
0
            }
2082
2083
0
            const MultiLineString* mls = dynamic_cast<const MultiLineString*>(g1);
2084
0
            if(mls) {
2085
0
                return mls->isClosed();
2086
0
            }
2087
2088
0
            const MultiCurve* mc = dynamic_cast<const MultiCurve*>(g1);
2089
0
            if(mc) {
2090
0
                return mc->isClosed();
2091
0
            }
2092
2093
0
            throw IllegalArgumentException("Argument is not a Curve, MultiLineString, or MultiCurve");
2094
0
        });
2095
0
    }
2096
2097
    /*
2098
     * Call only on LINESTRING
2099
     * return 0 on exception, otherwise 1
2100
     */
2101
    int
2102
    GEOSGeomGetLength_r(GEOSContextHandle_t extHandle, const Geometry* g1, double* length)
2103
0
    {
2104
0
        return execute(extHandle, 0, [&]() {
2105
0
            const LineString* ls = dynamic_cast<const LineString*>(g1);
2106
0
            if(!ls) {
2107
0
                throw IllegalArgumentException("Argument is not a LineString");
2108
0
            }
2109
0
            *length = ls->getLength();
2110
0
            return 1;
2111
0
        });
2112
0
    }
2113
2114
    /*
2115
     * Call only on LINESTRING
2116
     */
2117
    int
2118
    GEOSGeomGetNumPoints_r(GEOSContextHandle_t extHandle, const Geometry* g1)
2119
0
    {
2120
0
        return execute(extHandle, -1, [&]() {
2121
0
            const SimpleCurve* ls = dynamic_cast<const SimpleCurve*>(g1);
2122
0
            if(!ls) {
2123
0
                throw IllegalArgumentException("Argument is not a SimpleCurve");
2124
0
            }
2125
0
            return static_cast<int>(ls->getNumPoints());
2126
0
        });
2127
0
    }
2128
2129
    /*
2130
     * For POINT
2131
     * returns 0 on exception, otherwise 1
2132
     */
2133
    int
2134
    GEOSGeomGetX_r(GEOSContextHandle_t extHandle, const Geometry* g1, double* x)
2135
0
    {
2136
0
        return execute(extHandle, 0, [&]() {
2137
0
            const Point* po = dynamic_cast<const Point*>(g1);
2138
0
            if(!po) {
2139
0
                throw IllegalArgumentException("Argument is not a Point");
2140
0
            }
2141
0
            *x = po->getX();
2142
0
            return 1;
2143
0
        });
2144
0
    }
2145
2146
    /*
2147
     * For POINT
2148
     * returns 0 on exception, otherwise 1
2149
     */
2150
    int
2151
    GEOSGeomGetY_r(GEOSContextHandle_t extHandle, const Geometry* g1, double* y)
2152
0
    {
2153
0
        return execute(extHandle, 0, [&]() {
2154
0
            const Point* po = dynamic_cast<const Point*>(g1);
2155
0
            if(!po) {
2156
0
                throw IllegalArgumentException("Argument is not a Point");
2157
0
            }
2158
0
            *y = po->getY();
2159
0
            return 1;
2160
0
        });
2161
0
    }
2162
2163
    /*
2164
     * For POINT
2165
     * returns 0 on exception, otherwise 1
2166
     */
2167
    int
2168
    GEOSGeomGetZ_r(GEOSContextHandle_t extHandle, const Geometry* g1, double* z)
2169
0
    {
2170
0
        return execute(extHandle, 0, [&]() {
2171
0
            const Point* po = dynamic_cast<const Point*>(g1);
2172
0
            if(!po) {
2173
0
                throw IllegalArgumentException("Argument is not a Point");
2174
0
            }
2175
0
            *z = po->getZ();
2176
0
            return 1;
2177
0
        });
2178
0
    }
2179
2180
    /*
2181
     * For POINT
2182
     * returns 0 on exception, otherwise 1
2183
     */
2184
    int
2185
    GEOSGeomGetM_r(GEOSContextHandle_t extHandle, const Geometry* g1, double* m)
2186
0
    {
2187
0
        return execute(extHandle, 0, [&]() {
2188
0
            const Point* po = dynamic_cast<const Point*>(g1);
2189
0
            if(!po) {
2190
0
                throw IllegalArgumentException("Argument is not a Point");
2191
0
            }
2192
0
            *m = po->getM();
2193
0
            return 1;
2194
0
        });
2195
0
    }
2196
2197
    /*
2198
     * Call only on polygon
2199
     * Return a pointer to the internal Geometry.
2200
     */
2201
    const Geometry*
2202
    GEOSGetExteriorRing_r(GEOSContextHandle_t extHandle, const Geometry* g1)
2203
0
    {
2204
0
        return execute<NotInterruptible>(extHandle, [&]() {
2205
0
            const Surface* p = dynamic_cast<const Surface*>(g1);
2206
0
            if(!p) {
2207
0
                throw IllegalArgumentException("Invalid argument (must be a Surface)");
2208
0
            }
2209
0
            return p->getExteriorRing();
2210
0
        });
2211
0
    }
2212
2213
    /*
2214
     * Call only on polygon
2215
     * Return a pointer to internal storage, do not destroy it.
2216
     */
2217
    const Geometry*
2218
    GEOSGetInteriorRingN_r(GEOSContextHandle_t extHandle, const Geometry* g1, int n)
2219
0
    {
2220
0
        return execute<NotInterruptible>(extHandle, [&]() {
2221
0
            const Surface* p = dynamic_cast<const Surface*>(g1);
2222
0
            if(!p) {
2223
0
                throw IllegalArgumentException("Invalid argument (must be a Surface)");
2224
0
            }
2225
0
            if(n < 0) {
2226
0
                throw IllegalArgumentException("Index must be non-negative.");
2227
0
            }
2228
0
            return p->getInteriorRingN(static_cast<size_t>(n));
2229
0
        });
2230
0
    }
2231
2232
    Geometry*
2233
    GEOSGetCentroid_r(GEOSContextHandle_t extHandle, const Geometry* g)
2234
0
    {
2235
0
        return execute(extHandle, [&]() -> Geometry* {
2236
0
            auto ret = g->getCentroid();
2237
0
            ret->setSRID(g->getSRID());
2238
0
            return ret.release();
2239
0
        });
2240
0
    }
2241
2242
    int
2243
    GEOSHilbertCode_r(GEOSContextHandle_t extHandle, const GEOSGeometry *geom,
2244
                const GEOSGeometry* extent, unsigned int level,
2245
                unsigned int *code)
2246
0
    {
2247
0
        using geos::shape::fractal::HilbertEncoder;
2248
2249
0
        return execute(extHandle, 0, [&]() {
2250
0
            Envelope e = *extent->getEnvelopeInternal();
2251
0
            HilbertEncoder encoder(level, e);
2252
0
            *code = encoder.encode(geom->getEnvelopeInternal());
2253
0
            return 1;
2254
0
        });
2255
0
    }
2256
2257
    Geometry*
2258
    GEOSMinimumBoundingCircle_r(GEOSContextHandle_t extHandle, const Geometry* g,
2259
        double* radius, Geometry** center)
2260
0
    {
2261
0
        return execute(extHandle, [&]() -> Geometry* {
2262
0
            GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
2263
2264
0
            geos::algorithm::MinimumBoundingCircle mc(g);
2265
0
            std::unique_ptr<Geometry> ret = mc.getCircle();
2266
0
            const GeometryFactory* gf = handle->geomFactory;
2267
0
            if (center) *center = gf->createPoint(mc.getCentre()).release();
2268
0
            if (radius) *radius = mc.getRadius();
2269
0
            ret->setSRID(g->getSRID());
2270
0
            return ret.release();
2271
0
        });
2272
0
    }
2273
2274
    Geometry*
2275
    GEOSGeom_createEmptyCollection_r(GEOSContextHandle_t extHandle, int type)
2276
0
    {
2277
0
        return execute(extHandle, [&]() {
2278
0
            GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
2279
0
            const GeometryFactory* gf = handle->geomFactory;
2280
2281
0
            std::unique_ptr<Geometry> g = 0;
2282
0
            switch(type) {
2283
0
            case GEOS_GEOMETRYCOLLECTION:
2284
0
                g = gf->createGeometryCollection();
2285
0
                break;
2286
0
            case GEOS_MULTIPOINT:
2287
0
                g = gf->createMultiPoint();
2288
0
                break;
2289
0
            case GEOS_MULTILINESTRING:
2290
0
                g = gf->createMultiLineString();
2291
0
                break;
2292
0
            case GEOS_MULTIPOLYGON:
2293
0
                g = gf->createMultiPolygon();
2294
0
                break;
2295
0
            case GEOS_MULTICURVE:
2296
0
                g = gf->createMultiCurve();
2297
0
                break;
2298
0
            case GEOS_MULTISURFACE:
2299
0
                g = gf->createMultiSurface();
2300
0
                break;
2301
0
            default:
2302
0
                throw IllegalArgumentException("Unsupported type request for GEOSGeom_createEmptyCollection_r");
2303
0
            }
2304
2305
0
            return g.release();
2306
0
        });
2307
0
    }
2308
2309
    Geometry*
2310
    GEOSGeom_createCollection_r(GEOSContextHandle_t extHandle, int type, Geometry** geoms, unsigned int ngeoms)
2311
0
    {
2312
0
        return execute(extHandle, [&]() {
2313
0
            GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
2314
2315
0
            const GeometryFactory* gf = handle->geomFactory;
2316
2317
0
            std::vector<std::unique_ptr<Geometry>> vgeoms(ngeoms);
2318
0
            for (std::size_t i = 0; i < ngeoms; i++) {
2319
0
                vgeoms[i].reset(geoms[i]);
2320
0
            }
2321
2322
0
            std::unique_ptr<Geometry> g;
2323
0
            switch(type) {
2324
0
            case GEOS_GEOMETRYCOLLECTION:
2325
0
                g = gf->createGeometryCollection(std::move(vgeoms));
2326
0
                break;
2327
0
            case GEOS_MULTIPOINT:
2328
0
                g = gf->createMultiPoint(std::move(vgeoms));
2329
0
                break;
2330
0
            case GEOS_MULTILINESTRING:
2331
0
                g = gf->createMultiLineString(std::move(vgeoms));
2332
0
                break;
2333
0
            case GEOS_MULTIPOLYGON:
2334
0
                g = gf->createMultiPolygon(std::move(vgeoms));
2335
0
                break;
2336
0
            case GEOS_MULTICURVE:
2337
0
                g = gf->createMultiCurve(std::move(vgeoms));
2338
0
                break;
2339
0
            case GEOS_MULTISURFACE:
2340
0
                g = gf->createMultiSurface(std::move(vgeoms));
2341
0
                break;
2342
0
            default:
2343
0
                handle->ERROR_MESSAGE("Unsupported type request for GEOSGeom_createCollection_r");
2344
0
            }
2345
2346
0
            return g.release();
2347
0
        });
2348
0
    }
2349
2350
    Geometry**
2351
    GEOSGeom_releaseCollection_r(GEOSContextHandle_t extHandle, Geometry* collection, unsigned int * ngeoms)
2352
0
    {
2353
0
        return execute(extHandle, [&]() {
2354
0
            GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
2355
2356
0
            if (ngeoms == nullptr) {
2357
0
                handle->ERROR_MESSAGE("Parameter ngeoms of GEOSGeom_releaseCollection_r must not be null");
2358
0
            }
2359
2360
0
            GeometryCollection *col = dynamic_cast<GeometryCollection*>(collection);
2361
0
            if (!col) {
2362
0
                handle->ERROR_MESSAGE("Parameter collection of GEOSGeom_releaseCollection_r must not be a collection");
2363
0
            } else {
2364
0
                *ngeoms = static_cast<unsigned int>(col->getNumGeometries());
2365
0
            }
2366
2367
            // Early exit on empty/null input
2368
0
            if (!col || *ngeoms == 0) {
2369
0
                return static_cast<Geometry**>(nullptr);
2370
0
            }
2371
2372
0
            std::vector<std::unique_ptr<Geometry>> subgeoms = col->releaseGeometries();
2373
2374
0
            Geometry** subgeomArray = static_cast<Geometry**>(malloc(sizeof(Geometry*) * subgeoms.size()));
2375
0
            for (std::size_t i = 0; i < subgeoms.size(); i++) {
2376
0
                subgeomArray[i] = subgeoms[i].release();
2377
0
            }
2378
2379
0
            return subgeomArray;
2380
0
        });
2381
0
    }
2382
2383
    Geometry*
2384
    GEOSPolygonize_r(GEOSContextHandle_t extHandle, const Geometry* const* g, unsigned int ngeoms)
2385
0
    {
2386
0
        using geos::operation::polygonize::Polygonizer;
2387
2388
0
        return execute(extHandle, [&]() {
2389
0
            GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
2390
2391
            // Polygonize
2392
0
            Polygonizer plgnzr;
2393
0
            for(std::size_t i = 0; i < ngeoms; ++i) {
2394
0
                plgnzr.add(g[i]);
2395
0
            }
2396
2397
0
            auto polys = plgnzr.getPolygons();
2398
0
            const GeometryFactory* gf = handle->geomFactory;
2399
0
            return gf->createGeometryCollection(std::move(polys)).release();
2400
0
        });
2401
0
    }
2402
2403
    Geometry*
2404
    GEOSPolygonize_valid_r(GEOSContextHandle_t extHandle, const Geometry* const* g, unsigned int ngeoms)
2405
0
    {
2406
0
        using geos::operation::polygonize::Polygonizer;
2407
2408
0
        return execute(extHandle, [&]() -> Geometry* {
2409
0
            GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
2410
0
            Geometry* out;
2411
2412
            // Polygonize
2413
0
            Polygonizer plgnzr(true);
2414
0
            int srid = 0;
2415
0
            for(std::size_t i = 0; i < ngeoms; ++i) {
2416
0
                plgnzr.add(g[i]);
2417
0
                srid = g[i]->getSRID();
2418
0
            }
2419
2420
0
            auto polys = plgnzr.getPolygons();
2421
0
            if (polys.empty()) {
2422
0
                out = handle->geomFactory->createGeometryCollection().release();
2423
0
            } else if (polys.size() == 1) {
2424
0
                return polys[0].release();
2425
0
            } else {
2426
0
                return handle->geomFactory->createMultiPolygon(std::move(polys)).release();
2427
0
            }
2428
2429
0
            out->setSRID(srid);
2430
0
            return out;
2431
0
        });
2432
0
    }
2433
2434
    Geometry*
2435
    GEOSBuildArea_r(GEOSContextHandle_t extHandle, const Geometry* g)
2436
0
    {
2437
0
        using geos::operation::polygonize::BuildArea;
2438
2439
0
        return execute(extHandle, [&]() {
2440
0
            BuildArea builder;
2441
0
            auto out = builder.build(g);
2442
0
            out->setSRID(g->getSRID());
2443
0
            return out.release();
2444
0
        });
2445
0
    }
2446
2447
/************************************************************************
2448
 * Make Valid
2449
 */
2450
2451
    Geometry*
2452
    GEOSMakeValid_r(GEOSContextHandle_t extHandle, const Geometry* g)
2453
0
    {
2454
0
        GEOSMakeValidParams params;
2455
0
        params.method = GEOS_MAKE_VALID_LINEWORK;
2456
0
        params.keepCollapsed = 1;
2457
0
        return GEOSMakeValidWithParams_r(extHandle, g, &params);
2458
0
    }
2459
2460
    GEOSMakeValidParams*
2461
    GEOSMakeValidParams_create_r(GEOSContextHandle_t extHandle)
2462
0
    {
2463
0
        return execute(extHandle, [&]() {
2464
0
            GEOSMakeValidParams* p = new GEOSMakeValidParams();
2465
0
            p->method = GEOS_MAKE_VALID_LINEWORK;
2466
0
            p->keepCollapsed = 0;
2467
0
            return p;
2468
0
        });
2469
0
    }
2470
2471
    void
2472
    GEOSMakeValidParams_destroy_r(GEOSContextHandle_t extHandle, GEOSMakeValidParams* parms)
2473
0
    {
2474
0
        (void)extHandle;
2475
0
        delete parms;
2476
0
    }
2477
2478
    int
2479
    GEOSMakeValidParams_setKeepCollapsed_r(GEOSContextHandle_t extHandle,
2480
        GEOSMakeValidParams* p, int keepCollapsed)
2481
0
    {
2482
0
        return execute(extHandle, 0, [&]() {
2483
0
            p->keepCollapsed = keepCollapsed;
2484
0
            return 1;
2485
0
        });
2486
0
    }
2487
2488
    int
2489
    GEOSMakeValidParams_setMethod_r(GEOSContextHandle_t extHandle,
2490
        GEOSMakeValidParams* p, GEOSMakeValidMethods method)
2491
0
    {
2492
0
        return execute(extHandle, 0, [&]() {
2493
0
            p->method = method;
2494
0
            return 1;
2495
0
        });
2496
0
    }
2497
2498
    Geometry*
2499
    GEOSMakeValidWithParams_r(
2500
        GEOSContextHandle_t extHandle,
2501
        const Geometry* g,
2502
        const GEOSMakeValidParams* params)
2503
0
    {
2504
0
        using geos::geom::util::GeometryFixer;
2505
0
        using geos::operation::valid::MakeValid;
2506
2507
0
        if (params && params->method == GEOS_MAKE_VALID_LINEWORK) {
2508
0
            return execute(extHandle, [&]() {
2509
0
                MakeValid makeValid;
2510
0
                auto out = makeValid.build(g);
2511
0
                out->setSRID(g->getSRID());
2512
0
                return out.release();
2513
0
            });
2514
0
        }
2515
0
        else if (params && params->method == GEOS_MAKE_VALID_STRUCTURE) {
2516
0
            return execute(extHandle, [&]() {
2517
0
                GeometryFixer fixer(g);
2518
0
                fixer.setKeepCollapsed(params->keepCollapsed == 0 ? false : true);
2519
0
                auto out = fixer.getResult();
2520
0
                out->setSRID(g->getSRID());
2521
0
                return out.release();
2522
0
            });
2523
0
        }
2524
0
        else {
2525
0
            extHandle->ERROR_MESSAGE("Unknown method in GEOSMakeValidParams");
2526
0
            return nullptr;
2527
0
        }
2528
0
    }
2529
2530
    Geometry*
2531
    GEOSRemoveRepeatedPoints_r(
2532
        GEOSContextHandle_t extHandle,
2533
        const Geometry* g,
2534
        double tolerance)
2535
0
    {
2536
0
        using geos::operation::valid::RepeatedPointRemover;
2537
2538
0
        return execute(extHandle, [&]() {
2539
0
            auto out = RepeatedPointRemover::removeRepeatedPoints(g, tolerance);
2540
0
            out->setSRID(g->getSRID());
2541
0
            return out.release();
2542
0
        });
2543
0
    }
2544
2545
    Geometry*
2546
    GEOSPolygonizer_getCutEdges_r(GEOSContextHandle_t extHandle, const Geometry* const* g, unsigned int ngeoms)
2547
0
    {
2548
0
        using geos::operation::polygonize::Polygonizer;
2549
2550
0
        return execute(extHandle, [&]() {
2551
0
            GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
2552
0
            const GeometryFactory* gf = handle->geomFactory;
2553
2554
            // Polygonize
2555
0
            Polygonizer plgnzr;
2556
0
            int srid = 0;
2557
0
            for(std::size_t i = 0; i < ngeoms; ++i) {
2558
0
                plgnzr.add(g[i]);
2559
0
                srid = g[i]->getSRID();
2560
0
            }
2561
2562
0
            const std::vector<const LineString*>& lines = plgnzr.getCutEdges();
2563
2564
            // We need a vector of Geometry pointers, not Polygon pointers.
2565
            // STL vector doesn't allow transparent upcast of this
2566
            // nature, so we explicitly convert.
2567
            // (it's just a waste of processor and memory, btw)
2568
            // XXX mloskot: See comment for GEOSPolygonize_r
2569
2570
0
            std::vector<std::unique_ptr<Geometry>> linevec(lines.size());
2571
2572
0
            for(std::size_t i = 0, n = lines.size(); i < n; ++i) {
2573
0
                linevec[i] = lines[i]->clone();
2574
0
            }
2575
2576
0
            auto out = gf->createGeometryCollection(std::move(linevec));
2577
0
            out->setSRID(srid);
2578
2579
0
            return out.release();
2580
0
        });
2581
0
    }
2582
2583
    Geometry*
2584
    GEOSPolygonize_full_r(GEOSContextHandle_t extHandle, const Geometry* g,
2585
                          Geometry** cuts, Geometry** dangles, Geometry** invalid)
2586
0
    {
2587
0
        using geos::operation::polygonize::Polygonizer;
2588
2589
0
        return execute(extHandle, [&]() {
2590
            // Polygonize
2591
0
            Polygonizer plgnzr;
2592
0
            for(std::size_t i = 0; i < g->getNumGeometries(); ++i) {
2593
0
                plgnzr.add(g->getGeometryN(i));
2594
0
            }
2595
2596
0
            const GeometryFactory* gf = g->getFactory();
2597
2598
0
            if(cuts) {
2599
0
                const std::vector<const LineString*>& lines = plgnzr.getCutEdges();
2600
0
                std::vector<std::unique_ptr<Geometry>> linevec(lines.size());
2601
0
                for(std::size_t i = 0, n = lines.size(); i < n; ++i) {
2602
0
                    linevec[i] = lines[i]->clone();
2603
0
                }
2604
2605
0
                *cuts = gf->createGeometryCollection(std::move(linevec)).release();
2606
0
            }
2607
2608
0
            if(dangles) {
2609
0
                const std::vector<const LineString*>& lines = plgnzr.getDangles();
2610
0
                std::vector<std::unique_ptr<Geometry>> linevec(lines.size());
2611
0
                for(std::size_t i = 0, n = lines.size(); i < n; ++i) {
2612
0
                    linevec[i] = lines[i]->clone();
2613
0
                }
2614
2615
0
                *dangles = gf->createGeometryCollection(std::move(linevec)).release();
2616
0
            }
2617
2618
0
            if(invalid) {
2619
0
                const std::vector<std::unique_ptr<LineString>>& lines = plgnzr.getInvalidRingLines();
2620
0
                std::vector<std::unique_ptr<Geometry>> linevec(lines.size());
2621
0
                for(std::size_t i = 0, n = lines.size(); i < n; ++i) {
2622
0
                    linevec[i] = lines[i]->clone();
2623
0
                }
2624
2625
0
                *invalid = gf->createGeometryCollection(std::move(linevec)).release();
2626
0
            }
2627
2628
0
            auto polys = plgnzr.getPolygons();
2629
0
            Geometry* out = gf->createGeometryCollection(std::move(polys)).release();
2630
0
            out->setSRID(g->getSRID());
2631
0
            return out;
2632
0
        });
2633
0
    }
2634
2635
    Geometry*
2636
    GEOSLineMerge_r(GEOSContextHandle_t extHandle, const Geometry* g)
2637
0
    {
2638
0
        using geos::operation::linemerge::LineMerger;
2639
2640
0
        return execute(extHandle, [&]() {
2641
0
            GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
2642
0
            const GeometryFactory* gf = handle->geomFactory;
2643
0
            LineMerger lmrgr;
2644
0
            lmrgr.add(g);
2645
2646
0
            auto lines = lmrgr.getMergedLineStrings();
2647
2648
0
            auto out = gf->buildGeometry(std::move(lines));
2649
0
            out->setSRID(g->getSRID());
2650
2651
0
            return out.release();
2652
0
        });
2653
0
    }
2654
2655
    Geometry*
2656
    GEOSLineMergeDirected_r(GEOSContextHandle_t extHandle, const Geometry* g)
2657
0
    {
2658
0
        using geos::operation::linemerge::LineMerger;
2659
2660
0
        return execute(extHandle, [&]() {
2661
0
            GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
2662
0
            const GeometryFactory* gf = handle->geomFactory;
2663
0
            LineMerger lmrgr(true);
2664
0
            lmrgr.add(g);
2665
2666
0
            auto lines = lmrgr.getMergedLineStrings();
2667
2668
0
            auto out = gf->buildGeometry(std::move(lines));
2669
0
            out->setSRID(g->getSRID());
2670
2671
0
            return out.release();
2672
0
        });
2673
0
    }
2674
2675
    Geometry*
2676
    GEOSLineSubstring_r(GEOSContextHandle_t extHandle, const Geometry* g, double start_fraction, double end_fraction)
2677
0
    {
2678
0
        using geos::linearref::LengthIndexedLine;
2679
2680
0
        return execute(extHandle, [&]() {
2681
0
            if (start_fraction < 0 || end_fraction < 0) {
2682
0
                throw IllegalArgumentException("start fraction must be >= 0");
2683
0
            }
2684
0
            if (start_fraction > 1 || end_fraction > 1) {
2685
0
                throw IllegalArgumentException("end fraction must be <= 1");
2686
0
            }
2687
2688
0
            LengthIndexedLine lil(g);
2689
2690
0
            auto length = g->getLength();
2691
2692
0
            auto out = lil.extractLine(start_fraction * length, end_fraction * length);
2693
0
            out->setSRID(g->getSRID());
2694
2695
0
            return out.release();
2696
0
        });
2697
0
    }
2698
2699
    Geometry*
2700
    GEOSReverse_r(GEOSContextHandle_t extHandle, const Geometry* g)
2701
0
    {
2702
0
        return execute(extHandle, [&]() {
2703
0
            auto g3 = g->reverse();
2704
0
            g3->setSRID(g->getSRID());
2705
0
            return g3.release();
2706
0
        });
2707
0
    }
2708
2709
    void*
2710
    GEOSGeom_getUserData_r(GEOSContextHandle_t extHandle, const Geometry* g)
2711
0
    {
2712
0
        return execute(extHandle, [&]() {
2713
0
            return g->getUserData();
2714
0
        });
2715
0
    }
2716
2717
    int
2718
    GEOSGetSRID_r(GEOSContextHandle_t extHandle, const Geometry* g)
2719
0
    {
2720
0
        return execute(extHandle, 0, [&]() {
2721
0
            return g->getSRID();
2722
0
        });
2723
0
    }
2724
2725
    const char* GEOSversion()
2726
0
    {
2727
0
        static char version[256];
2728
0
        snprintf(version, 256, "%s", GEOS_CAPI_VERSION);
2729
0
        return version;
2730
0
    }
2731
2732
    const char* GEOSjtsport()
2733
0
    {
2734
0
        return GEOS_JTS_PORT;
2735
0
    }
2736
2737
    char
2738
    GEOSHasZ_r(GEOSContextHandle_t extHandle, const Geometry* g)
2739
0
    {
2740
0
        return execute(extHandle, 2, [&]() {
2741
0
            return g->hasZ();
2742
0
        });
2743
0
    }
2744
2745
    char
2746
    GEOSHasM_r(GEOSContextHandle_t extHandle, const Geometry* g)
2747
0
    {
2748
0
        return execute(extHandle, 2, [&]() {
2749
0
            return g->hasM();
2750
0
        });
2751
0
    }
2752
2753
    int
2754
    GEOS_getWKBOutputDims_r(GEOSContextHandle_t extHandle)
2755
0
    {
2756
0
        return execute(extHandle, -1, [&]() -> int {
2757
0
            GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
2758
0
            return handle->WKBOutputDims;
2759
0
        });
2760
0
    }
2761
2762
    int
2763
    GEOS_setWKBOutputDims_r(GEOSContextHandle_t extHandle, int newdims)
2764
0
    {
2765
0
        return execute(extHandle, -1, [&]() {
2766
0
            GEOSContextHandleInternal_t *handle = reinterpret_cast<GEOSContextHandleInternal_t *>(extHandle);
2767
2768
0
            if (newdims < 2 || newdims > 4) {
2769
0
                handle->ERROR_MESSAGE("WKB output dimensions out of range 2..4");
2770
0
            }
2771
2772
0
            const int olddims = handle->WKBOutputDims;
2773
0
            handle->WKBOutputDims = static_cast<uint8_t>(newdims);
2774
2775
0
            return olddims;
2776
0
        });
2777
0
    }
2778
2779
    int
2780
    GEOS_getWKBByteOrder_r(GEOSContextHandle_t extHandle)
2781
0
    {
2782
0
        return execute(extHandle, -1, [&]() {
2783
0
            GEOSContextHandleInternal_t *handle = reinterpret_cast<GEOSContextHandleInternal_t *>(extHandle);
2784
0
            return handle->WKBByteOrder;
2785
0
        });
2786
0
    }
2787
2788
    int
2789
    GEOS_setWKBByteOrder_r(GEOSContextHandle_t extHandle, int byteOrder)
2790
0
    {
2791
0
        return execute(extHandle, -1, [&]() {
2792
0
            GEOSContextHandleInternal_t *handle = reinterpret_cast<GEOSContextHandleInternal_t *>(extHandle);
2793
0
            const int oldByteOrder = handle->WKBByteOrder;
2794
0
            handle->WKBByteOrder = byteOrder;
2795
2796
0
            return oldByteOrder;
2797
0
        });
2798
0
    }
2799
2800
2801
    CoordinateSequence*
2802
    GEOSCoordSeq_create_r(GEOSContextHandle_t extHandle, unsigned int size, unsigned int dims)
2803
0
    {
2804
0
        return execute(extHandle, [&]() {
2805
0
            return new CoordinateSequence(size, dims);
2806
0
        });
2807
0
    }
2808
2809
    CoordinateSequence*
2810
    GEOSCoordSeq_createWithDimensions_r(GEOSContextHandle_t extHandle, unsigned int size, int hasZ, int hasM)
2811
0
    {
2812
0
        return execute(extHandle, [&]() {
2813
0
            return new CoordinateSequence(size, hasZ, hasM);
2814
0
        });
2815
0
    }
2816
2817
    CoordinateSequence*
2818
    GEOSCoordSeq_copyFromBuffer_r(GEOSContextHandle_t extHandle, const double* buf, unsigned int size, int hasZ, int hasM)
2819
0
    {
2820
0
        return execute(extHandle, [&]() {
2821
0
            std::ptrdiff_t stride = 2 + hasZ + hasM;
2822
0
            auto coords = geos::detail::make_unique<CoordinateSequence>(size, hasZ, hasM, false);
2823
0
            if (hasZ) {
2824
0
                if (hasM) {
2825
                    // XYZM
2826
0
                    assert(coords->getCoordinateType() == geos::geom::CoordinateType::XYZM);
2827
0
                    std::memcpy(coords->data(), buf, size * sizeof(CoordinateXYZM));
2828
0
                } else {
2829
                    // XYZ
2830
0
                    assert(coords->getCoordinateType() == geos::geom::CoordinateType::XYZ);
2831
0
                    std::memcpy(coords->data(), buf, size * sizeof(Coordinate));
2832
0
                }
2833
0
            } else {
2834
0
                if (hasM) {
2835
                    // XYM
2836
0
                    for (std::size_t i = 0; i < size; i++) {
2837
0
                        coords->setAt(CoordinateXYM{ *buf, *(buf + 1), *(buf + 2)}, i);
2838
0
                        buf += stride;
2839
0
                    }
2840
0
                } else {
2841
                    // XY
2842
0
                    for (std::size_t i = 0; i < size; i++) {
2843
0
                        coords->setAt(Coordinate{ *buf, *(buf + 1) }, i);
2844
0
                        buf += stride;
2845
0
                    }
2846
0
                }
2847
0
            }
2848
2849
0
            return coords.release();
2850
0
        });
2851
0
    }
2852
2853
    CoordinateSequence*
2854
    GEOSCoordSeq_copyFromArrays_r(GEOSContextHandle_t extHandle, const double* x, const double* y, const double* z, const double* m, unsigned int size)
2855
0
    {
2856
0
        return execute(extHandle, [&]() {
2857
0
            bool hasZ = z != nullptr;
2858
0
            bool hasM = m != nullptr;
2859
2860
0
            auto coords = geos::detail::make_unique<geos::geom::CoordinateSequence>(size, hasZ, hasM, false);
2861
2862
0
            CoordinateXYZM c;
2863
0
            for (std::size_t i = 0; i < size; i++) {
2864
0
                c.x = x[i];
2865
0
                c.y = y[i];
2866
0
                if (z) {
2867
0
                    c.z = z[i];
2868
0
                }
2869
0
                if (m) {
2870
0
                    c.m = m[i];
2871
0
                }
2872
2873
0
                coords->setAt(c, i);
2874
0
            }
2875
2876
0
            return coords.release();
2877
0
        });
2878
0
    }
2879
2880
    int
2881
    GEOSCoordSeq_copyToArrays_r(GEOSContextHandle_t extHandle, const CoordinateSequence* cs,
2882
                                double* x, double* y, double* z, double* m)
2883
0
    {
2884
0
        return execute(extHandle, 0, [&]() {
2885
0
            CoordinateXYZM c;
2886
0
            for (std::size_t i = 0; i < cs->size(); i++) {
2887
0
                cs->getAt(i, c);
2888
0
                x[i] = c.x;
2889
0
                y[i] = c.y;
2890
0
                if (z) {
2891
0
                    z[i] = c.z;
2892
0
                }
2893
0
                if (m) {
2894
0
                    m[i] = c.m;
2895
0
                }
2896
0
            }
2897
2898
0
            return 1;
2899
0
        });
2900
0
    }
2901
2902
    int
2903
    GEOSCoordSeq_copyToBuffer_r(GEOSContextHandle_t extHandle, const CoordinateSequence* cs,
2904
                                double* buf, int hasZ, int hasM)
2905
0
    {
2906
0
        using geos::geom::CoordinateType;
2907
2908
0
        return execute(extHandle, 0, [&]() {
2909
0
            CoordinateType srcType = cs->getCoordinateType();
2910
0
            CoordinateType dstType;
2911
0
            std::size_t stride;
2912
0
            if (hasZ) {
2913
0
                if (hasM) {
2914
0
                    dstType = CoordinateType::XYZM;
2915
0
                    stride = 4;
2916
0
                } else {
2917
0
                    dstType = CoordinateType::XYZ;
2918
0
                    stride = 3;
2919
0
                }
2920
0
            } else {
2921
0
                if (hasM) {
2922
0
                    dstType = CoordinateType::XYM;
2923
0
                    stride = 3;
2924
0
                } else {
2925
0
                    dstType = CoordinateType::XY;
2926
0
                    stride = 2;
2927
0
                }
2928
0
            }
2929
2930
0
            if (srcType == dstType) {
2931
0
                std::memcpy(buf, cs->data(), cs->size() * stride * sizeof(double));
2932
0
            } else {
2933
0
                switch(dstType) {
2934
0
                    case CoordinateType::XY: {
2935
0
                        for (std::size_t i = 0; i < cs->size(); i++) {
2936
0
                            CoordinateXY* c = reinterpret_cast<CoordinateXY*>(buf + i*stride);
2937
0
                            cs->getAt(i, *c);
2938
0
                        }
2939
0
                        break;
2940
0
                    }
2941
0
                    case CoordinateType::XYZ: {
2942
0
                        for (std::size_t i = 0; i < cs->size(); i++) {
2943
0
                            Coordinate* c = reinterpret_cast<Coordinate*>(buf + i*stride);
2944
0
                            cs->getAt(i, *c);
2945
0
                        }
2946
0
                        break;
2947
0
                    }
2948
0
                    case CoordinateType::XYM: {
2949
0
                        for (std::size_t i = 0; i < cs->size(); i++) {
2950
0
                            CoordinateXYM* c = reinterpret_cast<CoordinateXYM*>(buf + i*stride);
2951
0
                            cs->getAt(i, *c);
2952
0
                        }
2953
0
                        break;
2954
0
                    }
2955
0
                    case CoordinateType::XYZM: {
2956
0
                        for (std::size_t i = 0; i < cs->size(); i++) {
2957
0
                            CoordinateXYZM* c = reinterpret_cast<CoordinateXYZM*>(buf + i*stride);
2958
0
                            cs->getAt(i, *c);
2959
0
                        }
2960
0
                        break;
2961
0
                    }
2962
0
                }
2963
0
            }
2964
2965
0
            return 1;
2966
0
        });
2967
0
    }
2968
2969
    char
2970
    GEOSCoordSeq_hasZ_r(GEOSContextHandle_t extHandle, CoordinateSequence* cs)
2971
0
    {
2972
0
        return execute(extHandle, 2, [&]() {
2973
0
            return cs->hasZ();
2974
0
        });
2975
0
    }
2976
2977
    char
2978
    GEOSCoordSeq_hasM_r(GEOSContextHandle_t extHandle, CoordinateSequence* cs)
2979
0
    {
2980
0
        return execute(extHandle, 2, [&]() {
2981
0
            return cs->hasM();
2982
0
        });
2983
0
    }
2984
2985
    int
2986
    GEOSCoordSeq_setOrdinate_r(GEOSContextHandle_t extHandle, CoordinateSequence* cs,
2987
                               unsigned int idx, unsigned int dim, double val)
2988
0
    {
2989
0
        return execute<NotInterruptible>(extHandle, 0, [&]() {
2990
0
            cs->setOrdinate(idx, dim, val);
2991
0
            return 1;
2992
0
        });
2993
0
    }
2994
2995
    int
2996
    GEOSCoordSeq_setX_r(GEOSContextHandle_t extHandle, CoordinateSequence* s, unsigned int idx, double val)
2997
0
    {
2998
0
        return GEOSCoordSeq_setOrdinate_r(extHandle, s, idx, CoordinateSequence::X, val);
2999
0
    }
3000
3001
    int
3002
    GEOSCoordSeq_setY_r(GEOSContextHandle_t extHandle, CoordinateSequence* s, unsigned int idx, double val)
3003
0
    {
3004
0
        return GEOSCoordSeq_setOrdinate_r(extHandle, s, idx, CoordinateSequence::Y, val);
3005
0
    }
3006
3007
    int
3008
    GEOSCoordSeq_setZ_r(GEOSContextHandle_t extHandle, CoordinateSequence* s, unsigned int idx, double val)
3009
0
    {
3010
0
        return GEOSCoordSeq_setOrdinate_r(extHandle, s, idx, CoordinateSequence::Z, val);
3011
0
    }
3012
3013
    int
3014
    GEOSCoordSeq_setM_r(GEOSContextHandle_t extHandle, CoordinateSequence* s, unsigned int idx, double val)
3015
0
    {
3016
0
        return GEOSCoordSeq_setOrdinate_r(extHandle, s, idx, CoordinateSequence::M, val);
3017
0
    }
3018
3019
    int
3020
    GEOSCoordSeq_setXY_r(GEOSContextHandle_t extHandle, CoordinateSequence* cs, unsigned int idx, double x, double y)
3021
0
    {
3022
0
        return execute<NotInterruptible>(extHandle, 0, [&]() {
3023
0
            cs->setAt(CoordinateXY{x, y}, idx);
3024
0
            return 1;
3025
0
        });
3026
0
    }
3027
3028
    int
3029
    GEOSCoordSeq_setXYZ_r(GEOSContextHandle_t extHandle, CoordinateSequence* cs, unsigned int idx, double x, double y, double z)
3030
0
    {
3031
0
        return execute<NotInterruptible>(extHandle, 0, [&]() {
3032
0
            cs->setAt(Coordinate{x, y, z}, idx);
3033
0
            return 1;
3034
0
        });
3035
0
    }
3036
3037
    CoordinateSequence*
3038
    GEOSCoordSeq_clone_r(GEOSContextHandle_t extHandle, const CoordinateSequence* cs)
3039
0
    {
3040
0
        return execute(extHandle, [&]() {
3041
0
            return cs->clone().release();
3042
0
        });
3043
0
    }
3044
3045
    int
3046
    GEOSCoordSeq_getOrdinate_r(GEOSContextHandle_t extHandle, const CoordinateSequence* cs,
3047
                               unsigned int idx, unsigned int dim, double* val)
3048
0
    {
3049
0
        return execute<NotInterruptible>(extHandle, 0, [&]() {
3050
0
            *val = cs->getOrdinate(idx, dim);
3051
0
            return 1;
3052
0
        });
3053
0
    }
3054
3055
    int
3056
    GEOSCoordSeq_getX_r(GEOSContextHandle_t extHandle, const CoordinateSequence* s, unsigned int idx, double* val)
3057
0
    {
3058
0
        return GEOSCoordSeq_getOrdinate_r(extHandle, s, idx, CoordinateSequence::X, val);
3059
0
    }
3060
3061
    int
3062
    GEOSCoordSeq_getY_r(GEOSContextHandle_t extHandle, const CoordinateSequence* s, unsigned int idx, double* val)
3063
0
    {
3064
0
        return GEOSCoordSeq_getOrdinate_r(extHandle, s, idx, CoordinateSequence::Y, val);
3065
0
    }
3066
3067
    int
3068
    GEOSCoordSeq_getZ_r(GEOSContextHandle_t extHandle, const CoordinateSequence* s, unsigned int idx, double* val)
3069
0
    {
3070
0
        return GEOSCoordSeq_getOrdinate_r(extHandle, s, idx, CoordinateSequence::Z, val);
3071
0
    }
3072
3073
    int
3074
    GEOSCoordSeq_getM_r(GEOSContextHandle_t extHandle, const CoordinateSequence* s, unsigned int idx, double* val)
3075
0
    {
3076
0
        return GEOSCoordSeq_getOrdinate_r(extHandle, s, idx, CoordinateSequence::M, val);
3077
0
    }
3078
3079
    int
3080
    GEOSCoordSeq_getXY_r(GEOSContextHandle_t extHandle, const CoordinateSequence* cs, unsigned int idx, double* x, double* y)
3081
0
    {
3082
0
        return execute<NotInterruptible>(extHandle, 0, [&]() {
3083
0
            auto& c = cs->getAt<CoordinateXY>(idx);
3084
0
            *x = c.x;
3085
0
            *y = c.y;
3086
0
            return 1;
3087
0
        });
3088
0
    }
3089
3090
    int
3091
    GEOSCoordSeq_getXYZ_r(GEOSContextHandle_t extHandle, const CoordinateSequence* cs, unsigned int idx, double* x, double* y, double* z)
3092
0
    {
3093
0
        return execute<NotInterruptible>(extHandle, 0, [&]() {
3094
0
            auto& c = cs->getAt(idx);
3095
0
            *x = c.x;
3096
0
            *y = c.y;
3097
0
            *z = c.z;
3098
0
            return 1;
3099
0
        });
3100
0
    }
3101
3102
    int
3103
    GEOSCoordSeq_getSize_r(GEOSContextHandle_t extHandle, const CoordinateSequence* cs, unsigned int* size)
3104
0
    {
3105
0
        return execute<NotInterruptible>(extHandle, 0, [&]() {
3106
0
            const std::size_t sz = cs->getSize();
3107
0
            *size = static_cast<unsigned int>(sz);
3108
0
            return 1;
3109
0
        });
3110
0
    }
3111
3112
    int
3113
    GEOSCoordSeq_getDimensions_r(GEOSContextHandle_t extHandle, const CoordinateSequence* cs, unsigned int* dims)
3114
0
    {
3115
0
        return execute<NotInterruptible>(extHandle, 0, [&]() {
3116
0
            const std::size_t dim = cs->getDimension();
3117
0
            *dims = static_cast<unsigned int>(dim);
3118
3119
0
            return 1;
3120
0
        });
3121
0
    }
3122
3123
    int
3124
    GEOSCoordSeq_isCCW_r(GEOSContextHandle_t extHandle, const CoordinateSequence* cs, char* val)
3125
0
    {
3126
0
        return execute(extHandle, 0, [&]() {
3127
0
            *val = geos::algorithm::Orientation::isCCW(cs);
3128
0
            return 1;
3129
0
        });
3130
0
    }
3131
3132
    void
3133
    GEOSCoordSeq_destroy_r(GEOSContextHandle_t extHandle, CoordinateSequence* s)
3134
0
    {
3135
0
        return execute(extHandle, [&]() {
3136
0
            delete s;
3137
0
        });
3138
0
    }
3139
3140
    const CoordinateSequence*
3141
    GEOSGeom_getCoordSeq_r(GEOSContextHandle_t extHandle, const Geometry* g)
3142
0
    {
3143
0
        return execute(extHandle, [&]() {
3144
0
            const SimpleCurve* ls = dynamic_cast<const SimpleCurve*>(g);
3145
0
            if(ls) {
3146
0
                return ls->getCoordinatesRO();
3147
0
            }
3148
3149
0
            const Point* p = dynamic_cast<const Point*>(g);
3150
0
            if(p) {
3151
0
                return p->getCoordinatesRO();
3152
0
            }
3153
3154
0
            throw IllegalArgumentException("Geometry must be a Point or LineString");
3155
0
        });
3156
0
    }
3157
3158
    Geometry*
3159
    GEOSGeom_createEmptyPoint_r(GEOSContextHandle_t extHandle)
3160
0
    {
3161
0
        return execute(extHandle, [&]() {
3162
0
            GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
3163
0
            const GeometryFactory* gf = handle->geomFactory;
3164
0
            return gf->createPoint().release();
3165
0
        });
3166
0
    }
3167
3168
    Geometry*
3169
    GEOSGeom_createPoint_r(GEOSContextHandle_t extHandle, CoordinateSequence* cs)
3170
0
    {
3171
0
        return execute(extHandle, [&]() {
3172
0
            GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
3173
0
            const GeometryFactory* gf = handle->geomFactory;
3174
3175
0
            return gf->createPoint(std::unique_ptr<CoordinateSequence>(cs)).release();
3176
0
        });
3177
0
    }
3178
3179
    Geometry*
3180
    GEOSGeom_createPointFromXY_r(GEOSContextHandle_t extHandle, double x, double y)
3181
0
    {
3182
0
        return execute(extHandle, [&]() {
3183
0
            GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
3184
0
            const GeometryFactory* gf = handle->geomFactory;
3185
3186
0
            CoordinateXY c(x, y);
3187
0
            return gf->createPoint(c).release();
3188
0
        });
3189
0
    }
3190
3191
    Geometry*
3192
    GEOSGeom_createLinearRing_r(GEOSContextHandle_t extHandle, CoordinateSequence* cs)
3193
0
    {
3194
0
        return execute(extHandle, [&]() {
3195
0
            GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
3196
0
            const GeometryFactory* gf = handle->geomFactory;
3197
3198
0
            return gf->createLinearRing(std::unique_ptr<CoordinateSequence>(cs)).release();
3199
0
        });
3200
0
    }
3201
3202
    Geometry*
3203
    GEOSGeom_createEmptyLineString_r(GEOSContextHandle_t extHandle)
3204
0
    {
3205
0
        return execute(extHandle, [&]() {
3206
0
            GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
3207
0
            const GeometryFactory* gf = handle->geomFactory;
3208
3209
0
            return gf->createLineString().release();
3210
0
        });
3211
0
    }
3212
3213
    Geometry*
3214
    GEOSGeom_createLineString_r(GEOSContextHandle_t extHandle, CoordinateSequence* cs)
3215
0
    {
3216
0
        return execute(extHandle, [&]() {
3217
0
            GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
3218
0
            const GeometryFactory* gf = handle->geomFactory;
3219
3220
0
            return gf->createLineString(std::unique_ptr<CoordinateSequence>(cs)).release();
3221
0
        });
3222
0
    }
3223
3224
    Geometry*
3225
    GEOSGeom_createEmptyPolygon_r(GEOSContextHandle_t extHandle)
3226
0
    {
3227
0
        return execute(extHandle, [&]() {
3228
0
            GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
3229
0
            const GeometryFactory* gf = handle->geomFactory;
3230
0
            return gf->createPolygon().release();
3231
0
        });
3232
0
    }
3233
3234
    Geometry*
3235
    GEOSGeom_createPolygon_r(GEOSContextHandle_t extHandle, Geometry* shell, Geometry** holes, unsigned int nholes)
3236
0
    {
3237
0
        return execute(extHandle, [&]() {
3238
0
            GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
3239
0
            const GeometryFactory* gf = handle->geomFactory;
3240
0
            bool good_holes = true, good_shell = true;
3241
3242
            // Validate input before taking ownership
3243
0
            for (std::size_t i = 0; i < nholes; i++) {
3244
0
                if ((!holes) || (!dynamic_cast<LinearRing*>(holes[i]))) {
3245
0
                    good_holes = false;
3246
0
                    break;
3247
0
                }
3248
0
            }
3249
0
            if (!dynamic_cast<LinearRing*>(shell)) {
3250
0
                good_shell = false;
3251
0
            }
3252
3253
            // Contract for GEOSGeom_createPolygon is to take ownership of arguments
3254
            // which implies freeing them on exception,
3255
            // see https://trac.osgeo.org/geos/ticket/1111
3256
0
            if (!(good_holes && good_shell)) {
3257
0
                if (shell) delete shell;
3258
0
                for (std::size_t i = 0; i < nholes; i++) {
3259
0
                    if (holes && holes[i])
3260
0
                        delete holes[i];
3261
0
                }
3262
0
                if (!good_shell)
3263
0
                    throw IllegalArgumentException("Shell is not a LinearRing");
3264
0
                else
3265
0
                    throw IllegalArgumentException("Hole is not a LinearRing");
3266
0
            }
3267
3268
0
            std::unique_ptr<LinearRing> tmpshell(static_cast<LinearRing*>(shell));
3269
0
            if (nholes) {
3270
0
                std::vector<std::unique_ptr<LinearRing>> tmpholes(nholes);
3271
0
                for (size_t i = 0; i < nholes; i++) {
3272
0
                    tmpholes[i].reset(static_cast<LinearRing*>(holes[i]));
3273
0
                }
3274
3275
0
                return gf->createPolygon(std::move(tmpshell), std::move(tmpholes)).release();
3276
0
            }
3277
3278
0
            return gf->createPolygon(std::move(tmpshell)).release();
3279
0
        });
3280
0
    }
3281
3282
    Geometry*
3283
    GEOSGeom_createRectangle_r(GEOSContextHandle_t extHandle,
3284
                            double xmin, double ymin,
3285
                            double xmax, double ymax)
3286
0
    {
3287
0
        return execute(extHandle, [&]() {
3288
0
            GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
3289
0
            const GeometryFactory* gf = handle->geomFactory;
3290
0
            Envelope env(xmin, xmax, ymin, ymax);
3291
0
            return (gf->toGeometry(&env)).release();
3292
0
        });
3293
0
    }
3294
3295
    Geometry*
3296
    GEOSGeom_createCircularString_r(GEOSContextHandle_t extHandle, CoordinateSequence* cs)
3297
0
    {
3298
0
        return execute(extHandle, [&]() {
3299
0
            GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
3300
0
            const GeometryFactory* gf = handle->geomFactory;
3301
3302
0
            return gf->createCircularString(std::unique_ptr<CoordinateSequence>(cs)).release();
3303
0
        });
3304
0
    }
3305
3306
    Geometry*
3307
    GEOSGeom_createEmptyCircularString_r(GEOSContextHandle_t extHandle)
3308
0
    {
3309
0
        return execute(extHandle, [&]() {
3310
0
            GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
3311
0
            const GeometryFactory* gf = handle->geomFactory;
3312
3313
0
            return gf->createCircularString(false, false).release();
3314
0
        });
3315
0
    }
3316
3317
    Geometry*
3318
    GEOSGeom_createCompoundCurve_r(GEOSContextHandle_t extHandle, Geometry** geoms, unsigned int ngeoms)
3319
0
    {
3320
0
        return execute(extHandle, [&]() -> Geometry* {
3321
0
            GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
3322
0
            const GeometryFactory* gf = handle->geomFactory;
3323
3324
0
            bool invalid_input = false;
3325
0
            std::vector<std::unique_ptr<SimpleCurve>> geom_vec(ngeoms);
3326
0
            for (std::size_t i = 0; i < ngeoms; i++) {
3327
0
                if (SimpleCurve* c = dynamic_cast<SimpleCurve*>(geoms[i])) {
3328
0
                    geom_vec[i].reset(c);
3329
0
                } else {
3330
0
                    delete geoms[i];
3331
0
                    invalid_input = true;
3332
0
                }
3333
0
            }
3334
3335
0
            if (invalid_input) {
3336
0
                throw IllegalArgumentException("Input is not a SimpleCurve");
3337
0
            }
3338
3339
0
            return gf->createCompoundCurve(std::move(geom_vec)).release();
3340
0
        });
3341
0
    }
3342
3343
    Geometry*
3344
    GEOSGeom_createEmptyCompoundCurve_r(GEOSContextHandle_t extHandle)
3345
0
    {
3346
0
        return execute(extHandle, [&]() {
3347
0
            GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
3348
0
            const GeometryFactory* gf = handle->geomFactory;
3349
3350
0
            return gf->createCompoundCurve().release();
3351
0
        });
3352
0
    }
3353
3354
    Geometry*
3355
    GEOSGeom_createCurvePolygon_r(GEOSContextHandle_t extHandle, Geometry* p_shell, Geometry** p_holes, unsigned int nholes)
3356
0
    {
3357
0
        return execute(extHandle, [&]() {
3358
0
            GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
3359
0
            const GeometryFactory* gf = handle->geomFactory;
3360
0
            bool good_holes = true, good_shell = true;
3361
3362
0
            std::unique_ptr<Curve> shell;
3363
0
            std::vector<std::unique_ptr<Curve>> holes(nholes);
3364
3365
0
            if (Curve* c = dynamic_cast<Curve*>(p_shell)) {
3366
0
                shell.reset(c);
3367
0
            } else {
3368
0
                good_shell = false;
3369
0
                delete p_shell;
3370
0
            }
3371
3372
0
            for (std::size_t i = 0; i < nholes; i++) {
3373
0
                if (Curve* c = dynamic_cast<Curve*>(p_holes[i])) {
3374
0
                    holes[i].reset(c);
3375
0
                } else {
3376
0
                    good_shell = false;
3377
0
                    delete p_holes[i];
3378
0
                }
3379
0
            }
3380
3381
0
            if (good_shell && good_holes) {
3382
0
                return gf->createCurvePolygon(std::move(shell), std::move(holes)).release();
3383
0
            } else if (!good_shell) {
3384
0
                throw IllegalArgumentException("Shell is not a Curve");
3385
0
            } else {
3386
0
                throw IllegalArgumentException("Hole is not a Curve");
3387
0
            }
3388
0
        });
3389
0
    }
3390
3391
3392
    Geometry*
3393
    GEOSGeom_createEmptyCurvePolygon_r(GEOSContextHandle_t extHandle)
3394
0
    {
3395
0
        return execute(extHandle, [&]() {
3396
0
            GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
3397
0
            const GeometryFactory* gf = handle->geomFactory;
3398
0
            return gf->createCurvePolygon(false, false).release();
3399
0
        });
3400
0
    }
3401
3402
    Geometry*
3403
    GEOSGeom_clone_r(GEOSContextHandle_t extHandle, const Geometry* g)
3404
0
    {
3405
0
        return execute(extHandle, [&]() {
3406
0
            return g->clone().release();
3407
0
        });
3408
0
    }
3409
3410
    Geometry*
3411
    GEOSGeom_setPrecision_r(GEOSContextHandle_t extHandle, const GEOSGeometry* g,
3412
                            double gridSize, int flags)
3413
0
    {
3414
0
        return execute(extHandle, [&]() {
3415
0
            PrecisionModel newpm;
3416
0
            if(gridSize != 0) {
3417
                // Convert gridSize to scale factor
3418
0
                double scale = 1.0 / std::abs(gridSize);
3419
0
                newpm = PrecisionModel(scale);
3420
0
            }
3421
3422
0
            const PrecisionModel* pm = g->getPrecisionModel();
3423
0
            double cursize = pm->isFloating() ? 0 : 1.0 / pm->getScale();
3424
0
            std::unique_ptr<Geometry> ret;
3425
0
            GeometryFactory::Ptr gf =
3426
0
                GeometryFactory::create(&newpm, g->getSRID());
3427
0
            if(gridSize != 0 && cursize != gridSize) {
3428
0
                GeometryPrecisionReducer reducer(*gf);
3429
0
                reducer.setChangePrecisionModel(true);
3430
0
                reducer.setUseAreaReducer(!(flags & GEOS_PREC_NO_TOPO));
3431
0
                reducer.setPointwise(flags & GEOS_PREC_NO_TOPO);
3432
0
                reducer.setRemoveCollapsedComponents(!(flags & GEOS_PREC_KEEP_COLLAPSED));
3433
0
                ret = reducer.reduce(*g);
3434
0
            }
3435
0
            else {
3436
                // No need or willing to snap, just change the factory
3437
0
                ret = gf->createGeometry(g);
3438
0
            }
3439
0
            return ret.release();
3440
0
        });
3441
0
    }
3442
3443
    double
3444
    GEOSGeom_getPrecision_r(GEOSContextHandle_t extHandle, const GEOSGeometry* g)
3445
0
    {
3446
0
        return execute(extHandle, -1.0, [&]() {
3447
0
            const PrecisionModel* pm = g->getPrecisionModel();
3448
0
            double cursize = pm->isFloating() ? 0 : 1.0 / pm->getScale();
3449
0
            return cursize;
3450
0
        });
3451
0
    }
3452
3453
    int
3454
    GEOSGeom_getDimensions_r(GEOSContextHandle_t extHandle, const Geometry* g)
3455
0
    {
3456
0
        return execute(extHandle, 0, [&]() {
3457
0
            return (int) g->getDimension();
3458
0
        });
3459
0
    }
3460
3461
    int
3462
    GEOSGeom_getCoordinateDimension_r(GEOSContextHandle_t extHandle, const Geometry* g)
3463
0
    {
3464
0
        return execute(extHandle, 0, [&]() {
3465
0
            return (int)(g->getCoordinateDimension());
3466
0
        });
3467
0
    }
3468
3469
    int
3470
    GEOSGeom_getXMin_r(GEOSContextHandle_t extHandle, const Geometry* g, double* value)
3471
0
    {
3472
0
        return execute(extHandle, 0, [&]() {
3473
0
            if(g->isEmpty()) {
3474
0
                return 0;
3475
0
            }
3476
3477
0
            *value = g->getEnvelopeInternal()->getMinX();
3478
0
            return 1;
3479
0
        });
3480
0
    }
3481
3482
    int
3483
    GEOSGeom_getXMax_r(GEOSContextHandle_t extHandle, const Geometry* g, double* value)
3484
0
    {
3485
0
        return execute(extHandle, 0, [&]() {
3486
0
            if(g->isEmpty()) {
3487
0
                return 0;
3488
0
            }
3489
3490
0
            *value = g->getEnvelopeInternal()->getMaxX();
3491
0
            return 1;
3492
0
        });
3493
0
    }
3494
3495
    int
3496
    GEOSGeom_getYMin_r(GEOSContextHandle_t extHandle, const Geometry* g, double* value)
3497
0
    {
3498
0
        return execute(extHandle, 0, [&]() {
3499
0
            if(g->isEmpty()) {
3500
0
                return 0;
3501
0
            }
3502
3503
0
            *value = g->getEnvelopeInternal()->getMinY();
3504
0
            return 1;
3505
0
        });
3506
0
    }
3507
3508
    int
3509
    GEOSGeom_getYMax_r(GEOSContextHandle_t extHandle, const Geometry* g, double* value)
3510
0
    {
3511
0
        return execute(extHandle, 0, [&]() {
3512
0
            if(g->isEmpty()) {
3513
0
                return 0;
3514
0
            }
3515
3516
0
            *value = g->getEnvelopeInternal()->getMaxY();
3517
0
            return 1;
3518
0
        });
3519
0
    }
3520
3521
    int
3522
    GEOSGeom_getExtent_r(GEOSContextHandle_t extHandle, const Geometry* g, double* xmin, double* ymin, double* xmax, double* ymax)
3523
0
    {
3524
0
        return execute(extHandle, 0, [&]() {
3525
0
            if(g->isEmpty()) {
3526
0
                return 0;
3527
0
            }
3528
0
            const Envelope* extent = g->getEnvelopeInternal();
3529
0
            *xmin = extent->getMinX();
3530
0
            *ymin = extent->getMinY();
3531
0
            *xmax = extent->getMaxX();
3532
0
            *ymax = extent->getMaxY();
3533
0
            return 1;
3534
0
        });
3535
0
    }
3536
3537
    Geometry*
3538
    GEOSSimplify_r(GEOSContextHandle_t extHandle, const Geometry* g1, double tolerance)
3539
0
    {
3540
0
        return execute(extHandle, [&]() {
3541
0
            Geometry::Ptr g3(geos::simplify::DouglasPeuckerSimplifier::simplify(g1, tolerance));
3542
0
            g3->setSRID(g1->getSRID());
3543
0
            return g3.release();
3544
0
        });
3545
0
    }
3546
3547
    Geometry*
3548
    GEOSTopologyPreserveSimplify_r(GEOSContextHandle_t extHandle, const Geometry* g1, double tolerance)
3549
0
    {
3550
0
        return execute(extHandle, [&]() {
3551
0
            Geometry::Ptr g3(geos::simplify::TopologyPreservingSimplifier::simplify(g1, tolerance));
3552
0
            g3->setSRID(g1->getSRID());
3553
0
            return g3.release();
3554
0
        });
3555
0
    }
3556
3557
3558
    /* WKT Reader */
3559
    WKTReader*
3560
    GEOSWKTReader_create_r(GEOSContextHandle_t extHandle)
3561
0
    {
3562
0
        return execute(extHandle, [&]() {
3563
0
            GEOSContextHandleInternal_t *handle = reinterpret_cast<GEOSContextHandleInternal_t *>(extHandle);
3564
0
            return new WKTReader((GeometryFactory *) handle->geomFactory);
3565
0
        });
3566
0
    }
3567
3568
    void
3569
    GEOSWKTReader_destroy_r(GEOSContextHandle_t extHandle, WKTReader* reader)
3570
0
    {
3571
0
        return execute(extHandle, [&]() {
3572
0
            delete reader;
3573
0
        });
3574
0
    }
3575
3576
    void
3577
    GEOSWKTReader_setFixStructure_r(GEOSContextHandle_t extHandle, WKTReader* reader, char doFix)
3578
0
    {
3579
0
        return execute(extHandle, [&]() {
3580
0
            return reader->setFixStructure(doFix);
3581
0
        });
3582
0
    }
3583
3584
    Geometry*
3585
    GEOSWKTReader_read_r(GEOSContextHandle_t extHandle, WKTReader* reader, const char* wkt)
3586
0
    {
3587
0
        return execute(extHandle, [&]() {
3588
0
            const std::string wktstring(wkt);
3589
0
            return reader->read(wktstring).release();
3590
0
        });
3591
0
    }
3592
3593
    /* WKT Writer */
3594
    WKTWriter*
3595
    GEOSWKTWriter_create_r(GEOSContextHandle_t extHandle)
3596
0
    {
3597
0
        using geos::io::WKTWriter;
3598
3599
0
        return execute(extHandle, [&]() {
3600
0
            return new WKTWriter();
3601
0
        });
3602
0
    }
3603
3604
    void
3605
    GEOSWKTWriter_destroy_r(GEOSContextHandle_t extHandle, WKTWriter* Writer)
3606
0
    {
3607
0
        execute(extHandle, [&]() {
3608
0
            delete Writer;
3609
0
        });
3610
0
    }
3611
3612
3613
    char*
3614
    GEOSWKTWriter_write_r(GEOSContextHandle_t extHandle, WKTWriter* writer, const Geometry* geom)
3615
0
    {
3616
0
        return execute(extHandle, [&]() {
3617
0
            std::string sgeom(writer->write(geom));
3618
0
            char* result = gstrdup(sgeom);
3619
0
            return result;
3620
0
        });
3621
0
    }
3622
3623
    void
3624
    GEOSWKTWriter_setTrim_r(GEOSContextHandle_t extHandle, WKTWriter* writer, char trim)
3625
0
    {
3626
0
        execute(extHandle, [&]() {
3627
0
            writer->setTrim(0 != trim);
3628
0
        });
3629
0
    }
3630
3631
    void
3632
    GEOSWKTWriter_setRoundingPrecision_r(GEOSContextHandle_t extHandle, WKTWriter* writer, int precision)
3633
0
    {
3634
0
        execute(extHandle, [&]() {
3635
0
            writer->setRoundingPrecision(precision);
3636
0
        });
3637
0
    }
3638
3639
    void
3640
    GEOSWKTWriter_setOutputDimension_r(GEOSContextHandle_t extHandle, WKTWriter* writer, int dim)
3641
0
    {
3642
0
        execute(extHandle, [&]() {
3643
0
            writer->setOutputDimension(static_cast<uint8_t>(dim));
3644
0
        });
3645
0
    }
3646
3647
    int
3648
    GEOSWKTWriter_getOutputDimension_r(GEOSContextHandle_t extHandle, WKTWriter* writer)
3649
0
    {
3650
0
        return execute(extHandle, -1, [&]() {
3651
0
            return writer->getOutputDimension();
3652
0
        });
3653
0
    }
3654
3655
    void
3656
    GEOSWKTWriter_setOld3D_r(GEOSContextHandle_t extHandle, WKTWriter* writer, int useOld3D)
3657
0
    {
3658
0
        execute(extHandle, [&]() {
3659
0
            writer->setOld3D(0 != useOld3D);
3660
0
        });
3661
0
    }
3662
3663
    /* WKB Reader */
3664
    WKBReader*
3665
    GEOSWKBReader_create_r(GEOSContextHandle_t extHandle)
3666
0
    {
3667
0
        using geos::io::WKBReader;
3668
3669
0
        return execute(extHandle, [&]() {
3670
0
            GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
3671
0
            return new WKBReader(*(GeometryFactory*)handle->geomFactory);
3672
0
        });
3673
0
    }
3674
3675
    void
3676
    GEOSWKBReader_destroy_r(GEOSContextHandle_t extHandle, WKBReader* reader)
3677
0
    {
3678
0
        execute(extHandle, [&]() {
3679
0
            delete reader;
3680
0
        });
3681
0
    }
3682
3683
    void
3684
    GEOSWKBReader_setFixStructure_r(GEOSContextHandle_t extHandle, WKBReader* reader, char doFix)
3685
0
    {
3686
0
        return execute(extHandle, [&]() {
3687
0
            return reader->setFixStructure(doFix);
3688
0
        });
3689
0
    }
3690
3691
    struct membuf : public std::streambuf {
3692
        membuf(char* s, std::size_t n)
3693
0
        {
3694
0
            setg(s, s, s + n);
3695
0
        }
3696
    };
3697
3698
    Geometry*
3699
    GEOSWKBReader_read_r(GEOSContextHandle_t extHandle, WKBReader* reader, const unsigned char* wkb, std::size_t size)
3700
0
    {
3701
0
        return execute(extHandle, [&]() {
3702
0
            return reader->read(wkb, size).release();
3703
0
        });
3704
0
    }
3705
3706
    Geometry*
3707
    GEOSWKBReader_readHEX_r(GEOSContextHandle_t extHandle, WKBReader* reader, const unsigned char* hex, std::size_t size)
3708
0
    {
3709
0
        return execute(extHandle, [&]() {
3710
0
            std::string hexstring(reinterpret_cast<const char*>(hex), size);
3711
0
            std::istringstream is(std::ios_base::binary);
3712
0
            is.str(hexstring);
3713
0
            is.seekg(0, std::ios::beg); // rewind reader pointer
3714
3715
0
            return reader->readHEX(is).release();
3716
0
        });
3717
0
    }
3718
3719
    /* WKB Writer */
3720
    WKBWriter*
3721
    GEOSWKBWriter_create_r(GEOSContextHandle_t extHandle)
3722
0
    {
3723
0
        using geos::io::WKBWriter;
3724
3725
0
        return execute(extHandle, [&]() {
3726
0
            return new WKBWriter();
3727
0
        });
3728
0
    }
3729
3730
    void
3731
    GEOSWKBWriter_destroy_r(GEOSContextHandle_t extHandle, WKBWriter* Writer)
3732
0
    {
3733
0
        execute(extHandle, [&]() {
3734
0
            delete Writer;
3735
0
        });
3736
0
    }
3737
3738
3739
    /* The caller owns the result */
3740
    unsigned char*
3741
    GEOSWKBWriter_write_r(GEOSContextHandle_t extHandle, WKBWriter* writer, const Geometry* geom, std::size_t* size)
3742
0
    {
3743
0
        return execute(extHandle, [&]() {
3744
0
            std::ostringstream os(std::ios_base::binary);
3745
0
            writer->write(*geom, os);
3746
3747
0
            const std::string& wkbstring = os.str();
3748
0
            const std::size_t len = wkbstring.length();
3749
3750
0
            unsigned char* result = (unsigned char*) malloc(len);
3751
0
            std::memcpy(result, wkbstring.c_str(), len);
3752
0
            *size = len;
3753
0
            return result;
3754
0
        });
3755
0
    }
3756
3757
    /* The caller owns the result */
3758
    unsigned char*
3759
    GEOSWKBWriter_writeHEX_r(GEOSContextHandle_t extHandle, WKBWriter* writer, const Geometry* geom, std::size_t* size)
3760
0
    {
3761
0
        return execute(extHandle, [&]() {
3762
0
            std::ostringstream os(std::ios_base::binary);
3763
0
            writer->writeHEX(*geom, os);
3764
0
            std::string wkbstring(os.str());
3765
0
            const std::size_t len = wkbstring.length();
3766
3767
0
            unsigned char* result = (unsigned char*) malloc(len);
3768
0
            std::memcpy(result, wkbstring.c_str(), len);
3769
0
            *size = len;
3770
0
            return result;
3771
0
        });
3772
0
    }
3773
3774
    int
3775
    GEOSWKBWriter_getOutputDimension_r(GEOSContextHandle_t extHandle, const GEOSWKBWriter* writer)
3776
0
    {
3777
0
        return execute(extHandle, 0, [&]() {
3778
0
            return writer->getOutputDimension();
3779
0
        });
3780
0
    }
3781
3782
    void
3783
    GEOSWKBWriter_setOutputDimension_r(GEOSContextHandle_t extHandle, GEOSWKBWriter* writer, int newDimension)
3784
0
    {
3785
0
        execute(extHandle, [&]() {
3786
0
            writer->setOutputDimension(static_cast<uint8_t>(newDimension));
3787
0
        });
3788
0
    }
3789
3790
    int
3791
    GEOSWKBWriter_getByteOrder_r(GEOSContextHandle_t extHandle, const GEOSWKBWriter* writer)
3792
0
    {
3793
0
        return execute(extHandle, 0, [&]() {
3794
0
            return writer->getByteOrder();
3795
0
        });
3796
0
    }
3797
3798
    void
3799
    GEOSWKBWriter_setByteOrder_r(GEOSContextHandle_t extHandle, GEOSWKBWriter* writer, int newByteOrder)
3800
0
    {
3801
0
        execute(extHandle, [&]() {
3802
0
            writer->setByteOrder(newByteOrder);
3803
0
        });
3804
0
    }
3805
3806
    char
3807
    GEOSWKBWriter_getIncludeSRID_r(GEOSContextHandle_t extHandle, const GEOSWKBWriter* writer)
3808
0
    {
3809
0
        return execute(extHandle, 2, [&]{
3810
0
            return writer->getIncludeSRID();
3811
0
        });
3812
0
    }
3813
3814
    void
3815
    GEOSWKBWriter_setIncludeSRID_r(GEOSContextHandle_t extHandle, GEOSWKBWriter* writer, const char newIncludeSRID)
3816
0
    {
3817
0
        execute(extHandle, [&]{
3818
0
            writer->setIncludeSRID(newIncludeSRID);
3819
0
        });
3820
0
    }
3821
3822
    int
3823
    GEOSWKBWriter_getFlavor_r(GEOSContextHandle_t extHandle, const GEOSWKBWriter* writer)
3824
0
    {
3825
0
        return execute(extHandle, -1, [&]{
3826
0
            return writer->getFlavor();
3827
0
        });
3828
0
    }
3829
3830
    void
3831
    GEOSWKBWriter_setFlavor_r(GEOSContextHandle_t extHandle, GEOSWKBWriter* writer, int flavor)
3832
0
    {
3833
0
        execute(extHandle, [&]{
3834
0
            writer->setFlavor(flavor);
3835
0
        });
3836
0
    }
3837
3838
    /* GeoJSON Reader */
3839
    GeoJSONReader*
3840
    GEOSGeoJSONReader_create_r(GEOSContextHandle_t extHandle)
3841
0
    {
3842
0
        using geos::io::GeoJSONReader;
3843
3844
0
        return execute(extHandle, [&]() {
3845
0
            GEOSContextHandleInternal_t *handle = reinterpret_cast<GEOSContextHandleInternal_t *>(extHandle);
3846
0
            return new GeoJSONReader(*(GeometryFactory*)handle->geomFactory);
3847
0
        });
3848
0
    }
3849
3850
    void
3851
    GEOSGeoJSONReader_destroy_r(GEOSContextHandle_t extHandle, GEOSGeoJSONReader* reader)
3852
0
    {
3853
0
        return execute(extHandle, [&]() {
3854
0
            delete reader;
3855
0
        });
3856
0
    }
3857
3858
    Geometry*
3859
    GEOSGeoJSONReader_readGeometry_r(GEOSContextHandle_t extHandle, GEOSGeoJSONReader* reader, const char* geojson)
3860
0
    {
3861
0
        return execute(extHandle, [&]() {
3862
0
            const std::string geojsonstring(geojson);
3863
0
            return reader->read(geojsonstring).release();
3864
0
        });
3865
0
    }
3866
3867
    /* GeoJSON Writer */
3868
    GeoJSONWriter*
3869
    GEOSGeoJSONWriter_create_r(GEOSContextHandle_t extHandle)
3870
0
    {
3871
0
        using geos::io::GeoJSONWriter;
3872
3873
0
        return execute(extHandle, [&]() {
3874
0
            return new GeoJSONWriter();
3875
0
        });
3876
0
    }
3877
3878
    void
3879
    GEOSGeoJSONWriter_destroy_r(GEOSContextHandle_t extHandle, GEOSGeoJSONWriter* writer)
3880
0
    {
3881
0
        return execute(extHandle, [&]() {
3882
0
            delete writer;
3883
0
        });
3884
0
    }
3885
3886
    char*
3887
    GEOSGeoJSONWriter_writeGeometry_r(GEOSContextHandle_t extHandle, GEOSGeoJSONWriter* writer, const GEOSGeometry* g, int indent)
3888
0
    {
3889
0
        return execute(extHandle, [&]() {
3890
0
            std::string geojson;
3891
0
            if (indent >= 0) {
3892
0
                geojson = writer->writeFormatted(g, geos::io::GeoJSONType::GEOMETRY, indent);
3893
0
            } else {
3894
0
                geojson = writer->write(g, geos::io::GeoJSONType::GEOMETRY);
3895
0
            }
3896
0
            char* result = gstrdup(geojson);
3897
0
            return result;
3898
0
        });
3899
0
    }
3900
3901
    void
3902
    GEOSGeoJSONWriter_setOutputDimension_r(GEOSContextHandle_t extHandle, GeoJSONWriter* writer, int dim)
3903
0
    {
3904
0
        execute(extHandle, [&]() {
3905
0
            writer->setOutputDimension(static_cast<uint8_t>(dim));
3906
0
        });
3907
0
    }
3908
3909
    int
3910
    GEOSGeoJSONWriter_getOutputDimension_r(GEOSContextHandle_t extHandle, GeoJSONWriter* writer)
3911
0
    {
3912
0
        return execute(extHandle, -1, [&]() {
3913
0
            return writer->getOutputDimension();
3914
0
        });
3915
0
    }
3916
3917
3918
//-----------------------------------------------------------------
3919
// Prepared Geometry
3920
//-----------------------------------------------------------------
3921
3922
    const PreparedGeometry*
3923
    GEOSPrepare_r(GEOSContextHandle_t extHandle, const Geometry* g)
3924
0
    {
3925
0
        return execute(extHandle, [&]() {
3926
0
            return geos::geom::prep::PreparedGeometryFactory::prepare(g).release();
3927
0
        });
3928
0
    }
3929
3930
    void
3931
    GEOSPreparedGeom_destroy_r(GEOSContextHandle_t extHandle, const PreparedGeometry* a)
3932
0
    {
3933
0
        execute(extHandle, [&]() {
3934
0
            delete a;
3935
0
        });
3936
0
    }
3937
3938
    char
3939
    GEOSPreparedContains_r(GEOSContextHandle_t extHandle,
3940
                           const PreparedGeometry* pg, const Geometry* g)
3941
0
    {
3942
0
        return execute(extHandle, 2, [&]() {
3943
0
            return pg->contains(g);
3944
0
        });
3945
0
    }
3946
3947
    char
3948
    GEOSPreparedContainsXY_r(GEOSContextHandle_t extHandle,
3949
                           const PreparedGeometry* pg, double x, double y)
3950
0
    {
3951
0
        extHandle->point2d->setXY(x, y);
3952
3953
0
        return GEOSPreparedContains_r(extHandle, pg, extHandle->point2d.get());
3954
0
    }
3955
3956
    char
3957
    GEOSPreparedContainsProperly_r(GEOSContextHandle_t extHandle,
3958
                                   const PreparedGeometry* pg, const Geometry* g)
3959
0
    {
3960
0
        return execute(extHandle, 2, [&]() {
3961
0
            return pg->containsProperly(g);
3962
0
        });
3963
0
    }
3964
3965
    char
3966
    GEOSPreparedCoveredBy_r(GEOSContextHandle_t extHandle,
3967
                            const PreparedGeometry* pg, const Geometry* g)
3968
0
    {
3969
0
        return execute(extHandle, 2, [&]() {
3970
0
            return pg->coveredBy(g);
3971
0
        });
3972
0
    }
3973
3974
    char
3975
    GEOSPreparedCovers_r(GEOSContextHandle_t extHandle,
3976
                         const PreparedGeometry* pg, const Geometry* g)
3977
0
    {
3978
0
        return execute(extHandle, 2, [&]() {
3979
0
            return pg->covers(g);
3980
0
        });
3981
0
    }
3982
3983
    char
3984
    GEOSPreparedCrosses_r(GEOSContextHandle_t extHandle,
3985
                          const PreparedGeometry* pg, const Geometry* g)
3986
0
    {
3987
0
        return execute(extHandle, 2, [&]() {
3988
0
            return pg->crosses(g);
3989
0
        });
3990
0
    }
3991
3992
    char
3993
    GEOSPreparedDisjoint_r(GEOSContextHandle_t extHandle,
3994
                           const PreparedGeometry* pg, const Geometry* g)
3995
0
    {
3996
0
        return execute(extHandle, 2, [&]() {
3997
0
            return pg->disjoint(g);
3998
0
        });
3999
0
    }
4000
4001
    char
4002
    GEOSPreparedIntersects_r(GEOSContextHandle_t extHandle,
4003
                             const PreparedGeometry* pg, const Geometry* g)
4004
0
    {
4005
0
        return execute(extHandle, 2, [&]() {
4006
0
            return pg->intersects(g);
4007
0
        });
4008
0
    }
4009
4010
    char
4011
    GEOSPreparedIntersectsXY_r(GEOSContextHandle_t extHandle,
4012
                             const PreparedGeometry* pg, double x, double y)
4013
0
    {
4014
0
        extHandle->point2d->setXY(x, y);
4015
4016
0
        return GEOSPreparedIntersects_r(extHandle, pg, extHandle->point2d.get());
4017
0
    }
4018
4019
    char
4020
    GEOSPreparedOverlaps_r(GEOSContextHandle_t extHandle,
4021
                           const PreparedGeometry* pg, const Geometry* g)
4022
0
    {
4023
0
        return execute(extHandle, 2, [&]() {
4024
0
            return pg->overlaps(g);
4025
0
        });
4026
0
    }
4027
4028
    char
4029
    GEOSPreparedTouches_r(GEOSContextHandle_t extHandle,
4030
                          const PreparedGeometry* pg, const Geometry* g)
4031
0
    {
4032
0
        return execute(extHandle, 2, [&]() {
4033
0
            return pg->touches(g);
4034
0
        });
4035
0
    }
4036
4037
    char
4038
    GEOSPreparedWithin_r(GEOSContextHandle_t extHandle,
4039
                         const PreparedGeometry* pg, const Geometry* g)
4040
0
    {
4041
0
        return execute(extHandle, 2, [&]() {
4042
0
            return pg->within(g);
4043
0
        });
4044
0
    }
4045
4046
    char *
4047
    GEOSPreparedRelate_r(GEOSContextHandle_t extHandle,
4048
                         const PreparedGeometry* pg, const Geometry* g)
4049
0
    {
4050
0
        return execute(extHandle, [&]() -> char * {
4051
0
            return gstrdup(pg->relate(g)->toString());
4052
0
        });
4053
0
    }
4054
4055
    char
4056
    GEOSPreparedRelatePattern_r(GEOSContextHandle_t extHandle,
4057
                         const PreparedGeometry* pg, const Geometry* g, const char* imPattern)
4058
0
    {
4059
0
        return execute(extHandle, 2, [&]() {
4060
0
            return pg->relate(g, std::string(imPattern));
4061
0
        });
4062
0
    }
4063
4064
    CoordinateSequence*
4065
    GEOSPreparedNearestPoints_r(GEOSContextHandle_t extHandle,
4066
                         const PreparedGeometry* pg, const Geometry* g)
4067
0
    {
4068
0
        return execute(extHandle, [&]() -> geos::geom::CoordinateSequence* {
4069
0
            return pg->nearestPoints(g).release();
4070
0
        });
4071
0
    }
4072
4073
    int
4074
    GEOSPreparedDistance_r(GEOSContextHandle_t extHandle,
4075
                         const PreparedGeometry* pg,
4076
                         const Geometry* g, double* dist)
4077
0
    {
4078
0
        return execute(extHandle, 0, [&]() {
4079
0
            *dist = pg->distance(g);
4080
0
            return 1;
4081
0
        });
4082
0
    }
4083
4084
    char
4085
    GEOSPreparedDistanceWithin_r(GEOSContextHandle_t extHandle,
4086
                         const PreparedGeometry* pg,
4087
                         const Geometry* g, double dist)
4088
0
    {
4089
0
        return execute(extHandle, 2, [&]() {
4090
0
            return pg->isWithinDistance(g, dist);
4091
0
        });
4092
0
    }
4093
4094
//-----------------------------------------------------------------
4095
// STRtree
4096
//-----------------------------------------------------------------
4097
4098
    GEOSSTRtree*
4099
    GEOSSTRtree_create_r(GEOSContextHandle_t extHandle,
4100
                         std::size_t nodeCapacity)
4101
0
    {
4102
0
        return execute(extHandle, [&]() {
4103
0
            return new GEOSSTRtree(nodeCapacity);
4104
0
        });
4105
0
    }
4106
4107
    int
4108
    GEOSSTRtree_build_r(GEOSContextHandle_t extHandle,
4109
                        GEOSSTRtree* tree)
4110
0
    {
4111
0
        return execute(extHandle, 0, [&]() {
4112
0
            tree->build();
4113
0
            return 1;
4114
0
        });
4115
0
    }
4116
4117
    void
4118
    GEOSSTRtree_insert_r(GEOSContextHandle_t extHandle,
4119
                         GEOSSTRtree* tree,
4120
                         const Geometry* g,
4121
                         void* item)
4122
0
    {
4123
0
        execute(extHandle, [&]() {
4124
0
            tree->insert(g->getEnvelopeInternal(), item);
4125
0
        });
4126
0
    }
4127
4128
    void
4129
    GEOSSTRtree_query_r(GEOSContextHandle_t extHandle,
4130
                        GEOSSTRtree* tree,
4131
                        const Geometry* g,
4132
                        GEOSQueryCallback callback,
4133
                        void* userdata)
4134
0
    {
4135
0
        execute(extHandle, [&]() {
4136
0
            CAPI_ItemVisitor visitor(callback, userdata);
4137
0
            tree->query(g->getEnvelopeInternal(), visitor);
4138
0
        });
4139
0
    }
4140
4141
    const GEOSGeometry*
4142
    GEOSSTRtree_nearest_r(GEOSContextHandle_t extHandle,
4143
                          GEOSSTRtree* tree,
4144
                          const Geometry* geom)
4145
0
    {
4146
0
        return (const GEOSGeometry*) GEOSSTRtree_nearest_generic_r(extHandle, tree, geom, geom, nullptr, nullptr);
4147
0
    }
4148
4149
    const void*
4150
    GEOSSTRtree_nearest_generic_r(GEOSContextHandle_t extHandle,
4151
                                  GEOSSTRtree* tree,
4152
                                  const void* item,
4153
                                  const Geometry* itemEnvelope,
4154
                                  GEOSDistanceCallback distancefn,
4155
                                  void* userdata)
4156
0
    {
4157
0
        struct CustomItemDistance {
4158
0
            CustomItemDistance(GEOSDistanceCallback p_distancefn, void* p_userdata)
4159
0
                : m_distancefn(p_distancefn), m_userdata(p_userdata) {}
4160
4161
0
            GEOSDistanceCallback m_distancefn;
4162
0
            void* m_userdata;
4163
4164
0
            double operator()(const void* a, const void* b) const
4165
0
            {
4166
0
                double d;
4167
4168
0
                if(!m_distancefn(a, b, &d, m_userdata)) {
4169
0
                    throw std::runtime_error(std::string("Failed to compute distance."));
4170
0
                }
4171
4172
0
                return d;
4173
0
            }
4174
0
        };
4175
4176
0
        struct GeometryDistance {
4177
0
            double operator()(void* a, void* b) const {
4178
0
                return static_cast<const Geometry*>(a)->distance(static_cast<const Geometry*>(b));
4179
0
            }
4180
0
        };
4181
4182
0
        return execute(extHandle, [&]() {
4183
0
            if(distancefn) {
4184
0
                CustomItemDistance itemDistance(distancefn, userdata);
4185
0
                return tree->nearestNeighbour(*itemEnvelope->getEnvelopeInternal(), (void*) item, itemDistance);
4186
0
            }
4187
0
            else {
4188
0
                return tree->nearestNeighbour<GeometryDistance>(*itemEnvelope->getEnvelopeInternal(), (void*) item);
4189
0
            }
4190
0
        });
4191
0
    }
4192
4193
    void
4194
    GEOSSTRtree_iterate_r(GEOSContextHandle_t extHandle,
4195
                          GEOSSTRtree* tree,
4196
                          GEOSQueryCallback callback,
4197
                          void* userdata)
4198
0
    {
4199
0
        return execute(extHandle, [&]() {
4200
0
            CAPI_ItemVisitor visitor(callback, userdata);
4201
0
            tree->iterate(visitor);
4202
0
        });
4203
0
    }
4204
4205
    char
4206
    GEOSSTRtree_remove_r(GEOSContextHandle_t extHandle,
4207
                         GEOSSTRtree* tree,
4208
                         const Geometry* g,
4209
0
                         void* item) {
4210
0
        return execute(extHandle, 2, [&]() {
4211
0
            return tree->remove(g->getEnvelopeInternal(), item);
4212
0
        });
4213
0
    }
4214
4215
    void
4216
    GEOSSTRtree_destroy_r(GEOSContextHandle_t extHandle,
4217
                          GEOSSTRtree* tree)
4218
0
    {
4219
0
        return execute(extHandle, [&]() {
4220
0
            delete tree;
4221
0
        });
4222
0
    }
4223
4224
    double
4225
    GEOSProject_r(GEOSContextHandle_t extHandle,
4226
                  const Geometry* g,
4227
                  const Geometry* p)
4228
0
    {
4229
0
        return execute(extHandle, -1.0, [&]() {
4230
0
            const Point* point = dynamic_cast<const Point*>(p);
4231
0
            if(!point) {
4232
0
                throw std::runtime_error("third argument of GEOSProject_r must be Point");
4233
0
            }
4234
0
            const geos::geom::Coordinate inputPt(*p->getCoordinate());
4235
0
            return geos::linearref::LengthIndexedLine(g).project(inputPt);
4236
0
        });
4237
0
    }
4238
4239
4240
    Geometry*
4241
    GEOSInterpolate_r(GEOSContextHandle_t extHandle, const Geometry* g, double d)
4242
0
    {
4243
0
        return execute(extHandle, [&]() {
4244
0
            GEOSContextHandleInternal_t* handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
4245
4246
0
            geos::linearref::LengthIndexedLine lil(g);
4247
0
            geos::geom::Coordinate coord = lil.extractPoint(d);
4248
0
            const GeometryFactory* gf = handle->geomFactory;
4249
0
            auto point = coord.isNull() ? gf->createPoint(g->getCoordinateDimension()) : gf->createPoint(coord);
4250
0
            point->setSRID(g->getSRID());
4251
0
            return point.release();
4252
0
        });
4253
0
    }
4254
4255
4256
    double
4257
    GEOSProjectNormalized_r(GEOSContextHandle_t extHandle, const Geometry* g,
4258
                            const Geometry* p)
4259
0
    {
4260
4261
0
        double length;
4262
0
        double distance;
4263
0
        if(GEOSLength_r(extHandle, g, &length) != 1) {
4264
0
            return -1.0;
4265
0
        };
4266
4267
0
        distance = GEOSProject_r(extHandle, g, p);
4268
4269
0
        if (distance == 0.0 && length == 0.0)
4270
0
            return 0.0;
4271
4272
        /* Meaningless projection? error */
4273
0
        if (distance < 0.0 || ! std::isfinite(distance) || length == 0.0) {
4274
0
            return -1.0;
4275
0
        } else {
4276
0
            return distance / length;
4277
0
        }
4278
0
    }
4279
4280
4281
    Geometry*
4282
    GEOSInterpolateNormalized_r(GEOSContextHandle_t extHandle, const Geometry* g,
4283
                                double d)
4284
0
    {
4285
0
        double length;
4286
0
        if (GEOSLength_r(extHandle, g, &length) != 1) {
4287
0
            return 0;
4288
0
        }
4289
0
        return GEOSInterpolate_r(extHandle, g, d * length);
4290
0
    }
4291
4292
    GEOSGeometry*
4293
    GEOSGeom_extractUniquePoints_r(GEOSContextHandle_t extHandle,
4294
                                   const GEOSGeometry* g)
4295
0
    {
4296
0
        return execute(extHandle, [&]() {
4297
            /* 1: extract points */
4298
0
            std::vector<const Coordinate*> coords;
4299
0
            geos::util::UniqueCoordinateArrayFilter filter(coords);
4300
0
            g->apply_ro(&filter);
4301
4302
            /* 2: for each point, create a geometry and put into a vector */
4303
0
            std::vector<std::unique_ptr<Geometry>> points;
4304
0
            points.reserve(coords.size());
4305
0
            const GeometryFactory* factory = g->getFactory();
4306
0
            for(std::vector<const Coordinate*>::iterator it = coords.begin(),
4307
0
                    itE = coords.end();
4308
0
                    it != itE; ++it) {
4309
0
                auto point = factory->createPoint(*(*it));
4310
0
                points.push_back(std::move(point));
4311
0
            }
4312
4313
            /* 3: create a multipoint */
4314
0
            auto out = factory->createMultiPoint(std::move(points));
4315
0
            out->setSRID(g->getSRID());
4316
0
            return out.release();
4317
4318
0
        });
4319
0
    }
4320
4321
    int GEOSOrientationIndex_r(GEOSContextHandle_t extHandle,
4322
                               double Ax, double Ay, double Bx, double By, double Px, double Py)
4323
0
    {
4324
0
        return execute(extHandle, 2, [&]() {
4325
0
            Coordinate A(Ax, Ay);
4326
0
            Coordinate B(Bx, By);
4327
0
            Coordinate P(Px, Py);
4328
0
            return geos::algorithm::Orientation::index(A, B, P);
4329
0
        });
4330
0
    }
4331
4332
    GEOSGeometry*
4333
    GEOSSharedPaths_r(GEOSContextHandle_t extHandle, const GEOSGeometry* g1, const GEOSGeometry* g2)
4334
0
    {
4335
0
        using geos::operation::sharedpaths::SharedPathsOp;
4336
4337
0
        if(nullptr == extHandle) {
4338
0
            return nullptr;
4339
0
        }
4340
0
        GEOSContextHandleInternal_t* handle =
4341
0
            reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
4342
0
        if(handle->initialized == 0) {
4343
0
            return nullptr;
4344
0
        }
4345
4346
0
        SharedPathsOp::PathList forw, back;
4347
0
        try {
4348
0
            SharedPathsOp::sharedPathsOp(*g1, *g2, forw, back);
4349
0
        }
4350
0
        catch(const std::exception& e) {
4351
0
            SharedPathsOp::clearEdges(forw);
4352
0
            SharedPathsOp::clearEdges(back);
4353
0
            handle->ERROR_MESSAGE("%s", e.what());
4354
0
            return nullptr;
4355
0
        }
4356
0
        catch(...) {
4357
0
            SharedPathsOp::clearEdges(forw);
4358
0
            SharedPathsOp::clearEdges(back);
4359
0
            handle->ERROR_MESSAGE("Unknown exception thrown");
4360
0
            return nullptr;
4361
0
        }
4362
4363
        // Now forw and back have the geoms we want to use to construct
4364
        // our output GeometryCollections...
4365
4366
0
        const GeometryFactory* factory = g1->getFactory();
4367
0
        std::size_t count;
4368
4369
0
        std::vector<std::unique_ptr<Geometry>> out1;
4370
0
        count = forw.size();
4371
0
        out1.reserve(count);
4372
0
        for(std::size_t i = 0; i < count; ++i) {
4373
0
            out1.emplace_back(forw[i]);
4374
0
        }
4375
0
        std::unique_ptr<Geometry> out1g(
4376
0
            factory->createMultiLineString(std::move(out1))
4377
0
        );
4378
4379
0
        std::vector<std::unique_ptr<Geometry>> out2;
4380
0
        count = back.size();
4381
0
        out2.reserve(count);
4382
0
        for(std::size_t i = 0; i < count; ++i) {
4383
0
            out2.emplace_back(back[i]);
4384
0
        }
4385
0
        std::unique_ptr<Geometry> out2g(
4386
0
            factory->createMultiLineString(std::move(out2))
4387
0
        );
4388
4389
0
        std::vector<std::unique_ptr<Geometry>> out;
4390
0
        out.reserve(2);
4391
0
        out.push_back(std::move(out1g));
4392
0
        out.push_back(std::move(out2g));
4393
4394
0
        std::unique_ptr<Geometry> outg(
4395
0
            factory->createGeometryCollection(std::move(out))
4396
0
        );
4397
4398
0
        outg->setSRID(g1->getSRID());
4399
0
        return outg.release();
4400
0
    }
4401
4402
    GEOSGeometry*
4403
    GEOSSnap_r(GEOSContextHandle_t extHandle, const GEOSGeometry* g1,
4404
               const GEOSGeometry* g2, double tolerance)
4405
0
    {
4406
0
        return execute(extHandle, [&]() {
4407
0
            geos::operation::overlay::snap::GeometrySnapper snapper(*g1);
4408
0
            std::unique_ptr<Geometry> ret = snapper.snapTo(*g2, tolerance);
4409
0
            ret->setSRID(g1->getSRID());
4410
0
            return ret.release();
4411
0
        });
4412
0
    }
4413
4414
    BufferParameters*
4415
    GEOSBufferParams_create_r(GEOSContextHandle_t extHandle)
4416
0
    {
4417
0
        return execute(extHandle, [&]() {
4418
0
            return new BufferParameters();
4419
0
        });
4420
0
    }
4421
4422
    void
4423
    GEOSBufferParams_destroy_r(GEOSContextHandle_t extHandle, BufferParameters* p)
4424
0
    {
4425
0
        (void)extHandle;
4426
0
        delete p;
4427
0
    }
4428
4429
    int
4430
    GEOSBufferParams_setEndCapStyle_r(GEOSContextHandle_t extHandle,
4431
                                      GEOSBufferParams* p, int style)
4432
0
    {
4433
0
        return execute(extHandle, 0, [&]() {
4434
0
            if(style > BufferParameters::CAP_SQUARE) {
4435
0
                throw IllegalArgumentException("Invalid buffer endCap style");
4436
0
            }
4437
0
            p->setEndCapStyle(static_cast<BufferParameters::EndCapStyle>(style));
4438
0
            return 1;
4439
0
        });
4440
0
    }
4441
4442
    int
4443
    GEOSBufferParams_setJoinStyle_r(GEOSContextHandle_t extHandle,
4444
                                    GEOSBufferParams* p, int style)
4445
0
    {
4446
0
        return execute(extHandle, 0, [&]() {
4447
0
            if(style > BufferParameters::JOIN_BEVEL) {
4448
0
                throw IllegalArgumentException("Invalid buffer join style");
4449
0
            }
4450
0
            p->setJoinStyle(static_cast<BufferParameters::JoinStyle>(style));
4451
4452
0
            return 1;
4453
0
        });
4454
0
    }
4455
4456
    int
4457
    GEOSBufferParams_setMitreLimit_r(GEOSContextHandle_t extHandle,
4458
                                     GEOSBufferParams* p, double limit)
4459
0
    {
4460
0
        return execute(extHandle, 0, [&]() {
4461
0
            p->setMitreLimit(limit);
4462
0
            return 1;
4463
0
        });
4464
0
    }
4465
4466
    int
4467
    GEOSBufferParams_setQuadrantSegments_r(GEOSContextHandle_t extHandle,
4468
                                           GEOSBufferParams* p, int segs)
4469
0
    {
4470
0
        return execute(extHandle, 0, [&]() {
4471
0
            p->setQuadrantSegments(segs);
4472
0
            return 1;
4473
0
        });
4474
0
    }
4475
4476
    int
4477
    GEOSBufferParams_setSingleSided_r(GEOSContextHandle_t extHandle,
4478
                                      GEOSBufferParams* p, int ss)
4479
0
    {
4480
0
        return execute(extHandle, 0, [&]() {
4481
0
            p->setSingleSided((ss != 0));
4482
0
            return 1;
4483
0
        });
4484
0
    }
4485
4486
    Geometry*
4487
    GEOSBufferWithParams_r(GEOSContextHandle_t extHandle, const Geometry* g1, const BufferParameters* bp, double width)
4488
0
    {
4489
0
        using geos::operation::buffer::BufferOp;
4490
4491
0
        return execute(extHandle, [&]() {
4492
0
            BufferOp op(g1, *bp);
4493
0
            std::unique_ptr<Geometry> g3 = op.getResultGeometry(width);
4494
0
            g3->setSRID(g1->getSRID());
4495
0
            return g3.release();
4496
0
        });
4497
0
    }
4498
4499
    Geometry*
4500
    GEOSDelaunayTriangulation_r(GEOSContextHandle_t extHandle, const Geometry* g1, double tolerance, int onlyEdges)
4501
0
    {
4502
0
        using geos::triangulate::DelaunayTriangulationBuilder;
4503
4504
0
        return execute(extHandle, [&]() -> Geometry* {
4505
0
            DelaunayTriangulationBuilder builder;
4506
0
            builder.setTolerance(tolerance);
4507
0
            builder.setSites(*g1);
4508
4509
0
            if(onlyEdges) {
4510
0
                Geometry* out = builder.getEdges(*g1->getFactory()).release();
4511
0
                out->setSRID(g1->getSRID());
4512
0
                return out;
4513
0
            }
4514
0
            else {
4515
0
                Geometry* out = builder.getTriangles(*g1->getFactory()).release();
4516
0
                out->setSRID(g1->getSRID());
4517
0
                return out;
4518
0
            }
4519
0
        });
4520
0
    }
4521
4522
    Geometry*
4523
    GEOSConstrainedDelaunayTriangulation_r(GEOSContextHandle_t extHandle, const Geometry* g1)
4524
0
    {
4525
0
        using geos::triangulate::polygon::ConstrainedDelaunayTriangulator;
4526
4527
0
        return execute(extHandle, [&]() -> Geometry* {
4528
0
            return ConstrainedDelaunayTriangulator::triangulate(g1).release();
4529
0
        });
4530
0
    }
4531
4532
    Geometry*
4533
    GEOSVoronoiDiagram_r(GEOSContextHandle_t extHandle, const Geometry* g1, const Geometry* env, double tolerance,
4534
                         int flags)
4535
0
    {
4536
0
        using geos::triangulate::VoronoiDiagramBuilder;
4537
4538
0
        return execute(extHandle, [&]() -> Geometry* {
4539
0
            VoronoiDiagramBuilder builder;
4540
0
            builder.setSites(*g1);
4541
0
            builder.setTolerance(tolerance);
4542
0
            builder.setOrdered(flags & GEOS_VORONOI_PRESERVE_ORDER);
4543
0
            std::unique_ptr<Geometry> out;
4544
0
            if(env) {
4545
0
                builder.setClipEnvelope(env->getEnvelopeInternal());
4546
0
            }
4547
0
            if(flags & GEOS_VORONOI_ONLY_EDGES) {
4548
0
                out = builder.getDiagramEdges(*g1->getFactory());
4549
0
            }
4550
0
            else {
4551
0
                out = builder.getDiagram(*g1->getFactory());
4552
0
            }
4553
4554
0
            out->setSRID(g1->getSRID());
4555
0
            return out.release();
4556
0
        });
4557
0
    }
4558
4559
    int
4560
    GEOSSegmentIntersection_r(GEOSContextHandle_t extHandle,
4561
                              double ax0, double ay0, double ax1, double ay1,
4562
                              double bx0, double by0, double bx1, double by1,
4563
                              double* cx, double* cy)
4564
0
    {
4565
0
        return execute(extHandle, 0, [&]() {
4566
0
            geos::geom::LineSegment a(ax0, ay0, ax1, ay1);
4567
0
            geos::geom::LineSegment b(bx0, by0, bx1, by1);
4568
0
            geos::geom::Coordinate isect = a.intersection(b);
4569
4570
0
            if(isect.isNull()) {
4571
0
                return -1;
4572
0
            }
4573
4574
0
            *cx = isect.x;
4575
0
            *cy = isect.y;
4576
4577
0
            return 1;
4578
0
        });
4579
0
    }
4580
4581
    int
4582
    GEOSCoverageIsValid_r(GEOSContextHandle_t extHandle,
4583
        const Geometry* input,
4584
        double gapWidth,
4585
        Geometry** invalidEdges)
4586
0
    {
4587
0
        using geos::coverage::CoverageValidator;
4588
4589
0
        return execute(extHandle, 2, [&]() {
4590
0
            const GeometryCollection* col = dynamic_cast<const GeometryCollection*>(input);
4591
0
            if (!col)
4592
0
                throw geos::util::IllegalArgumentException("input is not a collection");
4593
4594
            // Initialize to nullptr
4595
0
            if (invalidEdges) *invalidEdges = nullptr;
4596
4597
0
            std::vector<const Geometry*> coverage;
4598
0
            for (const auto& g : *col) {
4599
0
                coverage.push_back(g.get());
4600
0
            }
4601
4602
0
            CoverageValidator cov(coverage);
4603
0
            cov.setGapWidth(gapWidth);
4604
0
            std::vector<std::unique_ptr<Geometry>> invalid = cov.validate();
4605
0
            bool hasInvalid = CoverageValidator::hasInvalidResult(invalid);
4606
4607
0
            if (invalidEdges) {
4608
0
                const GeometryFactory* gf = input->getFactory();
4609
0
                for (auto& g : invalid) {
4610
                    // Replace nullptr with 'MULTILINESTRING EMPTY'
4611
0
                    if (g == nullptr) {
4612
0
                        auto empty = gf->createEmpty(1);
4613
0
                        g.reset(empty.release());
4614
0
                    }
4615
0
                }
4616
0
                auto r = gf->createGeometryCollection(std::move(invalid));
4617
0
                *invalidEdges = r.release();
4618
0
            }
4619
4620
0
            return hasInvalid ? 0 : 1;
4621
0
        });
4622
0
    }
4623
4624
    Geometry*
4625
    GEOSCoverageSimplifyVW_r(GEOSContextHandle_t extHandle,
4626
        const Geometry* input,
4627
        double tolerance,
4628
        int preserveBoundary)
4629
0
    {
4630
0
        using geos::coverage::CoverageSimplifier;
4631
4632
0
        return execute(extHandle, [&]() -> Geometry* {
4633
0
            const GeometryCollection* col = dynamic_cast<const GeometryCollection*>(input);
4634
0
            if (!col)
4635
0
                return nullptr;
4636
4637
0
            std::vector<const Geometry*> coverage;
4638
0
            for (const auto& g : *col) {
4639
0
                coverage.push_back(g.get());
4640
0
            }
4641
0
            CoverageSimplifier cov(coverage);
4642
0
            std::vector<std::unique_ptr<Geometry>> simple;
4643
0
            if (preserveBoundary == 1) {
4644
0
                simple = cov.simplifyInner(tolerance);
4645
0
            }
4646
0
            else if (preserveBoundary == 0) {
4647
0
                simple = cov.simplify(tolerance);
4648
0
            }
4649
0
            else return nullptr;
4650
4651
0
            const GeometryFactory* gf = input->getFactory();
4652
0
            std::unique_ptr<Geometry> r = gf->createGeometryCollection(std::move(simple));
4653
0
            return r.release();
4654
0
        });
4655
0
    }
4656
4657
4658
/************************************************************************
4659
 * Coverage Cleaner
4660
 */
4661
4662
    GEOSCoverageCleanParams*
4663
    GEOSCoverageCleanParams_create_r(GEOSContextHandle_t extHandle)
4664
0
    {
4665
0
        return execute(extHandle, [&]() {
4666
0
            GEOSCoverageCleanParams* p = new GEOSCoverageCleanParams();
4667
0
            p->overlapMergeStrategy = geos::coverage::CoverageCleaner::MERGE_LONGEST_BORDER;
4668
0
            p->snappingDistance = -1.0;
4669
0
            p->gapMaximumWidth = 0.0;
4670
0
            return p;
4671
0
        });
4672
0
    }
4673
4674
    void
4675
    GEOSCoverageCleanParams_destroy_r(GEOSContextHandle_t extHandle,
4676
        GEOSCoverageCleanParams* params)
4677
0
    {
4678
0
        (void)extHandle;
4679
0
        delete params;
4680
0
    }
4681
4682
    int
4683
    GEOSCoverageCleanParams_setSnappingDistance_r(GEOSContextHandle_t extHandle,
4684
        GEOSCoverageCleanParams* params, double snappingDistance)
4685
0
    {
4686
0
        return execute(extHandle, 0, [&]() {
4687
0
            params->snappingDistance = snappingDistance;
4688
0
            return 1;
4689
0
        });
4690
0
    }
4691
4692
    int
4693
    GEOSCoverageCleanParams_setGapMaximumWidth_r(GEOSContextHandle_t extHandle,
4694
        GEOSCoverageCleanParams* params, double gapMaximumWidth)
4695
0
    {
4696
0
        return execute(extHandle, 0, [&]() {
4697
0
            params->gapMaximumWidth = gapMaximumWidth;
4698
0
            return 1;
4699
0
        });
4700
0
    }
4701
4702
    int
4703
    GEOSCoverageCleanParams_setOverlapMergeStrategy_r(GEOSContextHandle_t extHandle,
4704
        GEOSCoverageCleanParams* params, int overlapMergeStrategy)
4705
0
    {
4706
0
        return execute(extHandle, 0, [&]() {
4707
0
            if (   overlapMergeStrategy != geos::coverage::CoverageCleaner::MERGE_LONGEST_BORDER
4708
0
                && overlapMergeStrategy != geos::coverage::CoverageCleaner::MERGE_MAX_AREA
4709
0
                && overlapMergeStrategy != geos::coverage::CoverageCleaner::MERGE_MIN_AREA
4710
0
                && overlapMergeStrategy != geos::coverage::CoverageCleaner::MERGE_MIN_INDEX)
4711
0
            {
4712
0
                extHandle->ERROR_MESSAGE("GEOSCoverageCleanParams_setOverlapMergeStrategy: Invalid overlapMergeStrategy");
4713
0
                return 0;
4714
0
            }
4715
0
            params->overlapMergeStrategy = overlapMergeStrategy;
4716
0
            return 1;
4717
0
        });
4718
0
    }
4719
4720
    GEOSGeometry *
4721
    GEOSCoverageCleanWithParams_r(GEOSContextHandle_t extHandle,
4722
        const GEOSGeometry* input,
4723
        const GEOSCoverageCleanParams* params)
4724
0
    {
4725
0
        using geos::coverage::CoverageCleaner;
4726
4727
0
        return execute(extHandle, [&]() -> Geometry* {
4728
0
            const GeometryCollection* col = dynamic_cast<const GeometryCollection*>(input);
4729
0
            if (!col)
4730
0
                return nullptr;
4731
4732
0
            std::vector<const Geometry*> coverage;
4733
0
            for (const auto& g : *col) {
4734
0
                coverage.push_back(g.get());
4735
0
            }
4736
0
            geos::coverage::CoverageCleaner c(coverage);
4737
0
            if (params) {
4738
0
                c.setSnappingDistance(params->snappingDistance);
4739
0
                c.setGapMaximumWidth(params->gapMaximumWidth);
4740
0
                c.setOverlapMergeStrategy(params->overlapMergeStrategy);
4741
0
            }
4742
0
            c.clean();
4743
4744
0
            auto cleanCov = c.getResult();
4745
0
            const GeometryFactory* gf = input->getFactory();
4746
0
            std::unique_ptr<Geometry> r = gf->createGeometryCollection(std::move(cleanCov));
4747
0
            return r.release();
4748
0
        });
4749
0
    }
4750
4751
    GEOSGeometry *
4752
    GEOSCoverageClean_r(GEOSContextHandle_t extHandle,
4753
        const GEOSGeometry* input)
4754
0
    {
4755
0
        return GEOSCoverageCleanWithParams_r(extHandle, input, nullptr);
4756
0
    }
4757
4758
4759
} /* extern "C" */