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

Abstract base class for all geometries. More...

#include <qgsabstractgeometryv2.h>

Inheritance diagram for QgsAbstractGeometryV2:
Inheritance graph
[legend]

Public Member Functions

 QgsAbstractGeometryV2 ()
 
 QgsAbstractGeometryV2 (const QgsAbstractGeometryV2 &geom)
 
virtual ~QgsAbstractGeometryV2 ()
 
virtual bool addMValue (double mValue=0)=0
 Adds a measure to the geometry, initialized to a preset value. More...
 
virtual bool addZValue (double zValue=0)=0
 Adds a z-dimension to the geometry, initialized to a preset value. More...
 
virtual double area () const
 Returns the area of the geometry. More...
 
virtual QDomElement asGML2 (QDomDocument &doc, int precision=17, const QString &ns="gml") const =0
 Returns a GML2 representation of the geometry. More...
 
virtual QDomElement asGML3 (QDomDocument &doc, int precision=17, const QString &ns="gml") const =0
 Returns a GML3 representation of the geometry. More...
 
virtual QString asJSON (int precision=17) const =0
 Returns a GeoJSON representation of the geometry. More...
 
virtual unsigned char * asWkb (int &binarySize) const =0
 Returns a WKB representation of the geometry. More...
 
virtual QString asWkt (int precision=17) const =0
 Returns a WKT representation of the geometry. More...
 
virtual QgsRectangle boundingBox () const =0
 Returns the minimal bounding box for the geometry. More...
 
virtual QgsPointV2 centroid () const
 Returns the centroid of the geometry. More...
 
virtual void clear ()=0
 Clears the geometry, ie reset it to a null geometry. More...
 
virtual QgsAbstractGeometryV2clone () const =0
 Clones the geometry by performing a deep copy. More...
 
virtual double closestSegment (const QgsPointV2 &pt, QgsPointV2 &segmentPt, QgsVertexId &vertexAfter, bool *leftOf, double epsilon) const =0
 Searches for the closest segment of the geometry to a given point. More...
 
virtual bool convertTo (QgsWKBTypes::Type type)
 Converts the geometry to a specified type. More...
 
virtual QgsCoordinateSequenceV2 coordinateSequence () const =0
 Retrieves the sequence of geometries, rings and nodes. More...
 
virtual bool deleteVertex (QgsVertexId position)=0
 Deletes a vertex within the geometry. More...
 
virtual int dimension () const =0
 Returns the inherent dimension of the geometry. More...
 
virtual void draw (QPainter &p) const =0
 Draws the geometry using the specified QPainter. More...
 
virtual bool dropMValue ()=0
 Drops any measure values which exist in the geometry. More...
 
virtual bool dropZValue ()=0
 Drops any z-dimensions which exist in the geometry. More...
 
virtual bool fromWkb (QgsConstWkbPtr wkb)=0
 Sets the geometry from a WKB string. More...
 
virtual bool fromWkt (const QString &wkt)=0
 Sets the geometry from a WKT string. More...
 
virtual QString geometryType () const =0
 Returns a unique string representing the geometry type. More...
 
virtual bool hasCurvedSegments () const
 Returns true if the geometry contains curved segments. More...
 
virtual bool insertVertex (QgsVertexId position, const QgsPointV2 &vertex)=0
 Inserts a vertex into the geometry. 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...
 
virtual double length () const
 Returns the length of the geometry. More...
 
virtual bool moveVertex (QgsVertexId position, const QgsPointV2 &newPos)=0
 Moves a vertex within the geometry. More...
 
int nCoordinates () const
 Returns the number of nodes contained in the geometry. More...
 
virtual bool nextVertex (QgsVertexId &id, QgsPointV2 &vertex) const =0
 Returns next vertex id and coordinates. More...
 
virtual QgsAbstractGeometryV2operator= (const QgsAbstractGeometryV2 &geom)
 
virtual int partCount () const =0
 Returns count of parts contained in the geometry. More...
 
virtual double perimeter () const
 Returns the perimeter of the geometry. More...
 
virtual int ringCount (int part=0) const =0
 
