Skip to content

Commit

Permalink
Merge pull request #2302 from manisandro/geometry_plugins
Browse files Browse the repository at this point in the history
Geometry Checker and Geometry Snapper plugins
  • Loading branch information
mhugent committed Sep 25, 2015
2 parents e655c26 + 2ea4ee9 commit 8cec2c9
Show file tree
Hide file tree
Showing 144 changed files with 10,474 additions and 329 deletions.
2 changes: 1 addition & 1 deletion ci/travis/linux/before_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ sudo apt-get update -qq
sudo apt-get install --force-yes --no-install-recommends --no-install-suggests \
bison cmake cmake-data doxygen flex git graphviz \
grass-dev grass7-dev libexpat1-dev libfcgi-dev \
libgdal1-dev libgeos-dev libgsl0-dev libpq-dev \
libgdal1-dev libgeos-dev libgeos++-dev libgsl0-dev libpq-dev \
libproj-dev libqscintilla2-dev libqt4-dev \
libqt4-opengl-dev libqt4-sql-sqlite libqtwebkit-dev \
libqwt-dev libspatialindex-dev libspatialite-dev \
Expand Down
14 changes: 13 additions & 1 deletion cmake/FindGEOS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,16 @@ 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 geos_c_i geos_c PATHS
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
"$ENV{LIB_DIR}/lib"
$ENV{LIB}
)
Expand Down Expand Up @@ -67,6 +72,7 @@ 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)
Expand Down Expand Up @@ -132,12 +138,16 @@ 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)
Expand All @@ -146,9 +156,11 @@ 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}")

Expand Down
18 changes: 16 additions & 2 deletions python/core/geometry/qgsabstractgeometryv2.sip
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,16 @@ struct QgsVertexId
};

QgsVertexId();
QgsVertexId( int _part, int _ring, int _vertex, VertexType _type );
QgsVertexId( int _part, int _ring, int _vertex, VertexType _type);

bool isValid() const;
bool operator==( const QgsVertexId& other ) const;
bool operator!=( const QgsVertexId& other ) const;
bool partEqual( const QgsVertexId& o ) const;
bool ringEqual( const QgsVertexId& o ) const;
bool vertexEqual( const QgsVertexId& o ) const;
bool isValid(const QgsAbstractGeometryV2* geom) const;

int part;
int ring;
int vertex;
Expand Down Expand Up @@ -101,7 +108,7 @@ class QgsAbstractGeometryV2

virtual void coordinateSequence( QList< QList< QList< QgsPointV2 > > >& coord /Out/ ) const = 0;
int nCoordinates() const;
QgsPointV2 vertexAt( const QgsVertexId& id ) const;
virtual QgsPointV2 vertexAt( const QgsVertexId& id ) const = 0;
virtual double closestSegment( const QgsPointV2& pt, QgsPointV2& segmentPt, QgsVertexId& vertexAfter, bool* leftOf, double epsilon ) const = 0;

//low-level editing
Expand All @@ -113,11 +120,18 @@ class QgsAbstractGeometryV2
virtual double length() const;
virtual double area() const;

/** Returns the centroid of the geometry*/
virtual QgsPointV2 centroid() const;

virtual bool hasCurvedSegments() const;
/** Returns a geometry without curves. Caller takes ownership*/
virtual QgsAbstractGeometryV2* segmentize() const /Factory/;

/** Returns approximate rotation angle for a vertex. Usually average angle between adjacent segments.
@return rotation in radians, clockwise from north*/
virtual double vertexAngle( const QgsVertexId& vertex ) const = 0;

virtual int vertexCount(int part = 0, int ring = 0) const = 0;
virtual int ringCount(int part = 0) const = 0;
virtual int partCount() const = 0;
};
2 changes: 1 addition & 1 deletion python/core/geometry/qgscircularstringv2.sip
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class QgsCircularStringV2: public QgsCurveV2

virtual QString geometryType() const;
virtual int dimension() const;
virtual QgsAbstractGeometryV2* clone() const;
virtual QgsCircularStringV2* clone() const;
virtual void clear();

