QGIS API Documentation  2.10.1-Pisa
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Static 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 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...
 
QgsRectangle boundingBox () const
 Returns the minimal bounding box for the geometry. More...
 
virtual QgsRectangle calculateBoundingBox () const
 Calculates the minimal bounding box for 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 void coordinateSequence (QList< QList< QList< QgsPointV2 > > > &coord) const =0
 Retrieves the sequence of geometries, rings and nodes. More...
 
virtual bool deleteVertex (const 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 fromWkb (const unsigned char *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 (const 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 (or perimeter for area geometries) of the geometry. More...
 
virtual bool moveVertex (const 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 QgsAbstractGeometryV2segmentize () const
 Returns a version of the geometry without curves. More...
 
virtual void transform (const QgsCoordinateTransform &ct)=0
 Transforms the geometry using a coordinate transform. More...
 
virtual void transform (const QTransform &t)=0
 Transforms the geometry using a QTransform object. More...
 
QgsPointV2 vertexAt (const QgsVertexId &id) const
 Returns the point corresponding to a specified vertex id. More...
 
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

void setZMTypeFromSubGeometry (const QgsAbstractGeometryV2 *subggeom, QgsWKBTypes::Type baseGeomType)
 Updates the geometry type based on whether sub geometries contain z or m values. More...
 

Static Protected Member Functions

static bool readWkbHeader (QgsConstWkbPtr &wkbPtr, QgsWKBTypes::Type &wkbType, bool &endianSwap, QgsWKBTypes::Type expectedType)
 Reads a WKB header and tests its validity. More...
 

Protected Attributes

QgsRectangle mBoundingBox
 
QgsWKBTypes::Type mWkbType
 

Detailed Description

Abstract base class for all geometries.

Note
added in QGIS 2.10

Definition at line 75 of file qgsabstractgeometryv2.h.

Constructor & Destructor Documentation

QgsAbstractGeometryV2::QgsAbstractGeometryV2 ( )

Definition at line 24 of file qgsabstractgeometryv2.cpp.

QgsAbstractGeometryV2::~QgsAbstractGeometryV2 ( )
virtual

Definition at line 28 of file qgsabstractgeometryv2.cpp.

QgsAbstractGeometryV2::QgsAbstractGeometryV2 ( const QgsAbstractGeometryV2 geom)

Definition at line 32 of file qgsabstractgeometryv2.cpp.

Member Function Documentation

virtual double QgsAbstractGeometryV2::area ( ) const
inlinevirtual

Returns the area of the geometry.

See Also
length

Reimplemented in QgsGeometryCollectionV2, QgsCurveV2, and QgsCurvePolygonV2.

Definition at line 303 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 QgsGeometryCollectionV2, QgsPointV2, QgsCurvePolygonV2, QgsCompoundCurveV2, QgsCircularStringV2, QgsLineStringV2, 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 QgsGeometryCollectionV2, QgsPointV2, QgsCurvePolygonV2, QgsCompoundCurveV2, QgsCircularStringV2, QgsLineStringV2, 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 QgsGeometryCollectionV2, QgsPointV2, QgsCurvePolygonV2, QgsCompoundCurveV2, QgsCircularStringV2, QgsLineStringV2, 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 QgsGeometryCollectionV2, QgsPointV2, QgsCurvePolygonV2, QgsCompoundCurveV2, QgsCircularStringV2, QgsLineStringV2, 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 QgsGeometryCollectionV2, QgsPointV2, QgsCurvePolygonV2, QgsCompoundCurveV2, QgsCircularStringV2, and QgsLineStringV2.

QgsRectangle QgsAbstractGeometryV2::boundingBox ( ) const

Returns the minimal bounding box for the geometry.

Definition at line 47 of file qgsabstractgeometryv2.cpp.

QgsRectangle QgsAbstractGeometryV2::calculateBoundingBox ( ) const
virtual

Calculates the minimal bounding box for the geometry.

Derived classes should override this method to return the correct bounding box.

Reimplemented in QgsGeometryCollectionV2, QgsPointV2, QgsCurvePolygonV2, QgsCompoundCurveV2, and QgsCircularStringV2.

Definition at line 105 of file qgsabstractgeometryv2.cpp.

virtual void QgsAbstractGeometryV2::clear ( )
pure virtual

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

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

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 for search
segmentPtstorage for the closest point within the geometry
vertexAfterstorage for the id of the vertex after the closest segment
leftOfreturns if the point lies on the left of right side of the segment ( < 0 means left, > 0 means right )
epsilonepsilon for segment snapping
Returns
squared distance to closest segment

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

virtual void QgsAbstractGeometryV2::coordinateSequence ( QList< QList< QList< QgsPointV2 > > > &  coord) const
pure virtual

Retrieves the sequence of geometries, rings and nodes.

Parameters
coorddestination for coordinate sequence.

Implemented in QgsCurvePolygonV2, QgsCurveV2, QgsGeometryCollectionV2, and QgsPointV2.

virtual bool QgsAbstractGeometryV2::deleteVertex ( const 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 QgsCompoundCurveV2, QgsGeometryCollectionV2, QgsCurvePolygonV2, QgsCircularStringV2, QgsPointV2, and QgsLineStringV2.

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

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

Draws the geometry using the specified QPainter.

Parameters
pdestination QPainter

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

virtual bool QgsAbstractGeometryV2::fromWkb ( const unsigned char *  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 QgsCompoundCurveV2, QgsGeometryCollectionV2, QgsCurvePolygonV2, and QgsCircularStringV2.

Definition at line 311 of file qgsabstractgeometryv2.h.

virtual bool QgsAbstractGeometryV2::insertVertex ( const 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 QgsCompoundCurveV2, QgsGeometryCollectionV2, QgsCurvePolygonV2, QgsCircularStringV2, QgsPointV2, and QgsLineStringV2.

bool QgsAbstractGeometryV2::is3D ( ) const

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

See Also
isMeasure

Definition at line 56 of file qgsabstractgeometryv2.cpp.

bool QgsAbstractGeometryV2::isEmpty ( ) const

Returns true if the geometry is empty.

Definition at line 207 of file qgsabstractgeometryv2.cpp.

bool QgsAbstractGeometryV2::isMeasure ( ) const

Returns true if the geometry contains m values.

See Also
is3D

Definition at line 61 of file qgsabstractgeometryv2.cpp.

virtual double QgsAbstractGeometryV2::length ( ) const
inlinevirtual

Returns the length (or perimeter for area geometries) of the geometry.

See Also
area

Reimplemented in QgsGeometryCollectionV2, QgsCircularStringV2, QgsCurvePolygonV2, QgsCompoundCurveV2, and QgsLineStringV2.

Definition at line 298 of file qgsabstractgeometryv2.h.

virtual bool QgsAbstractGeometryV2::moveVertex ( const 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 QgsCompoundCurveV2, QgsGeometryCollectionV2, QgsCurvePolygonV2, QgsCircularStringV2, QgsPointV2, and QgsLineStringV2.

int QgsAbstractGeometryV2::nCoordinates ( ) const

Returns the number of nodes contained in the geometry.

Definition at line 154 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 QgsCurvePolygonV2, QgsCurveV2, QgsGeometryCollectionV2, and QgsPointV2.

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

Definition at line 37 of file qgsabstractgeometryv2.cpp.

bool QgsAbstractGeometryV2::readWkbHeader ( QgsConstWkbPtr wkbPtr,
QgsWKBTypes::Type wkbType,
bool &  endianSwap,
QgsWKBTypes::Type  expectedType 
)
staticprotected

Reads a WKB header and tests its validity.

Parameters
wkbPtr
wkbTypedestination for WKB type from header
endianSwapwill be set to true if endian from WKB must be swapped to match QGIS platform endianness
expectedTypeexpected WKB type
Returns
true if header is valid and matches expected type

Definition at line 184 of file qgsabstractgeometryv2.cpp.

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 316 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 77 of file qgsabstractgeometryv2.cpp.

virtual void QgsAbstractGeometryV2::transform ( const QgsCoordinateTransform ct)
pure virtual

Transforms the geometry using a coordinate transform.

Parameters
ctcoordinate transform

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

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

Transforms the geometry using a QTransform object.

Parameters
tQTransform transformation

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

QgsPointV2 QgsAbstractGeometryV2::vertexAt ( const QgsVertexId id) const

Returns the point corresponding to a specified vertex id.

Definition at line 132 of file qgsabstractgeometryv2.cpp.

virtual int QgsAbstractGeometryV2::wkbSize ( ) const
pure virtual

Returns the size of the WKB representation of the geometry.

See Also
asWkb

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

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

Returns the WKB type of the geometry.

See Also
geometryType
wktTypeStr

Definition at line 117 of file qgsabstractgeometryv2.h.

QString QgsAbstractGeometryV2::wktTypeStr ( ) const

Returns the WKT type string of the geometry.

See Also
geometryType
wkbType

Definition at line 174 of file qgsabstractgeometryv2.cpp.

Member Data Documentation

QgsRectangle QgsAbstractGeometryV2::mBoundingBox
mutableprotected

Definition at line 320 of file qgsabstractgeometryv2.h.

QgsWKBTypes::Type QgsAbstractGeometryV2::mWkbType
protected

Definition at line 319 of file qgsabstractgeometryv2.h.


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