virtual QgsAbstractGeometryV2segmentize () const
 Returns a version of the geometry without curves. More...
 
virtual void transform (const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection d=QgsCoordinateTransform::ForwardTransform)=0
 Transforms the geometry using a coordinate transform. More...
 
virtual void transform (const QTransform &t)=0
 Transforms the geometry using a QTransform object. More...
 
virtual double vertexAngle (QgsVertexId vertex) const =0
 Returns approximate angle at a vertex. More...
 
virtual QgsPointV2 vertexAt (QgsVertexId id) const =0
 Returns the point corresponding to a specified vertex id. More...
 
virtual int vertexCount (int part=0, int ring=0) const =0
 
virtual int wkbSize () const =0
 Returns the size of the WKB representation of the geometry. More...
 
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
 Default calculator for the minimal bounding box for the geometry. More...
 
virtual void clearCache () const
 Clears any cached parameters associated with the geometry, eg bounding boxes. More...
 
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

QgsWKBTypes::Type mWkbType
 

Detailed Description

Abstract base class for all geometries.

Note
added in QGIS 2.10

Definition at line 44 of file qgsabstractgeometryv2.h.

Constructor & Destructor Documentation

QgsAbstractGeometryV2::QgsAbstractGeometryV2 ( )

Definition at line 25 of file qgsabstractgeometryv2.cpp.

QgsAbstractGeometryV2::~QgsAbstractGeometryV2 ( )
virtual

Definition at line 29 of file qgsabstractgeometryv2.cpp.

QgsAbstractGeometryV2::QgsAbstractGeometryV2 ( const QgsAbstractGeometryV2 geom)

Definition at line 33 of file qgsabstractgeometryv2.cpp.

Member Function Documentation

virtual bool QgsAbstractGeometryV2::addMValue ( double  mValue = 0)
pure virtual

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()

Implemented in QgsPointV2, QgsLineStringV2, QgsCircularStringV2, QgsGeometryCollectionV2, QgsCompoundCurveV2, and QgsCurvePolygonV2.

virtual bool QgsAbstractGeometryV2::addZValue ( double  zValue = 0)
pure virtual

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()

Implemented in QgsPointV2, QgsLineStringV2, QgsCircularStringV2, QgsGeometryCollectionV2, QgsCompoundCurveV2, and QgsCurvePolygonV2.

virtual double QgsAbstractGeometryV2::area ( ) const
inlinevirtual

Returns the area of the geometry.

See also
length()
perimeter()

Reimplemented in QgsGeometryCollectionV2, and QgsCurvePolygonV2.

Definition at line 277 of file qgsabstractgeometryv2.h.

virtual QDomElement QgsAbstractGeometryV2::asGML2 ( QDomDocument doc,
int  precision = 17,
const QString ns = "gml" 
) const
pure virtual

Returns a GML2 representation of the geometry.

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

Implemented in QgsPointV2, QgsLineStringV2, QgsGeometryCollectionV2, QgsCompoundCurveV2, QgsCircularStringV2, QgsCurvePolygonV2, QgsMultiCurveV2, QgsMultiLineStringV2, QgsMultiPointV2, QgsMultiPolygonV2, and QgsMultiSurfaceV2.

virtual QDomElement QgsAbstractGeometryV2::asGML3 ( QDomDocument doc,
int  precision = 17,
const QString ns = "gml" 
) const
pure virtual

Returns a GML3 representation of the geometry.

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

Implemented in QgsPointV2, QgsLineStringV2, QgsGeometryCollectionV2, QgsCompoundCurveV2, QgsCircularStringV2, QgsCurvePolygonV2, QgsMultiCurveV2, QgsMultiLineStringV2, QgsMultiPointV2, QgsMultiPolygonV2, and QgsMultiSurfaceV2.

virtual QString QgsAbstractGeometryV2::asJSON ( int  precision = 17) const
pure virtual

Returns a GeoJSON representation of the geometry.

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

