Skip to content
Permalink
Browse files

Remove GEOS C++ lib dependency

  • Loading branch information
manisandro committed Oct 7, 2015
1 parent bf9fe7c commit 643eb1000d769b7835f1669bd557701ae04153d2
@@ -18,7 +18,6 @@ sudo apt-get install --force-yes --no-install-recommends --no-install-suggests \
libexpat1-dev \
libfcgi-dev \
libgdal1-dev \
libgeos++-dev \
libgeos-dev \
libgsl0-dev \
libpq-dev \
@@ -23,16 +23,11 @@ IF(WIN32)
IF (MINGW)
FIND_PATH(GEOS_INCLUDE_DIR geos_c.h /usr/local/include /usr/include c:/msys/local/include)
FIND_LIBRARY(GEOS_LIBRARY NAMES geos_c PATHS /usr/local/lib /usr/lib c:/msys/local/lib)
FIND_LIBRARY(GEOS_CPP_LIBRARY NAMES geos PATHS /usr/local/lib /usr/lib c:/msys/local/lib)
ENDIF (MINGW)

IF (MSVC)
FIND_PATH(GEOS_INCLUDE_DIR geos_c.h $ENV{LIB_DIR}/include $ENV{INCLUDE})
FIND_LIBRARY(GEOS_LIBRARY NAMES geos_c_i geos_c PATHS
"$ENV{LIB_DIR}/lib"
$ENV{LIB}
)
FIND_LIBRARY(GEOS_CPP_LIBRARY NAMES geos PATHS
FIND_LIBRARY(GEOS_LIBRARY NAMES geos geos_c_i geos_c PATHS
"$ENV{LIB_DIR}/lib"
$ENV{LIB}
)
@@ -72,7 +67,6 @@ ELSE(WIN32)

IF(CYGWIN)
FIND_LIBRARY(GEOS_LIBRARY NAMES geos_c PATHS /usr/lib /usr/local/lib)
FIND_LIBRARY(GEOS_CPP_LIBRARY NAMES geos PATHS /usr/lib /usr/local/lib)
ENDIF(CYGWIN)

IF (NOT GEOS_INCLUDE_DIR OR NOT GEOS_LIBRARY OR NOT GEOS_CONFIG)
@@ -138,16 +132,12 @@ ELSE(WIN32)
#MESSAGE("DBG GEOS_CONFIG_LIBS=${GEOS_CONFIG_LIBS}")
#MESSAGE("DBG GEOS_LIB_NAME_WITH_PREFIX=${GEOS_LIB_NAME_WITH_PREFIX}")
SET(GEOS_LIB_NAME_WITH_PREFIX -lgeos_c CACHE STRING INTERNAL)
SET(GEOS_CPP_LIB_NAME_WITH_PREFIX -lgeos CACHE STRING INTERNAL)

## remove prefix -l because we need the pure name

IF (GEOS_LIB_NAME_WITH_PREFIX)
STRING(REGEX REPLACE "[-][l]" "" GEOS_LIB_NAME ${GEOS_LIB_NAME_WITH_PREFIX} )
ENDIF (GEOS_LIB_NAME_WITH_PREFIX)
IF (GEOS_CPP_LIB_NAME_WITH_PREFIX)
STRING(REGEX REPLACE "[-][l]" "" GEOS_CPP_LIB_NAME ${GEOS_CPP_LIB_NAME_WITH_PREFIX} )
ENDIF (GEOS_CPP_LIB_NAME_WITH_PREFIX)
#MESSAGE("DBG GEOS_LIB_NAME=${GEOS_LIB_NAME}")

IF (APPLE)
@@ -156,11 +146,9 @@ ELSE(WIN32)
# while still preserving user setting if given
# ***FIXME*** need to improve framework check so below not needed
SET(GEOS_LIBRARY ${GEOS_LINK_DIRECTORIES}/lib${GEOS_LIB_NAME}.dylib CACHE STRING INTERNAL FORCE)
SET(GEOS_CPP_LIBRARY ${GEOS_LINK_DIRECTORIES}/lib${GEOS_CPP_LIB_NAME}.dylib CACHE STRING INTERNAL FORCE)
ENDIF (NOT GEOS_LIBRARY)
ELSE (APPLE)
SET(GEOS_LIBRARY ${GEOS_LINK_DIRECTORIES}/lib${GEOS_LIB_NAME}.so CACHE STRING INTERNAL)
SET(GEOS_CPP_LIBRARY ${GEOS_LINK_DIRECTORIES}/lib${GEOS_CPP_LIB_NAME}.so CACHE STRING INTERNAL)
ENDIF (APPLE)
#MESSAGE("DBG GEOS_LIBRARY=${GEOS_LIBRARY}")

@@ -334,8 +334,8 @@ STRING(REPLACE "\)" "\\)" JSON_HELP_FILES "${JSON_HELP_FILES}")
ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/qgsexpression_texts.cpp
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/scripts/process_function_template.py ${CMAKE_CURRENT_BINARY_DIR}/qgsexpression_texts.cpp.temp
COMMAND ${CMAKE_COMMAND} -DSRC=${CMAKE_CURRENT_BINARY_DIR}/qgsexpression_texts.cpp.temp -DDST=${CMAKE_CURRENT_SOURCE_DIR}/qgsexpression_texts.cpp -P ${CMAKE_SOURCE_DIR}/cmake/CopyIfChanged.cmake
DEPENDS ${JSON_HELP_FILES}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
DEPENDS ${JSON_HELP_FILES}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)

