Const correctness for QgsGeometry methods

This commit is contained in:
Nyall Dawson 2015-05-04 21:00:08 +10:00
parent 1100c9871d
commit e05246d754
6 changed files with 98 additions and 98 deletions

View File

@ -116,27 +116,27 @@ class QgsGeometry
bool isMultipart() const;
/** compare geometries using GEOS */
bool isGeosEqual( QgsGeometry & );
bool isGeosEqual( QgsGeometry & ) const;
/** check validity using GEOS */
bool isGeosValid();
bool isGeosValid() const;
/** check if geometry is empty using GEOS */
bool isGeosEmpty();
bool isGeosEmpty() const;
/** get area of geometry using GEOS */
double area();
double area() const;
/** get length of geometry using GEOS */
double length();
double length() const;
double distance( QgsGeometry& geom );
double distance( const QgsGeometry& geom ) const;
/**
Returns the vertex closest to the given point, the corresponding vertex index, squared distance snap point / target point
and the indices of the vertices before/after. The vertices before/after are -1 if not present
*/
QgsPoint closestVertex( const QgsPoint& point, int& atVertex /Out/, int& beforeVertex /Out/, int& afterVertex /Out/, double& sqrDist /Out/ );
QgsPoint closestVertex( const QgsPoint& point, int& atVertex /Out/, int& beforeVertex /Out/, int& afterVertex /Out/, double& sqrDist /Out/ ) const;
/**
Returns the indexes of the vertices before and after the given vertex index.
@ -150,7 +150,7 @@ class QgsGeometry
account the first vertex is equal to the last vertex (and will
skip equal vertex positions).
*/
void adjacentVertices( int atVertex, int& beforeVertex /Out/, int& afterVertex /Out/ );
void adjacentVertices( int atVertex, int& beforeVertex /Out/, int& afterVertex /Out/ ) const;
/** Insert a new vertex before the given vertex index,
* ring and item (first number is index 0)
@ -190,14 +190,14 @@ class QgsGeometry
* @param atVertex index of the vertex
* @return Coordinates of the vertex or QgsPoint(0,0) on error
*/
QgsPoint vertexAt( int atVertex );
QgsPoint vertexAt( int atVertex ) const;
/**
* Returns the squared cartesian distance between the given point
* to the given vertex index (vertex at the given position number,
* ring and item (first number is index 0))
*/
double sqrDistToVertexAt( QgsPoint& point /In/, int atVertex );
double sqrDistToVertexAt( QgsPoint& point /In/, int atVertex ) const;
/**
* Searches for the closest vertex in this geometry to the given point.
@ -205,7 +205,7 @@ class QgsGeometry
* @param atVertex Receives index of the closest vertex
* @return The squared cartesian distance is also returned in sqrDist, negative number on error
*/
double closestVertexWithContext( const QgsPoint& point, int& atVertex /Out/ );
double closestVertexWithContext( const QgsPoint& point, int& atVertex /Out/ ) const;
/**
* Searches for the closest segment of geometry to the given point
@ -217,7 +217,7 @@ class QgsGeometry
* @param epsilon epsilon for segment snapping
* @return The squared cartesian distance is also returned in sqrDist, negative number on error
*/
double closestSegmentWithContext( const QgsPoint& point, QgsPoint& minDistPoint /Out/, int& afterVertex /Out/ );
double closestSegmentWithContext( const QgsPoint& point, QgsPoint& minDistPoint /Out/, int& afterVertex /Out/ ) const;
/**Adds a new ring to this geometry. This makes only sense for polygon and multipolygons.
@return 0 in case of success (ring added), 1 problem with geometry type, 2 ring not closed,
@ -285,7 +285,7 @@ class QgsGeometry
int makeDifference( QgsGeometry* other );
/**Returns the bounding box of this feature*/
QgsRectangle boundingBox();
QgsRectangle boundingBox() const;
/** Test for intersection with a rectangle (uses GEOS) */
bool intersects( const QgsRectangle& r ) const;
@ -319,7 +319,7 @@ class QgsGeometry
/** Returns a buffer region around this geometry having the given width and with a specified number
of segments used to approximate curves */
QgsGeometry* buffer( double distance, int segments ) /Factory/;
QgsGeometry* buffer( double distance, int segments ) const /Factory/;
/** Returns a buffer region around the geometry, with additional style options.
* @param distance buffer distance
@ -330,17 +330,17 @@ class QgsGeometry
* @note added in 2.4
* @note needs GEOS >= 3.3 - otherwise always returns 0
*/
QgsGeometry* buffer( double distance, int segments, int endCapStyle, int joinStyle, double mitreLimit ) /Factory/;
QgsGeometry* buffer( double distance, int segments, int endCapStyle, int joinStyle, double mitreLimit ) const /Factory/;
/** Returns an offset line at a given distance and side from an input line.
* See buffer() method for details on parameters.
* @note added in 2.4
* @note needs GEOS >= 3.3 - otherwise always returns 0
*/
QgsGeometry* offsetCurve( double distance, int segments, int joinStyle, double mitreLimit ) /Factory/;
QgsGeometry* offsetCurve( double distance, int segments, int joinStyle, double mitreLimit ) const /Factory/;
/** Returns a simplified version of this geometry using a specified tolerance value */
QgsGeometry* simplify( double tolerance ) /Factory/;
QgsGeometry* simplify( double tolerance ) const /Factory/;
/**Smooths a geometry by rounding off corners using the Chaikin algorithm. This operation
* roughly doubles the number of vertices in a geometry.
@ -351,35 +351,35 @@ class QgsGeometry
* of the geometry for each iteration. Smaller values result in "tighter" smoothing.
* @note added in 2.9
*/
QgsGeometry* smooth( const unsigned int iterations = 1, const double offset = 0.25 ) /Factory/;
QgsGeometry* smooth( const unsigned int iterations = 1, const double offset = 0.25 ) const /Factory/;
/** Returns the center of mass of a geometry
* @note for line based geometries, the center point of the line is returned,
* and for point based geometries, the point itself is returned */
QgsGeometry* centroid() /Factory/;
QgsGeometry* centroid() const /Factory/;
/** Returns a point within a geometry */
QgsGeometry* pointOnSurface() /Factory/;
QgsGeometry* pointOnSurface() const /Factory/;
/** Returns the smallest convex polygon that contains all the points in the geometry. */
QgsGeometry* convexHull() /Factory/;
QgsGeometry* convexHull() const /Factory/;
/** Return interpolated point on line at distance */
QgsGeometry* interpolate( double distance ) /Factory/;
QgsGeometry* interpolate( double distance ) const /Factory/;
/** Returns a geometry representing the points shared by this geometry and other. */
QgsGeometry* intersection( QgsGeometry* geometry ) /Factory/;
QgsGeometry* intersection( const QgsGeometry* geometry ) const /Factory/;
/** Returns a geometry representing all the points in this geometry and other (a
* union geometry operation).
* @note this operation is not called union since its a reserved word in C++.*/
QgsGeometry* combine( QgsGeometry* geometry ) /Factory/;
QgsGeometry* combine( const QgsGeometry* geometry ) const /Factory/;
/** Returns a geometry representing the points making up this geometry that do not make up other. */
QgsGeometry* difference( QgsGeometry* geometry ) /Factory/;
QgsGeometry* difference( const QgsGeometry* geometry ) const /Factory/;
/** Returns a Geometry representing the points making up this Geometry that do not make up other. */
QgsGeometry* symDifference( QgsGeometry* geometry ) /Factory/;
QgsGeometry* symDifference( const QgsGeometry* geometry ) const /Factory/;
/** Exports the geometry to WKT
* @note precision parameter added in 2.4
@ -399,7 +399,7 @@ class QgsGeometry
* @return the converted geometry or NULL pointer if the conversion fails.
* @note added in 2.2
*/
QgsGeometry* convertToType( QGis::GeometryType destType, bool destMultipart = false ) /Factory/;
QgsGeometry* convertToType( QGis::GeometryType destType, bool destMultipart = false ) const /Factory/;
/* Accessor functions for getting geometry data */

