QGIS API Documentation  2.8.2-Wien
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Public Member Functions | Static Public Member Functions | List of all members
QgsGeometry Class Reference

#include <qgsgeometry.h>

Classes

class  Error

Public Member Functions

 QgsGeometry ()
 Constructor.
 QgsGeometry (const QgsGeometry &)
 copy constructor will prompt a deep copy of the object
 ~QgsGeometry ()
 Destructor.
int addPart (const QList< QgsPoint > &points, QGis::GeometryType geomType=QGis::UnknownGeometry)
 Adds a new island polygon to a multipolygon feature.
int addPart (GEOSGeometry *newPart)
 Adds a new island polygon to a multipolygon feature.
int addPart (QgsGeometry *newPart)
 Adds a new island polygon to a multipolygon feature.
int addRing (const QList< QgsPoint > &ring)
 Adds a new ring to this geometry.
void adjacentVertices (int atVertex, int &beforeVertex, int &afterVertex)
 Returns the indexes of the vertices before and after the given vertex index.
double area ()
 get area of geometry using GEOS
QList< QgsGeometry * > asGeometryCollection () const
 return contents of the geometry as a list of geometries
const GEOSGeometry * asGeos () const
 Returns a geos geometry.
QgsMultiPoint asMultiPoint () const
 return contents of the geometry as a multi point if wkbType is WKBMultiPoint, otherwise an empty list
QgsMultiPolygon asMultiPolygon () const
 return contents of the geometry as a multi polygon if wkbType is WKBMultiPolygon, otherwise an empty list
QgsMultiPolyline asMultiPolyline () const
 return contents of the geometry as a multi linestring if wkbType is WKBMultiLineString, otherwise an empty list
QgsPoint asPoint () const
 return contents of the geometry as a point if wkbType is WKBPoint, otherwise returns [0,0]
QgsPolygon asPolygon () const
 return contents of the geometry as a polygon if wkbType is WKBPolygon, otherwise an empty list
QgsPolyline asPolyline () const
 return contents of the geometry as a polyline if wkbType is WKBLineString, otherwise an empty list
QPointF asQPointF () const
 Return contents of the geometry as a QPointF if wkbType is WKBPoint, otherwise returns a null QPointF.
QPolygonF asQPolygonF () const
 Return contents of the geometry as a QPolygonF.
const unsigned char * asWkb () const
 Returns the buffer containing this geometry in WKB format.
int avoidIntersections (QMap< QgsVectorLayer *, QSet< QgsFeatureId > > ignoreFeatures=(QMap< QgsVectorLayer *, QSet< QgsFeatureId > >()))
 Modifies geometry to avoid intersections with the layers specified in project properties.
QgsRectangle boundingBox ()
 Returns the bounding box of this feature.
QgsGeometrybuffer (double distance, int segments)
 Returns a buffer region around this geometry having the given width and with a specified number of segments used to approximate curves.
QgsGeometrybuffer (double distance, int segments, int endCapStyle, int joinStyle, double mitreLimit)
 Returns a buffer region around the geometry, with additional style options.
QgsGeometrycentroid ()
 Returns the center of mass of a geometry.
double closestSegmentWithContext (const QgsPoint &point, QgsPoint &minDistPoint, int &afterVertex, double *leftOf=0, double epsilon=DEFAULT_SEGMENT_EPSILON)
 Searches for the closest segment of geometry to the given point.
QgsPoint closestVertex (const QgsPoint &point, int &atVertex, int &beforeVertex, int &afterVertex, double &sqrDist)
 Returns the vertex closest to the given point, the corresponding vertex index, squared distance snap point / target point and the indices of the vertices before/after.
double closestVertexWithContext (const QgsPoint &point, int &atVertex)
 Searches for the closest vertex in this geometry to the given point.
QgsGeometrycombine (QgsGeometry *geometry)
 Returns a geometry representing all the points in this geometry and other (a union geometry operation).
bool contains (const QgsPoint *p) const
 Test for containment of a point (uses GEOS)
bool contains (const QgsGeometry *geometry) const
 Test for if geometry is contained in another (uses GEOS)
bool convertToMultiType ()
 Converts single type geometry into multitype geometry e.g.