IF(ENABLE_MODELTEST)
@@ -756,12 +756,6 @@ SET(QGIS_CORE_HDRS
geometry/qgspointv2.h
)

IF(GEOS_CPP_LIBRARY)
SET(QGIS_CORE_SRCS ${QGIS_CORE_SRCS} geosextra/geos_c_extra.cpp)
SET(QGIS_CORE_HDRS ${QGIS_CORE_HDRS} geosextra/geos_c_extra.h)
ADD_DEFINITIONS("-DHAVE_GEOS_CPP")
ENDIF(GEOS_CPP_LIBRARY)

IF (QT_MOBILITY_LOCATION_FOUND OR Qt5Positioning_FOUND)
SET(QGIS_CORE_HDRS ${QGIS_CORE_HDRS}
gps/qgsqtlocationconnection.h
@@ -885,10 +879,6 @@ TARGET_LINK_LIBRARIES(qgis_core
${SPATIALITE_LIBRARY}
)

IF(GEOS_CPP_LIBRARY)
TARGET_LINK_LIBRARIES(qgis_core ${GEOS_CPP_LIBRARY})
ENDIF(GEOS_CPP_LIBRARY)

IF (Qt5Positioning_FOUND)
TARGET_LINK_LIBRARIES(qgis_core
Qt5::Positioning
@@ -116,36 +116,11 @@ class GEOSGeomScopedPtr

QgsGeos::QgsGeos( const QgsAbstractGeometryV2* geometry, int precision ) : QgsGeometryEngine( geometry ), mGeos( 0 ), mGeosPrepared( 0 )
{
#if defined(HAVE_GEOS_CPP) || defined(HAVE_GEOS_CAPI_PRECISION_MODEL)
double prec = qPow( 10, -precision );
mPrecisionModel = GEOSPrecisionModel_createFixed( 1.f / prec );
mPrecisionReducer = GEOSGeometryPrecisionReducer_create( mPrecisionModel );
#else
Q_UNUSED( precision )
#endif
cacheGeos();
}

QgsGeos::~QgsGeos()
{
#if defined(HAVE_GEOS_CPP) || defined(HAVE_GEOS_CAPI_PRECISION_MODEL)
GEOSGeom_destroy_r( geosinit.ctxt, mGeos );
GEOSPreparedGeom_destroy_r( geosinit.ctxt, mGeosPrepared );
GEOSGeometryPrecisionReducer_destroy( mPrecisionReducer );
GEOSPrecisionModel_destroy( mPrecisionModel );
#endif
}

inline GEOSGeometry* QgsGeos::getReducedGeometry( GEOSGeometry* geom ) const
{
#if defined(HAVE_GEOS_CPP) || defined(HAVE_GEOS_CAPI_PRECISION_MODEL)
//reduce precision
GEOSGeometry* reduced = GEOSGeometryPrecisionReducer_reduce( mPrecisionReducer, geom );
GEOSGeom_destroy_r( geosinit.ctxt, geom );
return reduced;
#else
return geom;
#endif
}

void QgsGeos::geometryChanged()
@@ -174,16 +149,7 @@ void QgsGeos::cacheGeos() const
return;
}

GEOSGeometry* g = asGeos( mGeometry );
#if defined(HAVE_GEOS_CPP) || defined(HAVE_GEOS_CAPI_PRECISION_MODEL)
if ( g )
{
mGeos = GEOSGeometryPrecisionReducer_reduce( mPrecisionReducer, g );
GEOSGeom_destroy_r( geosinit.ctxt, g );
}
#else
mGeos = g;
#endif
mGeos = asGeos( mGeometry );
}

