QGIS API Documentation  2.14.0-Essen
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
QgsGeometryCollectionV2 Class Reference

Geometry collection. More...

#include <qgsgeometrycollectionv2.h>

Inheritance diagram for QgsGeometryCollectionV2:
Inheritance graph
[legend]

Public Member Functions

 QgsGeometryCollectionV2 ()
 
 QgsGeometryCollectionV2 (const QgsGeometryCollectionV2 &c)
 
virtual ~QgsGeometryCollectionV2 ()
 
virtual bool addGeometry (QgsAbstractGeometryV2 *g)
 Adds a geometry and takes ownership. More...
 
virtual bool addMValue (double mValue=0) override
 Adds a measure to the geometry, initialized to a preset value. More...
 
virtual bool addZValue (double zValue=0) override
 Adds a z-dimension to the geometry, initialized to a preset value. More...
 
virtual double area () const override
 Returns the area of the geometry. More...
 
QDomElement asGML2 (QDomDocument &doc, int precision=17, const QString &ns="gml") const override
 Returns a GML2 representation of the geometry. More...
 
QDomElement asGML3 (QDomDocument &doc, int precision=17, const QString &ns="gml") const override
 Returns a GML3 representation of the geometry. More...
 
QString asJSON (int precision=17) const override
 Returns a GeoJSON representation of the geometry. More...
 
unsigned char * asWkb (int &binarySize) const override
 Returns a WKB representation of the geometry. More...
 
QString asWkt (int precision=17) const override
 Returns a WKT representation of the geometry. More...
 
virtual QgsRectangle boundingBox () const override
 Returns the minimal bounding box for the geometry. More...
 
virtual void clear () override
 Clears the geometry, ie reset it to a null geometry. More...
 
virtual QgsGeometryCollectionV2clone () const override
 Clones the geometry by performing a deep copy. More...
 
virtual double closestSegment (const QgsPointV2 &pt, QgsPointV2 &segmentPt, QgsVertexId &vertexAfter, bool *leftOf, double epsilon) const override
 Searches for the closest segment of the geometry to a given point. More...
 
virtual QgsCoordinateSequenceV2 coordinateSequence () const override
 Retrieves the sequence of geometries, rings and nodes. More...
 
virtual bool deleteVertex (QgsVertexId position) override
 Deletes a vertex within the geometry. More...
 
virtual int dimension () const override
 Returns the inherent dimension of the geometry. More...
 
virtual void draw (QPainter &p) const override
 Draws the geometry using the specified QPainter. More...
 
virtual bool dropMValue () override
 Drops any measure values which exist in the geometry. More...
 
virtual bool dropZValue () override
 Drops any z-dimensions which exist in the geometry. More...
 
bool fromWkb (QgsConstWkbPtr wkb) override
 Sets the geometry from a WKB string. More...
 
virtual bool fromWkt (const QString &wkt) override
 Sets the geometry from a WKT string. More...
 
const QgsAbstractGeometryV2geometryN (int n) const
 Returns a const reference to a geometry from within the collection. More...
 
QgsAbstractGeometryV2geometryN (int n)
 Returns a geometry from within the collection. More...
 
virtual QString geometryType () const override
 Returns a unique string representing the geometry type. More...
 
bool hasCurvedSegments () const override
 Returns true if the geometry contains curved segments. More...
 
virtual bool insertGeometry (QgsAbstractGeometryV2 *g, int index)
 Inserts a geometry before a specified index and takes ownership. More...
 
virtual bool insertVertex (QgsVertexId position, const QgsPointV2 &vertex) override
 Inserts a vertex into the geometry. More...
 
virtual double length () const override
 Returns the length of the geometry. More...
 
virtual bool moveVertex (QgsVertexId position, const QgsPointV2 &newPos) override
 Moves a vertex within the geometry. More...
 
bool nextVertex (QgsVertexId &id, QgsPointV2 &vertex) const override
 Returns next vertex id and coordinates. More...
 
int numGeometries () const
 Returns the number of geometries within the collection. More...
 
QgsGeometryCollectionV2operator= (const QgsGeometryCollectionV2 &c)
 
virtual int partCount () const override
 Returns count of parts contained in the geometry. More...
 
