Enable compilation using GEOS 3 as well as GEOS 2.

git-svn-id: http://svn.osgeo.org/qgis/trunk@6274 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
telwertowski 2006-12-18 06:06:48 +00:00
parent c68c76a638
commit 3388363866
11 changed files with 152 additions and 100 deletions

View File

@ -91,8 +91,8 @@ if test x${GEOS_CONFIG} = xno ; then
AC_MSG_ERROR([geos-config not found! Supply it with --with-geos=PATH])
else
ac_geos_version=`${GEOS_CONFIG} --version`
if test `echo ${ac_geos_version} | sed -e 's#2\.[0-9].*#OK#'` != OK ; then
AC_MSG_ERROR([Geos Version 2.x.x is needed, but you have $ac_geos_version!])
if test `echo ${ac_geos_version} | sed -e 's#[2-9]\.[0-9].*#OK#'` != OK ; then
AC_MSG_ERROR([Geos Version 2.x.x or greater is needed, but you have $ac_geos_version!])
else
AC_MSG_CHECKING([GEOS_CFLAGS])
GEOS_CFLAGS=`$GEOS_CONFIG --cflags`

View File

@ -818,9 +818,9 @@ void QgsFeature::resetDirty()
// {
// bool returnval=false;
//
// geos::GeometryFactory *gf = new geos::GeometryFactory();
// geos::WKTReader *wktReader = new geos::WKTReader(gf);
// geos::Geometry *geosGeom = wktReader->read( qstrdup(wellKnownText()) );
// GEOS_GEOM::GeometryFactory *gf = new GEOS_GEOM::GeometryFactory();
// GEOS_IO::WKTReader *wktReader = new GEOS_IO::WKTReader(gf);
// GEOS_GEOM::Geometry *geosGeom = wktReader->read( qstrdup(wellKnownText()) );
//
// //write the selection rectangle to wkt by hand
// QString rectwkt="POLYGON((";
@ -845,7 +845,7 @@ void QgsFeature::resetDirty()
// rectwkt+=QString::number(r->yMin(),'f',3);
// rectwkt+="))";
//
// geos::Geometry *geosRect = wktReader->read( qstrdup(rectwkt) );
// GEOS_GEOM::Geometry *geosRect = wktReader->read( qstrdup(rectwkt) );
// if(geosGeom->intersects(geosRect))
// {
// returnval=true;
@ -1655,7 +1655,7 @@ QgsRect QgsFeature::boundingBox() const
// }
//
geos::Geometry* QgsFeature::geosGeometry() const
GEOS_GEOM::Geometry* QgsFeature::geosGeometry() const
{
return mGeometry->geosGeometry();
}

View File