QgsGeometryconvertToType (QGis::GeometryType destType, bool destMultipart=false)
 try to convert the geometry to the requested type
QgsGeometryconvexHull ()
 Returns the smallest convex polygon that contains all the points in the geometry.
bool crosses (const QgsGeometry *geometry) const
 Test for if geometry crosses another (uses GEOS)
bool deletePart (int partNum)
 delete part identified by the part number
bool deleteRing (int ringNum, int partNum=0)
 delete a ring in polygon or multipolygon.
bool deleteVertex (int atVertex)
 Deletes the vertex at the given position number and item (first number is index 0) Returns false if atVertex does not correspond to a valid vertex on this geometry (including if this geometry is a Point), or if the number of remaining verticies in the linestring would be less than two.
QgsGeometrydifference (QgsGeometry *geometry)
 Returns a geometry representing the points making up this geometry that do not make up other.
bool disjoint (const QgsGeometry *geometry) const
 Test for if geometry is disjoint of another (uses GEOS)
double distance (QgsGeometry &geom)
bool equals (const QgsGeometry *geometry) const
 Test for if geometry equals another (uses GEOS)
QString exportToGeoJSON (const int &precision=17) const
 Exports the geometry to GeoJSON.
QString exportToWkt (const int &precision=17) const
 Exports the geometry to WKT.
void fromGeos (GEOSGeometry *geos)
 Set the geometry, feeding in a geometry in GEOS format.
void fromWkb (unsigned char *wkb, size_t length)
 Set the geometry, feeding in the buffer containing OGC Well-Known Binary and the buffer's length.
bool insertVertex (double x, double y, int beforeVertex)
 Insert a new vertex before the given vertex index, ring and item (first number is index 0) If the requested vertex number (beforeVertex.back()) is greater than the last actual vertex on the requested ring and item, it is assumed that the vertex is to be appended instead of inserted.
QgsGeometryinterpolate (double distance)
QgsGeometryintersection (QgsGeometry *geometry)
 Returns a geometry representing the points shared by this geometry and other.
bool intersects (const QgsRectangle &r) const
 Test for intersection with a rectangle (uses GEOS)
bool intersects (const QgsGeometry *geometry) const
 Test for intersection with a geometry (uses GEOS)
bool isGeosEmpty ()
 check if geometry is empty using GEOS
bool isGeosEqual (QgsGeometry &)
 compare geometries using GEOS
bool isGeosValid ()
 check validity using GEOS
bool isMultipart () const
 Returns true if wkb of the geometry is of WKBMulti* type.
double length ()
 get length of geometry using GEOS
int makeDifference (QgsGeometry *other)
 Changes this geometry such that it does not intersect the other geometry.
bool moveVertex (double x, double y, int atVertex)
 Moves the vertex at the given position number and item (first number is index 0) to the given coordinates.
QgsGeometryoffsetCurve (double distance, int segments, int joinStyle, double mitreLimit)
 Returns an offset line at a given distance and side from an input line.
QgsGeometryoperator= (QgsGeometry const &rhs)
 assignments will prompt a deep copy of the object
bool overlaps (const QgsGeometry *geometry) const
 Test for if geometry overlaps another (uses GEOS)
QgsGeometrypointOnSurface ()
 Returns a point within a geometry.
int reshapeGeometry (const QList< QgsPoint > &reshapeWithLine)
 Replaces a part of this geometry with another line.
int rotate (double rotation, const QgsPoint &center)
 Rotate this geometry around the Z axis.
QgsGeometrysimplify (double tolerance)
 Returns a simplified version of this geometry using a specified tolerance value.
int splitGeometry (const QList< QgsPoint > &splitLine, QList< QgsGeometry * > &newGeometries, bool topological, QList< QgsPoint > &topologyTestPoints)
 Splits this geometry according to a given line.
double sqrDistToVertexAt (QgsPoint &point, int atVertex)
 Returns the squared cartesian distance between the given point to the given vertex index (vertex at the given position number, ring and item (first number is index 0))
QgsGeometrysymDifference (QgsGeometry *geometry)
 Returns a Geometry representing the points making up this Geometry that do not make up other.
bool touches (const QgsGeometry *geometry) const
 Test for if geometry touch another (uses GEOS)