QgsAbstractGeometryV2* QgsGeos::intersection( const QgsAbstractGeometryV2& geom, QString* errorMsg ) const
@@ -208,7 +174,7 @@ QgsAbstractGeometryV2* QgsGeos::combine( const QList< const QgsAbstractGeometryV
geosGeometries.resize( geomList.size() );
for ( int i = 0; i < geomList.size(); ++i )
{
geosGeometries[i] = getReducedGeometry( asGeos( geomList.at( i ) ) );
geosGeometries[i] = asGeos( geomList.at( i ) );
}

GEOSGeometry* geomUnion = 0;
@@ -1065,7 +1031,7 @@ QgsAbstractGeometryV2* QgsGeos::overlay( const QgsAbstractGeometryV2& geom, Over
return 0;
}

GEOSGeomScopedPtr geosGeom( getReducedGeometry( asGeos( &geom ) ) );
GEOSGeomScopedPtr geosGeom( asGeos( &geom ) );
if ( !geosGeom )
{
return 0;
@@ -1125,7 +1091,7 @@ bool QgsGeos::relation( const QgsAbstractGeometryV2& geom, Relation r, QString*
return false;
}

GEOSGeomScopedPtr geosGeom( getReducedGeometry( asGeos( &geom ) ) );
GEOSGeomScopedPtr geosGeom( asGeos( &geom ) );
if ( !geosGeom )
{
return false;
@@ -1382,7 +1348,7 @@ bool QgsGeos::isEqual( const QgsAbstractGeometryV2& geom, QString* errorMsg ) co

try
{
GEOSGeomScopedPtr geosGeom( getReducedGeometry( asGeos( &geom ) ) );
GEOSGeomScopedPtr geosGeom( asGeos( &geom ) );
if ( !geosGeom )
{
return false;
@@ -19,9 +19,6 @@ email : marco.hugentobler at sourcepole dot com
#include "qgsgeometryengine.h"
#include "qgspointv2.h"
#include <geos_c.h>
#if defined(HAVE_GEOS_CPP) && !defined(HAVE_GEOS_CAPI_PRECISION_MODEL)
#include "geosextra/geos_c_extra.h"
#endif

class QgsLineStringV2;
class QgsPolygonV2;
@@ -92,11 +89,6 @@ class CORE_EXPORT QgsGeos: public QgsGeometryEngine
private:
mutable GEOSGeometry* mGeos;
const GEOSPreparedGeometry* mGeosPrepared;
#if defined(HAVE_GEOS_CPP) || defined(HAVE_GEOS_CAPI_PRECISION_MODEL)
//precision reducer
GEOSPrecisionModel* mPrecisionModel;
GEOSGeometryPrecisionReducer* mPrecisionReducer;
#endif

enum Overlay
{
@@ -144,9 +136,6 @@ class CORE_EXPORT QgsGeos: public QgsGeometryEngine
static int lineContainedInLine( const GEOSGeometry* line1, const GEOSGeometry* line2 );
static int pointContainedInLine( const GEOSGeometry* point, const GEOSGeometry* line );
static int geomDigits( const GEOSGeometry* geom );

private:
inline GEOSGeometry *getReducedGeometry( GEOSGeometry* geom ) const;
};

/// @cond

This file was deleted.

This file was deleted.

@@ -15,9 +15,6 @@
#include "geometry/qgsgeometry.h"
#include "../utils/qgsgeomutils.h"
#include "geos_c.h"
#if defined(HAVE_GEOS_CPP) || !defined(HAVE_GEOS_CAPI_PRECISION_MODEL)
#include <geosextra/geos_c_extra.h>
#endif
#include <QApplication>

class QgsGeometryCheckError;

0 comments on commit 643eb10

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