21 #include "qgis_core.h"
26 #if defined(GEOS_VERSION_MAJOR) && (GEOS_VERSION_MAJOR<3)
27 #define GEOSGeometry struct GEOSGeom_t
28 #define GEOSCoordSequence struct GEOSCoordSeq_t
55 void CORE_EXPORT
operator()( GEOSGeometry *geom )
const;
61 void CORE_EXPORT
operator()(
const GEOSPreparedGeometry *geom )
const;
67 void CORE_EXPORT
operator()( GEOSBufferParams *params )
const;
73 void CORE_EXPORT
operator()( GEOSCoordSequence *sequence )
const;
79 using unique_ptr = std::unique_ptr< GEOSGeometry, GeosDeleter>;
125 #if GEOS_VERSION_MAJOR>3 || ( GEOS_VERSION_MAJOR == 3 && GEOS_VERSION_MINOR>=8 )
131 std::unique_ptr< QgsAbstractGeometry > makeValid( QString *errorMsg =
nullptr )
const;
152 std::unique_ptr< QgsAbstractGeometry > clip(
const QgsRectangle &rectangle, QString *errorMsg =
nullptr )
const;
168 std::unique_ptr< QgsAbstractGeometry > subdivide(
int maxNodes, QString *errorMsg =
nullptr )
const;
192 bool contains(
double x,
double y, QString *errorMsg =
nullptr )
const;
201 double distance(
double x,
double y, QString *errorMsg =
nullptr )
const;
218 double hausdorffDistance(
const QgsAbstractGeometry *geom, QString *errorMsg =
nullptr )
const;
236 double hausdorffDistanceDensify(
const QgsAbstractGeometry *geom,
double densifyFraction, QString *errorMsg =
nullptr )
const;
250 double frechetDistance(
const QgsAbstractGeometry *geom, QString *errorMsg =
nullptr )
const;
274 double frechetDistanceDensify(
const QgsAbstractGeometry *geom,
double densifyFraction, QString *errorMsg =
nullptr )
const;
285 double area( QString *errorMsg =
nullptr )
const override;
286 double length( QString *errorMsg =
nullptr )
const override;
287 bool isValid( QString *errorMsg =
nullptr,
bool allowSelfTouchingHoles =
false,
QgsGeometry *errorLoc =
nullptr )
const override;
289 bool isEmpty( QString *errorMsg =
nullptr )
const override;
290 bool isSimple( QString *errorMsg =
nullptr )
const override;
293 QVector<QgsGeometry> &newGeometries,
296 QString *errorMsg =
nullptr,
bool skipIntersectionCheck =
false )
const override;
313 std::unique_ptr< QgsAbstractGeometry > singleSidedBuffer(
double distance,
int segments,
Qgis::BufferSide side,
315 QString *errorMsg =
nullptr )
const;
341 std::unique_ptr< QgsAbstractGeometry > maximumInscribedCircle(
double tolerance, QString *errorMsg =
nullptr )
const;
366 std::unique_ptr< QgsAbstractGeometry > largestEmptyCircle(
double tolerance,
const QgsAbstractGeometry *boundary =
nullptr, QString *errorMsg =
nullptr )
const;
382 std::unique_ptr< QgsAbstractGeometry > minimumWidth( QString *errorMsg =
nullptr )
const;
405 double minimumClearance( QString *errorMsg =
nullptr )
const;
418 std::unique_ptr< QgsAbstractGeometry > minimumClearanceLine( QString *errorMsg =
nullptr )
const;
430 std::unique_ptr< QgsAbstractGeometry > node( QString *errorMsg =
nullptr )
const;
446 std::unique_ptr< QgsAbstractGeometry > sharedPaths(
const QgsAbstractGeometry *other, QString *errorMsg =
nullptr )
const;
466 QgsGeometry mergeLines( QString *errorMsg =
nullptr )
const;
499 double lineLocatePoint(
const QgsPoint &point, QString *errorMsg =
nullptr )
const;
513 double lineLocatePoint(
double x,
double y, QString *errorMsg =
nullptr )
const;
524 static QgsGeometry polygonize(
const QVector<const QgsAbstractGeometry *> &geometries, QString *errorMsg =
nullptr );
541 QgsGeometry voronoiDiagram(
const QgsAbstractGeometry *extent =
nullptr,
double tolerance = 0.0,
bool edgesOnly =
false, QString *errorMsg =
nullptr )
const;
552 QgsGeometry delaunayTriangulation(
double tolerance = 0.0,
bool edgesOnly =
false, QString *errorMsg =
nullptr )
const;
558 static std::unique_ptr< QgsAbstractGeometry > fromGeos(
const GEOSGeometry *
geos );
559 static std::unique_ptr< QgsPolygon > fromGeosPolygon(
const GEOSGeometry *
geos );
575 static QgsPoint coordSeqPoint(
const GEOSCoordSequence *cs,
int i,
bool hasZ,
bool hasM );
577 static GEOSContextHandle_t getGEOSHandler();
583 double mPrecision = 0.0;
605 void cacheGeos()
const;
606 std::unique_ptr< QgsAbstractGeometry > overlay(
const QgsAbstractGeometry *geom, Overlay op, QString *errorMsg =
nullptr )
const;
607 bool relation(
const QgsAbstractGeometry *geom, Relation r, QString *errorMsg =
nullptr )
const;
608 static GEOSCoordSequence *createCoordinateSequence(
const QgsCurve *curve,
double precision,
bool forceClose =
false );
609 static std::unique_ptr< QgsLineString > sequenceToLinestring(
const GEOSGeometry *
geos,
bool hasZ,
bool hasM );
610 static int numberOfGeometries( GEOSGeometry *g );
611 static geos::unique_ptr nodeGeometries(
const GEOSGeometry *splitLine,
const GEOSGeometry *geom );
612 int mergeGeometriesMultiTypeSplit( QVector<GEOSGeometry *> &splitResult )
const;
617 static geos::unique_ptr createGeosCollection(
int typeId,
const QVector<GEOSGeometry *> &geoms );
619 static geos::unique_ptr createGeosPointXY(
double x,
double y,
bool hasZ,
double z,
bool hasM,
double m,
int coordDims,
double precision );
625 bool topologicalTestPointsSplit(
const GEOSGeometry *splitLine,
QgsPointSequence &testPoints, QString *errorMsg =
nullptr )
const;
627 EngineOperationResult splitLinearGeometry( GEOSGeometry *splitLine, QVector<QgsGeometry > &newGeometries,
bool skipIntersectionCheck )
const;
628 EngineOperationResult splitPolygonGeometry( GEOSGeometry *splitLine, QVector<QgsGeometry > &newGeometries,
bool skipIntersectionCheck )
const;
632 static geos::unique_ptr reshapePolygon(
const GEOSGeometry *polygon,
const GEOSGeometry *reshapeLineGeos,
double precision );
633 static int lineContainedInLine(
const GEOSGeometry *line1,
const GEOSGeometry *line2 );
634 static int pointContainedInLine(
const GEOSGeometry *point,
const GEOSGeometry *line );
635 static int geomDigits(
const GEOSGeometry *geom );
642 class GEOSException :
public std::runtime_error
645 explicit GEOSException(
const QString &message )
646 : std::runtime_error( message.toUtf8().constData() )