int transform (const QgsCoordinateTransform &ct)
 Transform this geometry as described by CoordinateTranasform ct.
int transform (const QTransform &ct)
 Transform this geometry as described by QTransform ct.
int translate (double dx, double dy)
 Translate this geometry by dx, dy.
QGis::GeometryType type () const
 Returns type of the vector.
void validateGeometry (QList< Error > &errors)
 Validate geometry and produce a list of geometry errors.
QgsPoint vertexAt (int atVertex)
 Returns coordinates of a vertex.
bool within (const QgsGeometry *geometry) const
 Test for if geometry is within another (uses GEOS)
size_t wkbSize () const
 Returns the size of the WKB in asWkb().
QGis::WkbType wkbType () const
 Returns type of wkb (point / linestring / polygon etc.)

Static Public Member Functions

static QgsGeometryfromMultiPoint (const QgsMultiPoint &multipoint)
 construct geometry from a multipoint
static QgsGeometryfromMultiPolygon (const QgsMultiPolygon &multipoly)
 construct geometry from a multipolygon
static QgsGeometryfromMultiPolyline (const QgsMultiPolyline &multiline)
 construct geometry from a multipolyline
static QgsGeometryfromPoint (const QgsPoint &point)
 construct geometry from a point
static QgsGeometryfromPolygon (const QgsPolygon &polygon)
 construct geometry from a polygon
static QgsGeometryfromPolyline (const QgsPolyline &polyline)
 construct geometry from a polyline
static QgsGeometryfromQPointF (const QPointF &point)
 Construct geometry from a QPointF.
static QgsGeometryfromQPolygonF (const QPolygonF &polygon)
 Construct geometry from a QPolygonF.
static QgsGeometryfromRect (const QgsRectangle &rect)
 construct geometry from a rectangle
static QgsGeometryfromWkt (QString wkt)
 static method that creates geometry from Wkt
static GEOSContextHandle_t getGEOSHandler ()
 return GEOS context handle
static QgsGeometryunaryUnion (const QList< QgsGeometry * > &geometryList)
 compute the unary union on a list of geometries.

Detailed Description

Definition at line 69 of file qgsgeometry.h.

Constructor & Destructor Documentation

QgsGeometry::QgsGeometry ( )

Constructor.

Definition at line 145 of file qgsgeometry.cpp.

QgsGeometry::QgsGeometry ( const QgsGeometry rhs)

copy constructor will prompt a deep copy of the object

Definition at line 154 of file qgsgeometry.cpp.

QgsGeometry::~QgsGeometry ( )

Destructor.

Definition at line 175 of file qgsgeometry.cpp.

Member Function Documentation

int QgsGeometry::addPart ( const QList< QgsPoint > &  points,
QGis::GeometryType  geomType = QGis::UnknownGeometry 
)

Adds a new island polygon to a multipolygon feature.

Returns
0 in case of success, 1 if not a multipolygon, 2 if ring is not a valid geometry, 3 if new polygon ring not disjoint with existing polygons of the feature

Definition at line 2541 of file qgsgeometry.cpp.

int QgsGeometry::addPart ( GEOSGeometry *  newPart)

Adds a new island polygon to a multipolygon feature.

Returns
0 in case of success, 1 if not a multipolygon, 2 if ring is not a valid geometry, 3 if new polygon ring not disjoint with existing polygons of the feature
Note
not available in python bindings

Definition at line 2648 of file qgsgeometry.cpp.

int QgsGeometry::addPart ( QgsGeometry newPart)

Adds a new island polygon to a multipolygon feature.

Returns
0 in case of success, 1 if not a multipolygon, 2 if ring is not a valid geometry, 3 if new polygon ring not disjoint with existing polygons of the feature
Note
available in python bindings as addPartGeometry (added in 2.2)

Definition at line 2639 of file qgsgeometry.cpp.

int QgsGeometry::addRing ( const QList< QgsPoint > &  ring)

Adds a new ring to this geometry.

This makes only sense for polygon and multipolygons.

Returns
0 in case of success (ring added), 1 problem with geometry type, 2 ring not closed, 3 ring is not valid geometry, 4 ring not disjoint with existing rings, 5 no polygon found which contained the ring

Definition at line 2343 of file qgsgeometry.cpp.

