Skip to content
Permalink
Browse files

GEOS context accessor for PAL

  • Loading branch information
wonder-sk committed Sep 14, 2014
1 parent aafbc4e commit 0b72fc8283c5210a13f3f2f3ff6f28400f252bb7
@@ -39,7 +39,6 @@
#endif

#include <qglobal.h>
#include <qgsgeometry.h>

#include <cmath>
#include <cstring>
@@ -110,7 +109,7 @@ namespace pal

if ( ownsGeom )
{
GEOSGeom_destroy_r( QgsGeometry::getGEOSHandler(), the_geom );
GEOSGeom_destroy_r( geosContext(), the_geom );
the_geom = NULL;
}
}
@@ -124,7 +123,7 @@ namespace pal
int i, j;

const GEOSCoordSequence *coordSeq;
GEOSContextHandle_t geosctxt = QgsGeometry::getGEOSHandler();
GEOSContextHandle_t geosctxt = geosContext();

type = GEOSGeomTypeId_r( geosctxt, geom );

@@ -1399,7 +1398,7 @@ namespace pal

void FeaturePart::addSizePenalty( int nbp, LabelPosition** lPos, double bbx[4], double bby[4] )
{
GEOSContextHandle_t ctxt = QgsGeometry::getGEOSHandler();
GEOSContextHandle_t ctxt = geosContext();
int geomType = GEOSGeomTypeId_r( ctxt, the_geom );

double sizeCost = 0;
@@ -1439,12 +1438,12 @@ namespace pal

bool FeaturePart::isConnected( FeaturePart* p2 )
{
return ( GEOSTouches_r( QgsGeometry::getGEOSHandler(), the_geom, p2->the_geom ) == 1 );
return ( GEOSTouches_r( geosContext(), the_geom, p2->the_geom ) == 1 );
}

bool FeaturePart::mergeWithFeaturePart( FeaturePart* other )
{
GEOSContextHandle_t ctxt = QgsGeometry::getGEOSHandler();
GEOSContextHandle_t ctxt = geosContext();
GEOSGeometry* g1 = GEOSGeom_clone_r( ctxt, the_geom );
GEOSGeometry* g2 = GEOSGeom_clone_r( ctxt, other->the_geom );
GEOSGeometry* geoms[2] = { g1, g2 };
@@ -41,8 +41,6 @@
#include <cmath>
#include <vector>

#include <qgsgeometry.h>

#include <pal/pal.h>
#include <pal/layer.h>
#include <pal/palexception.h>
@@ -287,7 +285,7 @@ namespace pal
throw InternalException::UnknownGeometry();
}

GEOSContextHandle_t geosctxt = QgsGeometry::getGEOSHandler();
GEOSContextHandle_t geosctxt = geosContext();

while ( simpleGeometries->size() > 0 )
{
@@ -496,7 +494,7 @@ namespace pal

void Layer::chopFeaturesAtRepeatDistance( )
{
GEOSContextHandle_t geosctxt = QgsGeometry::getGEOSHandler();
GEOSContextHandle_t geosctxt = geosContext();
LinkedList<FeaturePart*> * newFeatureParts = new LinkedList<FeaturePart*>( ptrFeaturePartCompare );
while ( FeaturePart* fpart = featureParts->pop_front() )
{
@@ -63,6 +63,8 @@
#include "simplemutex.h"
#include "util.h"

#include <qgsgeometry.h> // for GEOS context

namespace pal
{

@@ -80,6 +82,11 @@ namespace pal
vfprintf( stdout, fmt, list );
}

GEOSContextHandle_t geosContext()
{
return QgsGeometry::getGEOSHandler();
}

Pal::Pal()
{
// do not init and exit GEOS - we do it inside QGIS
@@ -38,6 +38,7 @@
#include <QList>
#include <iostream>
#include <ctime>
#include <geos_c.h>

// TODO ${MAJOR} ${MINOR} etc instead of 0.2

@@ -51,6 +52,8 @@

namespace pal
{
/** Get GEOS context handle to be used in all GEOS library calls with reentrant API */
GEOSContextHandle_t geosContext();

template <class Type> class LinkedList;

@@ -39,7 +39,6 @@
#endif

#include <qglobal.h>
#include <qgsgeometry.h>

#include "pointset.h"
#include "util.h"
@@ -989,7 +988,7 @@ namespace pal
// check if centroid inside in polygon
if ( forceInside && !isPointInPolygon( nbPoints, x, y, px, py ) )
{
GEOSContextHandle_t geosctxt = QgsGeometry::getGEOSHandler();
GEOSContextHandle_t geosctxt = geosContext();
GEOSCoordSequence *coord = GEOSCoordSeq_create_r( geosctxt, nbPoints, 2 );

for ( int i = 0; i < nbPoints; ++i )
@@ -42,8 +42,6 @@
#include <cstdarg>
#include <ctime>

#include "qgsgeometry.h"

#include <pal/layer.h>

#include "internalexception.h"
@@ -213,7 +211,7 @@ namespace pal
while ( queue->size() > 0 )
{
geom = queue->pop_front();
GEOSContextHandle_t geosctxt = QgsGeometry::getGEOSHandler();
GEOSContextHandle_t geosctxt = geosContext();
switch ( GEOSGeomTypeId_r( geosctxt, geom ) )
{
//case geos::geom::GEOS_MULTIPOINT:
@@ -83,7 +83,10 @@ class CORE_EXPORT QgsGeometry
//! Destructor
~QgsGeometry();

/** return GEOS context handle */
/** return GEOS context handle
* @note added in 2.6
* @note not available in Python
*/
static GEOSContextHandle_t getGEOSHandler();

/** static method that creates geometry from Wkt */

0 comments on commit 0b72fc8

Please sign in to comment.
You can’t perform that action at this time.