@ -235,7 +235,7 @@ class QgsFeature {
/** Creates a geos geometry from this features geometry. Note, that the returned object needs to be deleted.
@note This function is deprecated - use geometry()->geosGeometry() instead.
*/
geos::Geometry* geosGeometry() const;
GEOS_GEOM::Geometry* geosGeometry() const;
private:

View File

@ -22,7 +22,7 @@ email : morb at ozemail dot com dot au
// Set up static GEOS geometry factory
geos::GeometryFactory* QgsGeometry::geosGeometryFactory = new geos::GeometryFactory();
GEOS_GEOM::GeometryFactory* QgsGeometry::geosGeometryFactory = new GEOS_GEOM::GeometryFactory();
QgsGeometry::QgsGeometry()
@ -192,7 +192,7 @@ QString const& QgsGeometry::wkt() const
return mWkt;
}
void QgsGeometry::setGeos(geos::Geometry* geos)
void QgsGeometry::setGeos(GEOS_GEOM::Geometry* geos)
{
// TODO - make this more heap-friendly
@ -698,8 +698,8 @@ void QgsGeometry::adjacentVerticies(const QgsGeometryVertexIndex& atVertex, int&
bool QgsGeometry::insertVertexBefore(double x, double y,
int beforeVertex,
const geos::CoordinateSequence* old_sequence,
geos::CoordinateSequence** new_sequence)
const GEOS_GEOM::CoordinateSequence* old_sequence,
GEOS_GEOM::CoordinateSequence** new_sequence)
{
// Bounds checking
@ -712,7 +712,7 @@ bool QgsGeometry::insertVertexBefore(double x, double y,
int numPoints = old_sequence->getSize();
// Copy to the new sequence, including the new vertex
(*new_sequence) = new geos::DefaultCoordinateSequence();
(*new_sequence) = new GEOS_GEOM::DefaultCoordinateSequence();
bool inserted = FALSE;
for (int i = 0; i < numPoints; i++)
@ -720,7 +720,7 @@ bool QgsGeometry::insertVertexBefore(double x, double y,
// Do we insert the new vertex here?
if (beforeVertex == i)
{
(*new_sequence)->add( geos::Coordinate(x, y) );
(*new_sequence)->add( GEOS_GEOM::Coordinate(x, y) );
inserted = TRUE;
}
(*new_sequence)->add( old_sequence->getAt(i) );
@ -730,9 +730,9 @@ bool QgsGeometry::insertVertexBefore(double x, double y,
{
// The beforeVertex is greater than the actual number of vertices
// in the geometry - append it.
(*new_sequence)->add( geos::Coordinate(x, y) );
(*new_sequence)->add( GEOS_GEOM::Coordinate(x, y) );
}
// TODO: Check that the sequence is still simple, e.g. with geos::Geometry->isSimple()
// TODO: Check that the sequence is still simple, e.g. with GEOS_GEOM::Geometry->isSimple()
return inserted;
}
@ -1381,10 +1381,10 @@ bool QgsGeometry::vertexAt(double &x, double &y,
{
if(mGeos)//try to find the vertex from the Geos geometry (it present)
{
geos::CoordinateSequence* cs = mGeos->getCoordinates();
GEOS_GEOM::CoordinateSequence* cs = mGeos->getCoordinates();
if(cs)
{
const geos::Coordinate& coord = cs->getAt(atVertex.back());
const GEOS_GEOM::Coordinate& coord = cs->getAt(atVertex.back());
x = coord.x;
y = coord.y;
delete cs;
@ -1594,7 +1594,7 @@ QgsPoint QgsGeometry::closestVertexWithContext(QgsPoint& point,
if (mGeos)
{
geos::CoordinateSequence* sequence = mGeos->getCoordinates();
GEOS_GEOM::CoordinateSequence* sequence = mGeos->getCoordinates();
if(sequence)
{
for(int i = 0; i < sequence->getSize(); ++i)
@ -2048,9 +2048,9 @@ bool QgsGeometry::intersects(QgsRect* r) const
{
bool returnval=false;
geos::GeometryFactory *gf = new geos::GeometryFactory();
geos::WKTReader *wktReader = new geos::WKTReader(gf);
geos::Geometry *geosGeom = wktReader->read( qstrdup(wkt()) );
GEOS_GEOM::GeometryFactory *gf = new GEOS_GEOM::GeometryFactory();
GEOS_IO::WKTReader *wktReader = new GEOS_IO::WKTReader(gf);
GEOS_GEOM::Geometry *geosGeom = wktReader->read( qstrdup(wkt()) );
//write the selection rectangle to wkt by hand
QString rectwkt="POLYGON((";
@ -2075,7 +2075,7 @@ bool QgsGeometry::intersects(QgsRect* r) const
rectwkt+=QString::number(r->yMin(),'f',3);
rectwkt+="))";
geos::Geometry *geosRect = wktReader->read( qstrdup(rectwkt) );
GEOS_GEOM::Geometry *geosRect = wktReader->read( qstrdup(rectwkt) );
try // geos might throw exception on error
{
if(geosGeom->intersects(geosRect))
@ -2083,9 +2083,13 @@ bool QgsGeometry::intersects(QgsRect* r) const
returnval=true;
}
}
catch (geos::TopologyException* e)
catch (GEOS_UTIL::TopologyException* e)
{
#if GEOS_VERSION_MAJOR < 3
QString error = e->toString().c_str();
#else
QString error = e->what();
#endif
QgsLogger::warning("GEOS: " + error);
}
@ -2101,7 +2105,7 @@ bool QgsGeometry::fast_intersects(const QgsRect* r) const
bool returnval=false;
//use the geos export of QgsGeometry
geos::Geometry *geosGeom = geosGeometry();
GEOS_GEOM::Geometry *geosGeom = geosGeometry();
//write the selection rectangle to wkt by hand
QString rectwkt="POLYGON((";
@ -2125,9 +2129,9 @@ bool QgsGeometry::fast_intersects(const QgsRect* r) const
rectwkt+=" ";
rectwkt+=QString::number(r->yMin(),'f',3);
rectwkt+="))";
geos::GeometryFactory *gf = new geos::GeometryFactory();
geos::WKTReader *wktReader = new geos::WKTReader(gf);
geos::Geometry *geosRect = wktReader->read( qstrdup(rectwkt) );
GEOS_GEOM::GeometryFactory *gf = new GEOS_GEOM::GeometryFactory();
GEOS_IO::WKTReader *wktReader = new GEOS_IO::WKTReader(gf);
GEOS_GEOM::Geometry *geosRect = wktReader->read( qstrdup(rectwkt) );
try // geos might throw exception on error
{
@ -2136,9 +2140,13 @@ bool QgsGeometry::fast_intersects(const QgsRect* r) const
returnval=true;
}
}
catch (geos::TopologyException* e)
catch (GEOS_UTIL::TopologyException* e)
{
#if GEOS_VERSION_MAJOR < 3
QString error = e->toString().c_str();
#else
QString error = e->what();
#endif
QgsLogger::warning("GEOS: " + error);
}
@ -2156,7 +2164,7 @@ bool QgsGeometry::contains(QgsPoint* p) const
exportWkbToGeos();
geos::Point* geosPoint = geosGeometryFactory->createPoint(geos::Coordinate(p->x(), p->y()));
GEOS_GEOM::Point* geosPoint = geosGeometryFactory->createPoint(GEOS_GEOM::Coordinate(p->x(), p->y()));
returnval = mGeos->contains(geosPoint);
@ -2427,7 +2435,7 @@ bool QgsGeometry::exportToWkt() const
geos::Geometry* QgsGeometry::geosGeometry() const
GEOS_GEOM::Geometry* QgsGeometry::geosGeometry() const
{
if (!mDirtyGeos)
@ -2460,7 +2468,7 @@ geos::Geometry* QgsGeometry::geosGeometry() const
int wkbtype;
// // TODO: Make this a static member - save generating for every geometry
// geos::GeometryFactory* geometryFactory = new geos::GeometryFactory();
// GEOS_GEOM::GeometryFactory* geometryFactory = new GEOS_GEOM::GeometryFactory();
wkbtype = (mGeometry[0] == 1) ? mGeometry[1] : mGeometry[4];
switch(wkbtype)
@ -2471,11 +2479,11 @@ geos::Geometry* QgsGeometry::geosGeometry() const
y = (double *) (mGeometry + 5 + sizeof(double));
mDirtyGeos = FALSE;
return geosGeometryFactory->createPoint(geos::Coordinate(*x,*y));
return geosGeometryFactory->createPoint(GEOS_GEOM::Coordinate(*x,*y));
}
case QGis::WKBMultiPoint:
{
std::vector<geos::Geometry*>* points=new std::vector<geos::Geometry*>;
std::vector<GEOS_GEOM::Geometry*>* points=new std::vector<GEOS_GEOM::Geometry*>;
ptr = mGeometry + 5;
nPoints = (int *) ptr;
ptr = mGeometry + 1 + 2 * sizeof(int);
@ -2486,7 +2494,7 @@ geos::Geometry* QgsGeometry::geosGeometry() const
ptr += sizeof(double);
y = (double *) ptr;
ptr += sizeof(double);
points->push_back(geosGeometryFactory->createPoint(geos::Coordinate(*x,*y)));
points->push_back(geosGeometryFactory->createPoint(GEOS_GEOM::Coordinate(*x,*y)));
}
return geosGeometryFactory->createMultiPoint(points);
}
@ -2495,7 +2503,7 @@ geos::Geometry* QgsGeometry::geosGeometry() const
#ifdef QGISDEBUG
qWarning("QgsGeometry::geosGeometry: Linestring found");
#endif
geos::DefaultCoordinateSequence* sequence=new geos::DefaultCoordinateSequence();
GEOS_GEOM::DefaultCoordinateSequence* sequence=new GEOS_GEOM::DefaultCoordinateSequence();
ptr = mGeometry + 5;
nPoints = (int *) ptr;
ptr = mGeometry + 1 + 2 * sizeof(int);
@ -2505,18 +2513,18 @@ geos::Geometry* QgsGeometry::geosGeometry() const
ptr += sizeof(double);
y = (double *) ptr;
ptr += sizeof(double);
sequence->add(geos::Coordinate(*x,*y));
sequence->add(GEOS_GEOM::Coordinate(*x,*y));
}
return geosGeometryFactory->createLineString(sequence);
}
case QGis::WKBMultiLineString:
{
std::vector<geos::Geometry*>* lines=new std::vector<geos::Geometry*>;
std::vector<GEOS_GEOM::Geometry*>* lines=new std::vector<GEOS_GEOM::Geometry*>;
numLineStrings = (int) (mGeometry[5]);
ptr = mGeometry + 9;
for (jdx = 0; jdx < numLineStrings; jdx++)
{
geos::DefaultCoordinateSequence* sequence=new geos::DefaultCoordinateSequence();
GEOS_GEOM::DefaultCoordinateSequence* sequence=new GEOS_GEOM::DefaultCoordinateSequence();
// each of these is a wbklinestring so must handle as such
lsb = *ptr;
ptr += 5; // skip type since we know its 2
@ -2528,7 +2536,7 @@ geos::Geometry* QgsGeometry::geosGeometry() const
ptr += sizeof(double);
y = (double *) ptr;
ptr += sizeof(double);
sequence->add(geos::Coordinate(*x,*y));
sequence->add(GEOS_GEOM::Coordinate(*x,*y));
}
lines->push_back(geosGeometryFactory->createLineString(sequence));
}
@ -2543,15 +2551,15 @@ geos::Geometry* QgsGeometry::geosGeometry() const
numRings = (int *) (mGeometry + 1 + sizeof(int));
ptr = mGeometry + 1 + 2 * sizeof(int);
geos::LinearRing* outer=0;
std::vector<geos::Geometry*>* inner=new std::vector<geos::Geometry*>;
GEOS_GEOM::LinearRing* outer=0;
std::vector<GEOS_GEOM::Geometry*>* inner=new std::vector<GEOS_GEOM::Geometry*>;
for (idx = 0; idx < *numRings; idx++)
{
#ifdef QGISDEBUG
qWarning("Ring nr: "+QString::number(idx));
#endif
geos::DefaultCoordinateSequence* sequence=new geos::DefaultCoordinateSequence();
GEOS_GEOM::DefaultCoordinateSequence* sequence=new GEOS_GEOM::DefaultCoordinateSequence();
// get number of points in the ring
nPoints = (int *) ptr;
ptr += 4;
@ -2562,9 +2570,9 @@ geos::Geometry* QgsGeometry::geosGeometry() const
ptr += sizeof(double);
y = (double *) ptr;
ptr += sizeof(double);
sequence->add(geos::Coordinate(*x,*y));
sequence->add(GEOS_GEOM::Coordinate(*x,*y));
}
geos::LinearRing* ring=geosGeometryFactory->createLinearRing(sequence);
GEOS_GEOM::LinearRing* ring=geosGeometryFactory->createLinearRing(sequence);
if(idx==0)
{
outer=ring;
@ -2582,7 +2590,7 @@ geos::Geometry* QgsGeometry::geosGeometry() const
#ifdef QGISDEBUG
qWarning("Multipolygon found");
#endif
std::vector<geos::Geometry *> *polygons=new std::vector<geos::Geometry *>;
std::vector<GEOS_GEOM::Geometry *> *polygons=new std::vector<GEOS_GEOM::Geometry *>;
// get the number of polygons
ptr = mGeometry + 5;
numPolygons = (int *) ptr;
@ -2592,8 +2600,8 @@ geos::Geometry* QgsGeometry::geosGeometry() const
#ifdef QGISDEBUG
//qWarning("Polygon nr: "+QString::number(kdx));
#endif
geos::LinearRing* outer=0;
std::vector<geos::Geometry*>* inner=new std::vector<geos::Geometry*>;
GEOS_GEOM::LinearRing* outer=0;
std::vector<GEOS_GEOM::Geometry*>* inner=new std::vector<GEOS_GEOM::Geometry*>;
//skip the endian and mGeometry type info and
// get number of rings in the polygon
@ -2605,7 +2613,7 @@ geos::Geometry* QgsGeometry::geosGeometry() const
#ifdef QGISDEBUG
//qWarning("Ring nr: "+QString::number(idx));
#endif
geos::DefaultCoordinateSequence* sequence=new geos::DefaultCoordinateSequence();
GEOS_GEOM::DefaultCoordinateSequence* sequence=new GEOS_GEOM::DefaultCoordinateSequence();
// get number of points in the ring
nPoints = (int *) ptr;
ptr += 4;
@ -2616,9 +2624,9 @@ geos::Geometry* QgsGeometry::geosGeometry() const
ptr += sizeof(double);
y = (double *) ptr;
ptr += sizeof(double);
sequence->add(geos::Coordinate(*x,*y));
sequence->add(GEOS_GEOM::Coordinate(*x,*y));
}
geos::LinearRing* ring=geosGeometryFactory->createLinearRing(sequence);
GEOS_GEOM::LinearRing* ring=geosGeometryFactory->createLinearRing(sequence);
if(idx==0)
{
outer=ring;
@ -2687,16 +2695,16 @@ bool QgsGeometry::exportGeosToWkb() const
switch (mGeos->getGeometryTypeId())
{
case geos::GEOS_POINT: // a point
case GEOS_GEOM::GEOS_POINT: // a point
{
// TODO
break;
} // case geos::GEOS_POINT
} // case GEOS_GEOM::GEOS_POINT
case geos::GEOS_LINESTRING: // a linestring
case GEOS_GEOM::GEOS_LINESTRING: // a linestring
{
#ifdef QGISDEBUG
std::cout << "QgsGeometry::exportGeosToWkb: Got a geos::GEOS_LINESTRING." << std::endl;
std::cout << "QgsGeometry::exportGeosToWkb: Got a GEOS_GEOM::GEOS_LINESTRING." << std::endl;
#endif
// TODO
@ -2726,8 +2734,8 @@ bool QgsGeometry::exportGeosToWkb() const
memcpy(ptr, &numPoints, 4);
ptr += 4;
geos::LineString* geosls = static_cast<geos::LineString*>(mGeos);
const geos::CoordinateSequence* sequence = geosls->getCoordinatesRO();
GEOS_GEOM::LineString* geosls = static_cast<GEOS_GEOM::LineString*>(mGeos);
const GEOS_GEOM::CoordinateSequence* sequence = geosls->getCoordinatesRO();
// assign points
for (int n = 0; n < numPoints; n++)
@ -2750,20 +2758,20 @@ bool QgsGeometry::exportGeosToWkb() const
return true;
// TODO: Deal with endian-ness
} // case geos::GEOS_LINESTRING
} // case GEOS_GEOM::GEOS_LINESTRING
case geos::GEOS_LINEARRING: // a linear ring (linestring with 1st point == last point)
case GEOS_GEOM::GEOS_LINEARRING: // a linear ring (linestring with 1st point == last point)
{
// TODO
break;
} // case geos::GEOS_LINEARRING
} // case GEOS_GEOM::GEOS_LINEARRING
case geos::GEOS_POLYGON: // a polygon
case GEOS_GEOM::GEOS_POLYGON: // a polygon
{
int geometrySize;
double x, y; //point coordinates
geos::Polygon* thePolygon = dynamic_cast<geos::Polygon*>(mGeos);
const geos::LineString* theRing = 0;
GEOS_GEOM::Polygon* thePolygon = dynamic_cast<GEOS_GEOM::Polygon*>(mGeos);
const GEOS_GEOM::LineString* theRing = 0;
int nPointsInRing = 0;
if(thePolygon)
@ -2808,7 +2816,7 @@ bool QgsGeometry::exportGeosToWkb() const
nPointsInRing = theRing->getNumPoints();
memcpy(&mGeometry[position], &nPointsInRing, sizeof(int));
position += sizeof(int);
const geos::CoordinateSequence* ringSequence = theRing->getCoordinatesRO();
const GEOS_GEOM::CoordinateSequence* ringSequence = theRing->getCoordinatesRO();
//for(int j = 0; j < nPointsInRing; ++j)
for(int j = 0; j <ringSequence->getSize(); ++j)
{
@ -2851,31 +2859,31 @@ bool QgsGeometry::exportGeosToWkb() const
//error
}
break;
} // case geos::GEOS_POLYGON
} // case GEOS_GEOM::GEOS_POLYGON
case geos::GEOS_MULTIPOINT: // a collection of points
case GEOS_GEOM::GEOS_MULTIPOINT: // a collection of points
{
// TODO
break;
} // case geos::GEOS_MULTIPOINT
} // case GEOS_GEOM::GEOS_MULTIPOINT
case geos::GEOS_MULTILINESTRING: // a collection of linestrings
case GEOS_GEOM::GEOS_MULTILINESTRING: // a collection of linestrings
{
// TODO
break;
} // case geos::GEOS_MULTILINESTRING
} // case GEOS_GEOM::GEOS_MULTILINESTRING
case geos::GEOS_MULTIPOLYGON: // a collection of polygons
case GEOS_GEOM::GEOS_MULTIPOLYGON: // a collection of polygons
{
// TODO
break;
} // case geos::GEOS_MULTIPOLYGON
} // case GEOS_GEOM::GEOS_MULTIPOLYGON
case geos::GEOS_GEOMETRYCOLLECTION: // a collection of heterogeneus geometries
case GEOS_GEOM::GEOS_GEOMETRYCOLLECTION: // a collection of heterogeneus geometries
{
// TODO
break;
} // case geos::GEOS_GEOMETRYCOLLECTION
} // case GEOS_GEOM::GEOS_GEOMETRYCOLLECTION
} // switch (mGeos->getGeometryTypeId())