void QgsGeometry::adjacentVertices ( int  atVertex,
int &  beforeVertex,
int &  afterVertex 
)

Returns the indexes of the vertices before and after the given vertex index.

This function takes into account the following factors:

  1. If the given vertex index is at the end of a linestring, the adjacent index will be -1 (for "no adjacent vertex")
  2. If the given vertex index is at the end of a linear ring (such as in a polygon), the adjacent index will take into account the first vertex is equal to the last vertex (and will skip equal vertex positions).

Definition at line 961 of file qgsgeometry.cpp.

double QgsGeometry::area ( )

get area of geometry using GEOS

Definition at line 5669 of file qgsgeometry.cpp.

QList< QgsGeometry * > QgsGeometry::asGeometryCollection ( ) const

return contents of the geometry as a list of geometries

Definition at line 5963 of file qgsgeometry.cpp.

const GEOSGeometry * QgsGeometry::asGeos ( ) const

Returns a geos geometry.

QgsGeometry keeps ownership, don't delete the returned object!

Note
not available in python bindings

Definition at line 621 of file qgsgeometry.cpp.

QgsMultiPoint QgsGeometry::asMultiPoint ( ) const

return contents of the geometry as a multi point if wkbType is WKBMultiPoint, otherwise an empty list

Definition at line 5605 of file qgsgeometry.cpp.

QgsMultiPolygon QgsGeometry::asMultiPolygon ( ) const

return contents of the geometry as a multi polygon if wkbType is WKBMultiPolygon, otherwise an empty list

Definition at line 5648 of file qgsgeometry.cpp.

QgsMultiPolyline QgsGeometry::asMultiPolyline ( ) const

return contents of the geometry as a multi linestring if wkbType is WKBMultiLineString, otherwise an empty list

Definition at line 5627 of file qgsgeometry.cpp.

QgsPoint QgsGeometry::asPoint ( ) const

return contents of the geometry as a point if wkbType is WKBPoint, otherwise returns [0,0]

Definition at line 5575 of file qgsgeometry.cpp.

QgsPolygon QgsGeometry::asPolygon ( ) const

return contents of the geometry as a polygon if wkbType is WKBPolygon, otherwise an empty list

Definition at line 5595 of file qgsgeometry.cpp.

QgsPolyline QgsGeometry::asPolyline ( ) const

return contents of the geometry as a polyline if wkbType is WKBLineString, otherwise an empty list

Definition at line 5585 of file qgsgeometry.cpp.

QPointF QgsGeometry::asQPointF ( ) const

Return contents of the geometry as a QPointF if wkbType is WKBPoint, otherwise returns a null QPointF.

Note
added in QGIS 2.7

Definition at line 5998 of file qgsgeometry.cpp.

QPolygonF QgsGeometry::asQPolygonF ( ) const

Return contents of the geometry as a QPolygonF.

If geometry is a linestring, then the result will be an open QPolygonF. If the geometry is a polygon, then the result will be a closed QPolygonF of the geometry's exterior ring.

Note
added in QGIS 2.7

Definition at line 6004 of file qgsgeometry.cpp.

const unsigned char * QgsGeometry::asWkb ( ) const

Returns the buffer containing this geometry in WKB format.

You may wish to use in conjunction with wkbSize().

Definition at line 605 of file qgsgeometry.cpp.

int QgsGeometry::avoidIntersections ( QMap< QgsVectorLayer *, QSet< QgsFeatureId > >  ignoreFeatures = ( QMap<QgsVectorLayer*, QSet<QgsFeatureId> >() ))

Modifies geometry to avoid intersections with the layers specified in project properties.

Returns
0 in case of success, 1 if geometry is not of polygon type, 2 if avoid intersection would change the geometry type, 3 other error during intersection removal
Parameters
ignoreFeaturespossibility to give a list of features where intersections should be ignored (not available in python bindings)

Definition at line 6171 of file qgsgeometry.cpp.

QgsRectangle QgsGeometry::boundingBox ( )

Returns the bounding box of this feature.

Definition at line 3231 of file qgsgeometry.cpp.

QgsGeometry * QgsGeometry::buffer ( double  distance,
int  segments 
)

Returns a buffer region around this geometry having the given width and with a specified number of segments used to approximate curves.