virtual double perimeter () const override
 Returns the perimeter of the geometry. More...
 
virtual bool removeGeometry (int nr)
 Removes a geometry from the collection. More...
 
virtual int ringCount (int part=0) const override
 
QgsAbstractGeometryV2segmentize () const override
 Returns a geometry without curves. More...
 
virtual void transform (const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection d=QgsCoordinateTransform::ForwardTransform) override
 Transforms the geometry using a coordinate transform. More...
 
void transform (const QTransform &t) override
 Transforms the geometry using a QTransform object. More...
 
double vertexAngle (QgsVertexId vertex) const override
 Returns approximate rotation angle for a vertex. More...
 
virtual QgsPointV2 vertexAt (QgsVertexId id) const override
 Returns the point corresponding to a specified vertex id. More...
 
virtual int vertexCount (int part=0, int ring=0) const override
 
int wkbSize () const override
 Returns the size of the WKB representation of the geometry. More...
 
- Public Member Functions inherited from QgsAbstractGeometryV2
 QgsAbstractGeometryV2 ()
 
 QgsAbstractGeometryV2 (const QgsAbstractGeometryV2 &geom)
 
virtual ~QgsAbstractGeometryV2 ()
 
virtual QgsPointV2 centroid () const
 Returns the centroid of the geometry. More...
 
virtual bool convertTo (QgsWKBTypes::Type type)
 Converts the geometry to a specified type. More...
 
bool is3D () const
 Returns true if the geometry is 3D and contains a z-value. More...
 
bool isEmpty () const
 Returns true if the geometry is empty. More...
 
bool isMeasure () const
 Returns true if the geometry contains m values. More...
 
int nCoordinates () const
 Returns the number of nodes contained in the geometry. More...
 
virtual QgsAbstractGeometryV2operator= (const QgsAbstractGeometryV2 &geom)
 
QgsWKBTypes::Type wkbType () const
 Returns the WKB type of the geometry. More...
 
QString wktTypeStr () const
 Returns the WKT type string of the geometry. More...
 

Protected Member Functions

virtual QgsRectangle calculateBoundingBox () const override
 Default calculator for the minimal bounding box for the geometry. More...
 
virtual void clearCache () const override
 Clears any cached parameters associated with the geometry, eg bounding boxes. More...
 
bool fromCollectionWkt (const QString &wkt, const QList< QgsAbstractGeometryV2 * > &subtypes, const QString &defaultChildWkbType=QString())
 Reads a collection from a WKT string. More...
 
virtual bool wktOmitChildType () const
 Returns whether child type names are omitted from Wkt representations of the collection. More...
 
- Protected Member Functions inherited from QgsAbstractGeometryV2
void setZMTypeFromSubGeometry (const QgsAbstractGeometryV2 *subggeom, QgsWKBTypes::Type baseGeomType)
 Updates the geometry type based on whether sub geometries contain z or m values. More...
 

Protected Attributes

QVector< QgsAbstractGeometryV2 * > mGeometries
 
- Protected Attributes inherited from QgsAbstractGeometryV2
QgsWKBTypes::Type mWkbType
 

Detailed Description

Geometry collection.

Note
added in QGIS 2.10
this API is not considered stable and may change for 2.12

Definition at line 29 of file qgsgeometrycollectionv2.h.

Constructor & Destructor Documentation

QgsGeometryCollectionV2::QgsGeometryCollectionV2 ( )

Definition at line 30 of file qgsgeometrycollectionv2.cpp.

QgsGeometryCollectionV2::QgsGeometryCollectionV2 ( const QgsGeometryCollectionV2 c)

Definition at line 35 of file qgsgeometrycollectionv2.cpp.

QgsGeometryCollectionV2::~QgsGeometryCollectionV2 ( )
virtual

Definition at line 61 of file qgsgeometrycollectionv2.cpp.

Member Function Documentation

bool QgsGeometryCollectionV2::addGeometry ( QgsAbstractGeometryV2 g)
virtual

Adds a geometry and takes ownership.

Returns true in case of success.

Reimplemented in QgsMultiPointV2, QgsMultiPolygonV2, QgsMultiSurfaceV2, QgsMultiCurveV2, and QgsMultiLineStringV2.

