Coverage Report

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