Definition at line 5730 of file qgsgeometry.cpp.

QgsGeometry * QgsGeometry::buffer ( double  distance,
int  segments,
int  endCapStyle,
int  joinStyle,
double  mitreLimit 
)

Returns a buffer region around the geometry, with additional style options.

Parameters
distancebuffer distance
segmentsFor round joins, number of segments to approximate quarter-circle
endCapStyleRound (1) / Flat (2) / Square (3) end cap style
joinStyleRound (1) / Mitre (2) / Bevel (3) join style
mitreLimitLimit on the mitre ratio used for very sharp corners
Note
added in 2.4
needs GEOS >= 3.3 - otherwise always returns 0

Definition at line 5745 of file qgsgeometry.cpp.

QgsGeometry * QgsGeometry::centroid ( )

Returns the center of mass of a geometry.

Note
for line based geometries, the center point of the line is returned, and for point based geometries, the point itself is returned

Definition at line 5800 of file qgsgeometry.cpp.

double QgsGeometry::closestSegmentWithContext ( const QgsPoint point,
QgsPoint minDistPoint,
int &  afterVertex,
double *  leftOf = 0,
double  epsilon = DEFAULT_SEGMENT_EPSILON 
)

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

Parameters
pointSpecifies the point for search
minDistPointReceives the nearest point on the segment
afterVertexReceives index of the vertex after the closest segment. The vertex before the closest segment is always afterVertex - 1
leftOfOut: Returns if the point lies on the left of right side of the segment ( < 0 means left, > 0 means right )
epsilonepsilon for segment snapping
Returns
The squared cartesian distance is also returned in sqrDist, negative number on error

Definition at line 2113 of file qgsgeometry.cpp.

QgsPoint QgsGeometry::closestVertex ( const QgsPoint point,
int &  atVertex,
int &  beforeVertex,
int &  afterVertex,
double &  sqrDist 
)

Returns the vertex closest to the given point, the corresponding vertex index, squared distance snap point / target point and the indices of the vertices before/after.

The vertices before/after are -1 if not present

Definition at line 712 of file qgsgeometry.cpp.

double QgsGeometry::closestVertexWithContext ( const QgsPoint point,
int &  atVertex 
)

Searches for the closest vertex in this geometry to the given point.

Parameters
pointSpecifiest the point for search
atVertexReceives index of the closest vertex
Returns
The squared cartesian distance is also returned in sqrDist, negative number on error

Definition at line 2063 of file qgsgeometry.cpp.

QgsGeometry * QgsGeometry::combine ( QgsGeometry geometry)

Returns a geometry representing all the points in this geometry and other (a union geometry operation).

Note
this operation is not called union since its a reserved word in C++.

Definition at line 5887 of file qgsgeometry.cpp.

bool QgsGeometry::contains ( const QgsPoint p) const

Test for containment of a point (uses GEOS)

Definition at line 3499 of file qgsgeometry.cpp.

bool QgsGeometry::contains ( const QgsGeometry geometry) const

Test for if geometry is contained in another (uses GEOS)

Definition at line 3560 of file qgsgeometry.cpp.

bool QgsGeometry::convertToMultiType ( )

Converts single type geometry into multitype geometry e.g.

a polygon into a multipolygon geometry with one polygon

Returns
true in case of success and false else

Definition at line 4609 of file qgsgeometry.cpp.

QgsGeometry * QgsGeometry::convertToType ( QGis::GeometryType  destType,
bool  destMultipart = false 
)

try to convert the geometry to the requested type

Parameters
destTypethe geometry type to be converted to
destMultipartdetermines if the output geometry will be multipart or not
Returns
the converted geometry or NULL pointer if the conversion fails.
Note
added in 2.2

Definition at line 4591 of file qgsgeometry.cpp.

QgsGeometry * QgsGeometry::convexHull ( )

Returns the smallest convex polygon that contains all the points in the geometry.

Definition at line 5830 of file qgsgeometry.cpp.

bool QgsGeometry::crosses ( const QgsGeometry geometry) const

Test for if geometry crosses another (uses GEOS)

Definition at line 3590 of file qgsgeometry.cpp.

bool QgsGeometry::deletePart ( int  partNum)