Implemented in QgsPointV2, QgsLineStringV2, QgsGeometryCollectionV2, QgsCompoundCurveV2, QgsCircularStringV2, QgsCurvePolygonV2, QgsMultiCurveV2, QgsMultiLineStringV2, QgsMultiPointV2, QgsMultiPolygonV2, and QgsMultiSurfaceV2.

virtual unsigned char* QgsAbstractGeometryV2::asWkb ( int &  binarySize) const
pure virtual

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

Implemented in QgsPointV2, QgsLineStringV2, QgsGeometryCollectionV2, QgsCompoundCurveV2, QgsCircularStringV2, QgsCurvePolygonV2, and QgsPolygonV2.

virtual QString QgsAbstractGeometryV2::asWkt ( int  precision = 17) const
pure virtual

Returns a WKT representation of the geometry.

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

Implemented in QgsPointV2, QgsLineStringV2, QgsGeometryCollectionV2, QgsCompoundCurveV2, QgsCircularStringV2, and QgsCurvePolygonV2.

virtual QgsRectangle QgsAbstractGeometryV2::boundingBox ( ) const
pure virtual

Returns the minimal bounding box for the geometry.

Implemented in QgsPointV2, QgsCurveV2, QgsGeometryCollectionV2, and QgsSurfaceV2.

QgsRectangle QgsAbstractGeometryV2::calculateBoundingBox ( ) const
protectedvirtual

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 in QgsLineStringV2, QgsGeometryCollectionV2, QgsCircularStringV2, QgsCompoundCurveV2, and QgsCurvePolygonV2.

Definition at line 111 of file qgsabstractgeometryv2.cpp.

QgsPointV2 QgsAbstractGeometryV2::centroid ( ) const
virtual

Returns the centroid of the geometry.

Reimplemented in QgsLineStringV2.

Definition at line 163 of file qgsabstractgeometryv2.cpp.

virtual void QgsAbstractGeometryV2::clear ( )
pure virtual

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

Implemented in QgsPointV2, QgsLineStringV2, QgsGeometryCollectionV2, QgsCompoundCurveV2, QgsCircularStringV2, and QgsCurvePolygonV2.

virtual void QgsAbstractGeometryV2::clearCache ( ) const
inlineprotectedvirtual

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

Reimplemented in QgsGeometryCollectionV2, QgsCurveV2, and QgsSurfaceV2.

Definition at line 366 of file qgsabstractgeometryv2.h.

virtual QgsAbstractGeometryV2* QgsAbstractGeometryV2::clone ( ) const
pure virtual
virtual double QgsAbstractGeometryV2::closestSegment ( const QgsPointV2 pt,
QgsPointV2 segmentPt,
QgsVertexId vertexAfter,
bool *  leftOf,
double  epsilon 
) const
pure virtual

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

Implemented in QgsPointV2, QgsLineStringV2, QgsCircularStringV2, QgsCompoundCurveV2, QgsGeometryCollectionV2, and QgsCurvePolygonV2.

bool QgsAbstractGeometryV2::convertTo ( QgsWKBTypes::Type  type)
virtual

Converts the geometry to a specified type.

Returns
true if conversion was successful
Note
added in QGIS 2.14

Reimplemented in QgsPointV2, and QgsLineStringV2.

Definition at line 210 of file qgsabstractgeometryv2.cpp.

virtual QgsCoordinateSequenceV2 QgsAbstractGeometryV2::coordinateSequence ( ) const
pure virtual

Retrieves the sequence of geometries, rings and nodes.

Returns
coordinate sequence

Implemented in QgsPointV2, QgsGeometryCollectionV2, QgsCurvePolygonV2, and QgsCurveV2.

virtual bool QgsAbstractGeometryV2::deleteVertex ( QgsVertexId  position)
pure virtual

Deletes a vertex within the geometry.

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

Implemented in QgsPointV2, QgsLineStringV2, QgsCircularStringV2, QgsGeometryCollectionV2, QgsCompoundCurveV2, and QgsCurvePolygonV2.

virtual int QgsAbstractGeometryV2::dimension ( ) const
pure virtual

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.

Implemented in QgsPointV2, QgsLineStringV2, QgsGeometryCollectionV2, QgsCompoundCurveV2, QgsCircularStringV2, and QgsCurvePolygonV2.

