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

Contains various geometry utility functions. More...

#include <qgsgeometryutils.h>

Public Types

enum  componentType { VERTEX, RING, PART }
 

Static Public Member Functions

static void adjacentVertices (const QgsAbstractGeometryV2 &geom, const QgsVertexId &atVertex, QgsVertexId &beforeVertex, QgsVertexId &afterVertex)
 Returns vertices adjacent to a specified vertex within a geometry. More...
 
static bool angleOnCircle (double angle, double angle1, double angle2, double angle3)
 Returns true if an angle is between angle1 and angle3 on a circle described by angle1, angle2 and angle3. More...
 
static double ccwAngle (double dy, double dx)
 Returns the counter clockwise angle between a line with components dx, dy and the line with dx > 0 and dy = 0. More...
 
static bool circleAngleBetween (double angle, double angle1, double angle2, bool clockwise)
 Returns true if, in a circle, angle is between angle1 and angle2. More...
 
static void circleCenterRadius (const QgsPointV2 &pt1, const QgsPointV2 &pt2, const QgsPointV2 &pt3, double &radius, double &centerX, double &centerY)
 Returns radius and center of the circle through pt1, pt2, pt3. More...
 
static bool circleClockwise (double angle1, double angle2, double angle3)
 Returns true if circle is ordered clockwise. More...
 
static double circleLength (double x1, double y1, double x2, double y2, double x3, double y3)
 Length of a circular string segment defined by pt1, pt2, pt3. More...
 
template<class T >
static double closestSegmentFromComponents (T &container, componentType ctype, const QgsPointV2 &pt, QgsPointV2 &segmentPt, QgsVertexId &vertexAfter, bool *leftOf, double epsilon)
 
static QgsPointV2 closestVertex (const QgsAbstractGeometryV2 &geom, const QgsPointV2 &pt, QgsVertexId &id)
 Returns the closest vertex to a geometry for a specified point. More...
 
static double leftOfLine (double x, double y, double x1, double y1, double x2, double y2)
 Returns < 0 if point(x/y) is left of the line x1,y1 -> x2,y2. More...
 
static QgsPointV2 pointOnLineWithDistance (const QgsPointV2 &startPoint, const QgsPointV2 &directionPoint, double distance)
 Returns a point a specified distance toward a second point. More...
 
static QList< QgsPointV2pointsFromWKT (const QString &wktCoordinateList, bool is3D, bool isMeasure)
 Returns a list of points contained in a WKT string. More...
 
static QDomElement pointsToGML2 (const QList< QgsPointV2 > &points, QDomDocument &doc, int precision, const QString &ns)
 Returns a gml::coordinates DOM element. More...
 
static QDomElement pointsToGML3 (const QList< QgsPointV2 > &points, QDomDocument &doc, int precision, const QString &ns, bool is3D)
 Returns a gml::posList DOM element. More...
 
static QString pointsToJSON (const QList< QgsPointV2 > &points, int precision)
 Returns a geoJSON coordinates string. More...
 
static void pointsToWKB (QgsWkbPtr &wkb, const QList< QgsPointV2 > &points, bool is3D, bool isMeasure)
 Returns a LinearRing { uint32 numPoints; Point points[numPoints]; }. More...
 
static QString pointsToWKT (const QList< QgsPointV2 > &points, int precision, bool is3D, bool isMeasure)
 Returns a WKT coordinate list. More...
 
static bool segmentMidPoint (const QgsPointV2 &p1, const QgsPointV2 &p2, QgsPointV2 &result, double radius, const QgsPointV2 &mousePos)
 Calculates midpoint on circle passing through p1 and p2, closest to given coordinate. More...
 
static double sqrDistance2D (const QgsPointV2 &pt1, const QgsPointV2 &pt2)
 Returns the squared 2D distance between two points. More...
 
static double sqrDistToLine (double ptX, double ptY, double x1, double y1, double x2, double y2, double &minDistX, double &minDistY, double epsilon)
 Returns the squared distance between a point and a line. More...
 