delete part identified by the part number

Returns
true on success

Definition at line 6082 of file qgsgeometry.cpp.

bool QgsGeometry::deleteRing ( int  ringNum,
int  partNum = 0 
)

delete a ring in polygon or multipolygon.

Ring 0 is outer ring and can't be deleted.

Returns
true on success

Definition at line 6033 of file qgsgeometry.cpp.

bool QgsGeometry::deleteVertex ( int  atVertex)

Deletes the vertex at the given position number and item (first number is index 0) Returns false if atVertex does not correspond to a valid vertex on this geometry (including if this geometry is a Point), or if the number of remaining verticies in the linestring would be less than two.

It is up to the caller to distinguish between these error conditions. (Or maybe we add another method to this object to help make the distinction?)

Definition at line 1481 of file qgsgeometry.cpp.

QgsGeometry * QgsGeometry::difference ( QgsGeometry geometry)

Returns a geometry representing the points making up this geometry that do not make up other.

Definition at line 5921 of file qgsgeometry.cpp.

bool QgsGeometry::disjoint ( const QgsGeometry geometry) const

Test for if geometry is disjoint of another (uses GEOS)

Definition at line 3565 of file qgsgeometry.cpp.

double QgsGeometry::distance ( QgsGeometry geom)

Definition at line 5708 of file qgsgeometry.cpp.

bool QgsGeometry::equals ( const QgsGeometry geometry) const

Test for if geometry equals another (uses GEOS)

Definition at line 3570 of file qgsgeometry.cpp.

QString QgsGeometry::exportToGeoJSON ( const int &  precision = 17) const

Exports the geometry to GeoJSON.

Returns
a QString representing the geometry as GeoJSON
Note
precision parameter added in 2.4

Definition at line 3809 of file qgsgeometry.cpp.

QString QgsGeometry::exportToWkt ( const int &  precision = 17) const

Exports the geometry to WKT.

Note
precision parameter added in 2.4
Returns
true in case of success and false else

Definition at line 3595 of file qgsgeometry.cpp.

void QgsGeometry::fromGeos ( GEOSGeometry *  geos)

Set the geometry, feeding in a geometry in GEOS format.

This class will take ownership of the buffer.

Note
not available in python bindings

Definition at line 690 of file qgsgeometry.cpp.

QgsGeometry * QgsGeometry::fromMultiPoint ( const QgsMultiPoint multipoint)
static

construct geometry from a multipoint

Definition at line 433 of file qgsgeometry.cpp.

QgsGeometry * QgsGeometry::fromMultiPolygon ( const QgsMultiPolygon multipoly)
static

construct geometry from a multipolygon

Definition at line 477 of file qgsgeometry.cpp.

QgsGeometry * QgsGeometry::fromMultiPolyline ( const QgsMultiPolyline multiline)
static

construct geometry from a multipolyline

Definition at line 455 of file qgsgeometry.cpp.

QgsGeometry * QgsGeometry::fromPoint ( const QgsPoint point)
static

construct geometry from a point

Definition at line 418 of file qgsgeometry.cpp.

QgsGeometry * QgsGeometry::fromPolygon ( const QgsPolygon polygon)
static

construct geometry from a polygon

Definition at line 428 of file qgsgeometry.cpp.

QgsGeometry * QgsGeometry::fromPolyline ( const QgsPolyline polyline)
static

construct geometry from a polyline

Definition at line 423 of file qgsgeometry.cpp.

QgsGeometry * QgsGeometry::fromQPointF ( const QPointF &  point)
static

Construct geometry from a QPointF.

Parameters
pointsource QPointF
Note
added in QGIS 2.7

Definition at line 517 of file qgsgeometry.cpp.

QgsGeometry * QgsGeometry::fromQPolygonF ( const QPolygonF &  polygon)
static

Construct geometry from a QPolygonF.

If the polygon is closed than the resultant geometry will be a polygon, if it is open than the geometry will be a polyline.

Parameters
polygonsource QPolygonF
Note
added in QGIS 2.7

Definition at line 522 of file qgsgeometry.cpp.

QgsGeometry * QgsGeometry::fromRect ( const QgsRectangle rect)
static

construct geometry from a rectangle

Definition at line 502 of file qgsgeometry.cpp.