virtual void QgsAbstractGeometryV2::draw ( QPainter p) const
pure virtual

Draws the geometry using the specified QPainter.

Parameters
pdestination QPainter

Implemented in QgsPointV2, QgsLineStringV2, QgsCircularStringV2, QgsCompoundCurveV2, QgsGeometryCollectionV2, and QgsCurvePolygonV2.

virtual bool QgsAbstractGeometryV2::dropMValue ( )
pure virtual

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

Implemented in QgsPointV2, QgsLineStringV2, QgsCircularStringV2, QgsGeometryCollectionV2, QgsCompoundCurveV2, and QgsCurvePolygonV2.

virtual bool QgsAbstractGeometryV2::dropZValue ( )
pure virtual

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

Implemented in QgsPointV2, QgsLineStringV2, QgsCircularStringV2, QgsGeometryCollectionV2, QgsCompoundCurveV2, and QgsCurvePolygonV2.

virtual bool QgsAbstractGeometryV2::fromWkb ( QgsConstWkbPtr  wkb)
pure virtual
virtual bool QgsAbstractGeometryV2::fromWkt ( const QString wkt)
pure virtual
virtual QString QgsAbstractGeometryV2::geometryType ( ) const
pure virtual
virtual bool QgsAbstractGeometryV2::hasCurvedSegments ( ) const
inlinevirtual

Returns true if the geometry contains curved segments.

Reimplemented in QgsCircularStringV2, QgsGeometryCollectionV2, QgsCompoundCurveV2, and QgsCurvePolygonV2.

Definition at line 288 of file qgsabstractgeometryv2.h.

virtual bool QgsAbstractGeometryV2::insertVertex ( QgsVertexId  position,
const QgsPointV2 vertex 
)
pure virtual

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

Implemented in QgsPointV2, QgsLineStringV2, QgsCircularStringV2, QgsGeometryCollectionV2, QgsCompoundCurveV2, and QgsCurvePolygonV2.

bool QgsAbstractGeometryV2::is3D ( ) const

Returns true if the geometry is 3D and contains a z-value.

See also
isMeasure

Definition at line 48 of file qgsabstractgeometryv2.cpp.

bool QgsAbstractGeometryV2::isEmpty ( ) const

Returns true if the geometry is empty.

Definition at line 241 of file qgsabstractgeometryv2.cpp.

bool QgsAbstractGeometryV2::isMeasure ( ) const

Returns true if the geometry contains m values.

See also
is3D

Definition at line 53 of file qgsabstractgeometryv2.cpp.

virtual double QgsAbstractGeometryV2::length ( ) const
inlinevirtual

Returns the length of the geometry.

See also
area()
perimeter()

Reimplemented in QgsLineStringV2, QgsGeometryCollectionV2, QgsCircularStringV2, and QgsCompoundCurveV2.

Definition at line 265 of file qgsabstractgeometryv2.h.

virtual bool QgsAbstractGeometryV2::moveVertex ( QgsVertexId  position,
const QgsPointV2 newPos 
)
pure virtual

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

Implemented in QgsPointV2, QgsLineStringV2, QgsCircularStringV2, QgsGeometryCollectionV2, QgsCompoundCurveV2, and QgsCurvePolygonV2.

int QgsAbstractGeometryV2::nCoordinates ( ) const

Returns the number of nodes contained in the geometry.

Definition at line 138 of file qgsabstractgeometryv2.cpp.

virtual bool QgsAbstractGeometryV2::nextVertex ( QgsVertexId id,
QgsPointV2 vertex 
) const
pure virtual

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

Implemented in QgsPointV2, QgsGeometryCollectionV2, QgsCurvePolygonV2, and QgsCurveV2.

QgsAbstractGeometryV2 & QgsAbstractGeometryV2::operator= ( const QgsAbstractGeometryV2 geom)
virtual

Definition at line 38 of file qgsabstractgeometryv2.cpp.

virtual int QgsAbstractGeometryV2::partCount ( ) const
pure virtual

Returns count of parts contained in the geometry.

