Skip to content

Commit 76a6b4f

Browse files
committedJul 29, 2015
Merge pull request #2223 from mhugent/measurement_from_geometry
Measurement from geometry
2 parents 4660182 + 86329f0 commit 76a6b4f

File tree

11 files changed

+297
-253
lines changed

11 files changed

+297
-253
lines changed
 

‎src/core/geometry/qgsgeometry.h

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,19 @@ class QgsMapToPixel;
4242
class QPainter;
4343
class QgsPolygonV2;
4444

45-
/** polyline is represented as a vector of points */
45+
/** Polyline is represented as a vector of points */
4646
typedef QVector<QgsPoint> QgsPolyline;
4747

48-
/** polygon: first item of the list is outer ring, inner rings (if any) start from second item */
48+
/** Polygon: first item of the list is outer ring, inner rings (if any) start from second item */
4949
typedef QVector<QgsPolyline> QgsPolygon;
5050

51-
/** a collection of QgsPoints that share a common collection of attributes */
51+
/** A collection of QgsPoints that share a common collection of attributes */
5252
typedef QVector<QgsPoint> QgsMultiPoint;
5353

54-
/** a collection of QgsPolylines that share a common collection of attributes */
54+
/** A collection of QgsPolylines that share a common collection of attributes */
5555
typedef QVector<QgsPolyline> QgsMultiPolyline;
5656

57-
/** a collection of QgsPolygons that share a common collection of attributes */
57+
/** A collection of QgsPolygons that share a common collection of attributes */
5858
typedef QVector<QgsPolygon> QgsMultiPolygon;
5959

6060
class QgsRectangle;
@@ -78,10 +78,10 @@ class CORE_EXPORT QgsGeometry
7878
//! Constructor
7979
QgsGeometry();
8080

81-
/** copy constructor will prompt a deep copy of the object */
81+
/** Copy constructor will prompt a deep copy of the object */
8282
QgsGeometry( const QgsGeometry & );
8383

84-
/** assignments will prompt a deep copy of the object
84+
/** Assignments will prompt a deep copy of the object
8585
@note not available in python bindings
8686
*/
8787
QgsGeometry & operator=( QgsGeometry const & rhs );
@@ -300,61 +300,61 @@ class CORE_EXPORT QgsGeometry
300300
*/
301301
double closestSegmentWithContext( const QgsPoint& point, QgsPoint& minDistPoint, int& afterVertex, double* leftOf = 0, double epsilon = DEFAULT_SEGMENT_EPSILON ) const;
302302

303-
/**Adds a new ring to this geometry. This makes only sense for polygon and multipolygons.
303+
/** Adds a new ring to this geometry. This makes only sense for polygon and multipolygons.
304304
@return 0 in case of success (ring added), 1 problem with geometry type, 2 ring not closed,
305305
3 ring is not valid geometry, 4 ring not disjoint with existing rings, 5 no polygon found which contained the ring*/
306306
int addRing( const QList<QgsPoint>& ring );
307307

308-
/**Adds a new ring to this geometry. This makes only sense for polygon and multipolygons.
308+
/** Adds a new ring to this geometry. This makes only sense for polygon and multipolygons.
309309
@return 0 in case of success (ring added), 1 problem with geometry type, 2 ring not closed,
310310
3 ring is not valid geometry, 4 ring not disjoint with existing rings, 5 no polygon found which contained the ring*/
311311
int addRing( QgsCurveV2* ring );
312312

313-
/**Adds a new island polygon to a multipolygon feature
313+
/** Adds a new island polygon to a multipolygon feature
314314
@return 0 in case of success, 1 if not a multipolygon, 2 if ring is not a valid geometry, 3 if new polygon ring
315315
not disjoint with existing polygons of the feature*/
316316
int addPart( const QList<QgsPoint> &points, QGis::GeometryType geomType = QGis::UnknownGeometry );
317317

318-
/**Adds a new part to this geometry (takes ownership)
318+
/** Adds a new part to this geometry (takes ownership)
319319
@return 0 in case of success, 1 if not a multipolygon, 2 if ring is not a valid geometry, 3 if new polygon ring
320320
not disjoint with existing polygons of the feature*/
321321
int addPart( QgsAbstractGeometryV2* part );
322322