Definition at line 95 of file qgsgeometrycollectionv2.cpp.

bool QgsGeometryCollectionV2::addMValue ( double  mValue = 0)
overridevirtual

Adds a measure to the geometry, initialized to a preset value.

Parameters
mValueinitial m-value for all nodes
Returns
true on success
Note
added in QGIS 2.12
See also
dropMValue()
addZValue()

Implements QgsAbstractGeometryV2.

Definition at line 603 of file qgsgeometrycollectionv2.cpp.

bool QgsGeometryCollectionV2::addZValue ( double  zValue = 0)
overridevirtual

Adds a z-dimension to the geometry, initialized to a preset value.

Parameters
zValueinitial z-value for all nodes
Returns
true on success
Note
added in QGIS 2.12
See also
dropZValue()
addMValue()

Implements QgsAbstractGeometryV2.

Definition at line 588 of file qgsgeometrycollectionv2.cpp.

double QgsGeometryCollectionV2::area ( ) const
overridevirtual

Returns the area of the geometry.

See also
length()
perimeter()

Reimplemented from QgsAbstractGeometryV2.

Definition at line 462 of file qgsgeometrycollectionv2.cpp.

QDomElement QgsGeometryCollectionV2::asGML2 ( QDomDocument doc,
int  precision = 17,
const QString ns = "gml" 
) const
overridevirtual

Returns a GML2 representation of the geometry.

Parameters
docDOM document
precisionnumber of decimal places for coordinates
nsXML namespace
See also
asWkb
asWkt
asGML3
asJSON

Implements QgsAbstractGeometryV2.

Reimplemented in QgsMultiCurveV2, QgsMultiLineStringV2, QgsMultiPointV2, QgsMultiPolygonV2, and QgsMultiSurfaceV2.

Definition at line 280 of file qgsgeometrycollectionv2.cpp.

QDomElement QgsGeometryCollectionV2::asGML3 ( QDomDocument doc,
int  precision = 17,
const QString ns = "gml" 
) const
overridevirtual

Returns a GML3 representation of the geometry.

Parameters
docDOM document
precisionnumber of decimal places for coordinates
nsXML namespace
See also
asWkb
asWkt
asGML2
asJSON

Implements QgsAbstractGeometryV2.

Reimplemented in QgsMultiCurveV2, QgsMultiLineStringV2, QgsMultiPointV2, QgsMultiPolygonV2, and QgsMultiSurfaceV2.

Definition at line 292 of file qgsgeometrycollectionv2.cpp.

QString QgsGeometryCollectionV2::asJSON ( int  precision = 17) const
overridevirtual

Returns a GeoJSON representation of the geometry.

Parameters
precisionnumber of decimal places for coordinates
See also
asWkb
asWkt
asGML2
asGML3

Implements QgsAbstractGeometryV2.

Reimplemented in QgsMultiCurveV2, QgsMultiLineStringV2, QgsMultiPointV2, QgsMultiPolygonV2, and QgsMultiSurfaceV2.

Definition at line 304 of file qgsgeometrycollectionv2.cpp.

unsigned char * QgsGeometryCollectionV2::asWkb ( int &  binarySize) const
overridevirtual

Returns a WKB representation of the geometry.

Parameters
binarySizewill be set to the size of the returned WKB string
See also
wkbSize
asWkt
asGML2
asGML3
asJSON

Implements QgsAbstractGeometryV2.

Definition at line 238 of file qgsgeometrycollectionv2.cpp.

QString QgsGeometryCollectionV2::asWkt ( int  precision = 17) const
overridevirtual

Returns a WKT representation of the geometry.

Parameters
precisionnumber of decimal places for coordinates
See also
asWkb
asGML2
asGML3
asJSON

Implements QgsAbstractGeometryV2.

Definition at line 260 of file qgsgeometrycollectionv2.cpp.

QgsRectangle QgsGeometryCollectionV2::boundingBox ( ) const
overridevirtual

Returns the minimal bounding box for the geometry.

Implements QgsAbstractGeometryV2.

Definition at line 319 of file qgsgeometrycollectionv2.cpp.

QgsRectangle QgsGeometryCollectionV2::calculateBoundingBox ( ) const
overrideprotectedvirtual