See also
vertexCount
ringCount

Implemented in QgsPointV2, QgsGeometryCollectionV2, QgsCurveV2, and QgsCurvePolygonV2.

virtual double QgsAbstractGeometryV2::perimeter ( ) const
inlinevirtual

Returns the perimeter of the geometry.

See also
area()
length()

Reimplemented in QgsGeometryCollectionV2, and QgsCurvePolygonV2.

Definition at line 271 of file qgsabstractgeometryv2.h.

virtual int QgsAbstractGeometryV2::ringCount ( int  part = 0) const
pure virtual
virtual QgsAbstractGeometryV2* QgsAbstractGeometryV2::segmentize ( ) const
inlinevirtual

Returns a version of the geometry without curves.

Caller takes ownership of the returned geometry.

Reimplemented in QgsGeometryCollectionV2, QgsCurveV2, and QgsCurvePolygonV2.

Definition at line 293 of file qgsabstractgeometryv2.h.

void QgsAbstractGeometryV2::setZMTypeFromSubGeometry ( const QgsAbstractGeometryV2 subggeom,
QgsWKBTypes::Type  baseGeomType 
)
protected

Updates the geometry type based on whether sub geometries contain z or m values.

Definition at line 69 of file qgsabstractgeometryv2.cpp.

virtual void QgsAbstractGeometryV2::transform ( const QgsCoordinateTransform ct,
QgsCoordinateTransform::TransformDirection  d = QgsCoordinateTransform::ForwardTransform 
)
pure virtual

Transforms the geometry using a coordinate transform.

Parameters
ctcoordinate transform
dtransformation direction

Implemented in QgsPointV2, QgsLineStringV2, QgsCircularStringV2, QgsCompoundCurveV2, QgsCurvePolygonV2, and QgsGeometryCollectionV2.

virtual void QgsAbstractGeometryV2::transform ( const QTransform t)
pure virtual

Transforms the geometry using a QTransform object.

Parameters
tQTransform transformation

Implemented in QgsPointV2, QgsLineStringV2, QgsCircularStringV2, QgsCompoundCurveV2, QgsCurvePolygonV2, and QgsGeometryCollectionV2.

virtual double QgsAbstractGeometryV2::vertexAngle ( QgsVertexId  vertex) const
pure virtual

Returns approximate angle at a vertex.

This is usually the average angle between adjacent segments, and can be pictured as the orientation of a line following the curvature of the geometry at the specified vertex.

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

Implemented in QgsPointV2, QgsLineStringV2, QgsCircularStringV2, QgsGeometryCollectionV2, QgsCompoundCurveV2, and QgsCurvePolygonV2.

virtual QgsPointV2 QgsAbstractGeometryV2::vertexAt ( QgsVertexId  id) const
pure virtual

Returns the point corresponding to a specified vertex id.

Implemented in QgsPointV2, QgsGeometryCollectionV2, QgsCurveV2, and QgsCurvePolygonV2.

virtual int QgsAbstractGeometryV2::vertexCount ( int  part = 0,
int  ring = 0 
) const
pure virtual
virtual int QgsAbstractGeometryV2::wkbSize ( ) const
pure virtual

Returns the size of the WKB representation of the geometry.

See also
asWkb

Implemented in QgsPointV2, QgsLineStringV2, QgsGeometryCollectionV2, QgsCompoundCurveV2, QgsCircularStringV2, QgsCurvePolygonV2, and QgsPolygonV2.

QgsWKBTypes::Type QgsAbstractGeometryV2::wkbType ( ) const
inline

Returns the WKB type of the geometry.

See also
geometryType
wktTypeStr

Definition at line 81 of file qgsabstractgeometryv2.h.

QString QgsAbstractGeometryV2::wktTypeStr ( ) const

Returns the WKT type string of the geometry.

See also
geometryType
wkbType

Definition at line 153 of file qgsabstractgeometryv2.cpp.

Member Data Documentation

QgsWKBTypes::Type QgsAbstractGeometryV2::mWkbType
protected

Definition at line 353 of file qgsabstractgeometryv2.h.


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