323-
/**Adds a new island polygon to a multipolygon feature
323+
/** Adds a new island polygon to a multipolygon feature
324324
@return 0 in case of success, 1 if not a multipolygon, 2 if ring is not a valid geometry, 3 if new polygon ring
325325
not disjoint with existing polygons of the feature
326326
@note not available in python bindings
327327
*/
328328
int addPart( GEOSGeometry *newPart );
329329

330-
/**Adds a new island polygon to a multipolygon feature
330+
/** Adds a new island polygon to a multipolygon feature
331331
@return 0 in case of success, 1 if not a multipolygon, 2 if ring is not a valid geometry, 3 if new polygon ring
332332
not disjoint with existing polygons of the feature
333333
@note available in python bindings as addPartGeometry (added in 2.2)
334334
*/
335335
int addPart( const QgsGeometry *newPart );
336336

337-
/**Translate this geometry by dx, dy
337+
/** Translate this geometry by dx, dy
338338
@return 0 in case of success*/
339339
int translate( double dx, double dy );
340340

341-
/**Transform this geometry as described by CoordinateTransform ct
341+
/** Transform this geometry as described by CoordinateTransform ct
342342
@return 0 in case of success*/
343343
int transform( const QgsCoordinateTransform& ct );
344344

345-
/**Transform this geometry as described by QTransform ct
345+
/** Transform this geometry as described by QTransform ct
346346
@note added in 2.8
347347
@return 0 in case of success*/
348348
int transform( const QTransform& ct );
349349

350-
/**Rotate this geometry around the Z axis
350+
/** Rotate this geometry around the Z axis
351351
@note added in 2.8
352352
@param rotation clockwise rotation in degrees
353353
@param center rotation center
354354
@return 0 in case of success*/
355355
int rotate( double rotation, const QgsPoint& center );
356356

357-
/**Splits this geometry according to a given line.
357+
/** Splits this geometry according to a given line.
358358
@param splitLine the line that splits the geometry
359359
@param[out] newGeometries list of new geometries that have been created with the split
360360
@param topological true if topological editing is enabled
@@ -365,17 +365,17 @@ class CORE_EXPORT QgsGeometry
365365
bool topological,
366366
QList<QgsPoint> &topologyTestPoints );
367367

368-
/**Replaces a part of this geometry with another line
368+
/** Replaces a part of this geometry with another line
369369
@return 0 in case of success
370370
@note: this function was added in version 1.3*/
371371
int reshapeGeometry( const QList<QgsPoint>& reshapeWithLine );
372372

373-
/**Changes this geometry such that it does not intersect the other geometry
373+
/** Changes this geometry such that it does not intersect the other geometry
374374
@param other geometry that should not be intersect
375375
@return 0 in case of success*/
376376
int makeDifference( const QgsGeometry* other );
377377

378-
/**Returns the bounding box of this feature*/
378+
/** Returns the bounding box of this feature*/
379379
QgsRectangle boundingBox() const;
380380

381381
/** Test for intersection with a rectangle (uses GEOS) */
@@ -522,13 +522,13 @@ class CORE_EXPORT QgsGeometry
522522
@note added in version 1.1 */
523523
QList<QgsGeometry*> asGeometryCollection() const;
524524

525-
/**Return contents of the geometry as a QPointF if wkbType is WKBPoint,
525+
/** Return contents of the geometry as a QPointF if wkbType is WKBPoint,
526526
* otherwise returns a null QPointF.
527527
* @note added in QGIS 2.7
528528
*/
529529
QPointF asQPointF() const;
530530

531-
/**Return contents of the geometry as a QPolygonF. If geometry is a linestring,
531+
/** Return contents of the geometry as a QPolygonF. If geometry is a linestring,
532532
* then the result will be an open QPolygonF. If the geometry is a polygon,
533533
* then the result will be a closed QPolygonF of the geometry's exterior ring.
534534
* @note added in QGIS 2.7
@@ -587,7 +587,7 @@ class CORE_EXPORT QgsGeometry
587587
**/
588588
void validateGeometry( QList<Error> &errors );
589589

