Skip to content

Commit af34446

Browse files
author
cfarmer
committed
adds both simplify and centroid to qgsgeometry -> these will be used by the qgsanalysis branch
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@10392 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 7808ef5 commit af34446

File tree

5 files changed

+60
-9
lines changed

5 files changed

+60
-9
lines changed

python/core/qgsgeometry.sip

+8
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,14 @@ not disjoint with existing polygons of the feature*/
224224
of segments used to approximate curves */
225225
QgsGeometry* buffer(double distance, int segments) /Factory/;
226226

227+
/** Returns a simplified version of this geometry using a specified tolerance value */
228+
QgsGeometry* simplify(double tolerance) /Factory/;
229+
230+
/** Returns the center of mass of a geometry
231+
* @note for line based geometries, the center point of the line is returned,
232+
* and for point based geometries, the point itself is returned */
233+
QgsGeometry* centroid() /Factory/;
234+
227235
/** Returns the smallest convex polygon that contains all the points in the geometry. */
228236
QgsGeometry* convexHull() /Factory/;
229237

src/core/qgsgeometry.cpp

+38-3
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,10 @@ static GEOSInit geosinit;
132132
#define GEOSGetInteriorRingN(g,i) GEOSGetInteriorRingN( (GEOSGeometry *)g, i )
133133
#define GEOSDisjoint(g0,g1) GEOSDisjoint( (GEOSGeometry *)g0, (GEOSGeometry*)g1 )
134134
#define GEOSIntersection(g0,g1) GEOSIntersection( (GEOSGeometry*) g0, (GEOSGeometry*)g1 )
135-
#define GEOSBuffer(g, d, s) GEOSBuffer( (GEOSGeometry*) g, d, s)
136-
#define GEOSArea(g, a) GEOSArea( (GEOSGeometry*) g, a)
135+
#define GEOSBuffer(g, d, s) GEOSBuffer( (GEOSGeometry*) g, d, s )
136+
#define GEOSArea(g, a) GEOSArea( (GEOSGeometry*) g, a )
137+
#define GEOSSimplify(g, t) GEOSSimplify( (GEOSGeometry*) g, t )
138+
#define GEOSGetCentroid(g) GEOSGetCentroid( (GEOSGeometry*) g )
137139

138140
#define GEOSCoordSeq_getSize(cs,n) GEOSCoordSeq_getSize( (GEOSCoordSequence *) cs, n )
139141
#define GEOSCoordSeq_getX(cs,i,x) GEOSCoordSeq_getX( (GEOSCoordSequence *)cs, i, x )
@@ -5328,6 +5330,40 @@ QgsGeometry* QgsGeometry::buffer( double distance, int segments )
53285330
CATCH_GEOS( 0 )
53295331
}
53305332

5333+
QgsGeometry* QgsGeometry::simplify( double tolerance )
5334+
{
5335+
if ( mGeos == NULL )
5336+
{
5337+
exportWkbToGeos();
5338+
}
5339+
if ( !mGeos )
5340+
{
5341+
return 0;
5342+
}
5343+
try
5344+
{
5345+
return fromGeosGeom( GEOSSimplify( mGeos, tolerance ) );
5346+
}
5347+
CATCH_GEOS( 0 )
5348+
}
5349+
5350+
QgsGeometry* QgsGeometry::centroid()
5351+
{
5352+
if ( mGeos == NULL )
5353+
{
5354+
exportWkbToGeos();
5355+
}
5356+
if ( !mGeos )
5357+
{
5358+
return 0;
5359+
}
5360+
try
5361+
{
5362+
return fromGeosGeom( GEOSGetCentroid( mGeos ) );
5363+
}
5364+
CATCH_GEOS( 0 )
5365+
}
5366+
53315367
QgsGeometry* QgsGeometry::convexHull()
53325368
{
53335369
if ( mGeos == NULL )
@@ -5450,7 +5486,6 @@ QgsGeometry* QgsGeometry::symDifference( QgsGeometry* geometry )
54505486
CATCH_GEOS( 0 )
54515487
}
54525488

5453-
54545489
QList<QgsGeometry*> QgsGeometry::asGeometryCollection()
54555490
{
54565491
if ( mGeos == NULL )

src/core/qgsgeometry.h

+8-2
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,6 @@ class CORE_EXPORT QgsGeometry
128128
bool isMultipart();
129129

130130

131-
132-
133131
double distance( QgsGeometry& geom );
134132

135133
/**
@@ -269,6 +267,14 @@ class CORE_EXPORT QgsGeometry
269267
/** Returns a buffer region around this geometry having the given width and with a specified number
270268
of segments used to approximate curves */
271269
QgsGeometry* buffer( double distance, int segments );
270+
271+
/** Returns a simplified version of this geometry using a specified tolerance value */
272+
QgsGeometry* simplify( double tolerance );
273+
274+
/** Returns the center of mass of a geometry
275+
* @note for line based geometries, the center point of the line is returned,
276+
* and for point based geometries, the point itself is returned */
277+
QgsGeometry* centroid();
272278

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

src/gui/qgsgenericprojectionselector.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void QgsGenericProjectionSelector::setMessage( QString theMessage )
4040
{
4141
// Set up text edit pane
4242
QString format( "<h2>%1</h2>%2 %3" );
43-
QString header = tr( "Define this layer's projection:" );
43+
QString header = tr( "Define this layer's coordinate reference system:" );
4444
QString sentence1 = tr( "This layer appears to have no projection specification." );
4545
QString sentence2 = tr( "By default, this layer will now have its projection set to that of the project, "
4646
"but you may override this by selecting a different projection below." );

src/ui/qgsgenericprojectionselectorbase.ui

+5-3
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010
</rect>
1111
</property>
1212
<property name="windowTitle" >
13-
<string>Projection Selector</string>
13+
<string>Coordinate Reference System Selector</string>
1414
</property>
1515
<property name="windowIcon" >
16-
<iconset/>
16+
<iconset>
17+
<normaloff/>
18+
</iconset>
1719
</property>
1820
<property name="modal" >
1921
<bool>true</bool>
@@ -53,7 +55,7 @@
5355
<item row="2" column="0" >
5456
<widget class="QDialogButtonBox" name="buttonBox" >
5557
<property name="standardButtons" >
56-
<set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
58+
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
5759
</property>
5860
</widget>
5961
</item>

0 commit comments

Comments
 (0)