Skip to content

Commit

Permalink
Geometry Checker and Geometry Snapper plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
manisandro committed Sep 21, 2015
1 parent 992bacc commit e9e638f
Show file tree
Hide file tree
Showing 140 changed files with 10,419 additions and 308 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Expand Up @@ -191,6 +191,7 @@ ENDIF(NOT WIN32 AND NOT ANDROID)
# required
FIND_PACKAGE(Proj)
FIND_PACKAGE(GEOS)
SET(GEOS_CPP_LIBRARY -lgeos CACHE STRING "Path to the geos CPP library")
FIND_PACKAGE(GDAL)
FIND_PACKAGE(Expat REQUIRED)
FIND_PACKAGE(Spatialindex REQUIRED)
Expand Down
18 changes: 16 additions & 2 deletions python/core/geometry/qgsabstractgeometryv2.sip
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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;

virtual QgsAbstractGeometryV2* clone() const;
virtual QgsPointV2* clone() const;
void clear();

double x() const;
Expand Down Expand Up @@ -60,4 +61,9 @@ class QgsPointV2: public QgsAbstractGeometryV2
@param vertex the vertex id
@return 0.0*/
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;
};
2 changes: 1 addition & 1 deletion python/core/geometry/qgspolygonv2.sip
Expand Up @@ -6,7 +6,7 @@ class QgsPolygonV2: public QgsCurvePolygonV2

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

virtual bool fromWkb( const unsigned char* wkb );
// inherited: bool fromWkt( const QString &wkt );
Expand Down
1 change: 0 additions & 1 deletion python/core/geometry/qgssurfacev2.sip
Expand Up @@ -5,7 +5,6 @@ class QgsSurfaceV2: public QgsAbstractGeometryV2
%End

public:
virtual QgsPointV2 centroid() const = 0;
virtual QgsPointV2 pointOnSurface() const = 0;
virtual QgsPolygonV2* surfaceToPolygon() const = 0;
};
4 changes: 4 additions & 0 deletions python/core/qgsmapsettings.sip
Expand Up @@ -139,6 +139,10 @@ class QgsMapSettings

const QgsMapToPixel& mapToPixel() const;

//! computes an *estimated* conversion factor between layer and map units: layerUnits * layerToMapUnits = mapUnits
//! @param referenceExtent A reference extent based on which to perform the computation. If not specified, the layer extent is used
double layerToMapUnits( QgsMapLayer* theLayer, const QgsRectangle& referenceExtent = QgsRectangle() ) const;

/**
* @brief transform bounding box from layer's CRS to output CRS
* @see layerToMapCoordinates( QgsMapLayer* theLayer, QgsRectangle rect ) if you want to transform a rectangle
Expand Down
4 changes: 4 additions & 0 deletions python/core/qgsrectangle.sip
Expand Up @@ -58,6 +58,10 @@ class QgsRectangle
//! Scale the rectangle around its center point
void scale( double scaleFactor, const QgsPoint *c = 0 );
void scale( double scaleFactor, double centerX, double centerY );
//! Grow the rectangle by the specified amount
void grow( double delta );
/** Updates the rectangle to include the specified point */
void include( const QgsPoint& p );
/** Get rectangle enlarged by buffer.
* @note added in 2.1 */
QgsRectangle buffer( double width );
Expand Down
2 changes: 1 addition & 1 deletion python/gui/qgisinterface.sip
Expand Up @@ -252,7 +252,7 @@ class QgisInterface : QObject
virtual void showLayerProperties( QgsMapLayer *l ) = 0;

/** Open attribute table dialog */
virtual void showAttributeTable( QgsVectorLayer *l ) = 0;
virtual QDialog* showAttributeTable( QgsVectorLayer *l, const QString& filterExpression = QString() ) = 0;

/** Add window to Window menu. The action title is the window title
* and the action should raise, unminimize and activate the window. */
Expand Down
5 changes: 4 additions & 1 deletion src/app/qgisappinterface.cpp
Expand Up @@ -429,13 +429,16 @@ void QgisAppInterface::showLayerProperties( QgsMapLayer *l )
}
}

void QgisAppInterface::showAttributeTable( QgsVectorLayer *l )
QDialog* QgisAppInterface::showAttributeTable( QgsVectorLayer *l, const QString& filterExpression )
{
if ( l )
{
QgsAttributeTableDialog *dialog = new QgsAttributeTableDialog( l );
dialog->setFilterExpression( filterExpression );
dialog->show();
return dialog;
}
return 0;
}

void QgisAppInterface::addWindow( QAction *action )
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgisappinterface.h
Expand Up @@ -267,7 +267,7 @@ class APP_EXPORT QgisAppInterface : public QgisInterface
/** Show layer attribute dialog for layer
* @param l layer to show attribute table for
*/
virtual void showAttributeTable( QgsVectorLayer *l ) override;
virtual QDialog* showAttributeTable( QgsVectorLayer *l, const QString& filterExpression = QString() ) override;

/** Add window to Window menu. The action title is the window title
* and the action should raise, unminimize and activate the window. */
Expand Down
5 changes: 5 additions & 0 deletions src/core/CMakeLists.txt
Expand Up @@ -3,6 +3,8 @@

SET(QGIS_CORE_SRCS

geosextra/geos_c_extra.cpp

gps/qgsgpsconnection.cpp
gps/qgsgpsconnectionregistry.cpp
gps/qgsnmeaconnection.cpp
Expand Down Expand Up @@ -521,6 +523,8 @@ SET(QGIS_CORE_HDRS
${CMAKE_BINARY_DIR}/qgsconfig.h
../plugins/qgisplugin.h

geosextra/geos_c_extra.h

qgis.h
qgsattributeaction.h
qgscachedfeatureiterator.h
Expand Down Expand Up @@ -845,6 +849,7 @@ TARGET_LINK_LIBRARIES(qgis_core

${PROJ_LIBRARY}
${GEOS_LIBRARY}
${GEOS_CPP_LIBRARY}
${GDAL_LIBRARY}
${SPATIALINDEX_LIBRARY}
${EXPAT_LIBRARY}
Expand Down

0 comments on commit e9e638f

Please sign in to comment.