virtual QgsRectangle calculateBoundingBox() const;
Expand Down
2 changes: 1 addition & 1 deletion python/core/geometry/qgscompoundcurvev2.sip
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class QgsCompoundCurveV2: public QgsCurveV2

virtual QString geometryType() const;
virtual int dimension() const;
virtual QgsAbstractGeometryV2* clone() const;
virtual QgsCompoundCurveV2* clone() const;
virtual void clear();

virtual QgsRectangle calculateBoundingBox() const;
Expand Down
11 changes: 7 additions & 4 deletions python/core/geometry/qgscurvepolygonv2.sip
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class QgsCurvePolygonV2: public QgsSurfaceV2

virtual QString geometryType() const;
virtual int dimension() const;
virtual QgsAbstractGeometryV2* clone() const;
virtual QgsCurvePolygonV2* clone() const;
void clear();


Expand All @@ -30,14 +30,13 @@ class QgsCurvePolygonV2: public QgsSurfaceV2
//surface interface
virtual double area() const;
virtual double length() const;
QgsPointV2 centroid() const;
QgsPointV2 pointOnSurface() const;
QgsPolygonV2* surfaceToPolygon() const;

//curve polygon interface
int numInteriorRings() const;
const QgsCurveV2* exteriorRing() const;
const QgsCurveV2* interiorRing( int i ) const;
QgsCurveV2* exteriorRing() const;
QgsCurveV2* interiorRing( int i ) const;
virtual QgsPolygonV2* toPolygon() const;

/** Sets exterior ring (takes ownership)*/
Expand Down Expand Up @@ -67,4 +66,8 @@ class QgsCurvePolygonV2: public QgsSurfaceV2
@param vertex the vertex id
@return rotation in radians, clockwise from north*/
double vertexAngle( const QgsVertexId& vertex ) const;

virtual int vertexCount(int part = 0, int ring = 0) const;
virtual int ringCount(int part = 0) const;
virtual int partCount() const;
};
5 changes: 5 additions & 0 deletions python/core/geometry/qgscurvev2.sip
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,9 @@ class QgsCurveV2: public QgsAbstractGeometryV2

/** Returns a geometry without curves. Caller takes ownership*/
QgsAbstractGeometryV2* segmentize() const /Factory/;

virtual int vertexCount(int part = 0, int ring = 0) const;
virtual int ringCount(int part = 0) const;
virtual int partCount() const;
virtual QgsPointV2 vertexAt( const QgsVertexId& id ) const;
};
2 changes: 1 addition & 1 deletion python/core/geometry/qgsgeometry.sip
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class QgsGeometry
* @note added in QGIS 2.10
* @see setGeometry
*/
const QgsAbstractGeometryV2* geometry() const;
QgsAbstractGeometryV2* geometry() const;

/** Sets the underlying geometry store. Ownership of geometry is transferred.
* @note added in QGIS 2.10
Expand Down
7 changes: 7 additions & 0 deletions python/core/geometry/qgsgeometrycollectionv2.sip
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class QgsGeometryCollectionV2: public QgsAbstractGeometryV2
//QgsGeometryCollectionV2& operator=( const QgsGeometryCollectionV2& c );
virtual ~QgsGeometryCollectionV2();

virtual QgsGeometryCollectionV2* clone() const;

int numGeometries() const;
//const QgsAbstractGeometryV2* geometryN( int n ) const;
QgsAbstractGeometryV2* geometryN( int n );
Expand Down Expand Up @@ -63,4 +65,9 @@ class QgsGeometryCollectionV2: public QgsAbstractGeometryV2
@param vertex the vertex id
@return rotation in radians, clockwise from north*/
double vertexAngle( const QgsVertexId& vertex ) const;

virtual int vertexCount(int part = 0, int ring = 0) const;
virtual int ringCount(int part = 0) const;
virtual int partCount() const;
virtual QgsPointV2 vertexAt( const QgsVertexId& id ) const;
};
53 changes: 27 additions & 26 deletions python/core/geometry/qgsgeometryengine.sip
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,32 @@ class QgsGeometryEngine
virtual void geometryChanged() = 0;
virtual void prepareGeometry() = 0;