Default calculator for the minimal bounding box for the geometry.

Derived classes should override this method if a more efficient bounding box calculation is available.

Reimplemented from QgsAbstractGeometryV2.

Definition at line 328 of file qgsgeometrycollectionv2.cpp.

void QgsGeometryCollectionV2::clear ( )
overridevirtual

Clears the geometry, ie reset it to a null geometry.

Implements QgsAbstractGeometryV2.

Definition at line 71 of file qgsgeometrycollectionv2.cpp.

virtual void QgsGeometryCollectionV2::clearCache ( ) const
inlineoverrideprotectedvirtual

Clears any cached parameters associated with the geometry, eg bounding boxes.

Reimplemented from QgsAbstractGeometryV2.

Definition at line 142 of file qgsgeometrycollectionv2.h.

QgsGeometryCollectionV2 * QgsGeometryCollectionV2::clone ( ) const
overridevirtual

Clones the geometry by performing a deep copy.

Implements QgsAbstractGeometryV2.

Reimplemented in QgsMultiCurveV2, QgsMultiLineStringV2, QgsMultiPointV2, QgsMultiPolygonV2, and QgsMultiSurfaceV2.

Definition at line 66 of file qgsgeometrycollectionv2.cpp.

double QgsGeometryCollectionV2::closestSegment ( const QgsPointV2 pt,
QgsPointV2 segmentPt,
QgsVertexId vertexAfter,
bool *  leftOf,
double  epsilon 
) const
overridevirtual

Searches for the closest segment of the geometry to a given point.

Parameters
ptspecifies the point to find closest segment to
segmentPtstorage for the closest point within the geometry
vertexAfterstorage for the ID of the vertex at the end of the closest segment
leftOfreturns whether the point lies on the left side of the nearest segment (true if point is to left of segment, false if point is to right of segment)
epsilonepsilon for segment snapping
Returns
squared distance to closest segment

Implements QgsAbstractGeometryV2.

Definition at line 364 of file qgsgeometrycollectionv2.cpp.

QgsCoordinateSequenceV2 QgsGeometryCollectionV2::coordinateSequence ( ) const
overridevirtual

Retrieves the sequence of geometries, rings and nodes.

Returns
coordinate sequence

Implements QgsAbstractGeometryV2.

Definition at line 344 of file qgsgeometrycollectionv2.cpp.

bool QgsGeometryCollectionV2::deleteVertex ( QgsVertexId  position)
overridevirtual

Deletes a vertex within the geometry.

Parameters
positionvertex id for vertex to delete
Returns
true if delete was successful
See also
insertVertex
moveVertex

Implements QgsAbstractGeometryV2.

Definition at line 423 of file qgsgeometrycollectionv2.cpp.

int QgsGeometryCollectionV2::dimension ( ) const
overridevirtual

Returns the inherent dimension of the geometry.

For example, this is 0 for a point geometry, 1 for a linestring and 2 for a polygon.

Implements QgsAbstractGeometryV2.

Definition at line 131 of file qgsgeometrycollectionv2.cpp.

void QgsGeometryCollectionV2::draw ( QPainter p) const
overridevirtual

Draws the geometry using the specified QPainter.

Parameters
pdestination QPainter

Implements QgsAbstractGeometryV2.

Definition at line 175 of file qgsgeometrycollectionv2.cpp.

bool QgsGeometryCollectionV2::dropMValue ( )
overridevirtual

Drops any measure values which exist in the geometry.

Returns
true if m-values were present and have been removed
See also
addMValue()
dropZValue()
Note
added in QGIS 2.14

Implements QgsAbstractGeometryV2.

Definition at line 633 of file qgsgeometrycollectionv2.cpp.

bool QgsGeometryCollectionV2::dropZValue ( )
overridevirtual

Drops any z-dimensions which exist in the geometry.

Returns
true if Z values were present and have been removed
See also
addZValue()
dropMValue()
Note
added in QGIS 2.14

Implements QgsAbstractGeometryV2.

Definition at line 619 of file qgsgeometrycollectionv2.cpp.

bool QgsGeometryCollectionV2::fromCollectionWkt ( const QString wkt,
const QList< QgsAbstractGeometryV2 * > &  subtypes,
const QString defaultChildWkbType = QString() 
)
protected

