Skip to content
Permalink
Browse files
#9480: New 'pointOnSurface' method for QgsGeometry
  • Loading branch information
ahuarte47 committed May 27, 2014
1 parent 20015e7 commit cbee3d35ff76a6677ce46b2b185cebc566d8371b
Showing with 22 additions and 0 deletions.
  1. +3 −0 python/core/qgsgeometry.sip
  2. +16 −0 src/core/qgsgeometry.cpp
  3. +3 −0 src/core/qgsgeometry.h
@@ -322,6 +322,9 @@ class QgsGeometry
* and for point based geometries, the point itself is returned */
QgsGeometry* centroid() /Factory/;

/** Returns a point within a geometry */
QgsGeometry* pointOnSurface();

/** Returns the smallest convex polygon that contains all the points in the geometry. */
QgsGeometry* convexHull() /Factory/;

@@ -145,6 +145,7 @@ static GEOSInit geosinit;
#define GEOSArea(g, a) GEOSArea( (GEOSGeometry*) g, a )
#define GEOSTopologyPreserveSimplify(g, t) GEOSTopologyPreserveSimplify( (GEOSGeometry*) g, t )
#define GEOSGetCentroid(g) GEOSGetCentroid( (GEOSGeometry*) g )
#define GEOSPointOnSurface(g) GEOSPointOnSurface( (GEOSGeometry*) g )

#define GEOSCoordSeq_getSize(cs,n) GEOSCoordSeq_getSize( (GEOSCoordSequence *) cs, n )
#define GEOSCoordSeq_getX(cs,i,x) GEOSCoordSeq_getX( (GEOSCoordSequence *)cs, i, x )
@@ -5623,6 +5624,21 @@ QgsGeometry* QgsGeometry::centroid()
CATCH_GEOS( 0 )
}

QgsGeometry* QgsGeometry::pointOnSurface()
{
if ( mDirtyGeos )
exportWkbToGeos();

if ( !mGeos )
return 0;

try
{
return fromGeosGeom( GEOSPointOnSurface( mGeos ) );
}
CATCH_GEOS( 0 )
}

QgsGeometry* QgsGeometry::convexHull()
{
if ( mDirtyGeos )
@@ -363,6 +363,9 @@ class CORE_EXPORT QgsGeometry
* and for point based geometries, the point itself is returned */
QgsGeometry* centroid();

/** Returns a point within a geometry */
QgsGeometry* pointOnSurface();

/** Returns the smallest convex polygon that contains all the points in the geometry. */
QgsGeometry* convexHull();

0 comments on commit cbee3d3

Please sign in to comment.