View File

@ -6,14 +6,14 @@ class QgsGeometryValidator : QThread
public:
//! Constructor
QgsGeometryValidator( QgsGeometry *g, QList<QgsGeometry::Error> *errors = 0 );
QgsGeometryValidator( const QgsGeometry *g, QList<QgsGeometry::Error> *errors = 0 );
~QgsGeometryValidator();
void run();
void stop();
/** Validate geometry and produce a list of geometry errors */
static void validateGeometry( QgsGeometry *g, QList<QgsGeometry::Error> &errors );
static void validateGeometry( const QgsGeometry *g, QList<QgsGeometry::Error> &errors );
signals:
void errorFound( QgsGeometry::Error );

View File

@ -708,7 +708,7 @@ void QgsGeometry::fromGeos( GEOSGeometry *geos )
mDirtyGeos = false;
}
QgsPoint QgsGeometry::closestVertex( const QgsPoint& point, int& atVertex, int& beforeVertex, int& afterVertex, double& sqrDist )
QgsPoint QgsGeometry::closestVertex( const QgsPoint& point, int& atVertex, int& beforeVertex, int& afterVertex, double& sqrDist ) const
{
// TODO: implement with GEOS
if ( mDirtyWkb )
@ -957,7 +957,7 @@ QgsPoint QgsGeometry::closestVertex( const QgsPoint& point, int& atVertex, int&
return p;
}
void QgsGeometry::adjacentVertices( int atVertex, int& beforeVertex, int& afterVertex )
void QgsGeometry::adjacentVertices( int atVertex, int& beforeVertex, int& afterVertex ) const
{
// TODO: implement with GEOS
if ( mDirtyWkb )
@ -1865,7 +1865,7 @@ bool QgsGeometry::insertVertex( double x, double y, int beforeVertex )
}
}
QgsPoint QgsGeometry::vertexAt( int atVertex )
QgsPoint QgsGeometry::vertexAt( int atVertex ) const
{
if ( atVertex < 0 )
return QgsPoint( 0, 0 );
@ -2043,7 +2043,7 @@ QgsPoint QgsGeometry::vertexAt( int atVertex )
}
}
double QgsGeometry::sqrDistToVertexAt( QgsPoint& point, int atVertex )
double QgsGeometry::sqrDistToVertexAt( QgsPoint& point, int atVertex ) const
{
QgsPoint pnt = vertexAt( atVertex );
if ( pnt != QgsPoint( 0, 0 ) )
@ -2059,7 +2059,7 @@ double QgsGeometry::sqrDistToVertexAt( QgsPoint& point, int atVertex )
}
}
double QgsGeometry::closestVertexWithContext( const QgsPoint& point, int& atVertex )
double QgsGeometry::closestVertexWithContext( const QgsPoint& point, int& atVertex ) const
{
double sqrDist = std::numeric_limits<double>::max();
@ -2114,7 +2114,7 @@ double QgsGeometry::closestSegmentWithContext(
QgsPoint& minDistPoint,
int& afterVertex,
double *leftOf,
double epsilon )
double epsilon ) const
{
QgsDebugMsgLevel( "Entering.", 3 );
@ -3227,7 +3227,7 @@ int QgsGeometry::makeDifference( QgsGeometry* other )
return 0;
}
QgsRectangle QgsGeometry::boundingBox()
QgsRectangle QgsGeometry::boundingBox() const
{
double xmin = std::numeric_limits<double>::max();
double ymin = std::numeric_limits<double>::max();
@ -4587,7 +4587,7 @@ bool QgsGeometry::exportGeosToWkb() const
return false;
}
QgsGeometry* QgsGeometry::convertToType( QGis::GeometryType destType, bool destMultipart )
QgsGeometry* QgsGeometry::convertToType( QGis::GeometryType destType, bool destMultipart ) const
{
switch ( destType )
{
@ -5665,7 +5665,7 @@ QgsMultiPolygon QgsGeometry::asMultiPolygon() const
return polygons;
}
double QgsGeometry::area()
double QgsGeometry::area() const
{
if ( mDirtyGeos )
exportWkbToGeos();
@ -5685,7 +5685,7 @@ double QgsGeometry::area()
return area;
}
double QgsGeometry::length()
double QgsGeometry::length() const
{
if ( mDirtyGeos )
exportWkbToGeos();
@ -5704,7 +5704,7 @@ double QgsGeometry::length()
return length;
}
double QgsGeometry::distance( QgsGeometry& geom )
double QgsGeometry::distance( const QgsGeometry& geom ) const
{
if ( mDirtyGeos )
exportWkbToGeos();
@ -5726,7 +5726,7 @@ double QgsGeometry::distance( QgsGeometry& geom )
return dist;
}
QgsGeometry* QgsGeometry::buffer( double distance, int segments )
QgsGeometry* QgsGeometry::buffer( double distance, int segments ) const
{
if ( mDirtyGeos )
exportWkbToGeos();
@ -5741,7 +5741,7 @@ QgsGeometry* QgsGeometry::buffer( double distance, int segments )
CATCH_GEOS( 0 )
}
QgsGeometry*QgsGeometry::buffer( double distance, int segments, int endCapStyle, int joinStyle, double mitreLimit )
QgsGeometry*QgsGeometry::buffer( double distance, int segments, int endCapStyle, int joinStyle, double mitreLimit ) const
{
#if defined(GEOS_VERSION_MAJOR) && defined(GEOS_VERSION_MINOR) && \
((GEOS_VERSION_MAJOR>3) || ((GEOS_VERSION_MAJOR==3) && (GEOS_VERSION_MINOR>=3)))
@ -5761,7 +5761,7 @@ QgsGeometry*QgsGeometry::buffer( double distance, int segments, int endCapStyle,
#endif
}
QgsGeometry* QgsGeometry::offsetCurve( double distance, int segments, int joinStyle, double mitreLimit )
QgsGeometry* QgsGeometry::offsetCurve( double distance, int segments, int joinStyle, double mitreLimit ) const
{
#if defined(GEOS_VERSION_MAJOR) && defined(GEOS_VERSION_MINOR) && \
((GEOS_VERSION_MAJOR>3) || ((GEOS_VERSION_MAJOR==3) && (GEOS_VERSION_MINOR>=3)))
@ -5781,7 +5781,7 @@ QgsGeometry* QgsGeometry::offsetCurve( double distance, int segments, int joinSt
#endif
}
QgsGeometry* QgsGeometry::simplify( double tolerance )
QgsGeometry* QgsGeometry::simplify( double tolerance ) const
{
if ( mDirtyGeos )
exportWkbToGeos();
@ -5796,7 +5796,7 @@ QgsGeometry* QgsGeometry::simplify( double tolerance )
CATCH_GEOS( 0 )
}
QgsGeometry* QgsGeometry::smooth( const unsigned int iterations, const double offset )
QgsGeometry* QgsGeometry::smooth( const unsigned int iterations, const double offset ) const
{
switch ( wkbType() )
{
@ -5906,7 +5906,7 @@ QgsPolygon QgsGeometry::smoothPolygon( const QgsPolygon& polygon, const unsigned
return resultPoly;
}
QgsGeometry* QgsGeometry::centroid()
QgsGeometry* QgsGeometry::centroid() const
{
if ( mDirtyGeos )
exportWkbToGeos();
@ -5921,7 +5921,7 @@ QgsGeometry* QgsGeometry::centroid()
CATCH_GEOS( 0 )
}
QgsGeometry* QgsGeometry::pointOnSurface()
QgsGeometry* QgsGeometry::pointOnSurface() const
{
if ( mDirtyGeos )
exportWkbToGeos();
@ -5936,7 +5936,7 @@ QgsGeometry* QgsGeometry::pointOnSurface()
CATCH_GEOS( 0 )
}
QgsGeometry* QgsGeometry::convexHull()
QgsGeometry* QgsGeometry::convexHull() const
{
if ( mDirtyGeos )
exportWkbToGeos();
@ -5951,7 +5951,7 @@ QgsGeometry* QgsGeometry::convexHull()
CATCH_GEOS( 0 )
}
QgsGeometry* QgsGeometry::interpolate( double distance )
QgsGeometry* QgsGeometry::interpolate( double distance ) const
{
#if defined(GEOS_VERSION_MAJOR) && defined(GEOS_VERSION_MINOR) && \
((GEOS_VERSION_MAJOR>3) || ((GEOS_VERSION_MAJOR==3) && (GEOS_VERSION_MINOR>=2)))
@ -5972,7 +5972,7 @@ QgsGeometry* QgsGeometry::interpolate( double distance )
#endif
}
QgsGeometry* QgsGeometry::intersection( QgsGeometry* geometry )
QgsGeometry* QgsGeometry::intersection( const QgsGeometry* geometry ) const
{
if ( !geometry )
return NULL;
@ -5993,7 +5993,7 @@ QgsGeometry* QgsGeometry::intersection( QgsGeometry* geometry )
CATCH_GEOS( 0 )
}
QgsGeometry* QgsGeometry::combine( QgsGeometry* geometry )
QgsGeometry* QgsGeometry::combine( const QgsGeometry *geometry ) const
{
if ( !geometry )
return NULL;
@ -6027,7 +6027,7 @@ QgsGeometry* QgsGeometry::combine( QgsGeometry* geometry )
CATCH_GEOS( new QgsGeometry( *this ) ) //return this geometry if union not possible
}
QgsGeometry* QgsGeometry::difference( QgsGeometry* geometry )
QgsGeometry* QgsGeometry::difference( const QgsGeometry* geometry ) const
{
if ( !geometry )
return NULL;
@ -6048,7 +6048,7 @@ QgsGeometry* QgsGeometry::difference( QgsGeometry* geometry )
CATCH_GEOS( 0 )
}
QgsGeometry* QgsGeometry::symDifference( QgsGeometry* geometry )
QgsGeometry* QgsGeometry::symDifference( const QgsGeometry* geometry ) const
{
if ( !geometry )
return NULL;
@ -6362,7 +6362,7 @@ void QgsGeometry::validateGeometry( QList<Error> &errors )
QgsGeometryValidator::validateGeometry( this, errors );
}
bool QgsGeometry::isGeosValid()
bool QgsGeometry::isGeosValid() const
{
try
{
@ -6380,12 +6380,12 @@ bool QgsGeometry::isGeosValid()
}
}
bool QgsGeometry::isGeosEqual( QgsGeometry &g )
bool QgsGeometry::isGeosEqual( const QgsGeometry &g ) const
{
return geosRelOp( GEOSEquals_r, this, &g );
}
bool QgsGeometry::isGeosEmpty()
bool QgsGeometry::isGeosEmpty() const
{
try
{
@ -6403,7 +6403,7 @@ bool QgsGeometry::isGeosEmpty()
}
}
double QgsGeometry::leftOf( double x, double y, double& x1, double& y1, double& x2, double& y2 )
double QgsGeometry::leftOf( double x, double y, double& x1, double& y1, double& x2, double& y2 ) const
{
double f1 = x - x1;
double f2 = y2 - y1;
@ -6412,7 +6412,7 @@ double QgsGeometry::leftOf( double x, double y, double& x1, double& y1, double&
return f1*f2 - f3*f4;
}
QgsGeometry* QgsGeometry::convertToPoint( bool destMultipart )
QgsGeometry* QgsGeometry::convertToPoint( bool destMultipart ) const
{
switch ( type() )
{
@ -6503,7 +6503,7 @@ QgsGeometry* QgsGeometry::convertToPoint( bool destMultipart )
}
}
QgsGeometry* QgsGeometry::convertToLine( bool destMultipart )
QgsGeometry* QgsGeometry::convertToLine( bool destMultipart ) const
{
switch ( type() )
{
@ -6610,7 +6610,7 @@ QgsGeometry* QgsGeometry::convertToLine( bool destMultipart )
}
}
QgsGeometry* QgsGeometry::convertToPolygon( bool destMultipart )
QgsGeometry* QgsGeometry::convertToPolygon( bool destMultipart ) const
{
switch ( type() )
{
@ -6729,7 +6729,7 @@ QgsGeometry* QgsGeometry::convertToPolygon( bool destMultipart )
}
}
QgsGeometry *QgsGeometry::unaryUnion( const QList<QgsGeometry*> &geometryList )
QgsGeometry *QgsGeometry::unaryUnion( const QList<QgsGeometry *> &geometryList )
{
QList<GEOSGeometry*> geoms;
foreach ( QgsGeometry* g, geometryList )

View File

@ -158,27 +158,27 @@ class CORE_EXPORT QgsGeometry
bool isMultipart() const;
/** compare geometries using GEOS */
bool isGeosEqual( QgsGeometry & );
bool isGeosEqual( const QgsGeometry & ) const;
/** check validity using GEOS */
bool isGeosValid();
bool isGeosValid() const;
/** check if geometry is empty using GEOS */
bool isGeosEmpty();
bool isGeosEmpty() const;
/** get area of geometry using GEOS */
double area();
double area() const;
/** get length of geometry using GEOS */
double length();
double length() const;
double distance( QgsGeometry& geom );
double distance( const QgsGeometry &geom ) const;
/**
Returns the vertex closest to the given point, the corresponding vertex index, squared distance snap point / target point
and the indices of the vertices before/after. The vertices before/after are -1 if not present
*/
QgsPoint closestVertex( const QgsPoint& point, int& atVertex, int& beforeVertex, int& afterVertex, double& sqrDist );
QgsPoint closestVertex( const QgsPoint& point, int& atVertex, int& beforeVertex, int& afterVertex, double& sqrDist ) const;
/**
Returns the indexes of the vertices before and after the given vertex index.
@ -192,7 +192,7 @@ class CORE_EXPORT QgsGeometry
account the first vertex is equal to the last vertex (and will
skip equal vertex positions).
*/
void adjacentVertices( int atVertex, int& beforeVertex, int& afterVertex );
void adjacentVertices( int atVertex, int& beforeVertex, int& afterVertex ) const;
/** Insert a new vertex before the given vertex index,
* ring and item (first number is index 0)
@ -232,14 +232,14 @@ class CORE_EXPORT QgsGeometry
* @param atVertex index of the vertex
* @return Coordinates of the vertex or QgsPoint(0,0) on error
*/
QgsPoint vertexAt( int atVertex );
QgsPoint vertexAt( int atVertex ) const;
/**
* Returns the squared cartesian distance between the given point
* to the given vertex index (vertex at the given position number,
* ring and item (first number is index 0))
*/
double sqrDistToVertexAt( QgsPoint& point, int atVertex );
double sqrDistToVertexAt( QgsPoint& point, int atVertex ) const;
/**
* Searches for the closest vertex in this geometry to the given point.
@ -247,7 +247,7 @@ class CORE_EXPORT QgsGeometry
* @param atVertex Receives index of the closest vertex
* @return The squared cartesian distance is also returned in sqrDist, negative number on error
*/
double closestVertexWithContext( const QgsPoint& point, int& atVertex );
double closestVertexWithContext( const QgsPoint& point, int& atVertex ) const;
/**
* Searches for the closest segment of geometry to the given point
@ -259,7 +259,7 @@ class CORE_EXPORT QgsGeometry
* @param epsilon epsilon for segment snapping
* @return The squared cartesian distance is also returned in sqrDist, negative number on error
*/
double closestSegmentWithContext( const QgsPoint& point, QgsPoint& minDistPoint, int& afterVertex, double* leftOf = 0, double epsilon = DEFAULT_SEGMENT_EPSILON );
double closestSegmentWithContext( const QgsPoint& point, QgsPoint& minDistPoint, int& afterVertex, double* leftOf = 0, double epsilon = DEFAULT_SEGMENT_EPSILON ) const;
/**Adds a new ring to this geometry. This makes only sense for polygon and multipolygons.
@return 0 in case of success (ring added), 1 problem with geometry type, 2 ring not closed,
@ -327,7 +327,7 @@ class CORE_EXPORT QgsGeometry
int makeDifference( QgsGeometry* other );
/**Returns the bounding box of this feature*/
QgsRectangle boundingBox();
QgsRectangle boundingBox() const;
/** Test for intersection with a rectangle (uses GEOS) */
bool intersects( const QgsRectangle& r ) const;
@ -361,7 +361,7 @@ class CORE_EXPORT QgsGeometry
/** Returns a buffer region around this geometry having the given width and with a specified number
of segments used to approximate curves */
QgsGeometry* buffer( double distance, int segments );
QgsGeometry* buffer( double distance, int segments ) const;
/** Returns a buffer region around the geometry, with additional style options.
* @param distance buffer distance
@ -372,17 +372,17 @@ class CORE_EXPORT QgsGeometry
* @note added in 2.4
* @note needs GEOS >= 3.3 - otherwise always returns 0
*/
QgsGeometry* buffer( double distance, int segments, int endCapStyle, int joinStyle, double mitreLimit );
QgsGeometry* buffer( double distance, int segments, int endCapStyle, int joinStyle, double mitreLimit ) const;
/** Returns an offset line at a given distance and side from an input line.
* See buffer() method for details on parameters.
* @note added in 2.4
* @note needs GEOS >= 3.3 - otherwise always returns 0
*/
QgsGeometry* offsetCurve( double distance, int segments, int joinStyle, double mitreLimit );
QgsGeometry* offsetCurve( double distance, int segments, int joinStyle, double mitreLimit ) const;
/** Returns a simplified version of this geometry using a specified tolerance value */
QgsGeometry* simplify( double tolerance );
QgsGeometry* simplify( double tolerance ) const;
/**Smooths a geometry by rounding off corners using the Chaikin algorithm. This operation
* roughly doubles the number of vertices in a geometry.
@ -393,35 +393,35 @@ class CORE_EXPORT QgsGeometry
* of the geometry for each iteration. Smaller values result in "tighter" smoothing.
* @note added in 2.9
*/
QgsGeometry* smooth( const unsigned int iterations = 1, const double offset = 0.25 );
QgsGeometry* smooth( const unsigned int iterations = 1, const double offset = 0.25 ) const;
/** Returns the center of mass of a geometry
* @note for line based geometries, the center point of the line is returned,
* and for point based geometries, the point itself is returned */
QgsGeometry* centroid();
QgsGeometry* centroid() const;
/** Returns a point within a geometry */
QgsGeometry* pointOnSurface();
QgsGeometry* pointOnSurface() const;
/** Returns the smallest convex polygon that contains all the points in the geometry. */
QgsGeometry* convexHull();
QgsGeometry* convexHull() const;
/** Return interpolated point on line at distance */
QgsGeometry* interpolate( double distance );
QgsGeometry* interpolate( double distance ) const;
/** Returns a geometry representing the points shared by this geometry and other. */
QgsGeometry* intersection( QgsGeometry* geometry );
QgsGeometry* intersection( const QgsGeometry *geometry ) const;
/** Returns a geometry representing all the points in this geometry and other (a
* union geometry operation).
* @note this operation is not called union since its a reserved word in C++.*/
QgsGeometry* combine( QgsGeometry* geometry );
QgsGeometry* combine( const QgsGeometry* geometry ) const;
/** Returns a geometry representing the points making up this geometry that do not make up other. */
QgsGeometry* difference( QgsGeometry* geometry );
QgsGeometry* difference( const QgsGeometry* geometry ) const;
/** Returns a Geometry representing the points making up this Geometry that do not make up other. */
QgsGeometry* symDifference( QgsGeometry* geometry );
QgsGeometry* symDifference( const QgsGeometry* geometry ) const;
/** Exports the geometry to WKT
* @note precision parameter added in 2.4
@ -441,7 +441,7 @@ class CORE_EXPORT QgsGeometry
* @return the converted geometry or NULL pointer if the conversion fails.
* @note added in 2.2
*/
QgsGeometry* convertToType( QGis::GeometryType destType, bool destMultipart = false );
QgsGeometry* convertToType( QGis::GeometryType destType, bool destMultipart = false ) const;
/* Accessor functions for getting geometry data */
@ -518,7 +518,7 @@ class CORE_EXPORT QgsGeometry
Error( QString m ) : message( m ), hasLocation( false ) {}
Error( QString m, QgsPoint p ) : message( m ), location( p ), hasLocation( true ) {}
QString what() { return message; };
QString what() { return message; }
QgsPoint where() { return location; }
bool hasWhere() { return hasLocation; }
};
@ -530,7 +530,7 @@ class CORE_EXPORT QgsGeometry
@param geometryList a list of QgsGeometry* as input
@returns the new computed QgsGeometry, or null
*/
static QgsGeometry *unaryUnion( const QList<QgsGeometry*>& geometryList );
static QgsGeometry *unaryUnion( const QList< QgsGeometry*>& geometryList );
/** Compares two polylines for equality within a specified tolerance.
* @param p1 first polyline
@ -702,18 +702,18 @@ class CORE_EXPORT QgsGeometry
const QgsGeometry* a, const QgsGeometry* b );
/**Returns < 0 if point(x/y) is left of the line x1,y1 -> x1,y2*/
double leftOf( double x, double y, double& x1, double& y1, double& x2, double& y2 );
double leftOf( double x, double y, double& x1, double& y1, double& x2, double& y2 ) const;
static inline bool moveVertex( QgsWkbPtr &wkbPtr, const double &x, const double &y, int atVertex, bool hasZValue, int &pointIndex, bool isRing );
static inline int deleteVertex( QgsConstWkbPtr &srcPtr, QgsWkbPtr &dstPtr, int atVertex, bool hasZValue, int &pointIndex, bool isRing, bool lastItem );
static inline bool insertVertex( QgsConstWkbPtr &srcPtr, QgsWkbPtr &dstPtr, int beforeVertex, const double &x, const double &y, bool hasZValue, int &pointIndex, bool isRing );
/** try to convert the geometry to a point */
QgsGeometry* convertToPoint( bool destMultipart );
QgsGeometry* convertToPoint( bool destMultipart ) const;
/** try to convert the geometry to a line */
QgsGeometry* convertToLine( bool destMultipart );
QgsGeometry* convertToLine( bool destMultipart ) const;
/** try to convert the geometry to a polygon */
QgsGeometry* convertToPolygon( bool destMultipart );
QgsGeometry* convertToPolygon( bool destMultipart ) const;
static QgsPolyline createPolylineFromQPolygonF( const QPolygonF &polygon );
static QgsPolygon createPolygonFromQPolygonF( const QPolygonF &polygon );

View File

@ -20,7 +20,7 @@ email : jef at norbit dot de
#include <QSettings>
QgsGeometryValidator::QgsGeometryValidator( QgsGeometry *g, QList<QgsGeometry::Error> *errors )
QgsGeometryValidator::QgsGeometryValidator( const QgsGeometry *g, QList<QgsGeometry::Error> *errors )
: QThread()
, mErrors( errors )
, mStop( false )
@ -346,7 +346,7 @@ void QgsGeometryValidator::addError( QgsGeometry::Error e )
*mErrors << e;
}
void QgsGeometryValidator::validateGeometry( QgsGeometry *g, QList<QgsGeometry::Error> &errors )
void QgsGeometryValidator::validateGeometry( const QgsGeometry *g, QList<QgsGeometry::Error> &errors )
{
QgsGeometryValidator *gv = new QgsGeometryValidator( g, &errors );
connect( gv, SIGNAL( errorFound( QgsGeometry::Error ) ), gv, SLOT( addError( QgsGeometry::Error ) ) );

View File

@ -25,14 +25,14 @@ class CORE_EXPORT QgsGeometryValidator : public QThread
public:
//! Constructor
QgsGeometryValidator( QgsGeometry *g, QList<QgsGeometry::Error> *errors = 0 );
QgsGeometryValidator( const QgsGeometry *g, QList<QgsGeometry::Error> *errors = 0 );
~QgsGeometryValidator();
void run() override;
void stop();
/** Validate geometry and produce a list of geometry errors */
static void validateGeometry( QgsGeometry *g, QList<QgsGeometry::Error> &errors );
static void validateGeometry( const QgsGeometry *g, QList<QgsGeometry::Error> &errors );
signals:
void errorFound( QgsGeometry::Error );