void QgsGeometry::fromWkb ( unsigned char *  wkb,
size_t  length 
)

Set the geometry, feeding in the buffer containing OGC Well-Known Binary and the buffer's length.

This class will take ownership of the buffer.

Definition at line 583 of file qgsgeometry.cpp.

QgsGeometry * QgsGeometry::fromWkt ( QString  wkt)
static

static method that creates geometry from Wkt

Definition at line 402 of file qgsgeometry.cpp.

GEOSContextHandle_t QgsGeometry::getGEOSHandler ( )
static

return GEOS context handle

Note
added in 2.6
not available in Python

Definition at line 140 of file qgsgeometry.cpp.

bool QgsGeometry::insertVertex ( double  x,
double  y,
int  beforeVertex 
)

Insert a new vertex before the given vertex index, ring and item (first number is index 0) If the requested vertex number (beforeVertex.back()) is greater than the last actual vertex on the requested ring and item, it is assumed that the vertex is to be appended instead of inserted.

Returns false if atVertex does not correspond to a valid vertex on this geometry (including if this geometry is a Point). It is up to the caller to distinguish between these error conditions. (Or maybe we add another method to this object to help make the distinction?)

Definition at line 1724 of file qgsgeometry.cpp.

QgsGeometry * QgsGeometry::interpolate ( double  distance)

Definition at line 5845 of file qgsgeometry.cpp.

QgsGeometry * QgsGeometry::intersection ( QgsGeometry geometry)

Returns a geometry representing the points shared by this geometry and other.

Definition at line 5866 of file qgsgeometry.cpp.

bool QgsGeometry::intersects ( const QgsRectangle r) const

Test for intersection with a rectangle (uses GEOS)

Definition at line 3469 of file qgsgeometry.cpp.

bool QgsGeometry::intersects ( const QgsGeometry geometry) const

Test for intersection with a geometry (uses GEOS)

Definition at line 3477 of file qgsgeometry.cpp.

bool QgsGeometry::isGeosEmpty ( )

check if geometry is empty using GEOS

Definition at line 6279 of file qgsgeometry.cpp.

bool QgsGeometry::isGeosEqual ( QgsGeometry g)

compare geometries using GEOS

Definition at line 6274 of file qgsgeometry.cpp.

bool QgsGeometry::isGeosValid ( )

check validity using GEOS

Definition at line 6256 of file qgsgeometry.cpp.

bool QgsGeometry::isMultipart ( ) const

Returns true if wkb of the geometry is of WKBMulti* type.

Definition at line 682 of file qgsgeometry.cpp.

double QgsGeometry::length ( )

get length of geometry using GEOS

Definition at line 5689 of file qgsgeometry.cpp.

int QgsGeometry::makeDifference ( QgsGeometry other)

Changes this geometry such that it does not intersect the other geometry.

Parameters
othergeometry that should not be intersect
Returns
0 in case of success

Definition at line 3173 of file qgsgeometry.cpp.

bool QgsGeometry::moveVertex ( double  x,
double  y,
int  atVertex 
)

Moves the vertex at the given position number and item (first number is index 0) to the given coordinates.

Returns false if atVertex does not correspond to a valid vertex on this geometry

Definition at line 1244 of file qgsgeometry.cpp.

QgsGeometry * QgsGeometry::offsetCurve ( double  distance,
int  segments,
int  joinStyle,
double  mitreLimit 
)

Returns an offset line at a given distance and side from an input line.

See buffer() method for details on parameters.

Note
added in 2.4
needs GEOS >= 3.3 - otherwise always returns 0

Definition at line 5765 of file qgsgeometry.cpp.

QgsGeometry & QgsGeometry::operator= ( QgsGeometry const &  rhs)

assignments will prompt a deep copy of the object

Note
not available in python bindings

Definition at line 552 of file qgsgeometry.cpp.

bool QgsGeometry::overlaps ( const QgsGeometry geometry) const

Test for if geometry overlaps another (uses GEOS)

Definition at line 3580 of file qgsgeometry.cpp.

QgsGeometry * QgsGeometry::pointOnSurface ( )

Returns a point within a geometry.

Definition at line 5815 of file qgsgeometry.cpp.

