diff --git a/python/core/qgsgeometry.sip b/python/core/qgsgeometry.sip index f057e332412..29f4146a10b 100644 --- a/python/core/qgsgeometry.sip +++ b/python/core/qgsgeometry.sip @@ -224,6 +224,14 @@ not disjoint with existing polygons of the feature*/ of segments used to approximate curves */ QgsGeometry* buffer(double distance, int segments) /Factory/; + /** Returns a simplified version of this geometry using a specified tolerance value */ + QgsGeometry* simplify(double tolerance) /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/; + /** Returns the smallest convex polygon that contains all the points in the geometry. */ QgsGeometry* convexHull() /Factory/; diff --git a/src/core/qgsgeometry.cpp b/src/core/qgsgeometry.cpp index b77a85139f7..aa0d8151bf3 100644 --- a/src/core/qgsgeometry.cpp +++ b/src/core/qgsgeometry.cpp @@ -132,8 +132,10 @@ static GEOSInit geosinit; #define GEOSGetInteriorRingN(g,i) GEOSGetInteriorRingN( (GEOSGeometry *)g, i ) #define GEOSDisjoint(g0,g1) GEOSDisjoint( (GEOSGeometry *)g0, (GEOSGeometry*)g1 ) #define GEOSIntersection(g0,g1) GEOSIntersection( (GEOSGeometry*) g0, (GEOSGeometry*)g1 ) -#define GEOSBuffer(g, d, s) GEOSBuffer( (GEOSGeometry*) g, d, s) -#define GEOSArea(g, a) GEOSArea( (GEOSGeometry*) g, a) +#define GEOSBuffer(g, d, s) GEOSBuffer( (GEOSGeometry*) g, d, s ) +#define GEOSArea(g, a) GEOSArea( (GEOSGeometry*) g, a ) +#define GEOSSimplify(g, t) GEOSSimplify( (GEOSGeometry*) g, t ) +#define GEOSGetCentroid(g) GEOSGetCentroid( (GEOSGeometry*) g ) #define GEOSCoordSeq_getSize(cs,n) GEOSCoordSeq_getSize( (GEOSCoordSequence *) cs, n ) #define GEOSCoordSeq_getX(cs,i,x) GEOSCoordSeq_getX( (GEOSCoordSequence *)cs, i, x ) @@ -5328,6 +5330,40 @@ QgsGeometry* QgsGeometry::buffer( double distance, int segments ) CATCH_GEOS( 0 ) } +QgsGeometry* QgsGeometry::simplify( double tolerance ) +{ + if ( mGeos == NULL ) + { + exportWkbToGeos(); + } + if ( !mGeos ) + { + return 0; + } + try + { + return fromGeosGeom( GEOSSimplify( mGeos, tolerance ) ); + } + CATCH_GEOS( 0 ) +} + +QgsGeometry* QgsGeometry::centroid() +{ + if ( mGeos == NULL ) + { + exportWkbToGeos(); + } + if ( !mGeos ) + { + return 0; + } + try + { + return fromGeosGeom( GEOSGetCentroid( mGeos ) ); + } + CATCH_GEOS( 0 ) +} + QgsGeometry* QgsGeometry::convexHull() { if ( mGeos == NULL ) @@ -5450,7 +5486,6 @@ QgsGeometry* QgsGeometry::symDifference( QgsGeometry* geometry ) CATCH_GEOS( 0 ) } - QList QgsGeometry::asGeometryCollection() { if ( mGeos == NULL ) diff --git a/src/core/qgsgeometry.h b/src/core/qgsgeometry.h index ace4f47c242..46d80ab4802 100644 --- a/src/core/qgsgeometry.h +++ b/src/core/qgsgeometry.h @@ -128,8 +128,6 @@ class CORE_EXPORT QgsGeometry bool isMultipart(); - - double distance( QgsGeometry& geom ); /** @@ -269,6 +267,14 @@ 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 ); + + /** Returns a simplified version of this geometry using a specified tolerance value */ + QgsGeometry* simplify( double tolerance ); + + /** 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(); /** Returns the smallest convex polygon that contains all the points in the geometry. */ QgsGeometry* convexHull(); diff --git a/src/gui/qgsgenericprojectionselector.cpp b/src/gui/qgsgenericprojectionselector.cpp index da4f0e6da66..7b3843dd441 100644 --- a/src/gui/qgsgenericprojectionselector.cpp +++ b/src/gui/qgsgenericprojectionselector.cpp @@ -40,7 +40,7 @@ void QgsGenericProjectionSelector::setMessage( QString theMessage ) { // Set up text edit pane QString format( "

%1

%2 %3" ); - QString header = tr( "Define this layer's projection:" ); + QString header = tr( "Define this layer's coordinate reference system:" ); QString sentence1 = tr( "This layer appears to have no projection specification." ); QString sentence2 = tr( "By default, this layer will now have its projection set to that of the project, " "but you may override this by selecting a different projection below." ); diff --git a/src/ui/qgsgenericprojectionselectorbase.ui b/src/ui/qgsgenericprojectionselectorbase.ui index 1b134dff0eb..e094c8832c5 100644 --- a/src/ui/qgsgenericprojectionselectorbase.ui +++ b/src/ui/qgsgenericprojectionselectorbase.ui @@ -10,10 +10,12 @@ - Projection Selector + Coordinate Reference System Selector - + + + true @@ -53,7 +55,7 @@ - QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok + QDialogButtonBox::Cancel|QDialogButtonBox::Ok