View File

@ -20,6 +20,15 @@ email : morb at ozemail dot com dot au
#include <qstring.h>
#include <geos.h>
#if GEOS_VERSION_MAJOR < 3
#define GEOS_GEOM geos
#define GEOS_IO geos
#define GEOS_UTIL geos
#else
#define GEOS_GEOM geos::geom
#define GEOS_IO geos::io
#define GEOS_UTIL geos::util
#endif
#include "qgsgeometryvertexindex.h"
#include "qgspoint.h"
@ -80,7 +89,7 @@ class QgsGeometry {
/**
Set the geometry, feeding in a geometry in GEOS format.
*/
void setGeos(geos::Geometry* geos);
void setGeos(GEOS_GEOM::Geometry* geos);
/**
Returns the vertex closest to the given point
@ -188,7 +197,7 @@ class QgsGeometry {
bool contains(QgsPoint* p) const;
/**Creates a geos geometry from this features geometry. Note, that the returned object needs to be deleted*/
geos::Geometry* geosGeometry() const;
GEOS_GEOM::Geometry* geosGeometry() const;
@ -197,7 +206,7 @@ class QgsGeometry {
// Private static members
//! This is used to create new GEOS variables.
static geos::GeometryFactory* geosGeometryFactory;
static GEOS_GEOM::GeometryFactory* geosGeometryFactory;
// Private variables
@ -219,7 +228,7 @@ class QgsGeometry {
mutable QString mWkt;
/** cached GEOS version of this geometry */
mutable geos::Geometry* mGeos;
mutable GEOS_GEOM::Geometry* mGeos;
/** If the geometry has been set since the last conversion to WKB **/
mutable bool mDirtyWkb;
@ -270,8 +279,8 @@ class QgsGeometry {
*/
bool insertVertexBefore(double x, double y,
int beforeVertex,
const geos::CoordinateSequence* old_sequence,
geos::CoordinateSequence** new_sequence);
const GEOS_GEOM::CoordinateSequence* old_sequence,
GEOS_GEOM::CoordinateSequence** new_sequence);
}; // class QgsGeometry

View File

@ -60,6 +60,15 @@
#include <QVBoxLayout>
#include <QWhatsThis>
#include <QtGlobal>
//
// Mac OS X Includes
// Must include before GEOS 3 due to unqualified use of 'Point'
//
#ifdef Q_OS_MACX
#include <ApplicationServices/ApplicationServices.h>
#endif
//
// QGIS Specific Includes
//
@ -136,10 +145,6 @@
//
// Conditional Includes
//
#ifdef Q_OS_MACX
#include <ApplicationServices/ApplicationServices.h>
#endif
#ifdef HAVE_POSTGRESQL
#include "qgsdbsourceselect.h"
#endif

View File

@ -78,7 +78,7 @@ BUILT_SOURCES = $(spit_MOC) $(spit_UI) $(spitplugin_la_MOC)
spitplugin_la_LIBADD = $(QT_LDADD) $(PG_LIB) $(GDAL_LDADD) ../../core/libqgis_core.la
spitplugin_la_LDFLAGS = -avoid-version -module
spitplugin_la_CXXFLAGS = $(CXXFLAGS) $(EXTRA_CXXFLAGS) $(GEOS_FLAGS) $(GDAL_CFLAGS) $(QT_CXXFLAGS) $(PG_INC) -I../../gui -I../../ui -I../../core
spitplugin_la_CXXFLAGS = $(CXXFLAGS) $(EXTRA_CXXFLAGS) $(GEOS_CFLAGS) $(GDAL_CFLAGS) $(QT_CXXFLAGS) $(PG_INC) -I../../gui -I../../ui -I../../core
spit_LDADD = $(QT_LDADD) $(PG_LIB) $(GDAL_LDADD) ../../core/libqgis_core.la ../../gui/libqgis_gui.la

View File

@ -143,11 +143,11 @@ QgsOgrProvider::QgsOgrProvider(QString const & uri)
minmaxcache[i]=new double[2];
}
// create the geos objects
geometryFactory = new geos::GeometryFactory();
geometryFactory = new GEOS_GEOM::GeometryFactory();
assert(geometryFactory!=0);
// create the reader
// std::cerr << "Creating the wktReader\n";
wktReader = new geos::WKTReader(geometryFactory);
wktReader = new GEOS_IO::WKTReader(geometryFactory);
mNumericalTypes.push_back("Integer");
mNumericalTypes.push_back("Real");
@ -415,13 +415,13 @@ QgsFeature *QgsOgrProvider::getNextFeature(bool fetchAttributes)
if(mUseIntersect)
{
geos::Geometry *geosGeom = 0;
GEOS_GEOM::Geometry *geosGeom = 0;
geosGeom=f->geosGeometry();
assert(geosGeom != 0);
char *sWkt = new char[2 * mSelectionRectangle->WkbSize()];
mSelectionRectangle->exportToWkt(&sWkt);
geos::Geometry *geosRect = wktReader->read(sWkt);
GEOS_GEOM::Geometry *geosRect = wktReader->read(sWkt);
assert(geosRect != 0);
bool intersection = false;
@ -430,9 +430,13 @@ QgsFeature *QgsOgrProvider::getNextFeature(bool fetchAttributes)
if(geosGeom->intersects(geosRect))
intersection = true;
}
catch (geos::TopologyException* e)
catch (GEOS_UTIL::TopologyException* e)
{
#if GEOS_VERSION_MAJOR < 3
QString error = e->toString().c_str();
#else
QString error = e->what();
#endif
QgsLogger::warning("GEOS: " + error);
}
@ -481,14 +485,14 @@ QgsFeature *QgsOgrProvider::getNextFeature(bool fetchAttributes)
geom = fet->GetGeometryRef();
char *wkt = new char[2 * geom->WkbSize()];
geom->exportToWkt(&wkt);
geos::Geometry *geosGeom = wktReader->read(wkt);
GEOS_GEOM::Geometry *geosGeom = wktReader->read(wkt);
assert(geosGeom != 0);
QgsDebugMsg("Geometry type of geos object is : " + geosGeom->getGeometryType());
// get the selection rectangle and create a geos geometry from it
char *sWkt = new char[2 * mSelectionRectangle->WkbSize()];
mSelectionRectangle->exportToWkt(&sWkt);
std::cerr << "Passing " << sWkt << " to goes\n";
geos::Geometry *geosRect = wktReader->read(sWkt);
GEOS_GEOM::Geometry *geosRect = wktReader->read(sWkt);
assert(geosRect != 0);
std::cerr << "About to apply intersects function\n";
// test the geometry

View File

@ -18,7 +18,17 @@ email : sherman at mrcc.com
#include "qgsrect.h"
#include "qgsvectordataprovider.h"
#include <geos.h>
#if GEOS_VERSION_MAJOR < 3
#define GEOS_GEOM geos
#define GEOS_IO geos
#define GEOS_UTIL geos
#else
#define GEOS_GEOM geos::geom
#define GEOS_IO geos::io
#define GEOS_UTIL geos::util
#endif
#include <ogr_spatialref.h>
#include <ogrsf_frmts.h>
@ -285,8 +295,8 @@ class QgsOgrProvider:public QgsVectorDataProvider
/**Deletes one feature*/
bool deleteFeature(int id);
//! The geometry factory
geos::GeometryFactory *geometryFactory;
GEOS_GEOM::GeometryFactory *geometryFactory;
//! The well known text reader
geos::WKTReader *wktReader;
GEOS_IO::WKTReader *wktReader;
};