virtual QgsAbstractGeometryV2* intersection( const QgsAbstractGeometryV2& geom ) const = 0;
virtual QgsAbstractGeometryV2* difference( const QgsAbstractGeometryV2& geom ) const = 0;
virtual QgsAbstractGeometryV2* combine( const QgsAbstractGeometryV2& geom ) const = 0;
virtual QgsAbstractGeometryV2* combine( const QList< const QgsAbstractGeometryV2* > ) const = 0;
virtual QgsAbstractGeometryV2* symDifference( const QgsAbstractGeometryV2& geom ) const = 0;
virtual QgsAbstractGeometryV2* buffer( double distance, int segments ) const = 0;
virtual QgsAbstractGeometryV2* buffer( double distance, int segments, int endCapStyle, int joinStyle, double mitreLimit ) const = 0;
virtual QgsAbstractGeometryV2* simplify( double tolerance ) const = 0;
virtual QgsAbstractGeometryV2* interpolate( double distance ) const = 0;
virtual bool centroid( QgsPointV2& pt ) const = 0;
virtual bool pointOnSurface( QgsPointV2& pt ) const = 0;
virtual QgsAbstractGeometryV2* convexHull() const = 0;
virtual double distance( const QgsAbstractGeometryV2& geom ) const = 0;
virtual bool intersects( const QgsAbstractGeometryV2& geom ) const = 0;
virtual bool touches( const QgsAbstractGeometryV2& geom ) const = 0;
virtual bool crosses( const QgsAbstractGeometryV2& geom ) const = 0;
virtual bool within( const QgsAbstractGeometryV2& geom ) const = 0;
virtual bool overlaps( const QgsAbstractGeometryV2& geom ) const = 0;
virtual bool contains( const QgsAbstractGeometryV2& geom ) const = 0;
virtual bool disjoint( const QgsAbstractGeometryV2& geom ) const = 0;
virtual double area() const = 0;
virtual double length() const = 0;
virtual bool isValid() const = 0;
virtual bool isEqual( const QgsAbstractGeometryV2& geom ) const = 0;
virtual bool isEmpty() const = 0;
virtual QgsAbstractGeometryV2* intersection( const QgsAbstractGeometryV2& geom, QString* errorMsg = 0 ) const = 0;
virtual QgsAbstractGeometryV2* difference( const QgsAbstractGeometryV2& geom, QString* errorMsg = 0 ) const = 0;
virtual QgsAbstractGeometryV2* combine( const QgsAbstractGeometryV2& geom, QString* errorMsg = 0 ) const = 0;
virtual QgsAbstractGeometryV2* combine( const QList< const QgsAbstractGeometryV2* >, QString* errorMsg = 0 ) const = 0;
virtual QgsAbstractGeometryV2* symDifference( const QgsAbstractGeometryV2& geom, QString* errorMsg = 0 ) const = 0;
virtual QgsAbstractGeometryV2* buffer( double distance, int segments, QString* errorMsg = 0 ) const = 0;
virtual QgsAbstractGeometryV2* buffer( double distance, int segments, int endCapStyle, int joinStyle, double mitreLimit, QString* errorMsg = 0 ) const = 0;
virtual QgsAbstractGeometryV2* simplify( double tolerance, QString* errorMsg = 0 ) const = 0;
virtual QgsAbstractGeometryV2* interpolate( double distance, QString* errorMsg = 0 ) const = 0;
virtual QgsAbstractGeometryV2* envelope( QString* errorMsg = 0 ) const = 0;
virtual bool centroid( QgsPointV2& pt, QString* errorMsg = 0 ) const = 0;
virtual bool pointOnSurface( QgsPointV2& pt, QString* errorMsg = 0 ) const = 0;
virtual QgsAbstractGeometryV2* convexHull( QString* errorMsg = 0 ) const = 0;
virtual double distance( const QgsAbstractGeometryV2& geom, QString* errorMsg = 0 ) const = 0;
virtual bool intersects( const QgsAbstractGeometryV2& geom, QString* errorMsg = 0 ) const = 0;
virtual bool touches( const QgsAbstractGeometryV2& geom, QString* errorMsg = 0 ) const = 0;
virtual bool crosses( const QgsAbstractGeometryV2& geom, QString* errorMsg = 0 ) const = 0;
virtual bool within( const QgsAbstractGeometryV2& geom, QString* errorMsg = 0 ) const = 0;
virtual bool overlaps( const QgsAbstractGeometryV2& geom, QString* errorMsg = 0 ) const = 0;
virtual bool contains( const QgsAbstractGeometryV2& geom, QString* errorMsg = 0 ) const = 0;
virtual bool disjoint( const QgsAbstractGeometryV2& geom, QString* errorMsg = 0 ) const = 0;
virtual double area( QString* errorMsg = 0 ) const = 0;
virtual double length( QString* errorMsg = 0 ) const = 0;
virtual bool isValid( QString* errorMsg = 0 ) const = 0;
virtual bool isEqual( const QgsAbstractGeometryV2& geom, QString* errorMsg = 0 ) const = 0;
virtual bool isEmpty( QString* errorMsg = 0 ) const = 0;