static double sweepAngle (double centerX, double centerY, double x1, double y1, double x2, double y2, double x3, double y3)
 Calculates angle of a circular string part defined by pt1, pt2, pt3. More...
 
static QStringList wktGetChildBlocks (const QString &wkt, const QString &defaultType="")
 Parses a WKT string and returns of list of blocks contained in the WKT. More...
 
static QPair
< QgsWKBTypes::Type, QString
wktReadBlock (const QString &wkt)
 Parses a WKT block of the format "TYPE( contents )" and returns a pair of geometry type to contents ("Pair(wkbType, "contents")") More...
 

Detailed Description

Contains various geometry utility functions.

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

Definition at line 28 of file qgsgeometryutils.h.

Member Enumeration Documentation

Enumerator
VERTEX 
RING 
PART 

Definition at line 107 of file qgsgeometryutils.h.

Member Function Documentation

void QgsGeometryUtils::adjacentVertices ( const QgsAbstractGeometryV2 geom,
const QgsVertexId atVertex,
QgsVertexId beforeVertex,
QgsVertexId afterVertex 
)
static

Returns vertices adjacent to a specified vertex within a geometry.

Definition at line 49 of file qgsgeometryutils.cpp.

bool QgsGeometryUtils::angleOnCircle ( double  angle,
double  angle1,
double  angle2,
double  angle3 
)
static

Returns true if an angle is between angle1 and angle3 on a circle described by angle1, angle2 and angle3.

Definition at line 269 of file qgsgeometryutils.cpp.

double QgsGeometryUtils::ccwAngle ( double  dy,
double  dx 
)
static

Returns the counter clockwise angle between a line with components dx, dy and the line with dx > 0 and dy = 0.

Definition at line 172 of file qgsgeometryutils.cpp.

bool QgsGeometryUtils::circleAngleBetween ( double  angle,
double  angle1,
double  angle2,
bool  clockwise 
)
static

Returns true if, in a circle, angle is between angle1 and angle2.

Definition at line 243 of file qgsgeometryutils.cpp.

void QgsGeometryUtils::circleCenterRadius ( const QgsPointV2 pt1,
const QgsPointV2 pt2,
const QgsPointV2 pt3,
double &  radius,
double &  centerX,
double &  centerY 
)
static

Returns radius and center of the circle through pt1, pt2, pt3.

Definition at line 186 of file qgsgeometryutils.cpp.

bool QgsGeometryUtils::circleClockwise ( double  angle1,
double  angle2,
double  angle3 
)
static

Returns true if circle is ordered clockwise.

Definition at line 217 of file qgsgeometryutils.cpp.

double QgsGeometryUtils::circleLength ( double  x1,
double  y1,
double  x2,
double  y2,
double  x3,
double  y3 
)
static

Length of a circular string segment defined by pt1, pt2, pt3.

Definition at line 275 of file qgsgeometryutils.cpp.

template<class T >
static double QgsGeometryUtils::closestSegmentFromComponents ( T &  container,
componentType  ctype,
const QgsPointV2 pt,
QgsPointV2 segmentPt,
QgsVertexId vertexAfter,
bool *  leftOf,
double  epsilon 
)
inlinestatic

Definition at line 114 of file qgsgeometryutils.h.

QgsPointV2 QgsGeometryUtils::closestVertex ( const QgsAbstractGeometryV2 geom,
const QgsPointV2 pt,
QgsVertexId id 
)
static

Returns the closest vertex to a geometry for a specified point.

Definition at line 20 of file qgsgeometryutils.cpp.

double QgsGeometryUtils::leftOfLine ( double  x,
double  y,
double  x1,
double  y1,
double  x2,
double  y2 
)
static

Returns < 0 if point(x/y) is left of the line x1,y1 -> x2,y2.

Definition at line 148 of file qgsgeometryutils.cpp.

QgsPointV2 QgsGeometryUtils::pointOnLineWithDistance ( const QgsPointV2 startPoint,
const QgsPointV2 directionPoint,
double  distance 
)
static