View File

@ -55,7 +55,7 @@ QgsWFSProvider::~QgsWFSProvider()
{
delete mSelectedFeatures;
delete mSourceSRS;
for(std::list<std::pair<geos::Envelope*, QgsFeature*> >::iterator it = mEnvelopesAndFeatures.begin();\
for(std::list<std::pair<GEOS_GEOM::Envelope*, QgsFeature*> >::iterator it = mEnvelopesAndFeatures.begin();\
it != mEnvelopesAndFeatures.end(); ++it)
{
delete it->first;
@ -149,9 +149,14 @@ std::vector<QgsField> const & QgsWFSProvider::fields() const
void QgsWFSProvider::reset()
{
geos::Envelope e(mExtent.xMin(), mExtent.xMax(), mExtent.yMin(), mExtent.yMax());
GEOS_GEOM::Envelope e(mExtent.xMin(), mExtent.xMax(), mExtent.yMin(), mExtent.yMax());
delete mSelectedFeatures;
#if GEOS_VERSION_MAJOR < 3
mSelectedFeatures = mSpatialIndex.query(&e);
#else
#warning *** FIXME: Need to revise use of mSelectedFeatures for GEOS 3.0.0
mSpatialIndex.query(&e, *mSelectedFeatures);
#endif
if(mSelectedFeatures)
{
mFeatureIterator = mSelectedFeatures->begin();
@ -242,8 +247,13 @@ void QgsWFSProvider::select(QgsRect *mbr, bool useIntersect)
mUseIntersect = useIntersect;
delete mSelectedFeatures;
mSpatialFilter = *mbr;
geos::Envelope filter(mbr->xMin(), mbr->xMax(), mbr->yMin(), mbr->yMax());
GEOS_GEOM::Envelope filter(mbr->xMin(), mbr->xMax(), mbr->yMin(), mbr->yMax());
#if GEOS_VERSION_MAJOR < 3
mSelectedFeatures = mSpatialIndex.query(&filter);
#else
#warning *** FIXME: Need to revise use of mSelectedFeatures for GEOS 3.0.0
mSpatialIndex.query(&filter, *mSelectedFeatures);
#endif
mFeatureIterator = mSelectedFeatures->begin();
}
@ -750,7 +760,7 @@ int QgsWFSProvider::getFeaturesFromGML2(const QDomElement& wfsCollectionElement,
int wkbSize = 0;
QGis::WKBTYPE currentType;
QgsRect featureBBox;
geos::Envelope* geosBBox;
GEOS_GEOM::Envelope* geosBBox;
mFeatureCount = 0;
for(int i = 0; i < featureTypeNodeList.size(); ++i)
@ -783,7 +793,7 @@ int QgsWFSProvider::getFeaturesFromGML2(const QDomElement& wfsCollectionElement,
{
//insert bbox and pointer to feature into search tree
featureBBox = f->boundingBox();
geosBBox = new geos::Envelope(featureBBox.xMin(), featureBBox.xMax(), featureBBox.yMin(), featureBBox.yMax());
geosBBox = new GEOS_GEOM::Envelope(featureBBox.xMin(), featureBBox.xMax(), featureBBox.yMin(), featureBBox.yMax());
mSpatialIndex.insert(geosBBox, (void*)f);
mEnvelopesAndFeatures.push_back(std::make_pair(geosBBox, f));
++mFeatureCount;

View File

@ -22,7 +22,13 @@
#include "qgis.h"
#include "qgsrect.h"
#include "qgsvectordataprovider.h"
#include <indexStrtree.h>
#if GEOS_VERSION_MAJOR < 3
#define GEOS_INDEX_STRTREE geos
#else
#define GEOS_INDEX_STRTREE geos::index::strtree
#endif
class QgsRect;
@ -85,9 +91,9 @@ class QgsWFSProvider: public QgsVectorDataProvider
/**Flag if precise intersection test is needed. Otherwise, every feature is returned (even if a filter is set)*/
bool mUseIntersect;
/**A spatial index for fast access to a feature subset*/
geos::STRtree mSpatialIndex;
GEOS_INDEX_STRTREE::STRtree mSpatialIndex;
/**Stores all the inserted rectangles and features. This is used to clean up the memory in the destructor*/
std::list< std::pair<geos::Envelope*, QgsFeature*> > mEnvelopesAndFeatures;
std::list< std::pair<GEOS_GEOM::Envelope*, QgsFeature*> > mEnvelopesAndFeatures;
/**Vector where the QgsFeature* of a query are inserted*/
std::vector<void*>* mSelectedFeatures;
/**Iterator on the feature vector for use in reset(), getNextFeature(), etc...*/