Skip to content

Commit 2fb8915

Browse files

File tree

3 files changed

+1146
-1283
lines changed

3 files changed

+1146
-1283
lines changed
 

‎cmake/FindGEOS.cmake

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,21 @@
1313
# and then again with no specified paths to search the default
1414
# locations. When an earlier FIND_* succeeds, subsequent FIND_*s
1515
# searching for the same item do nothing.
16-
FIND_PATH(GEOS_INCLUDE_DIR geos.h
16+
FIND_PATH(GEOS_INCLUDE_DIR geos_c.h
1717
"$ENV{LIB_DIR}/include"
1818
#mingw
1919
c:/msys/local/include
2020
NO_DEFAULT_PATH
2121
)
22-
FIND_PATH(GEOS_INCLUDE_DIR geos.h)
22+
FIND_PATH(GEOS_INCLUDE_DIR geos_c.h)
2323

24-
FIND_LIBRARY(GEOS_LIBRARY NAMES geos PATHS
24+
FIND_LIBRARY(GEOS_LIBRARY NAMES geos_c PATHS
2525
"$ENV{LIB_DIR}/lib"
2626
#mingw
2727
c:/msys/local/lib
2828
NO_DEFAULT_PATH
2929
)
30-
FIND_LIBRARY(GEOS_LIBRARY NAMES geos)
30+
FIND_LIBRARY(GEOS_LIBRARY NAMES geos_c)
3131

3232
IF (GEOS_INCLUDE_DIR AND GEOS_LIBRARY)
3333
SET(GEOS_FOUND TRUE)

‎src/core/qgsgeometry.cpp

Lines changed: 1123 additions & 1250 deletions
Large diffs are not rendered by default.

‎src/core/qgsgeometry.h

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,11 @@ email : morb at ozemail dot com dot au
2222

2323
#include "qgis.h"
2424

25-
#include <geos/version.h>
26-
#if GEOS_VERSION_MAJOR < 3
27-
#include <geos/geom.h>
28-
#define GEOS_GEOM geos
29-
#else
30-
#include <geos/geom/CoordinateSequence.h>
31-
#include <geos/geom/Geometry.h>
32-
#include <geos/geom/LineString.h>
33-
#define GEOS_GEOM geos::geom
25+
#include <geos_c.h>
26+
27+
#if GEOS_VERSION_MAJOR<3
28+
#define GEOSGeometry struct GEOSGeom_t
29+
#define GEOSCoordSequence struct GEOSCoordSeq_t
3430
#endif
3531

3632
#include "qgspoint.h"
@@ -66,11 +62,9 @@ class QgsRect;
6662
* @author Brendan Morley
6763
*/
6864

69-
class CORE_EXPORT QgsGeometry {
70-
65+
class CORE_EXPORT QgsGeometry
66+
{
7167
public:
72-
73-
7468
//! Constructor
7569
QgsGeometry();
7670

@@ -125,7 +119,7 @@ class CORE_EXPORT QgsGeometry {
125119
Set the geometry, feeding in a geometry in GEOS format.
126120
This class will take ownership of the buffer.
127121
*/
128-
void setGeos(GEOS_GEOM::Geometry* geos);
122+
void setGeos(GEOSGeometry* geos);
129123

130124
/**
131125
Set the geometry, feeding in the buffer containing OGC Well-Known Binary and the buffer's length.
@@ -230,8 +224,8 @@ and the indices of the vertices before/after. The vertices before/after are -1 i
230224
int addRing(const QList<QgsPoint>& ring);
231225

232226
/**Adds a new island polygon to a multipolygon feature
233-
@return 0 in case of success, 1 if not a multipolygon, 2 if ring is not a valid geometry, 3 if new polygon ring \
234-
not disjoint with existing polygons of the feature*/
227+
@return 0 in case of success, 1 if not a multipolygon, 2 if ring is not a valid geometry, 3 if new polygon ring
228+
not disjoint with existing polygons of the feature*/
235229
int addIsland(const QList<QgsPoint>& ring);
236230

237231
/**Translate this geometry by dx, dy
@@ -285,7 +279,6 @@ not disjoint with existing polygons of the feature*/
285279
*/
286280
QString exportToWkt();
287281

288-
289282
/* Accessor functions for getting geometry data */
290283

291284
/** return contents of the geometry as a point
@@ -312,9 +305,7 @@ not disjoint with existing polygons of the feature*/
312305
if wkbType is WKBPolygon, otherwise an empty list */
313306
QgsMultiPolygon asMultiPolygon();
314307

315-
private:
316-
317-
308+
private:
318309
// Private variables
319310

320311
// All of these are mutable since there may be on-the-fly
@@ -331,7 +322,7 @@ not disjoint with existing polygons of the feature*/
331322
size_t mGeometrySize;
332323

333324
/** cached GEOS version of this geometry */
334-
GEOS_GEOM::Geometry* mGeos;
325+
GEOSGeometry* mGeos;
335326

336327
/** If the geometry has been set since the last conversion to WKB **/
337328
bool mDirtyWkb;
@@ -360,8 +351,6 @@ not disjoint with existing polygons of the feature*/
360351
*/
361352
bool exportGeosToWkb();
362353

363-
364-
365354
/** Insert a new vertex before the given vertex index (first number is index 0)
366355
* in the given GEOS Coordinate Sequence.
367356
* If the requested vertex number is greater
@@ -374,8 +363,8 @@ not disjoint with existing polygons of the feature*/
374363
*/
375364
bool insertVertexBefore(double x, double y,
376365
int beforeVertex,
377-
const GEOS_GEOM::CoordinateSequence* old_sequence,
378-
GEOS_GEOM::CoordinateSequence** new_sequence);
366+
const GEOSCoordSequence* old_sequence,
367+
GEOSCoordSequence** new_sequence);
379368

380369
/**Converts single type geometry into multitype geometry
381370
e.g. a polygon into a multipolygon geometry with one polygon
@@ -396,18 +385,18 @@ not disjoint with existing polygons of the feature*/
396385
@splitLine the line that splits the feature
397386
@newGeometry new geometry if splitting was successful
398387
@return 0 in case of success, 1 if geometry has not been split, error else*/
399-
int splitLinearGeometry(GEOS_GEOM::LineString* splitLine, QList<QgsGeometry*>& newGeometries);
388+
int splitLinearGeometry(GEOSGeometry *splitLine, QList<QgsGeometry*>& newGeometries);
400389
/**Splits polygon/multipolygon geometries
401390
@return 0 in case of success, 1 if geometry has not been split, error else*/
402-
int splitPolygonGeometry(GEOS_GEOM::LineString* splitLine, QList<QgsGeometry*>& newGeometries);
391+
int splitPolygonGeometry(GEOSGeometry *splitLine, QList<QgsGeometry*>& newGeometries);
403392
/**Finds the vertices next to point where the line is split. If it is split at a vertex, beforeVertex
404393
and afterVertex are the same*/
405394

406395
/**Nodes together a split line and a (multi-) polygon geometry in a multilinestring
407396
@return the noded multiline geometry or 0 in case of error. The calling function takes ownership of the node geometry*/
408-
GEOS_GEOM::Geometry* nodeGeometries(const GEOS_GEOM::LineString* splitLine, const GEOS_GEOM::Geometry* poly) const;
397+
GEOSGeometry* nodeGeometries(const GEOSGeometry *splitLine, GEOSGeometry *poly) const;
409398

410-
int mergeGeometriesMultiTypeSplit(QList<GEOS_GEOM::Geometry*>& splitResult);
399+
int mergeGeometriesMultiTypeSplit(QVector<GEOSGeometry*>& splitResult);
411400

412401
/** return point from wkb */
413402
QgsPoint asPoint(unsigned char*& ptr, bool hasZValue);
@@ -418,6 +407,7 @@ not disjoint with existing polygons of the feature*/
418407
/** return polygon from wkb */
419408
QgsPolygon asPolygon(unsigned char*& ptr, bool hasZValue);
420409

410+
static int refcount;
421411
}; // class QgsGeometry
422412

423413
#endif

0 commit comments

Comments
 (0)
Please sign in to comment.