virtual QgsAbstractGeometryV2* offsetCurve( double distance, int segments, int joinStyle, double mitreLimit ) const = 0;
virtual QgsAbstractGeometryV2* offsetCurve( double distance, int segments, int joinStyle, double mitreLimit, QString* errorMsg = 0 ) const = 0;
};
2 changes: 1 addition & 1 deletion python/core/geometry/qgslinestringv2.sip
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class QgsLineStringV2: public QgsCurveV2

virtual QString geometryType() const;
virtual int dimension() const;
virtual QgsAbstractGeometryV2* clone() const;
virtual QgsLineStringV2* clone() const;
virtual void clear();

virtual bool fromWkb( const unsigned char* wkb );
Expand Down
2 changes: 1 addition & 1 deletion python/core/geometry/qgsmulticurvev2.sip
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class QgsMultiCurveV2: public QgsGeometryCollectionV2

public:
virtual QString geometryType() const;
QgsAbstractGeometryV2* clone() const;
virtual QgsMultiCurveV2* clone() const;

bool fromWkt( const QString& wkt );

Expand Down
2 changes: 1 addition & 1 deletion python/core/geometry/qgsmultilinestringv2.sip
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class QgsMultiLineStringV2: public QgsMultiCurveV2

public:
virtual QString geometryType() const;
QgsAbstractGeometryV2* clone() const;
virtual QgsMultiLineStringV2* clone() const;

bool fromWkt( const QString& wkt );

Expand Down
2 changes: 1 addition & 1 deletion python/core/geometry/qgsmultipointv2.sip
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class QgsMultiPointV2: public QgsGeometryCollectionV2
%End
public:
virtual QString geometryType() const;
QgsAbstractGeometryV2* clone() const;
virtual QgsMultiPointV2* clone() const;

bool fromWkt( const QString& wkt );

Expand Down
2 changes: 1 addition & 1 deletion python/core/geometry/qgsmultipolygonv2.sip
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class QgsMultiPolygonV2: public QgsMultiSurfaceV2
%End
public:
virtual QString geometryType() const;
QgsAbstractGeometryV2* clone() const;
virtual QgsMultiPolygonV2* clone() const;

bool fromWkt( const QString& wkt );

Expand Down
2 changes: 1 addition & 1 deletion python/core/geometry/qgsmultisurfacev2.sip
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class QgsMultiSurfaceV2: public QgsGeometryCollectionV2
%End
public:
virtual QString geometryType() const;
QgsAbstractGeometryV2* clone() const;
virtual QgsMultiSurfaceV2* clone() const;

bool fromWkt( const QString& wkt );

Expand Down
8 changes: 7 additions & 1 deletion python/core/geometry/qgspointv2.sip
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ class QgsPointV2: public QgsAbstractGeometryV2

public:
QgsPointV2( double x = 0.0, double y = 0.0 );
QgsPointV2( const QgsPoint& p );
QgsPointV2( QgsWKBTypes::Type type, double x = 0.0, double y = 0.0, double z = 0.0, double m = 0.0 );

bool operator==( const QgsPointV2& pt ) const;
bool operator!=( const QgsPointV2& pt ) const;