int QgsGeometry::reshapeGeometry ( const QList< QgsPoint > &  reshapeWithLine)

Replaces a part of this geometry with another line.

Returns
0 in case of success

Definition at line 3066 of file qgsgeometry.cpp.

int QgsGeometry::rotate ( double  rotation,
const QgsPoint center 
)

Rotate this geometry around the Z axis.

Note
added in 2.8
Parameters
rotationclockwise rotation in degrees
centerrotation center
Returns
0 in case of success

Definition at line 2858 of file qgsgeometry.cpp.

QgsGeometry * QgsGeometry::simplify ( double  tolerance)

Returns a simplified version of this geometry using a specified tolerance value.

Definition at line 5785 of file qgsgeometry.cpp.

int QgsGeometry::splitGeometry ( const QList< QgsPoint > &  splitLine,
QList< QgsGeometry * > &  newGeometries,
bool  topological,
QList< QgsPoint > &  topologyTestPoints 
)

Splits this geometry according to a given line.

Note that the geometry is only split once. If there are several intersections between geometry and splitLine, only the first one is considered.

Parameters
splitLinethe line that splits the geometry
[out]newGeometrieslist of new geometries that have been created with the split
topologicaltrue if topological editing is enabled
[out]topologyTestPointspoints that need to be tested for topological completeness in the dataset
Returns
0 in case of success, 1 if geometry has not been split, error else

Definition at line 2986 of file qgsgeometry.cpp.

double QgsGeometry::sqrDistToVertexAt ( QgsPoint point,
int  atVertex 
)

Returns the squared cartesian distance between the given point to the given vertex index (vertex at the given position number, ring and item (first number is index 0))

Definition at line 2047 of file qgsgeometry.cpp.

QgsGeometry * QgsGeometry::symDifference ( QgsGeometry geometry)

Returns a Geometry representing the points making up this Geometry that do not make up other.

Definition at line 5942 of file qgsgeometry.cpp.

bool QgsGeometry::touches ( const QgsGeometry geometry) const

Test for if geometry touch another (uses GEOS)

Definition at line 3575 of file qgsgeometry.cpp.

int QgsGeometry::transform ( const QgsCoordinateTransform ct)

Transform this geometry as described by CoordinateTranasform ct.

Returns
0 in case of success

Definition at line 2866 of file qgsgeometry.cpp.

int QgsGeometry::transform ( const QTransform &  ct)

Transform this geometry as described by QTransform ct.

Note
added in 2.8
Returns
0 in case of success

Definition at line 2733 of file qgsgeometry.cpp.

int QgsGeometry::translate ( double  dx,
double  dy 
)

Translate this geometry by dx, dy.

Returns
0 in case of success

Definition at line 2853 of file qgsgeometry.cpp.

QGis::GeometryType QgsGeometry::type ( ) const

Returns type of the vector.

Definition at line 652 of file qgsgeometry.cpp.

QgsGeometry * QgsGeometry::unaryUnion ( const QList< QgsGeometry * > &  geometryList)
static

compute the unary union on a list of geometries.

May be faster than an iterative union on a set of geometries.

Parameters
geometryLista list of QgsGeometry* as input
Returns
the new computed QgsGeometry, or null

Definition at line 6623 of file qgsgeometry.cpp.

void QgsGeometry::validateGeometry ( QList< Error > &  errors)

Validate geometry and produce a list of geometry errors.

Definition at line 6251 of file qgsgeometry.cpp.

QgsPoint QgsGeometry::vertexAt ( int  atVertex)

Returns coordinates of a vertex.

Parameters
atVertexindex of the vertex
Returns
Coordinates of the vertex or QgsPoint(0,0) on error

Definition at line 1869 of file qgsgeometry.cpp.

bool QgsGeometry::within ( const QgsGeometry geometry) const

Test for if geometry is within another (uses GEOS)

Definition at line 3585 of file qgsgeometry.cpp.

size_t QgsGeometry::wkbSize ( ) const

Returns the size of the WKB in asWkb().

Definition at line 613 of file qgsgeometry.cpp.

QGis::WkbType QgsGeometry::wkbType ( ) const

Returns type of wkb (point / linestring / polygon etc.)

Definition at line 635 of file qgsgeometry.cpp.


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