48 #include <netinet/in.h>
59 mutable const unsigned char*
mWkb;
103 void QgsGeometry::detach(
bool cloneGeom )
125 void QgsGeometry::removeWkbGeos()
379 beforeVertex = -1; afterVertex = -1;
507 double epsilon )
const
520 minDistPoint.
setX( segmentPt.
x() );
521 minDistPoint.
setY( segmentPt.
y() );
525 *leftOf = leftOfBool ? 1.0 : -1.0;
537 convertPointList( ring, ringPoints );
584 if ( points.
size() == 1 )
586 partGeom =
new QgsPointV2( points[0].x(), points[0].y() );
588 else if ( points.
size() > 1 )
592 convertPointList( points, partPoints );
608 if ( !d || !d->
geometry || !newPart || !newPart->d || !newPart->d->
geometry )
618 if ( !d || !d->
geometry || !newPart )
671 convertPointList( splitLine, splitLinePointsV2 );
672 splitLineString.
setPoints( splitLinePointsV2 );
676 int result = geos.
splitGeometry( splitLineString, newGeoms, topological, tp );
683 newGeometries.
clear();
684 for (
int i = 1; i < newGeoms.
size(); ++i )
690 convertPointList( tp, topologyTestPoints );
704 convertPointList( reshapeWithLine, reshapeLine );
706 reshapeLineString.
setPoints( reshapeLine );
711 if ( errorCode == 0 && geom )
764 if ( !d || !d->
geometry || !geometry || !geometry->d || !geometry->d->
geometry )
782 return geos.contains( pt );
787 if ( !d || !d->
geometry || !geometry || !geometry->d || !geometry->d->
geometry )
798 if ( !d || !d->
geometry || !geometry || !geometry->d || !geometry->d->
geometry )
809 if ( !d || !d->
geometry || !geometry || !geometry->d || !geometry->d->
geometry )
820 if ( !d || !d->
geometry || !geometry || !geometry->d || !geometry->d->
geometry )
831 if ( !d || !d->
geometry || !geometry || !geometry->d || !geometry->d->
geometry )
842 if ( !d || !d->
geometry || !geometry || !geometry->d || !geometry->d->
geometry )
853 if ( !d || !d->
geometry || !geometry || !geometry->d || !geometry->d->
geometry )
885 return convertToPoint( destMultipart );
888 return convertToLine( destMultipart );
891 return convertToPolygon( destMultipart );
949 if ( doSegmentation )
968 polyLine.
resize( nVertices );
969 for (
int i = 0; i < nVertices; ++i )
972 polyLine[i].setX( pt.
x() );
973 polyLine[i].setY( pt.
y() );
976 if ( doSegmentation )
989 if ( doSegmentation )
1009 convertPolygon( *p, polygon );
1011 if ( doSegmentation )
1033 for (
int i = 0; i < nPoints; ++i )
1036 multiPoint[i].setX( pt->
x() );
1037 multiPoint[i].setY( pt->
y() );
1050 if ( !geomCollection )
1062 for (
int i = 0; i < nLines; ++i )
1064 bool deleteLine =
false;
1078 line->
points( lineCoords );
1080 convertToPolyline( lineCoords, polyLine );
1099 if ( !geomCollection )
1105 if ( nPolygons < 1 )
1111 for (
int i = 0; i < nPolygons; ++i )
1128 convertPolygon( *polygon, poly );
1144 double geosArea = g.
area();
1145 double qgisArea = 0;
1149 qgisArea = surface->
area();
1234 if ( !simplifiedGeom )
1250 bool ok = geos.
centroid( centroid );
1374 return geometryList;
1381 for (
int i = 0; i < numGeom; ++i )
1391 return geometryList;
1412 if ( polygon.
size() < 1 )
1414 polyline = polygon.
at( 0 );
1422 for ( ; lineIt != polyline.
constEnd(); ++lineIt )
1424 result << lineIt->toQPointF();
1521 for ( ; it != geometryList.
constEnd(); ++it )
1525 geomV2List.
append(( *it )->geometry() );
1622 int vertexCount = 0;
1623 for (
int part = 0; part < coords.
size(); ++part )
1626 for (
int ring = 0; ring < featureCoords.
size(); ++ring )
1629 for (
int vertex = 0; vertex < ringCoords.
size(); ++vertex )
1631 if ( vertexCount == nr )
1655 int vertexCount = 0;
1656 for (
int part = 0; part < coords.
size(); ++part )
1659 for (
int ring = 0; ring < featureCoords.
size(); ++ring )
1662 for (
int vertex = 0; vertex < ringCoords.
size(); ++vertex )
1664 if ( vertex ==
id.vertex && ring ==
id.ring && part ==
id.part )
1679 for ( ; it != input.
constEnd(); ++it )
1689 for ( ; it != input.
constEnd(); ++it )
1700 for (
int i = 0; i < input.
size(); ++i )
1703 output[i].setX( pt.
x() );
1704 output[i].setY( pt.
y() );
1713 if ( coord.
size() < 1 )
1720 for (
int i = 0; i < rings.
size(); ++i )
1722 convertToPolyline( rings[i], output[i] );
1759 for ( ; it != polygon.
constEnd(); ++it )
1771 for (
int i = 0; i < p1.
count(); ++i )
1773 if ( !p1.
at( i ).compare( p2.
at( i ), epsilon ) )
1784 for (
int i = 0; i < p1.
count(); ++i )
1798 for (
int i = 0; i < p1.
count(); ++i )
1830 for ( ; lineIt != multiline.
constEnd(); ++lineIt )
1832 resultMultiline <<
smoothLine( *lineIt, iterations, offset );
1850 for ( ; polyIt != multipoly.
constEnd(); ++polyIt )
1852 resultMultipoly <<
smoothPolygon( *polyIt, iterations, offset );
1866 double deltaX = p2.
x() - p1.
x();
1867 double deltaY = p2.
y() - p1.
y();
1868 return QgsPoint( p1.
x() + deltaX * offset, p1.
y() + deltaY * offset );
1874 for (
unsigned int iteration = 0; iteration < iterations; ++iteration )
1877 for (
int i = 0; i < result.
count() - 1; i++ )
1884 result = outputLine;
1893 for ( ; ringIt != polygon.
constEnd(); ++ringIt )
1896 for (
unsigned int iteration = 0; iteration < iterations; ++iteration )
1899 for (
int i = 0; i < resultRing.
count() - 1; ++i )
1907 outputRing << outputRing.
at( 0 );
1909 resultRing = outputRing;
1911 resultPoly << resultRing;
1916 QgsGeometry* QgsGeometry::convertToPoint(
bool destMultipart )
const
1924 if (( destMultipart && srcIsMultipart ) ||
1925 ( !destMultipart && !srcIsMultipart ) )
1930 if ( destMultipart )
1939 if ( multiPoint.
count() == 1 )
1950 if ( !destMultipart )
1960 multiPoint << *lineIt;
1976 if ( !destMultipart )
1987 multiPoint << *lineIt;
1997 multiPoint << *lineIt;
2007 QgsGeometry* QgsGeometry::convertToLine(
bool destMultipart )
const
2017 if ( multiPoint.
count() < 2 )
2020 if ( destMultipart )
2030 if (( destMultipart && srcIsMultipart ) ||
2031 ( !destMultipart && ! srcIsMultipart ) )
2036 if ( destMultipart )
2047 if ( multiLine.
count() == 1 )
2062 multiLine << *multiLineIt;
2064 if ( destMultipart )
2069 else if ( multiLine.
count() == 1 )
2080 if ( polygon.
count() > 1 )
2084 if ( destMultipart )
2089 multiLine << *multiLineIt;
2094 else if ( polygon.
count() == 1 )
2096 if ( destMultipart )
2114 QgsGeometry* QgsGeometry::convertToPolygon(
bool destMultipart )
const
2124 if ( multiPoint.
count() < 3 )
2127 if ( multiPoint.
last() != multiPoint.
first() )
2128 multiPoint << multiPoint.
first();
2131 if ( destMultipart )
2147 if (( *multiLineIt ).count() < 3 )
2149 if (( *multiLineIt ).count() == 3 && ( *multiLineIt ).first() == ( *multiLineIt ).last() )
2153 if (( *multiLineIt ).first() != ( *multiLineIt ).last() )
2154 *multiLineIt << ( *multiLineIt ).
first();
2155 multiPolygon << (
QgsPolygon() << *multiLineIt );
2158 if ( !multiPolygon.
isEmpty() )
2160 if ( destMultipart )
2164 else if ( multiPolygon.
count() == 1 )
2177 if ( line.
count() < 3 )
2184 line << line.
first();
2187 if ( destMultipart )
2203 if (( destMultipart && srcIsMultipart ) ||
2204 ( !destMultipart && ! srcIsMultipart ) )
2209 if ( destMultipart )
2219 if ( multiPolygon.
count() == 1 )
2235 return new QgsGeos( geometry );
2249 char *data =
new char[byteArray.size()];
2250 memcpy( data, byteArray.data(), byteArray.size() );
2251 geometry.
fromWkb((
unsigned char* )data, byteArray.size() );
QgsPolyline smoothLine(const QgsPolyline &polyline, const unsigned int iterations=1, const double offset=0.25) const
Smooths a polyline using the Chaikin algorithm.
QgsAbstractGeometryV2 * reshapeGeometry(const QgsLineStringV2 &reshapeWithLine, int *errorCode) const
static QgsGeometry * fromQPolygonF(const QPolygonF &polygon)
Construct geometry from a QPolygonF.
QgsGeometry * simplify(double tolerance) const
Returns a simplified version of this geometry using a specified tolerance value.
QgsAbstractGeometryV2 * difference(const QgsAbstractGeometryV2 &geom) const override
QgsWKBTypes::Type wkbType() const
Returns the WKB type of the geometry.
bool isEqual(const QgsAbstractGeometryV2 &geom) const override
A rectangle specified with double values.
bool isValid() const override
static bool isMultiType(Type type)
QgsPointV2 pointN(int i) const
const QgsAbstractGeometryV2 * geometry() const
Returns the underlying geometry store.
QgsGeometry * convexHull() const
Returns the smallest convex polygon that contains all the points in the geometry. ...
QDataStream & operator<<(QDataStream &out, const QgsGeometry &geometry)
Writes the geometry to stream out.
QgsGeometry * symDifference(const QgsGeometry *geometry) const
Returns a Geometry representing the points making up this Geometry that do not make up other...
QgsAbstractGeometryV2 * interpolate(double distance) const override
static Type multiType(Type type)
int reshapeGeometry(const QList< QgsPoint > &reshapeWithLine)
Replaces a part of this geometry with another line.
void append(const T &value)
QPolygonF asQPolygonF() const
Return contents of the geometry as a QPolygonF.
void push_back(const T &value)
QgsGeometry * difference(const QgsGeometry *geometry) const
Returns a geometry representing the points making up this geometry that do not make up other...
double distance(const QgsGeometry &geom) const
Returns the minimum distanace between this geometry and another geometry, using GEOS.
size_t wkbSize() const
Returns the size of the WKB in asWkb().
QgsAbstractGeometryV2 * convexHull() const override
void points(QList< QgsPointV2 > &pt) const override
Returns a list of points within the curve.
double yMaximum() const
Get the y maximum value (top side of rectangle)
virtual bool moveVertex(const QgsVertexId &position, const QgsPointV2 &newPos)=0
Moves a vertex within the geometry.
QgsMultiPolyline asMultiPolyline() const
Return contents of the geometry as a multi linestring if wkbType is WKBMultiLineString, otherwise an empty list.
QVector< QgsPoint > QgsPolyline
polyline is represented as a vector of points
QPointF asQPointF() const
Return contents of the geometry as a QPointF if wkbType is WKBPoint, otherwise returns a null QPointF...
QgsPolygon asPolygon() const
Return contents of the geometry as a polygon if wkbType is WKBPolygon, otherwise an empty list...
const_iterator constEnd() const
QList< QgsGeometry * > asGeometryCollection() const
Return contents of the geometry as a list of geometries.
QgsPoint transform(const QgsPoint &p) const
Transform the point from map (world) coordinates to device coordinates.
const T & at(int i) const
QgsAbstractGeometryV2 * simplify(double tolerance) const override
virtual QString asJSON(int precision=17) const =0
Returns a GeoJSON representation of the geometry.
void setGeometry(QgsAbstractGeometryV2 *geometry)
Sets the underlying geometry store.
QgsRectangle boundingBox() const
Returns the bounding box of this feature.
int makeDifference(const 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 coordin...
QGis::GeometryType type() const
Returns type of the geometry as a QGis::GeometryType.
static QgsAbstractGeometryV2 * fromPolygon(const QgsPolygon &polygon)
construct geometry from a polygon
Abstract base class for all geometries.
bool crosses(const QgsGeometry *geometry) const
Test for if geometry crosses another (uses GEOS)
void adjacentVertices(int atVertex, int &beforeVertex, int &afterVertex) const
Returns the indexes of the vertices before and after the given vertex index.
double length() const override
QgsGeometry * pointOnSurface() const
Returns a point within a geometry.
int addPart(const QList< QgsPoint > &points, QGis::GeometryType geomType=QGis::UnknownGeometry)
Adds a new island polygon to a multipolygon feature.
A geometry is the spatial representation of a feature.
static QgsAbstractGeometryV2 * fromGeos(const GEOSGeometry *geos)
double distance(const QgsAbstractGeometryV2 &geom) const override
static QgsPointV2 closestVertex(const QgsAbstractGeometryV2 &geom, const QgsPointV2 &pt, QgsVertexId &id)
Returns the closest vertex to a geometry for a specified point.
QByteArray fromRawData(const char *data, int size)
WkbType
Used for symbology operations.
QgsGeometry()
Constructor.
Multi point geometry collection.
static QgsAbstractGeometryV2 * fromPolyline(const QgsPolyline &polyline)
construct geometry from a polyline
static QgsAbstractGeometryV2 * fromPoint(const QgsPoint &point)
construct geometry from a point
static QgsAbstractGeometryV2 * fromMultiPolygon(const QgsMultiPolygon &multipoly)
construct geometry from a multipolygon
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 req...
bool pointOnSurface(QgsPointV2 &pt) const override
QgsPointV2 vertexAt(const QgsVertexId &id) const
Returns the point corresponding to a specified vertex id.
bool within(const QgsAbstractGeometryV2 &geom) const override
QgsGeometry & operator=(QgsGeometry const &rhs)
assignments will prompt a deep copy of the object
Multi line string geometry collection.
static QgsPolyline createPolylineFromQPolygonF(const QPolygonF &polygon)
Creates a QgsPolyline from a QPolygonF.
virtual void coordinateSequence(QList< QList< QList< QgsPointV2 > > > &coord) const override
Retrieves the sequence of geometries, rings and nodes.
static int addPart(QgsAbstractGeometryV2 *geom, QgsAbstractGeometryV2 *part)
Adds part to multi type geometry (taking ownership)
bool deleteRing(int ringNum, int partNum=0)
Delete a ring in polygon or multipolygon.
bool contains(const QgsAbstractGeometryV2 &geom) const override
const GEOSGeometry * asGeos() const
Returns a geos geometry.
static GEOSContextHandle_t getGEOSHandler()
virtual bool insertVertex(const QgsVertexId &position, const QgsPointV2 &vertex)=0
Inserts a vertex into the geometry.
QgsMultiPolygon asMultiPolygon() const
Return contents of the geometry as a multi polygon if wkbType is WKBMultiPolygon, otherwise an empty ...
static QgsAbstractGeometryV2 * geomFromWkt(const QString &text)
Construct geometry from a WKT string.
bool deletePart(int partNum)
Delete part identified by the part number.
bool isGeosEmpty() const
Check if the geometry is empty using GEOS.
Perform transforms between map coordinates and device coordinates.
bool crosses(const QgsAbstractGeometryV2 &geom) const override
int splitGeometry(const QList< QgsPoint > &splitLine, QList< QgsGeometry * > &newGeometries, bool topological, QList< QgsPoint > &topologyTestPoints)
Splits this geometry according to a given line.
int vertexNrFromVertexId(const QgsVertexId &i) const
Returns the vertex number corresponding to a vertex idd.
bool contains(const QgsPoint *p) const
Test for containment of a point (uses GEOS)
static QgsAbstractGeometryV2 * fromMultiPoint(const QgsMultiPoint &multipoint)
construct geometry from a multipoint
void append(const T &value)
static void adjacentVertices(const QgsAbstractGeometryV2 &geom, const QgsVertexId &atVertex, QgsVertexId &beforeVertex, QgsVertexId &afterVertex)
Returns vertices adjacent to a specified vertex within a geometry.
static double sqrDistance2D(const QgsPointV2 &pt1, const QgsPointV2 &pt2)
Returns the squared 2D distance between two points.
int splitGeometry(const QgsLineStringV2 &splitLine, QList< QgsAbstractGeometryV2 * > &newGeometries, bool topological, QList< QgsPointV2 > &topologyTestPoints) const override
Splits this geometry according to a given line.
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
double xMaximum() const
Get the x maximum value (right side of rectangle)
Utility class for identifying a unique vertex within a geometry.
virtual QgsAbstractGeometryV2 * clone() const override
Clones the geometry by performing a deep copy.
Line string geometry type.
QgsPoint interpolatePointOnLine(const QgsPoint &p1, const QgsPoint &p2, const double offset)
bool overlaps(const QgsGeometry *geometry) const
Test for if geometry overlaps another (uses GEOS)
static GeometryType geometryType(Type type)
bool deleteVertex(int atVertex)
Deletes the vertex at the given position number and item (first number is index 0) Returns false if a...
QgsPolygon smoothPolygon(const QgsPolygon &polygon, const unsigned int iterations=1, const double offset=0.25) const
Smooths a polygon using the Chaikin algorithm.
QgsPoint closestVertex(const QgsPoint &point, int &atVertex, int &beforeVertex, int &afterVertex, double &sqrDist) const
Returns the vertex closest to the given point, the corresponding vertex index, squared distance snap ...
QgsGeometry * interpolate(double distance) const
int avoidIntersections(QMap< QgsVectorLayer *, QSet< QgsFeatureId > > ignoreFeatures=(QMap< QgsVectorLayer *, QSet< QgsFeatureId > >()))
Modifies geometry to avoid intersections with the layers specified in project properties.
static bool compare(const QgsPolyline &p1, const QgsPolyline &p2, double epsilon=4 *DBL_EPSILON)
Compares two polylines for equality within a specified tolerance.
QVector< QgsPolygon > QgsMultiPolygon
a collection of QgsPolygons that share a common collection of attributes
QVector< QgsPoint > QgsMultiPoint
a collection of QgsPoints that share a common collection of attributes
void fromGeos(GEOSGeometry *geos)
Set the geometry, feeding in a geometry in GEOS format.
virtual bool hasCurvedSegments() const
Returns true if the geometry contains curved segments.
virtual unsigned char * asWkb(int &binarySize) const =0
Returns a WKB representation of the geometry.
virtual QgsPolygonV2 * toPolygon() const
QGis::WkbType wkbType() const
Returns type of the geometry as a WKB type (point / linestring / polygon etc.)
QgsAbstractGeometryV2 * intersection(const QgsAbstractGeometryV2 &geom) const override
double closestSegmentWithContext(const QgsPoint &point, QgsPoint &minDistPoint, int &afterVertex, double *leftOf=0, double epsilon=DEFAULT_SEGMENT_EPSILON) const
Searches for the closest segment of geometry to the given point.
QVector< QgsPolyline > QgsPolygon
polygon: first item of the list is outer ring, inner rings (if any) start from second item ...
QgsGeometry * centroid() const
Returns the center of mass of a geometry.
void validateGeometry(QList< Error > &errors)
Validate geometry and produce a list of geometry errors.
void convertToStraightSegment()
Converts the geometry to straight line segments, if it is a curved geometry type. ...
static QgsAbstractGeometryV2 * geomFromWkbType(QgsWKBTypes::Type t)
return empty geometry from wkb type
Does vector analysis using the geos library and handles import, export, exception handling*...
QgsGeometry * buffer(double distance, int segments) const
Returns a buffer region around this geometry having the given width and with a specified number of se...
A class to represent a point.
static QgsGeometry * fromPoint(const QgsPoint &point)
Creates a new geometry from a QgsPoint object.
int translate(double dx, double dy)
Translate this geometry by dx, dy.
void draw(QPainter &p) const
Draws the geometry onto a QPainter.
static QgsGeometryEngine * createGeometryEngine(const QgsAbstractGeometryV2 *geometry)
Creates and returns a new geometry engine.
virtual QString geometryType() const =0
Returns a unique string representing the geometry type.
QgsAbstractGeometryV2 * symDifference(const QgsAbstractGeometryV2 &geom) const override
static void validateGeometry(const QgsGeometry *g, QList< QgsGeometry::Error > &errors)
Validate geometry and produce a list of geometry errors.
double length() const
Returns the length of geometry using GEOS.
QVector< QgsPolyline > QgsMultiPolyline
a collection of QgsPolylines that share a common collection of attributes
virtual QgsAbstractGeometryV2 * segmentize() const
Returns a version of the geometry without curves.
static QgsAbstractGeometryV2 * geomFromWkb(const unsigned char *wkb)
Construct geometry from a WKB string.
static QgsGeometry * fromMultiPolyline(const QgsMultiPolyline &multiline)
Creates a new geometry from a QgsMultiPolyline object.
static QgsGeometry * fromQPointF(const QPointF &point)
Construct geometry from a QPointF.
static bool deletePart(QgsAbstractGeometryV2 *geom, int partNum)
Deletes a part from a geometry.
bool isGeosEqual(const QgsGeometry &) const
Compares the geometry with another geometry using GEOS.
QgsGeometry * intersection(const QgsGeometry *geometry) const
Returns a geometry representing the points shared by this geometry and other.
bool vertexIdFromVertexNr(int nr, QgsVertexId &id) const
Calculates the vertex ID from a vertex number.
QgsGeometry * combine(const QgsGeometry *geometry) const
Returns a geometry representing all the points in this geometry and other (a union geometry operation...
static bool deleteRing(QgsAbstractGeometryV2 *geom, int ringNum, int partNum=0)
Deletes a ring from a geometry.
QgsPolyline asPolyline() const
Return contents of the geometry as a polyline if wkbType is WKBLineString, otherwise an empty list...
static QgsAbstractGeometryV2 * avoidIntersections(const QgsAbstractGeometryV2 &geom, QMap< QgsVectorLayer *, QSet< QgsFeatureId > > ignoreFeatures=(QMap< QgsVectorLayer *, QSet< QgsFeatureId > >()))
Alters a geometry so that it avoids intersections with features from all open vector layers...
virtual bool deleteVertex(const QgsVertexId &position)=0
Deletes a vertex within the geometry.
int numGeometries() const
Returns the number of geometries within the collection.
static QgsPolygon createPolygonFromQPolygonF(const QPolygonF &polygon)
Creates a QgsPolygon from a QPolygonF.
const T & at(int i) const
virtual QgsLineStringV2 * curveToLine() const =0
Returns a new line string geometry corresponding to a segmentized approximation of the curve...
const_iterator constBegin() const
QgsAbstractGeometryV2 * offsetCurve(double distance, int segments, int joinStyle, double mitreLimit) const override
bool intersects(const QgsAbstractGeometryV2 &geom) const override
static GEOSGeometry * asGeos(const QgsAbstractGeometryV2 *geom)
bool convertToMultiType()
Converts single type geometry into multitype geometry e.g.
void setPoints(const QList< QgsPointV2 > &points)
static GEOSContextHandle_t getGEOSHandler()
return GEOS context handle
void mapToPixel(const QgsMapToPixel &mtp)
Transforms the geometry from map units to pixels in place.
QString exportToGeoJSON(const int &precision=17) const
Exports the geometry to GeoJSON.
QgsGeometry * offsetCurve(double distance, int segments, int joinStyle, double mitreLimit) const
Returns an offset line at a given distance and side from an input line.
bool centroid(QgsPointV2 &pt) const override
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...
virtual void transform(const QgsCoordinateTransform &ct)=0
Transforms the geometry using a coordinate transform.
QgsMultiPoint asMultiPoint() const
Return contents of the geometry as a multi point if wkbType is WKBMultiPoint, otherwise an empty list...
bool equals(const QgsGeometry *geometry) const
Test for if geometry equals another (uses GEOS)
const unsigned char * mWkb
int rotate(double rotation, const QgsPoint ¢er)
Rotate this geometry around the Z axis.
QgsAbstractGeometryV2 * combine(const QgsAbstractGeometryV2 &geom) const override
bool isMultipart() const
Returns true if WKB of the geometry is of WKBMulti* type.
bool overlaps(const QgsAbstractGeometryV2 &geom) const override
virtual bool addGeometry(QgsAbstractGeometryV2 *g)
Adds a geometry and takes ownership.
virtual double area() const
Returns the area of the geometry.
int count(const T &value) const
bool within(const QgsGeometry *geometry) const
Test for if geometry is within another (uses GEOS)
virtual void coordinateSequence(QList< QList< QList< QgsPointV2 > > > &coord) const =0
Retrieves the sequence of geometries, rings and nodes.
virtual QString asWkt(int precision=17) const =0
Returns a WKT representation of the geometry.
const QgsAbstractGeometryV2 * geometryN(int n) const
Returns a const reference to a geometry from within the collection.
static QgsGeometry * fromRect(const QgsRectangle &rect)
Creates a new geometry from a QgsRectangle.
bool requiresConversionToStraightSegments() const
Returns true if the geometry is a curved geometry type which requires conversion to display as straig...
int transform(const QgsCoordinateTransform &ct)
Transform this geometry as described by CoordinateTransform ct.
static QgsGeometry * fromMultiPoint(const QgsMultiPoint &multipoint)
Creates a new geometry from a QgsMultiPoint object.
static QgsAbstractGeometryV2 * fromMultiPolyline(const QgsMultiPolyline &multiline)
construct geometry from a multipolyline
static QgsGeometry * fromPolyline(const QgsPolyline &polyline)
Creates a new geometry from a QgsPolyline object.
static QgsGeometry * fromWkt(QString wkt)
Creates a new geometry from a WKT string.
static int addRing(QgsAbstractGeometryV2 *geom, QgsCurveV2 *ring)
Adds interior ring (taking ownership).
static QgsGeometry * unaryUnion(const QList< QgsGeometry * > &geometryList)
compute the unary union on a list of geometries.
Multi polygon geometry collection.
Contains geometry relation and modification algorithms.
bool disjoint(const QgsGeometry *geometry) const
Test for if geometry is disjoint of another (uses GEOS)
virtual void draw(QPainter &p) const =0
Draws the geometry using the specified QPainter.
bool isEmpty() const
Returns true if the geometry is empty (ie, contains no underlying geometry accessible via geometry)...
static QgsGeometry * fromMultiPolygon(const QgsMultiPolygon &multipoly)
Creates a new geometry from a QgsMultiPolygon.
QgsAbstractGeometryV2 * buffer(double distance, int segments) const override
static QgsGeometry * fromPolygon(const QgsPolygon &polygon)
Creates a new geometry from a QgsPolygon.
~QgsGeometry()
Destructor.
bool touches(const QgsGeometry *geometry) const
Test for if geometry touch another (uses GEOS)
double ANALYSIS_EXPORT leftOf(Point3D *thepoint, Point3D *p1, Point3D *p2)
Returns whether 'thepoint' is left or right of the line from 'p1' to 'p2'.
Curve polygon geometry type.
int addRing(const QList< QgsPoint > &ring)
Adds a new ring to this geometry.
const_iterator constEnd() const
const_iterator constBegin() const
QgsRectangle boundingBox() const
Returns the minimal bounding box for the geometry.
virtual QgsAbstractGeometryV2 * clone() const =0
Clones the geometry by performing a deep copy.
Abstract base class for curved geometry type.
QgsGeometry * smooth(const unsigned int iterations=1, const double offset=0.25) const
Smooths a geometry by rounding off corners using the Chaikin algorithm.
QgsPoint asPoint() const
Return contents of the geometry as a point if wkbType is WKBPoint, otherwise returns [0...
QgsGeometry * convertToType(QGis::GeometryType destType, bool destMultipart=false) const
Try to convert the geometry to the requested type.
bool intersects(const QgsRectangle &r) const
Test for intersection with a rectangle (uses GEOS)
Represents a vector layer which manages a vector based data sets.
virtual double closestSegment(const QgsPointV2 &pt, QgsPointV2 &segmentPt, QgsVertexId &vertexAfter, bool *leftOf, double epsilon) const =0
Searches for the closest segment of the geometry to a given point.
bool isGeosValid() const
Checks validity of the geometry using GEOS.
const unsigned char * asWkb() const
Returns the buffer containing this geometry in WKB format.
double xMinimum() const
Get the x minimum value (left side of rectangle)
double closestVertexWithContext(const QgsPoint &point, int &atVertex) const
Searches for the closest vertex in this geometry to the given point.
bool touches(const QgsAbstractGeometryV2 &geom) const override
QString exportToWkt(const int &precision=17) const
Exports the geometry to WKT.
QgsPoint vertexAt(int atVertex) const
Returns coordinates of a vertex.
bool isEmpty() const override
double area() const
Returns the area of the geometry using GEOS.
bool disjoint(const QgsAbstractGeometryV2 &geom) const override
QgsAbstractGeometryV2 * geometry
int numPoints() const override
Returns the number of points in the curve.
double area() const override
QDataStream & operator>>(QDataStream &in, QgsGeometry &geometry)
Reads a geometry from stream in into geometry.
double sqrDistToVertexAt(QgsPoint &point, int atVertex) const
Returns the squared cartesian distance between the given point to the given vertex index (vertex at t...
QPointF toQPointF() const
Converts a point to a QPointF.