Returns a point a specified distance toward a second point.

Definition at line 157 of file qgsgeometryutils.cpp.

QList< QgsPointV2 > QgsGeometryUtils::pointsFromWKT ( const QString wktCoordinateList,
bool  is3D,
bool  isMeasure 
)
static

Returns a list of points contained in a WKT string.

Definition at line 360 of file qgsgeometryutils.cpp.

QDomElement QgsGeometryUtils::pointsToGML2 ( const QList< QgsPointV2 > &  points,
QDomDocument doc,
int  precision,
const QString ns 
)
static

Returns a gml::coordinates DOM element.

Definition at line 434 of file qgsgeometryutils.cpp.

QDomElement QgsGeometryUtils::pointsToGML3 ( const QList< QgsPointV2 > &  points,
QDomDocument doc,
int  precision,
const QString ns,
bool  is3D 
)
static

Returns a gml::posList DOM element.

Definition at line 450 of file qgsgeometryutils.cpp.

QString QgsGeometryUtils::pointsToJSON ( const QList< QgsPointV2 > &  points,
int  precision 
)
static

Returns a geoJSON coordinates string.

Definition at line 469 of file qgsgeometryutils.cpp.

void QgsGeometryUtils::pointsToWKB ( QgsWkbPtr wkb,
const QList< QgsPointV2 > &  points,
bool  is3D,
bool  isMeasure 
)
static

Returns a LinearRing { uint32 numPoints; Point points[numPoints]; }.

Definition at line 398 of file qgsgeometryutils.cpp.

QString QgsGeometryUtils::pointsToWKT ( const QList< QgsPointV2 > &  points,
int  precision,
bool  is3D,
bool  isMeasure 
)
static

Returns a WKT coordinate list.

Definition at line 415 of file qgsgeometryutils.cpp.

bool QgsGeometryUtils::segmentMidPoint ( const QgsPointV2 p1,
const QgsPointV2 p2,
QgsPointV2 result,
double  radius,
const QgsPointV2 mousePos 
)
static

Calculates midpoint on circle passing through p1 and p2, closest to given coordinate.

Definition at line 317 of file qgsgeometryutils.cpp.

double QgsGeometryUtils::sqrDistance2D ( const QgsPointV2 pt1,
const QgsPointV2 pt2 
)
static

Returns the squared 2D distance between two points.

Definition at line 105 of file qgsgeometryutils.cpp.

double QgsGeometryUtils::sqrDistToLine ( double  ptX,
double  ptY,
double  x1,
double  y1,
double  x2,
double  y2,
double &  minDistX,
double &  minDistY,
double  epsilon 
)
static

Returns the squared distance between a point and a line.

Definition at line 110 of file qgsgeometryutils.cpp.

double QgsGeometryUtils::sweepAngle ( double  centerX,
double  centerY,
double  x1,
double  y1,
double  x2,
double  y2,
double  x3,
double  y3 
)
static

Calculates angle of a circular string part defined by pt1, pt2, pt3.

Definition at line 287 of file qgsgeometryutils.cpp.

QStringList QgsGeometryUtils::wktGetChildBlocks ( const QString wkt,
const QString defaultType = "" 
)
static

Parses a WKT string and returns of list of blocks contained in the WKT.

Parameters
wktWKT string in the format "TYPE1 (contents1), TYPE2 (TYPE3 (contents3), TYPE4 (contents4))"
defaultTypedefault geometry type for childen
Returns
list of WKT child block strings, eg List("TYPE1 (contents1)", "TYPE2 (TYPE3 (contents3), TYPE4 (contents4))")

Definition at line 493 of file qgsgeometryutils.cpp.

QPair< QgsWKBTypes::Type, QString > QgsGeometryUtils::wktReadBlock ( const QString wkt)
static

Parses a WKT block of the format "TYPE( contents )" and returns a pair of geometry type to contents ("Pair(wkbType, "contents")")

Definition at line 484 of file qgsgeometryutils.cpp.


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