Reads a collection from a WKT string.

Definition at line 484 of file qgsgeometrycollectionv2.cpp.

bool QgsGeometryCollectionV2::fromWkb ( QgsConstWkbPtr  wkb)
overridevirtual

Sets the geometry from a WKB string.

See also
fromWkt

Implements QgsAbstractGeometryV2.

Definition at line 184 of file qgsgeometrycollectionv2.cpp.

bool QgsGeometryCollectionV2::fromWkt ( const QString wkt)
overridevirtual

Sets the geometry from a WKT string.

See also
fromWkb

Implements QgsAbstractGeometryV2.

Reimplemented in QgsMultiCurveV2, QgsMultiLineStringV2, QgsMultiPointV2, QgsMultiPolygonV2, and QgsMultiSurfaceV2.

Definition at line 217 of file qgsgeometrycollectionv2.cpp.

const QgsAbstractGeometryV2 * QgsGeometryCollectionV2::geometryN ( int  n) const

Returns a const reference to a geometry from within the collection.

Parameters
nindex of geometry to return

Definition at line 84 of file qgsgeometrycollectionv2.cpp.

QgsAbstractGeometryV2 * QgsGeometryCollectionV2::geometryN ( int  n)

Returns a geometry from within the collection.

Parameters
nindex of geometry to return

Definition at line 89 of file qgsgeometrycollectionv2.cpp.

virtual QString QgsGeometryCollectionV2::geometryType ( ) const
inlineoverridevirtual

Returns a unique string representing the geometry type.

See also
wkbType
wktTypeStr

Implements QgsAbstractGeometryV2.

Reimplemented in QgsMultiCurveV2, QgsMultiLineStringV2, QgsMultiPointV2, QgsMultiPolygonV2, and QgsMultiSurfaceV2.

Definition at line 55 of file qgsgeometrycollectionv2.h.

bool QgsGeometryCollectionV2::hasCurvedSegments ( ) const
overridevirtual

Returns true if the geometry contains curved segments.

Reimplemented from QgsAbstractGeometryV2.

Definition at line 541 of file qgsgeometrycollectionv2.cpp.

bool QgsGeometryCollectionV2::insertGeometry ( QgsAbstractGeometryV2 g,
int  index 
)
virtual

Inserts a geometry before a specified index and takes ownership.

Returns true in case of success.

Parameters
ggeometry to insert. Ownership is transferred to the collection.
indexposition to insert geometry before

Definition at line 107 of file qgsgeometrycollectionv2.cpp.

bool QgsGeometryCollectionV2::insertVertex ( QgsVertexId  position,
const QgsPointV2 vertex 
)
overridevirtual

Inserts a vertex into the geometry.

Parameters
positionvertex id for position of inserted vertex
vertexvertex to insert
Returns
true if insert was successful
See also
moveVertex
deleteVertex

Implements QgsAbstractGeometryV2.

Definition at line 393 of file qgsgeometrycollectionv2.cpp.

double QgsGeometryCollectionV2::length ( ) const
overridevirtual

Returns the length of the geometry.

See also
area()
perimeter()

Reimplemented from QgsAbstractGeometryV2.

Definition at line 451 of file qgsgeometrycollectionv2.cpp.

bool QgsGeometryCollectionV2::moveVertex ( QgsVertexId  position,
const QgsPointV2 newPos 
)
overridevirtual

Moves a vertex within the geometry.

Parameters
positionvertex id for vertex to move
newPosnew position of vertex
Returns
true if move was successful
See also
insertVertex
deleteVertex

Implements QgsAbstractGeometryV2.

Definition at line 408 of file qgsgeometrycollectionv2.cpp.

bool QgsGeometryCollectionV2::nextVertex ( QgsVertexId id,
QgsPointV2 vertex 
) const
overridevirtual

Returns next vertex id and coordinates.

Parameters
idinitial value should be the starting vertex id. The next vertex id will be stored in this variable if found.
vertexcontainer for found node
Returns
false if at end

Implements QgsAbstractGeometryV2.

Definition at line 369 of file qgsgeometrycollectionv2.cpp.

int QgsGeometryCollectionV2::numGeometries ( ) const

