#include <qgsgeometry.h>
Public Member Functions | |
QgsGeometry () | |
Constructor. | |
QgsGeometry (QgsGeometry const &) | |
copy constructor will prompt a deep copy of the object | |
QgsGeometry & | operator= (QgsGeometry const &rhs) |
assignments will prompt a deep copy of the object | |
~QgsGeometry () | |
Destructor. | |
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. | |
unsigned char * | asWkb () |
Returns the buffer containing this geometry in WKB format. | |
size_t | wkbSize () |
Returns the size of the WKB in asWkb(). | |
GEOSGeometry * | asGeos () |
Returns a geos geomtry. | |
QGis::WkbType | wkbType () |
Returns type of wkb (point / linestring / polygon etc. | |
QGis::GeometryType | type () |
Returns type of the vector. | |
bool | isMultipart () |
Returns true if wkb of the geometry is of WKBMulti* type. | |
bool | isGeosEqual (QgsGeometry &) |
compare geometries using GEOS | |
bool | isGeosValid () |
check validity using GEOS | |
bool | isGeosEmpty () |
check if geometry is empty using GEOS | |
double | area () |
get area of geometry using GEOS | |
double | length () |
get length of geometry using GEOS | |
double | distance (QgsGeometry &geom) |
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. | |
void | adjacentVertices (int atVertex, int &beforeVertex, int &afterVertex) |
Returns the indexes of the vertices before and after the given vertex index. | |
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. | |
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. | |
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. | |
QgsPoint | vertexAt (int atVertex) |
Returns coordinates of a vertex. | |
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)). | |
double | closestVertexWithContext (const QgsPoint &point, int &atVertex) |
Searches for the the closest vertex in this geometry to the given point. | |
double | closestSegmentWithContext (const QgsPoint &point, QgsPoint &minDistPoint, int &beforeVertex) |
Searches for the closest segment of geometry to the given point. | |
int | addRing (const QList< QgsPoint > &ring) |
Adds a new ring to this geometry. | |
int | addIsland (const QList< QgsPoint > &ring) |
Adds a new island polygon to a multipolygon feature. | |
int | translate (double dx, double dy) |
Translate this geometry by dx, dy. | |
int | transform (const QgsCoordinateTransform &ct) |
Transform this geometry as described by CoordinateTranasform ct. | |
int | splitGeometry (const QList< QgsPoint > &splitLine, QList< QgsGeometry * > &newGeometries, bool topological, QList< QgsPoint > &topologyTestPoints) |
Splits this geometry according to a given line. | |
int | reshapeGeometry (const QList< QgsPoint > &reshapeWithLine) |
Replaces a part of this geometry with another line. | |
int | makeDifference (QgsGeometry *other) |
Changes this geometry such that it does not intersect the other geometry. | |
QgsRectangle | boundingBox () |
Returns the bounding box of this feature. | |
bool | intersects (const QgsRectangle &r) |
Test for intersection with a rectangle (uses GEOS). | |
bool | intersects (QgsGeometry *geometry) |
Test for intersection with a geometry (uses GEOS). | |
bool | contains (QgsPoint *p) |
Test for containment of a point (uses GEOS). | |
bool | contains (QgsGeometry *geometry) |
Test for if geometry is contained in an other (uses GEOS). | |
bool | disjoint (QgsGeometry *geometry) |
Test for if geometry is disjoint of an other (uses GEOS). | |
bool | equals (QgsGeometry *geometry) |
Test for if geometry equals an other (uses GEOS). | |
bool | touches (QgsGeometry *geometry) |
Test for if geometry touch an other (uses GEOS). | |
bool | overlaps (QgsGeometry *geometry) |
Test for if geometry overlaps an other (uses GEOS). | |
bool | within (QgsGeometry *geometry) |
Test for if geometry is within an other (uses GEOS). | |
bool | crosses (QgsGeometry *geometry) |
Test for if geometry crosses an other (uses GEOS). | |
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. | |
QgsGeometry * | simplify (double tolerance) |
Returns a simplified version of this geometry using a specified tolerance value. | |
QgsGeometry * | centroid () |
Returns the center of mass of a geometry. | |
QgsGeometry * | convexHull () |
Returns the smallest convex polygon that contains all the points in the geometry. | |
QgsGeometry * | intersection (QgsGeometry *geometry) |
Returns a geometry representing the points shared by this geometry and other. | |
QgsGeometry * | combine (QgsGeometry *geometry) |
Returns a geometry representing all the points in this geometry and other (a union geometry operation). | |
QgsGeometry * | difference (QgsGeometry *geometry) |
Returns a geometry representing the points making up this geometry that do not make up other. | |
QgsGeometry * | symDifference (QgsGeometry *geometry) |
Returns a Geometry representing the points making up this Geometry that do not make up other. | |
QString | exportToWkt () |
Exports the geometry to mWkt. | |
QgsPoint | asPoint () |
return contents of the geometry as a point if wkbType is WKBPoint, otherwise returns [0,0] | |
QgsPolyline | asPolyline () |
return contents of the geometry as a polyline if wkbType is WKBLineString, otherwise an empty list | |
QgsPolygon | asPolygon () |
return contents of the geometry as a polygon if wkbType is WKBPolygon, otherwise an empty list | |
QgsMultiPoint | asMultiPoint () |
return contents of the geometry as a multi point if wkbType is WKBMultiPoint, otherwise an empty list | |
QgsMultiPolyline | asMultiPolyline () |
return contents of the geometry as a multi linestring if wkbType is WKBMultiLineString, otherwise an empty list | |
QgsMultiPolygon | asMultiPolygon () |
return contents of the geometry as a multi polygon if wkbType is WKBMultiPolygon, otherwise an empty list | |
QList< QgsGeometry * > | asGeometryCollection () |
return contents of the geometry as a list of geometries | |
bool | deleteRing (int ringNum, int partNum=0) |
delete a ring in polygon or multipolygon. | |
bool | deletePart (int partNum) |
delete part identified by the part number | |
bool | convertToMultiType () |
Converts single type geometry into multitype geometry e.g. | |
int | avoidIntersections () |
Modifies geometry to avoid intersections with the layers specified in project properties. | |
void | validateGeometry (QList< Error > &errors) |
Validate geometry and produce a list of geometry errors. | |
Static Public Member Functions | |
static QgsGeometry * | fromWkt (QString wkt) |
static method that creates geometry from Wkt | |
static QgsGeometry * | fromPoint (const QgsPoint &point) |
construct geometry from a point | |
static QgsGeometry * | fromMultiPoint (const QgsMultiPoint &multipoint) |
construct geometry from a multipoint | |
static QgsGeometry * | fromPolyline (const QgsPolyline &polyline) |
construct geometry from a polyline | |
static QgsGeometry * | fromMultiPolyline (const QgsMultiPolyline &multiline) |
construct geometry from a multipolyline | |
static QgsGeometry * | fromPolygon (const QgsPolygon &polygon) |
construct geometry from a polygon | |
static QgsGeometry * | fromMultiPolygon (const QgsMultiPolygon &multipoly) |
construct geometry from a multipolygon | |
static QgsGeometry * | fromRect (const QgsRectangle &rect) |
construct geometry from a rectangle | |
static void | validatePolyline (QList< Error > &errors, int i, QgsPolyline polyline, bool ring=false) |
static void | validatePolygon (QList< Error > &errors, int i, const QgsPolygon &polygon) |
Private Member Functions | |
bool | exportWkbToGeos () |
Converts from the WKB geometry to the GEOS geometry. | |
bool | exportGeosToWkb () |
Converts from the GEOS geometry to the WKB geometry. | |
bool | insertVertex (double x, double y, int beforeVertex, const GEOSCoordSequence *old_sequence, GEOSCoordSequence **new_sequence) |
Insert a new vertex before the given vertex index (first number is index 0) in the given GEOS Coordinate Sequence. | |
void | translateVertex (int &wkbPosition, double dx, double dy, bool hasZValue) |
Translates a single vertex by dx and dy. | |
void | transformVertex (int &wkbPosition, const QgsCoordinateTransform &ct, bool hasZValue) |
Transforms a single vertex by ct. | |
int | splitLinearGeometry (GEOSGeometry *splitLine, QList< QgsGeometry * > &newGeometries) |
Splits line/multiline geometries. | |
int | splitPolygonGeometry (GEOSGeometry *splitLine, QList< QgsGeometry * > &newGeometries) |
Splits polygon/multipolygon geometries. | |
int | topologicalTestPointsSplit (const GEOSGeometry *splitLine, QList< QgsPoint > &testPoints) const |
Finds out the points that need to be tested for topological correctnes if this geometry will be split. | |
int | numberOfGeometries (GEOSGeometry *g) const |
Returns number of single geometry in a geos geometry. | |
int | mergeGeometriesMultiTypeSplit (QVector< GEOSGeometry * > &splitResult) |
QgsPoint | asPoint (unsigned char *&ptr, bool hasZValue) |
return point from wkb | |
QgsPolyline | asPolyline (unsigned char *&ptr, bool hasZValue) |
return polyline from wkb | |
QgsPolygon | asPolygon (unsigned char *&ptr, bool hasZValue) |
return polygon from wkb | |
Static Private Member Functions | |
static GEOSGeometry * | reshapeLine (const GEOSGeometry *origLine, const GEOSGeometry *reshapeLineGeos) |
Creates a new line from an original line and a reshape line. | |
static GEOSGeometry * | reshapePolygon (const GEOSGeometry *polygon, const GEOSGeometry *reshapeLineGeos) |
Creates a new polygon replacing the part from the first to the second intersection with the reshape line. | |
static GEOSGeometry * | nodeGeometries (const GEOSGeometry *splitLine, const GEOSGeometry *poly) |
Nodes together a split line and a (multi-) polygon geometry in a multilinestring. | |
static int | lineContainedInLine (const GEOSGeometry *line1, const GEOSGeometry *line2) |
Tests if line1 is completely contained in line2. | |
static int | pointContainedInLine (const GEOSGeometry *point, const GEOSGeometry *line) |
Tests if a point is on a line. | |
static bool | geomInDegrees (const GEOSGeometry *geom) |
Tests if geom bounding rect is within -180 <= x <= 180, -90 <= y <= 90. | |
static void | checkRingIntersections (QList< Error > &errors, int p0, int i0, const QgsPolyline &ring0, int p1, int i1, const QgsPolyline &ring1) |
static bool | geosRelOp (char(*op)(const GEOSGeometry *, const GEOSGeometry *), QgsGeometry *a, QgsGeometry *b) |
Private Attributes | |
unsigned char * | mGeometry |
pointer to geometry in binary WKB format This is the class' native implementation | |
size_t | mGeometrySize |
size of geometry | |
GEOSGeometry * | mGeos |
cached GEOS version of this geometry | |
bool | mDirtyWkb |
If the geometry has been set since the last conversion to WKB. | |
bool | mDirtyGeos |
If the geometry has been set since the last conversion to GEOS. | |
Static Private Attributes | |
static int | refcount |
Classes | |
class | Error |
Represents a geometry with input and output in formats specified by (at least) the Open Geospatial Consortium (WKB / Wkt), and containing various functions for geoprocessing of the geometry.
The geometry is represented internally by the OGC WKB format or as GEOS geometry. Some functions use WKB for their work, others use GEOS.
TODO: migrate completely to GEOS and only support WKB/Wkt import/export.
Definition at line 67 of file qgsgeometry.h.
QgsGeometry::QgsGeometry | ( | ) |
Constructor.
Definition at line 183 of file qgsgeometry.cpp.
Referenced by asGeometryCollection(), and combine().
QgsGeometry::QgsGeometry | ( | QgsGeometry const & | rhs | ) |
copy constructor will prompt a deep copy of the object
Definition at line 192 of file qgsgeometry.cpp.
References mGeometry, mGeometrySize, and mGeos.
QgsGeometry::~QgsGeometry | ( | ) |
QgsGeometry & QgsGeometry::operator= | ( | QgsGeometry const & | rhs | ) |
assignments will prompt a deep copy of the object
Definition at line 517 of file qgsgeometry.cpp.
References mDirtyGeos, mDirtyWkb, mGeometry, mGeometrySize, and mGeos.
QgsGeometry * QgsGeometry::fromWkt | ( | QString | wkt | ) | [static] |
static method that creates geometry from Wkt
Definition at line 407 of file qgsgeometry.cpp.
References fromGeosGeom().
QgsGeometry * QgsGeometry::fromPoint | ( | const QgsPoint & | point | ) | [static] |
construct geometry from a point
Definition at line 419 of file qgsgeometry.cpp.
References createGeosPoint(), and fromGeosGeom().
QgsGeometry * QgsGeometry::fromMultiPoint | ( | const QgsMultiPoint & | multipoint | ) | [static] |
construct geometry from a multipoint
Definition at line 434 of file qgsgeometry.cpp.
References createGeosCollection(), createGeosPoint(), and fromGeosGeom().
Referenced by deletePart().
QgsGeometry * QgsGeometry::fromPolyline | ( | const QgsPolyline & | polyline | ) | [static] |
construct geometry from a polyline
Definition at line 424 of file qgsgeometry.cpp.
References createGeosLineString(), and fromGeosGeom().
Referenced by QgsRubberBand::asGeometry(), and QgsGeometryAnalyzer::perimeterMeasure().
QgsGeometry * QgsGeometry::fromMultiPolyline | ( | const QgsMultiPolyline & | multiline | ) | [static] |
construct geometry from a multipolyline
Definition at line 457 of file qgsgeometry.cpp.
References createGeosCollection(), createGeosLineString(), and fromGeosGeom().
Referenced by QgsRubberBand::asGeometry(), and deletePart().
QgsGeometry * QgsGeometry::fromPolygon | ( | const QgsPolygon & | polygon | ) | [static] |
construct geometry from a polygon
Definition at line 429 of file qgsgeometry.cpp.
References createGeosPolygon(), and fromGeosGeom().
Referenced by QgsRubberBand::asGeometry(), deleteRing(), and fromRect().
QgsGeometry * QgsGeometry::fromMultiPolygon | ( | const QgsMultiPolygon & | multipoly | ) | [static] |
construct geometry from a multipolygon
Definition at line 478 of file qgsgeometry.cpp.
References createGeosCollection(), createGeosPolygon(), and fromGeosGeom().
Referenced by deletePart(), and deleteRing().
QgsGeometry * QgsGeometry::fromRect | ( | const QgsRectangle & | rect | ) | [static] |
construct geometry from a rectangle
Definition at line 502 of file qgsgeometry.cpp.
References fromPolygon(), QgsRectangle::xMaximum(), QgsRectangle::xMinimum(), QgsRectangle::yMaximum(), and QgsRectangle::yMinimum().
Referenced by QgsGeometryAnalyzer::extent(), intersects(), and QgsZonalStatistics::statisticsFromPreciseIntersection().
void QgsGeometry::fromGeos | ( | GEOSGeometry * | geos | ) |
Set the geometry, feeding in a geometry in GEOS format.
This class will take ownership of the buffer.
Definition at line 664 of file qgsgeometry.cpp.
References mDirtyGeos, mDirtyWkb, mGeometry, and mGeos.
Referenced by fromGeosGeom().
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 550 of file qgsgeometry.cpp.
References mDirtyGeos, mDirtyWkb, mGeometry, mGeometrySize, and mGeos.
Referenced by QgsFeature::setGeometryAndOwnership().
unsigned char * QgsGeometry::asWkb | ( | ) |
Returns the buffer containing this geometry in WKB format.
You may wish to use in conjunction with wkbSize().
Definition at line 571 of file qgsgeometry.cpp.
References exportGeosToWkb(), mDirtyWkb, and mGeometry.
Referenced by QgsVectorFileWriter::addFeature(), QgsInterpolator::addVerticesToCache(), QgsGeometryAnalyzer::dissolveFeature(), QgsVectorLayer::drawFeature(), QgsTINInterpolator::insertData(), QgsLabel::labelPoint(), QgsDistanceArea::measure(), QgsFeatureRendererV2::renderFeature(), and wkbType().
size_t QgsGeometry::wkbSize | ( | ) |
Returns the size of the WKB in asWkb().
Definition at line 582 of file qgsgeometry.cpp.
References exportGeosToWkb(), mDirtyWkb, and mGeometrySize.
Referenced by QgsVectorFileWriter::addFeature(), QgsGeometryAnalyzer::dissolveFeature(), and QgsLabel::labelPoint().
GEOSGeometry * QgsGeometry::asGeos | ( | ) |
Returns a geos geomtry.
QgsGeometry keeps ownership, don't delete the returned object!
Definition at line 592 of file qgsgeometry.cpp.
References exportWkbToGeos(), mDirtyGeos, and mGeos.
Referenced by QgsPALGeometry::getGeosGeometry(), QgsOverlayObject::getGeosGeometry(), isGeosEmpty(), isGeosValid(), QgsPalLayerSettings::registerFeature(), and QgsZonalStatistics::statisticsFromMiddlePointTest_improved().
QGis::WkbType QgsGeometry::wkbType | ( | ) |
Returns type of wkb (point / linestring / polygon etc.
)
Definition at line 605 of file qgsgeometry.cpp.
References asWkb(), and QGis::WKBUnknown.
Referenced by QgsVectorFileWriter::addFeature(), QgsRubberBand::addGeometry(), addIsland(), addRing(), QgsVectorLayer::addTopologicalPoints(), QgsInterpolator::addVerticesToCache(), adjacentVertices(), asMultiPoint(), asMultiPolygon(), asMultiPolyline(), asPoint(), asPolygon(), asPolyline(), avoidIntersections(), boundingBox(), closestSegmentWithContext(), closestVertex(), combine(), convertToMultiType(), deletePart(), deleteRing(), deleteVertex(), QgsVectorLayer::drawFeature(), exportGeosToWkb(), exportToWkt(), QgsTINInterpolator::insertData(), insertVertex(), isMultipart(), QgsLabel::labelPoint(), moveVertex(), QgsFeatureRendererV2::renderFeature(), QgsGeometryAnalyzer::simpleMeasure(), transform(), translate(), type(), validateGeometry(), and vertexAt().
QGis::GeometryType QgsGeometry::type | ( | ) |
Returns type of the vector.
Definition at line 621 of file qgsgeometry.cpp.
References exportGeosToWkb(), QGis::Line, mDirtyWkb, QGis::Point, QGis::Polygon, QGis::UnknownGeometry, QGis::WKBLineString, QGis::WKBLineString25D, QGis::WKBMultiLineString, QGis::WKBMultiLineString25D, QGis::WKBMultiPoint, QGis::WKBMultiPoint25D, QGis::WKBMultiPolygon, QGis::WKBMultiPolygon25D, QGis::WKBPoint, QGis::WKBPoint25D, QGis::WKBPolygon, QGis::WKBPolygon25D, and wkbType().
Referenced by addRing(), avoidIntersections(), QgsPalLayerSettings::checkMinimumSizeMM(), QgsVectorLayer::removePolygonIntersections(), reshapeGeometry(), QgsUndoCommand::GeometryChangeEntry::setOriginalGeometry(), QgsUndoCommand::GeometryChangeEntry::setTargetGeometry(), QgsGeometryAnalyzer::simpleMeasure(), splitGeometry(), and QgsSearchTreeNode::valueAgainst().
bool QgsGeometry::isMultipart | ( | ) |
Returns true if wkb of the geometry is of WKBMulti* type.
Definition at line 643 of file qgsgeometry.cpp.
References exportGeosToWkb(), mDirtyWkb, QGis::WKBMultiLineString, QGis::WKBMultiLineString25D, QGis::WKBMultiPoint, QGis::WKBMultiPoint25D, QGis::WKBMultiPolygon, QGis::WKBMultiPolygon25D, and wkbType().
Referenced by makeDifference(), and QgsGeometryAnalyzer::perimeterMeasure().
bool QgsGeometry::isGeosEqual | ( | QgsGeometry & | g | ) |
compare geometries using GEOS
Definition at line 6621 of file qgsgeometry.cpp.
References geosRelOp().
bool QgsGeometry::isGeosValid | ( | ) |
check validity using GEOS
Definition at line 6601 of file qgsgeometry.cpp.
References asGeos(), QgsDebugMsg, and GEOSException::what().
bool QgsGeometry::isGeosEmpty | ( | ) |
check if geometry is empty using GEOS
Definition at line 6626 of file qgsgeometry.cpp.
References asGeos(), QgsDebugMsg, and GEOSException::what().
double QgsGeometry::area | ( | ) |
get area of geometry using GEOS
Definition at line 5864 of file qgsgeometry.cpp.
References CATCH_GEOS, exportWkbToGeos(), and mGeos.
Referenced by QgsPalLayerSettings::checkMinimumSizeMM(), and QgsZonalStatistics::statisticsFromPreciseIntersection().
double QgsGeometry::length | ( | ) |
get length of geometry using GEOS
Definition at line 5883 of file qgsgeometry.cpp.
References CATCH_GEOS, exportWkbToGeos(), and mGeos.
Referenced by QgsPalLayerSettings::checkMinimumSizeMM().
double QgsGeometry::distance | ( | QgsGeometry & | geom | ) |
Definition at line 5901 of file qgsgeometry.cpp.
References CATCH_GEOS, exportWkbToGeos(), and mGeos.
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 685 of file qgsgeometry.cpp.
References exportGeosToWkb(), MathUtils::max(), mDirtyWkb, mGeometry, QgsDebugMsg, QgsPoint::sqrDist(), QGis::WKBLineString, QGis::WKBLineString25D, QGis::WKBMultiLineString, QGis::WKBMultiLineString25D, QGis::WKBMultiPoint, QGis::WKBMultiPoint25D, QGis::WKBMultiPolygon, QGis::WKBMultiPolygon25D, QGis::WKBPoint, QGis::WKBPoint25D, QGis::WKBPolygon, QGis::WKBPolygon25D, and wkbType().
Referenced by QgsVectorLayer::snapToGeometry().
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 963 of file qgsgeometry.cpp.
References exportGeosToWkb(), mDirtyWkb, mGeometry, QgsDebugMsg, QGis::WKBLineString, QGis::WKBLineString25D, QGis::WKBMultiLineString, QGis::WKBMultiLineString25D, QGis::WKBMultiPoint, QGis::WKBMultiPoint25D, QGis::WKBMultiPolygon, QGis::WKBMultiPolygon25D, QGis::WKBPoint, QGis::WKBPolygon, QGis::WKBPolygon25D, and wkbType().
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 1822 of file qgsgeometry.cpp.
References exportGeosToWkb(), mDirtyGeos, mDirtyWkb, mGeometry, mGeometrySize, QgsDebugMsg, QGis::WKBLineString, QGis::WKBLineString25D, QGis::WKBMultiLineString, QGis::WKBMultiLineString25D, QGis::WKBMultiPoint, QGis::WKBMultiPoint25D, QGis::WKBMultiPolygon, QGis::WKBMultiPolygon25D, QGis::WKBNoGeometry, QGis::WKBPoint, QGis::WKBPoint25D, QGis::WKBPolygon, QGis::WKBPolygon25D, wkbType(), and QGis::WKBUnknown.
Referenced by QgsVectorLayer::insertVertex().
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.
References exportGeosToWkb(), mDirtyGeos, mDirtyWkb, mGeometry, QgsDebugMsg, QGis::WKBLineString, QGis::WKBLineString25D, QGis::WKBMultiLineString, QGis::WKBMultiLineString25D, QGis::WKBMultiPoint, QGis::WKBMultiPoint25D, QGis::WKBMultiPolygon, QGis::WKBMultiPolygon25D, QGis::WKBPoint, QGis::WKBPoint25D, QGis::WKBPolygon, QGis::WKBPolygon25D, and wkbType().
Referenced by QgsVectorLayer::moveVertex().
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 1493 of file qgsgeometry.cpp.
References exportGeosToWkb(), mDirtyGeos, mDirtyWkb, mGeometry, mGeometrySize, QgsDebugMsg, QGis::WKBLineString, QGis::WKBLineString25D, QGis::WKBMultiLineString, QGis::WKBMultiLineString25D, QGis::WKBMultiPoint, QGis::WKBMultiPoint25D, QGis::WKBMultiPolygon, QGis::WKBMultiPolygon25D, QGis::WKBNoGeometry, QGis::WKBPoint, QGis::WKBPoint25D, QGis::WKBPolygon, QGis::WKBPolygon25D, wkbType(), and QGis::WKBUnknown.
Referenced by QgsVectorLayer::deleteVertex().
QgsPoint QgsGeometry::vertexAt | ( | int | atVertex | ) |
Returns coordinates of a vertex.
atVertex | index of the vertex |
Definition at line 2127 of file qgsgeometry.cpp.
References exportGeosToWkb(), mDirtyWkb, mGeometry, QgsDebugMsg, QGis::WKBLineString, QGis::WKBLineString25D, QGis::WKBMultiLineString, QGis::WKBMultiLineString25D, QGis::WKBMultiPoint, QGis::WKBMultiPoint25D, QGis::WKBMultiPolygon, QGis::WKBMultiPolygon25D, QGis::WKBPoint, QGis::WKBPoint25D, QGis::WKBPolygon, QGis::WKBPolygon25D, and wkbType().
Referenced by QgsVectorLayer::snapToGeometry(), and sqrDistToVertexAt().
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 2330 of file qgsgeometry.cpp.
References MathUtils::max(), QgsDebugMsg, QgsPoint::sqrDist(), QgsPoint::toString(), and vertexAt().
double QgsGeometry::closestVertexWithContext | ( | const QgsPoint & | point, | |
int & | atVertex | |||
) |
Searches for the the closest vertex in this geometry to the given point.
point | Specifiest the point for search | |
atVertex | Receives index of the closest vertex |
Definition at line 2347 of file qgsgeometry.cpp.
References exportWkbToGeos(), MathUtils::max(), mGeos, and QgsPoint::sqrDist().
double QgsGeometry::closestSegmentWithContext | ( | const QgsPoint & | point, | |
QgsPoint & | minDistPoint, | |||
int & | beforeVertex | |||
) |
Searches for the closest segment of geometry to the given point.
point | Specifies the point for search | |
minDistPoint | Receives the nearest point on the segment | |
beforeVertex | Receives index of the vertex before the closest segment. The vertex after the closest segment is always beforeVertex + 1 |
Definition at line 2395 of file qgsgeometry.cpp.
References exportGeosToWkb(), MathUtils::max(), mDirtyWkb, mGeometry, QgsDebugMsg, QgsPoint::sqrDistToSegment(), QgsPoint::toString(), QGis::WKBLineString, QGis::WKBLineString25D, QGis::WKBMultiLineString, QGis::WKBMultiLineString25D, QGis::WKBMultiPoint, QGis::WKBMultiPoint25D, QGis::WKBMultiPolygon, QGis::WKBMultiPolygon25D, QGis::WKBPoint, QGis::WKBPoint25D, QGis::WKBPolygon, QGis::WKBPolygon25D, wkbType(), and QGis::WKBUnknown.
Referenced by QgsVectorLayer::snapToGeometry().
int QgsGeometry::addRing | ( | const QList< QgsPoint > & | ring | ) |
Adds a new ring to this geometry.
This makes only sense for polygon and multipolygons.
Definition at line 2621 of file qgsgeometry.cpp.
References createGeosCollection(), createGeosLinearRing(), createGeosPolygon(), exportWkbToGeos(), mDirtyGeos, mDirtyWkb, mGeos, QGis::Polygon, throwGEOSException(), type(), QGis::WKBMultiPolygon, QGis::WKBPolygon, and wkbType().
Referenced by QgsVectorLayer::addRing().
int QgsGeometry::addIsland | ( | const QList< QgsPoint > & | ring | ) |
Adds a new island polygon to a multipolygon feature.
Definition at line 2810 of file qgsgeometry.cpp.
References convertToMultiType(), createGeosCollection(), createGeosLinearRing(), createGeosPolygon(), exportWkbToGeos(), mDirtyGeos, mDirtyWkb, mGeos, QGis::WKBMultiPolygon, QGis::WKBMultiPolygon25D, QGis::WKBPolygon, QGis::WKBPolygon25D, and wkbType().
Referenced by QgsVectorLayer::addIsland().
int QgsGeometry::translate | ( | double | dx, | |
double | dy | |||
) |
Translate this geometry by dx, dy.
Definition at line 2906 of file qgsgeometry.cpp.
References exportGeosToWkb(), mDirtyGeos, mDirtyWkb, mGeometry, QgsDebugMsg, translateVertex(), QGis::WKBLineString, QGis::WKBLineString25D, QGis::WKBMultiLineString, QGis::WKBMultiLineString25D, QGis::WKBMultiPoint, QGis::WKBMultiPoint25D, QGis::WKBMultiPolygon, QGis::WKBMultiPolygon25D, QGis::WKBPoint, QGis::WKBPoint25D, QGis::WKBPolygon, QGis::WKBPolygon25D, and wkbType().
Referenced by QgsVectorLayer::translateFeature().
int QgsGeometry::transform | ( | const QgsCoordinateTransform & | ct | ) |
Transform this geometry as described by CoordinateTranasform ct.
Definition at line 3032 of file qgsgeometry.cpp.
References exportGeosToWkb(), mDirtyGeos, mDirtyWkb, mGeometry, QgsDebugMsg, transformVertex(), QGis::WKBLineString, QGis::WKBLineString25D, QGis::WKBMultiLineString, QGis::WKBMultiLineString25D, QGis::WKBMultiPoint, QGis::WKBMultiPoint25D, QGis::WKBMultiPolygon, QGis::WKBMultiPolygon25D, QGis::WKBPoint, QGis::WKBPoint25D, QGis::WKBPolygon, QGis::WKBPolygon25D, and wkbType().
Referenced by QgsPalLayerSettings::registerFeature(), and QgsVectorFileWriter::writeAsVectorFormat().
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.
splitLine | the line that splits the geometry | |
[out] | newGeometries | list of new geometries that have been created with the split |
topological | true if topological editing is enabled | |
[out] | topologyTestPoints | points that need to be tested for topological completeness in the dataset |
Definition at line 3158 of file qgsgeometry.cpp.
References CATCH_GEOS, createGeosLineString(), exportGeosToWkb(), exportWkbToGeos(), QGis::Line, mDirtyGeos, mDirtyWkb, mGeos, QGis::Point, QGis::Polygon, splitLinearGeometry(), splitPolygonGeometry(), topologicalTestPointsSplit(), and type().
int QgsGeometry::reshapeGeometry | ( | const QList< QgsPoint > & | reshapeWithLine | ) |
Replaces a part of this geometry with another line.
Definition at line 3227 of file qgsgeometry.cpp.
References createGeosLineString(), exportWkbToGeos(), QGis::Line, mDirtyGeos, mDirtyWkb, mGeos, QGis::Point, reshapeLine(), reshapePolygon(), and type().
int QgsGeometry::makeDifference | ( | QgsGeometry * | other | ) |
Changes this geometry such that it does not intersect the other geometry.
other | geometry that should not be intersect |
Definition at line 3350 of file qgsgeometry.cpp.
References CATCH_GEOS, convertToMultiType(), exportWkbToGeos(), isMultipart(), mDirtyGeos, mDirtyWkb, and mGeos.
Referenced by QgsVectorLayer::removePolygonIntersections().
QgsRectangle QgsGeometry::boundingBox | ( | ) |
Returns the bounding box of this feature.
Definition at line 3417 of file qgsgeometry.cpp.
References exportGeosToWkb(), MathUtils::max(), mDirtyWkb, mGeometry, QgsDebugMsg, QGis::WKBLineString, QGis::WKBLineString25D, QGis::WKBMultiLineString, QGis::WKBMultiLineString25D, QGis::WKBMultiPoint, QGis::WKBMultiPoint25D, QGis::WKBMultiPolygon, QGis::WKBMultiPolygon25D, QGis::WKBPoint, QGis::WKBPoint25D, QGis::WKBPolygon, QGis::WKBPolygon25D, and wkbType().
Referenced by QgsVectorLayer::boundingBoxOfSelected(), QgsZonalStatistics::calculateStatistics(), QgsOverlayAnalyzer::intersectFeature(), QgsVectorLayer::removePolygonIntersections(), QgsVectorLayer::snapWithContext(), and QgsVectorLayer::updateExtents().
bool QgsGeometry::intersects | ( | const QgsRectangle & | r | ) |
Test for intersection with a rectangle (uses GEOS).
Definition at line 3697 of file qgsgeometry.cpp.
References fromRect().
Referenced by QgsOverlayAnalyzer::intersectFeature().
bool QgsGeometry::intersects | ( | QgsGeometry * | geometry | ) |
Test for intersection with a geometry (uses GEOS).
Definition at line 3705 of file qgsgeometry.cpp.
References CATCH_GEOS, exportWkbToGeos(), mGeos, and QgsDebugMsg.
bool QgsGeometry::contains | ( | QgsPoint * | p | ) |
Test for containment of a point (uses GEOS).
Definition at line 3725 of file qgsgeometry.cpp.
References createGeosPoint(), exportWkbToGeos(), mGeos, and QgsDebugMsg.
Referenced by QgsZonalStatistics::statisticsFromMiddlePointTest().
bool QgsGeometry::contains | ( | QgsGeometry * | geometry | ) |
Test for if geometry is contained in an other (uses GEOS).
Definition at line 3777 of file qgsgeometry.cpp.
References geosRelOp().
bool QgsGeometry::disjoint | ( | QgsGeometry * | geometry | ) |
Test for if geometry is disjoint of an other (uses GEOS).
Definition at line 3782 of file qgsgeometry.cpp.
References geosRelOp().
bool QgsGeometry::equals | ( | QgsGeometry * | geometry | ) |
Test for if geometry equals an other (uses GEOS).
Definition at line 3787 of file qgsgeometry.cpp.
References geosRelOp().
bool QgsGeometry::touches | ( | QgsGeometry * | geometry | ) |
Test for if geometry touch an other (uses GEOS).
Definition at line 3792 of file qgsgeometry.cpp.
References geosRelOp().
bool QgsGeometry::overlaps | ( | QgsGeometry * | geometry | ) |
Test for if geometry overlaps an other (uses GEOS).
Definition at line 3797 of file qgsgeometry.cpp.
References geosRelOp().
bool QgsGeometry::within | ( | QgsGeometry * | geometry | ) |
Test for if geometry is within an other (uses GEOS).
Definition at line 3802 of file qgsgeometry.cpp.
References geosRelOp().
bool QgsGeometry::crosses | ( | QgsGeometry * | geometry | ) |
Test for if geometry crosses an other (uses GEOS).
Definition at line 3807 of file qgsgeometry.cpp.
References geosRelOp().
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 5928 of file qgsgeometry.cpp.
References CATCH_GEOS, exportWkbToGeos(), fromGeosGeom(), and mGeos.
Referenced by QgsGeometryAnalyzer::bufferFeature().
QgsGeometry * QgsGeometry::simplify | ( | double | tolerance | ) |
Returns a simplified version of this geometry using a specified tolerance value.
Definition at line 5946 of file qgsgeometry.cpp.
References CATCH_GEOS, exportWkbToGeos(), fromGeosGeom(), and mGeos.
Referenced by QgsGeometryAnalyzer::simplifyFeature().
QgsGeometry * QgsGeometry::centroid | ( | ) |
Returns the center of mass of a geometry.
Definition at line 5963 of file qgsgeometry.cpp.
References CATCH_GEOS, exportWkbToGeos(), fromGeosGeom(), and mGeos.
Referenced by QgsGeometryAnalyzer::centroidFeature().
QgsGeometry * QgsGeometry::convexHull | ( | ) |
Returns the smallest convex polygon that contains all the points in the geometry.
Definition at line 5980 of file qgsgeometry.cpp.
References CATCH_GEOS, exportWkbToGeos(), fromGeosGeom(), and mGeos.
Referenced by QgsGeometryAnalyzer::convexFeature(), and QgsGeometryAnalyzer::convexHull().
QgsGeometry * QgsGeometry::intersection | ( | QgsGeometry * | geometry | ) |
Returns a geometry representing the points shared by this geometry and other.
Definition at line 5998 of file qgsgeometry.cpp.
References CATCH_GEOS, exportWkbToGeos(), fromGeosGeom(), and mGeos.
Referenced by QgsOverlayAnalyzer::intersectFeature(), and QgsZonalStatistics::statisticsFromPreciseIntersection().
QgsGeometry * QgsGeometry::combine | ( | QgsGeometry * | geometry | ) |
Returns a geometry representing all the points in this geometry and other (a union geometry operation).
Definition at line 6024 of file qgsgeometry.cpp.
References CATCH_GEOS, exportWkbToGeos(), fromGeosGeom(), mGeos, QgsGeometry(), QGis::WKBLineString, QGis::WKBLineString25D, and wkbType().
Referenced by QgsGeometryAnalyzer::bufferFeature(), QgsGeometryAnalyzer::convexFeature(), and QgsGeometryAnalyzer::dissolveFeature().
QgsGeometry * QgsGeometry::difference | ( | QgsGeometry * | geometry | ) |
Returns a geometry representing the points making up this geometry that do not make up other.
Definition at line 6063 of file qgsgeometry.cpp.
References CATCH_GEOS, exportWkbToGeos(), fromGeosGeom(), and mGeos.
QgsGeometry * QgsGeometry::symDifference | ( | QgsGeometry * | geometry | ) |
Returns a Geometry representing the points making up this Geometry that do not make up other.
Definition at line 6089 of file qgsgeometry.cpp.
References CATCH_GEOS, exportWkbToGeos(), fromGeosGeom(), and mGeos.
QString QgsGeometry::exportToWkt | ( | ) |
Exports the geometry to mWkt.
Definition at line 3812 of file qgsgeometry.cpp.
References exportGeosToWkb(), mDirtyWkb, mGeometry, QgsDebugMsg, QGis::WKBLineString, QGis::WKBLineString25D, QGis::WKBMultiLineString, QGis::WKBMultiLineString25D, QGis::WKBMultiPoint, QGis::WKBMultiPoint25D, QGis::WKBMultiPolygon, QGis::WKBMultiPolygon25D, QGis::WKBPoint, QGis::WKBPoint25D, QGis::WKBPolygon, QGis::WKBPolygon25D, and wkbType().
QgsPoint QgsGeometry::asPoint | ( | ) |
return contents of the geometry as a point if wkbType is WKBPoint, otherwise returns [0,0]
Definition at line 5769 of file qgsgeometry.cpp.
References mGeometry, QGis::WKBPoint, QGis::WKBPoint25D, and wkbType().
Referenced by QgsRubberBand::addGeometry(), asMultiPoint(), and QgsGeometryAnalyzer::simpleMeasure().
QgsPolyline QgsGeometry::asPolyline | ( | ) |
return contents of the geometry as a polyline if wkbType is WKBLineString, otherwise an empty list
Definition at line 5779 of file qgsgeometry.cpp.
References mGeometry, QGis::WKBLineString, QGis::WKBLineString25D, and wkbType().
Referenced by QgsRubberBand::addGeometry(), QgsVectorLayer::addTopologicalPoints(), asMultiPolyline(), and validateGeometry().
QgsPolygon QgsGeometry::asPolygon | ( | ) |
return contents of the geometry as a polygon if wkbType is WKBPolygon, otherwise an empty list
Definition at line 5789 of file qgsgeometry.cpp.
References mGeometry, QGis::WKBPolygon, QGis::WKBPolygon25D, and wkbType().
Referenced by QgsRubberBand::addGeometry(), QgsVectorLayer::addTopologicalPoints(), asMultiPolygon(), deleteRing(), QgsGeometryAnalyzer::perimeterMeasure(), and validateGeometry().
QgsMultiPoint QgsGeometry::asMultiPoint | ( | ) |
return contents of the geometry as a multi point if wkbType is WKBMultiPoint, otherwise an empty list
Definition at line 5799 of file qgsgeometry.cpp.
References asPoint(), mGeometry, QGis::WKBMultiPoint, QGis::WKBMultiPoint25D, and wkbType().
Referenced by QgsRubberBand::addGeometry(), and deletePart().
QgsMultiPolyline QgsGeometry::asMultiPolyline | ( | ) |
return contents of the geometry as a multi linestring if wkbType is WKBMultiLineString, otherwise an empty list
Definition at line 5820 of file qgsgeometry.cpp.
References asPolyline(), mGeometry, QGis::WKBMultiLineString, QGis::WKBMultiLineString25D, and wkbType().
Referenced by QgsRubberBand::addGeometry(), QgsVectorLayer::addTopologicalPoints(), deletePart(), and validateGeometry().
QgsMultiPolygon QgsGeometry::asMultiPolygon | ( | ) |
return contents of the geometry as a multi polygon if wkbType is WKBMultiPolygon, otherwise an empty list
Definition at line 5842 of file qgsgeometry.cpp.
References asPolygon(), mGeometry, QGis::WKBMultiPolygon, QGis::WKBMultiPolygon25D, and wkbType().
Referenced by QgsRubberBand::addGeometry(), QgsVectorLayer::addTopologicalPoints(), deletePart(), deleteRing(), QgsGeometryAnalyzer::perimeterMeasure(), and validateGeometry().
QList< QgsGeometry * > QgsGeometry::asGeometryCollection | ( | ) |
return contents of the geometry as a list of geometries
Definition at line 6115 of file qgsgeometry.cpp.
References exportWkbToGeos(), fromGeosGeom(), mGeos, QgsDebugMsg, and QgsGeometry().
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.
Definition at line 6152 of file qgsgeometry.cpp.
References asMultiPolygon(), asPolygon(), fromMultiPolygon(), fromPolygon(), QGis::WKBMultiPolygon, QGis::WKBMultiPolygon25D, QGis::WKBPolygon, QGis::WKBPolygon25D, and wkbType().
bool QgsGeometry::deletePart | ( | int | partNum | ) |
delete part identified by the part number
Definition at line 6202 of file qgsgeometry.cpp.
References asMultiPoint(), asMultiPolygon(), asMultiPolyline(), fromMultiPoint(), fromMultiPolygon(), fromMultiPolyline(), QGis::WKBMultiLineString, QGis::WKBMultiLineString25D, QGis::WKBMultiPoint, QGis::WKBMultiPoint25D, QGis::WKBMultiPolygon, QGis::WKBMultiPolygon25D, and wkbType().
bool QgsGeometry::convertToMultiType | ( | ) |
Converts single type geometry into multitype geometry e.g.
a polygon into a multipolygon geometry with one polygon
Definition at line 4739 of file qgsgeometry.cpp.
References QgsApplication::endian(), mDirtyGeos, mGeometry, mGeometrySize, QGis::WKBLineString, QGis::WKBLineString25D, QGis::WKBMultiLineString, QGis::WKBMultiLineString25D, QGis::WKBMultiPoint, QGis::WKBMultiPoint25D, QGis::WKBMultiPolygon, QGis::WKBMultiPolygon25D, QGis::WKBPoint, QGis::WKBPoint25D, QGis::WKBPolygon, QGis::WKBPolygon25D, wkbType(), and QGis::WKBUnknown.
Referenced by addIsland(), and makeDifference().
int QgsGeometry::avoidIntersections | ( | ) |
Modifies geometry to avoid intersections with the layers specified in project properties.
Definition at line 6265 of file qgsgeometry.cpp.
References QgsMapLayerRegistry::instance(), QgsProject::instance(), QgsMapLayerRegistry::mapLayer(), QGis::Polygon, QgsProject::readListEntry(), QgsVectorLayer::removePolygonIntersections(), type(), and wkbType().
void QgsGeometry::validateGeometry | ( | QList< Error > & | errors | ) |
Validate geometry and produce a list of geometry errors.
Definition at line 6530 of file qgsgeometry.cpp.
References asMultiPolygon(), asMultiPolyline(), asPolygon(), asPolyline(), checkRingIntersections(), QgsDebugMsg, ringInRing(), validatePolygon(), validatePolyline(), QGis::WKBLineString, QGis::WKBLineString25D, QGis::WKBMultiLineString, QGis::WKBMultiLineString25D, QGis::WKBMultiPoint, QGis::WKBMultiPoint25D, QGis::WKBMultiPolygon, QGis::WKBMultiPolygon25D, QGis::WKBNoGeometry, QGis::WKBPoint, QGis::WKBPoint25D, QGis::WKBPolygon, QGis::WKBPolygon25D, wkbType(), and QGis::WKBUnknown.
void QgsGeometry::validatePolyline | ( | QList< Error > & | errors, | |
int | i, | |||
QgsPolyline | polyline, | |||
bool | ring = false | |||
) | [static] |
Definition at line 6416 of file qgsgeometry.cpp.
References distLine2Point(), intersectLines(), QgsVector::length(), QgsVector::perpVector(), QgsDebugMsg, and QgsPoint::toString().
Referenced by validateGeometry(), and validatePolygon().
void QgsGeometry::validatePolygon | ( | QList< Error > & | errors, | |
int | i, | |||
const QgsPolygon & | polygon | |||
) | [static] |
Definition at line 6501 of file qgsgeometry.cpp.
References checkRingIntersections(), QgsDebugMsg, ringInRing(), and validatePolyline().
Referenced by validateGeometry().
bool QgsGeometry::exportWkbToGeos | ( | ) | [private] |
Converts from the WKB geometry to the GEOS geometry.
Definition at line 4092 of file qgsgeometry.cpp.
References CATCH_GEOS, createGeosCollection(), createGeosLinearRing(), createGeosLineString(), createGeosPoint(), createGeosPolygon(), mDirtyGeos, mGeometry, mGeos, QgsDebugMsgLevel, QGis::WKBLineString, QGis::WKBLineString25D, QGis::WKBMultiLineString, QGis::WKBMultiLineString25D, QGis::WKBMultiPoint, QGis::WKBMultiPoint25D, QGis::WKBMultiPolygon, QGis::WKBMultiPolygon25D, QGis::WKBPoint, QGis::WKBPoint25D, QGis::WKBPolygon, and QGis::WKBPolygon25D.
Referenced by addIsland(), addRing(), area(), asGeometryCollection(), asGeos(), buffer(), centroid(), closestVertexWithContext(), combine(), contains(), convexHull(), difference(), distance(), geosRelOp(), intersection(), intersects(), length(), makeDifference(), mergeGeometriesMultiTypeSplit(), reshapeGeometry(), simplify(), splitGeometry(), splitLinearGeometry(), splitPolygonGeometry(), and symDifference().
bool QgsGeometry::exportGeosToWkb | ( | ) | [private] |
Converts from the GEOS geometry to the WKB geometry.
Definition at line 4344 of file qgsgeometry.cpp.
References QgsApplication::endian(), getNumGeosPoints(), mDirtyWkb, mGeometry, mGeometrySize, mGeos, QgsDebugMsg, QGis::WKBLineString, QGis::WKBMultiLineString, QGis::WKBMultiPoint, QGis::WKBMultiPolygon, QGis::WKBPoint, QGis::WKBPolygon, and wkbType().
Referenced by adjacentVertices(), asWkb(), boundingBox(), closestSegmentWithContext(), closestVertex(), deleteVertex(), exportToWkt(), insertVertex(), isMultipart(), moveVertex(), splitGeometry(), transform(), translate(), type(), vertexAt(), and wkbSize().
bool QgsGeometry::insertVertex | ( | double | x, | |
double | y, | |||
int | beforeVertex, | |||
const GEOSCoordSequence * | old_sequence, | |||
GEOSCoordSequence ** | new_sequence | |||
) | [private] |
Insert a new vertex before the given vertex index (first number is index 0) in the given GEOS Coordinate Sequence.
If the requested vertex number is greater than the last actual vertex, it is assumed that the vertex is to be appended instead of inserted.
x | x coordinate | |
y | y coordinate | |
beforeVertex | insert before vertex with this index | |
old_sequence | The sequence to update (The caller remains the owner). | |
new_sequence | The updated sequence (The caller becomes the owner if the function returns true). Returns false if beforeVertex does not correspond to a valid vertex number on the Coordinate Sequence. |
Definition at line 1192 of file qgsgeometry.cpp.
void QgsGeometry::translateVertex | ( | int & | wkbPosition, | |
double | dx, | |||
double | dy, | |||
bool | hasZValue | |||
) | [private] |
Translates a single vertex by dx and dy.
wkbPosition | position in wkb array. Is increased automatically by the function | |
dx | translation of x-coordinate | |
dy | translation of y-coordinate | |
hasZValue | 25D type? |
Definition at line 4809 of file qgsgeometry.cpp.
References mGeometry.
Referenced by translate().
void QgsGeometry::transformVertex | ( | int & | wkbPosition, | |
const QgsCoordinateTransform & | ct, | |||
bool | hasZValue | |||
) | [private] |
Transforms a single vertex by ct.
wkbPosition | position in wkb array. Is increased automatically by the function | |
ct | the QgsCoordinateTransform | |
hasZValue | 25D type? |
Definition at line 4831 of file qgsgeometry.cpp.
References mGeometry, and QgsCoordinateTransform::transformInPlace().
Referenced by transform().
int QgsGeometry::splitLinearGeometry | ( | GEOSGeometry * | splitLine, | |
QList< QgsGeometry * > & | newGeometries | |||
) | [private] |
Splits line/multiline geometries.
splitLine | the line that splits the feature | |
newGeometries | new geometries if splitting was successful |
Definition at line 4856 of file qgsgeometry.cpp.
References exportWkbToGeos(), fromGeosGeom(), lineContainedInLine(), mDirtyGeos, mDirtyWkb, mergeGeometriesMultiTypeSplit(), mGeos, and nodeGeometries().
Referenced by splitGeometry().
int QgsGeometry::splitPolygonGeometry | ( | GEOSGeometry * | splitLine, | |
QList< QgsGeometry * > & | newGeometries | |||
) | [private] |
Splits polygon/multipolygon geometries.
Definition at line 4917 of file qgsgeometry.cpp.
References exportWkbToGeos(), fromGeosGeom(), mDirtyGeos, mDirtyWkb, mergeGeometriesMultiTypeSplit(), mGeos, nodeGeometries(), numberOfGeometries(), and QgsDebugMsg.
Referenced by splitGeometry().
int QgsGeometry::topologicalTestPointsSplit | ( | const GEOSGeometry * | splitLine, | |
QList< QgsPoint > & | testPoints | |||
) | const [private] |
Finds out the points that need to be tested for topological correctnes if this geometry will be split.
Definition at line 5394 of file qgsgeometry.cpp.
References mGeos.
Referenced by splitGeometry().
GEOSGeometry * QgsGeometry::reshapeLine | ( | const GEOSGeometry * | origLine, | |
const GEOSGeometry * | reshapeLineGeos | |||
) | [static, private] |
Creates a new line from an original line and a reshape line.
The part of the input line from the first to the last intersection with the \ reshape line will be replaced. The calling function takes ownership of the result.
origLine | the original line | |
reshapeLineGeos | the reshape line |
Definition at line 5162 of file qgsgeometry.cpp.
References createGeosPoint(), lineContainedInLine(), nodeGeometries(), and pointContainedInLine().
Referenced by reshapeGeometry(), and reshapePolygon().
GEOSGeometry * QgsGeometry::reshapePolygon | ( | const GEOSGeometry * | polygon, | |
const GEOSGeometry * | reshapeLineGeos | |||
) | [static, private] |
Creates a new polygon replacing the part from the first to the second intersection with the reshape line.
As a polygon ring is always closed, the method keeps the longer part of the existing boundary
polygon | geometry to reshape | |
reshapeLineGeos | the reshape line |
Definition at line 5037 of file qgsgeometry.cpp.
References reshapeLine().
Referenced by reshapeGeometry().
GEOSGeometry * QgsGeometry::nodeGeometries | ( | const GEOSGeometry * | splitLine, | |
const GEOSGeometry * | poly | |||
) | [static, private] |
Nodes together a split line and a (multi-) polygon geometry in a multilinestring.
Definition at line 5452 of file qgsgeometry.cpp.
Referenced by reshapeLine(), splitLinearGeometry(), and splitPolygonGeometry().
int QgsGeometry::lineContainedInLine | ( | const GEOSGeometry * | line1, | |
const GEOSGeometry * | line2 | |||
) | [static, private] |
Tests if line1 is completely contained in line2.
This method works with a very small buffer around line2 and therefore is less prone to numerical errors as the corresponding geos method
Definition at line 5477 of file qgsgeometry.cpp.
References DEFAULT_QUADRANT_SEGMENTS, and geomInDegrees().
Referenced by reshapeLine(), and splitLinearGeometry().
int QgsGeometry::pointContainedInLine | ( | const GEOSGeometry * | point, | |
const GEOSGeometry * | line | |||
) | [static, private] |
Tests if a point is on a line.
This method works with a very small buffer and is thus less prone to numerical problems as the direct geos functions.
point | the point to test | |
line | line to test |
Definition at line 5516 of file qgsgeometry.cpp.
References geomInDegrees().
Referenced by reshapeLine().
bool QgsGeometry::geomInDegrees | ( | const GEOSGeometry * | geom | ) | [static, private] |
Tests if geom bounding rect is within -180 <= x <= 180, -90 <= y <= 90.
Other methods may use more accurate tolerances if this is true
Definition at line 5544 of file qgsgeometry.cpp.
Referenced by lineContainedInLine(), and pointContainedInLine().
int QgsGeometry::numberOfGeometries | ( | GEOSGeometry * | g | ) | const [private] |
Returns number of single geometry in a geos geometry.
Is save for geos 2 and 3
Definition at line 5588 of file qgsgeometry.cpp.
Referenced by splitPolygonGeometry().
int QgsGeometry::mergeGeometriesMultiTypeSplit | ( | QVector< GEOSGeometry * > & | splitResult | ) | [private] |
Definition at line 5605 of file qgsgeometry.cpp.
References createGeosCollection(), exportWkbToGeos(), mDirtyGeos, and mGeos.
Referenced by splitLinearGeometry(), and splitPolygonGeometry().
QgsPoint QgsGeometry::asPoint | ( | unsigned char *& | ptr, | |
bool | hasZValue | |||
) | [private] |
QgsPolyline QgsGeometry::asPolyline | ( | unsigned char *& | ptr, | |
bool | hasZValue | |||
) | [private] |
QgsPolygon QgsGeometry::asPolygon | ( | unsigned char *& | ptr, | |
bool | hasZValue | |||
) | [private] |
void QgsGeometry::checkRingIntersections | ( | QList< Error > & | errors, | |
int | p0, | |||
int | i0, | |||
const QgsPolyline & | ring0, | |||
int | p1, | |||
int | i1, | |||
const QgsPolyline & | ring1 | |||
) | [static, private] |
Definition at line 6374 of file qgsgeometry.cpp.
References distLine2Point(), intersectLines(), QgsVector::length(), QgsVector::perpVector(), QgsDebugMsg, and QgsPoint::toString().
Referenced by validateGeometry(), and validatePolygon().
bool QgsGeometry::geosRelOp | ( | char(*)(const GEOSGeometry *, const GEOSGeometry *) | op, | |
QgsGeometry * | a, | |||
QgsGeometry * | b | |||
) | [static, private] |
Definition at line 3756 of file qgsgeometry.cpp.
References CATCH_GEOS, exportWkbToGeos(), mGeos, and QgsDebugMsg.
Referenced by contains(), crosses(), disjoint(), equals(), isGeosEqual(), overlaps(), touches(), and within().
unsigned char* QgsGeometry::mGeometry [private] |
pointer to geometry in binary WKB format This is the class' native implementation
Definition at line 452 of file qgsgeometry.h.
Referenced by adjacentVertices(), asMultiPoint(), asMultiPolygon(), asMultiPolyline(), asPoint(), asPolygon(), asPolyline(), asWkb(), boundingBox(), closestSegmentWithContext(), closestVertex(), convertToMultiType(), deleteVertex(), exportGeosToWkb(), exportToWkt(), exportWkbToGeos(), fromGeos(), fromWkb(), insertVertex(), moveVertex(), operator=(), QgsGeometry(), transform(), transformVertex(), translate(), translateVertex(), vertexAt(), and ~QgsGeometry().
size_t QgsGeometry::mGeometrySize [private] |
size of geometry
Definition at line 455 of file qgsgeometry.h.
Referenced by convertToMultiType(), deleteVertex(), exportGeosToWkb(), fromWkb(), insertVertex(), operator=(), QgsGeometry(), and wkbSize().
GEOSGeometry* QgsGeometry::mGeos [private] |
cached GEOS version of this geometry
Definition at line 458 of file qgsgeometry.h.
Referenced by addIsland(), addRing(), area(), asGeometryCollection(), asGeos(), buffer(), centroid(), closestVertexWithContext(), combine(), contains(), convexHull(), difference(), distance(), exportGeosToWkb(), exportWkbToGeos(), fromGeos(), fromWkb(), geosRelOp(), intersection(), intersects(), length(), makeDifference(), mergeGeometriesMultiTypeSplit(), operator=(), QgsGeometry(), reshapeGeometry(), simplify(), splitGeometry(), splitLinearGeometry(), splitPolygonGeometry(), symDifference(), topologicalTestPointsSplit(), and ~QgsGeometry().
bool QgsGeometry::mDirtyWkb [private] |
If the geometry has been set since the last conversion to WKB.
Definition at line 461 of file qgsgeometry.h.
Referenced by addIsland(), addRing(), adjacentVertices(), asWkb(), boundingBox(), closestSegmentWithContext(), closestVertex(), deleteVertex(), exportGeosToWkb(), exportToWkt(), fromGeos(), fromWkb(), insertVertex(), isMultipart(), makeDifference(), moveVertex(), operator=(), reshapeGeometry(), splitGeometry(), splitLinearGeometry(), splitPolygonGeometry(), transform(), translate(), type(), vertexAt(), and wkbSize().
bool QgsGeometry::mDirtyGeos [private] |
If the geometry has been set since the last conversion to GEOS.
Definition at line 464 of file qgsgeometry.h.
Referenced by addIsland(), addRing(), asGeos(), convertToMultiType(), deleteVertex(), exportWkbToGeos(), fromGeos(), fromWkb(), insertVertex(), makeDifference(), mergeGeometriesMultiTypeSplit(), moveVertex(), operator=(), reshapeGeometry(), splitGeometry(), splitLinearGeometry(), splitPolygonGeometry(), transform(), and translate().
int QgsGeometry::refcount [static, private] |
Definition at line 577 of file qgsgeometry.h.