590-
/** compute the unary union on a list of geometries. May be faster than an iterative union on a set of geometries.
590+
/** Compute the unary union on a list of geometries. May be faster than an iterative union on a set of geometries.
591591
@param geometryList a list of QgsGeometry* as input
592592
@returns the new computed QgsGeometry, or null
593593
*/
@@ -642,19 +642,19 @@ class CORE_EXPORT QgsGeometry
642642
*/
643643
int vertexNrFromVertexId( const QgsVertexId& i ) const;
644644

645-
/** return GEOS context handle
645+
/** Return GEOS context handle
646646
* @note added in 2.6
647647
* @note not available in Python
648648
*/
649649
static GEOSContextHandle_t getGEOSHandler();
650650

651-
/**Construct geometry from a QPointF
651+
/** Construct geometry from a QPointF
652652
* @param point source QPointF
653653
* @note added in QGIS 2.7
654654
*/
655655
static QgsGeometry* fromQPointF( const QPointF& point );
656656

657-
/**Construct geometry from a QPolygonF. If the polygon is closed than
657+
/** Construct geometry from a QPolygonF. If the polygon is closed than
658658
* the resultant geometry will be a polygon, if it is open than the
659659
* geometry will be a polyline.
660660
* @param polygon source QPolygonF
@@ -707,7 +707,7 @@ class CORE_EXPORT QgsGeometry
707707
*/
708708
static bool compare( const QgsMultiPolygon& p1, const QgsMultiPolygon& p2, double epsilon = 4 * DBL_EPSILON );
709709

710-
/**Smooths a geometry by rounding off corners using the Chaikin algorithm. This operation
710+
/** Smooths a geometry by rounding off corners using the Chaikin algorithm. This operation
711711
* roughly doubles the number of vertices in a geometry.
712712
* @param iterations number of smoothing iterations to run. More iterations results
713713
* in a smoother geometry
@@ -718,33 +718,34 @@ class CORE_EXPORT QgsGeometry
718718
*/
719719
QgsGeometry* smooth( const unsigned int iterations = 1, const double offset = 0.25 ) const;
720720

721-
/**Smooths a polygon using the Chaikin algorithm*/
721+
/** Smooths a polygon using the Chaikin algorithm*/
722722
QgsPolygon smoothPolygon( const QgsPolygon &polygon, const unsigned int iterations = 1, const double offset = 0.25 ) const;
723-
/**Smooths a polyline using the Chaikin algorithm*/
723+
/** Smooths a polyline using the Chaikin algorithm*/
724724
QgsPolyline smoothLine( const QgsPolyline &polyline, const unsigned int iterations = 1, const double offset = 0.25 ) const;
725725

726726
/** Creates and returns a new geometry engine
727727
*/
728728
static QgsGeometryEngine* createGeometryEngine( const QgsAbstractGeometryV2* geometry );
729729

730+
//convert point list from v1 to v2
731+
static void convertPointList( const QList<QgsPoint>& input, QList<QgsPointV2>& output );
732+
static void convertPointList( const QList<QgsPointV2>& input, QList<QgsPoint>& output );
733+
730734
private:
731735

732736
QgsGeometryPrivate* d; //implicitely shared data pointer
733737

734738
void detach( bool cloneGeom = true ); //make sure mGeometry only referenced from this instance
735739
void removeWkbGeos();
736740

737-
//convert point list from v1 to v2
738-
static void convertPointList( const QList<QgsPoint>& input, QList<QgsPointV2>& output );
739-
static void convertPointList( const QList<QgsPointV2>& input, QList<QgsPoint>& output );
740741
static void convertToPolyline( const QList<QgsPointV2>& input, QgsPolyline& output );
741742
static void convertPolygon( const QgsPolygonV2& input, QgsPolygon& output );
742743

743-
/** try to convert the geometry to a point */
744+
/** Try to convert the geometry to a point */
744745
QgsGeometry* convertToPoint( bool destMultipart ) const;
745-
/** try to convert the geometry to a line */
746+
/** Try to convert the geometry to a line */
746747
QgsGeometry* convertToLine( bool destMultipart ) const;
747-
/** try to convert the geometry to a polygon */
748+
/** Try to convert the geometry to a polygon */
748749
QgsGeometry* convertToPolygon( bool destMultipart ) const;
749750
}; // class QgsGeometry
750751

0 commit comments

Comments
 (0)