Returns the number of geometries within the collection.

Definition at line 79 of file qgsgeometrycollectionv2.cpp.

QgsGeometryCollectionV2 & QgsGeometryCollectionV2::operator= ( const QgsGeometryCollectionV2 c)

Definition at line 45 of file qgsgeometrycollectionv2.cpp.

virtual int QgsGeometryCollectionV2::partCount ( ) const
inlineoverridevirtual

Returns count of parts contained in the geometry.

See also
vertexCount
ringCount

Implements QgsAbstractGeometryV2.

Definition at line 121 of file qgsgeometrycollectionv2.h.

double QgsGeometryCollectionV2::perimeter ( ) const
overridevirtual

Returns the perimeter of the geometry.

See also
area()
length()

Reimplemented from QgsAbstractGeometryV2.

Definition at line 473 of file qgsgeometrycollectionv2.cpp.

bool QgsGeometryCollectionV2::removeGeometry ( int  nr)
virtual

Removes a geometry from the collection.

Parameters
nrindex of geometry to remove
Returns
true if removal was successful.

Definition at line 119 of file qgsgeometrycollectionv2.cpp.

virtual int QgsGeometryCollectionV2::ringCount ( int  part = 0) const
inlineoverridevirtual

Implements QgsAbstractGeometryV2.

Definition at line 120 of file qgsgeometrycollectionv2.h.

QgsAbstractGeometryV2 * QgsGeometryCollectionV2::segmentize ( ) const
overridevirtual

Returns a geometry without curves.

Caller takes ownership

Reimplemented from QgsAbstractGeometryV2.

Definition at line 554 of file qgsgeometrycollectionv2.cpp.

void QgsGeometryCollectionV2::transform ( const QgsCoordinateTransform ct,
QgsCoordinateTransform::TransformDirection  d = QgsCoordinateTransform::ForwardTransform 
)
overridevirtual

Transforms the geometry using a coordinate transform.

Parameters
ctcoordinate transform
dtransformation direction

Implements QgsAbstractGeometryV2.

Definition at line 146 of file qgsgeometrycollectionv2.cpp.

void QgsGeometryCollectionV2::transform ( const QTransform t)
overridevirtual

Transforms the geometry using a QTransform object.

Parameters
tQTransform transformation

Implements QgsAbstractGeometryV2.

Definition at line 155 of file qgsgeometrycollectionv2.cpp.

double QgsGeometryCollectionV2::vertexAngle ( QgsVertexId  vertex) const
overridevirtual

Returns approximate rotation angle for a vertex.

Usually average angle between adjacent segments.

Parameters
vertexthe vertex id
Returns
rotation in radians, clockwise from north

Implements QgsAbstractGeometryV2.

Definition at line 572 of file qgsgeometrycollectionv2.cpp.

virtual QgsPointV2 QgsGeometryCollectionV2::vertexAt ( QgsVertexId  id) const
inlineoverridevirtual

Returns the point corresponding to a specified vertex id.

Implements QgsAbstractGeometryV2.

Definition at line 122 of file qgsgeometrycollectionv2.h.

virtual int QgsGeometryCollectionV2::vertexCount ( int  part = 0,
int  ring = 0 
) const
inlineoverridevirtual

Implements QgsAbstractGeometryV2.

Definition at line 119 of file qgsgeometrycollectionv2.h.

int QgsGeometryCollectionV2::wkbSize ( ) const
overridevirtual

Returns the size of the WKB representation of the geometry.

See also
asWkb

Implements QgsAbstractGeometryV2.

Definition at line 225 of file qgsgeometrycollectionv2.cpp.

virtual bool QgsGeometryCollectionV2::wktOmitChildType ( ) const
inlineprotectedvirtual

Returns whether child type names are omitted from Wkt representations of the collection.

Note
added in QGIS 2.12

Reimplemented in QgsMultiPointV2, QgsMultiPolygonV2, and QgsMultiLineStringV2.

Definition at line 135 of file qgsgeometrycollectionv2.h.

Member Data Documentation

QVector< QgsAbstractGeometryV2* > QgsGeometryCollectionV2::mGeometries
protected

Definition at line 130 of file qgsgeometrycollectionv2.h.


The documentation for this class was generated from the following files: