48 #include <netinet/in.h>
59 mutable const unsigned char*
mWkb;
103 void QgsGeometry::detach(
bool cloneGeom )
125 void QgsGeometry::removeWkbGeos()
386 beforeVertex = -1; afterVertex = -1;
543 double epsilon )
const
556 minDistPoint.
setX( segmentPt.
x() );
557 minDistPoint.
setY( segmentPt.
y() );
561 *leftOf = leftOfBool ? 1.0 : -1.0;
595 if ( points.
size() == 1 )
597 partGeom =
new QgsPointV2( points[0].x(), points[0].y() );
599 else if ( points.
size() > 1 )
607 return addPart( partGeom, geomType );
647 if ( !d || !d->
geometry || !newPart || !newPart->d || !newPart->d->
geometry )
657 if ( !d || !d->
geometry || !newPart )
711 splitLineString.
setPoints( splitLinePointsV2 );
715 int result = geos.
splitGeometry( splitLineString, newGeoms, topological, tp );
722 newGeometries.
clear();
723 for (
int i = 1; i < newGeoms.
size(); ++i )
745 reshapeLineString.
setPoints( reshapeLine );
750 if ( errorCode == 0 && geom )
803 if ( !d || !d->
geometry || !geometry || !geometry->d || !geometry->d->
geometry )
821 return geos.contains( pt );
826 if ( !d || !d->
geometry || !geometry || !geometry->d || !geometry->d->
geometry )
837 if ( !d || !d->
geometry || !geometry || !geometry->d || !geometry->d->
geometry )
848 if ( !d || !d->
geometry || !geometry || !geometry->d || !geometry->d->
geometry )
859 if ( !d || !d->
geometry || !geometry || !geometry->d || !geometry->d->
geometry )
870 if ( !d || !d->
geometry || !geometry || !geometry->d || !geometry->d->
geometry )
881 if ( !d || !d->
geometry || !geometry || !geometry->d || !geometry->d->
geometry )
892 if ( !d || !d->
geometry || !geometry || !geometry->d || !geometry->d->
geometry )
924 return convertToPoint( destMultipart );
927 return convertToLine( destMultipart );
930 return convertToPolygon( destMultipart );
976 if ( !multiGeom || multiGeom->
partCount() < 1 )
1012 if ( doSegmentation )
1031 polyLine.
resize( nVertices );
1032 for (
int i = 0; i < nVertices; ++i )
1035 polyLine[i].setX( pt.
x() );
1036 polyLine[i].setY( pt.
y() );
1039 if ( doSegmentation )
1052 if ( doSegmentation )
1072 convertPolygon( *p, polygon );
1074 if ( doSegmentation )
1096 for (
int i = 0; i < nPoints; ++i )
1099 multiPoint[i].setX( pt->
x() );
1100 multiPoint[i].setY( pt->
y() );
1113 if ( !geomCollection )
1125 for (
int i = 0; i < nLines; ++i )
1127 bool deleteLine =
false;
1141 line->
points( lineCoords );
1143 convertToPolyline( lineCoords, polyLine );
1162 if ( !geomCollection )
1168 if ( nPolygons < 1 )
1174 for (
int i = 0; i < nPolygons; ++i )
1191 convertPolygon( *polygon, poly );
1207 double geosArea = g.
area();
1208 double qgisArea = 0;
1212 qgisArea = surface->
area();
1297 if ( !simplifiedGeom )
1313 bool ok = geos.
centroid( centroid );
1437 return geometryList;
1444 geometryList.
reserve( numGeom );
1445 for (
int i = 0; i < numGeom; ++i )
1455 return geometryList;
1476 if ( polygon.
size() < 1 )
1478 polyline = polygon.
at( 0 );
1486 for ( ; lineIt != polyline.
constEnd(); ++lineIt )
1488 result << lineIt->toQPointF();
1585 for ( ; it != geometryList.
constEnd(); ++it )
1589 geomV2List.
append(( *it )->geometry() );
1686 int vertexCount = 0;
1687 for (
int part = 0; part < coords.
size(); ++part )
1690 for (
int ring = 0; ring < featureCoords.
size(); ++ring )
1693 for (
int vertex = 0; vertex < ringCoords.
size(); ++vertex )
1695 if ( vertexCount == nr )
1719 int vertexCount = 0;
1720 for (
int part = 0; part < coords.
size(); ++part )
1723 for (
int ring = 0; ring < featureCoords.
size(); ++ring )
1726 for (
int vertex = 0; vertex < ringCoords.
size(); ++vertex )
1728 if ( vertex ==
id.vertex && ring ==
id.ring && part ==
id.part )
1743 for ( ; it != input.
constEnd(); ++it )
1753 for ( ; it != input.
constEnd(); ++it )
1764 for (
int i = 0; i < input.
size(); ++i )
1767 output[i].setX( pt.
x() );
1768 output[i].setY( pt.
y() );
1777 if ( coord.
size() < 1 )
1784 for (
int i = 0; i < rings.
size(); ++i )
1786 convertToPolyline( rings[i], output[i] );
1823 for ( ; it != polygon.
constEnd(); ++it )
1835 for (
int i = 0; i < p1.
count(); ++i )
1837 if ( !p1.
at( i ).compare( p2.
at( i ), epsilon ) )
1848 for (
int i = 0; i < p1.
count(); ++i )
1862 for (
int i = 0; i < p1.
count(); ++i )
1894 for ( ; lineIt != multiline.
constEnd(); ++lineIt )
1896 resultMultiline <<
smoothLine( *lineIt, iterations, offset );
1914 for ( ; polyIt != multipoly.
constEnd(); ++polyIt )
1916 resultMultipoly <<
smoothPolygon( *polyIt, iterations, offset );
1930 double deltaX = p2.
x() - p1.
x();
1931 double deltaY = p2.
y() - p1.
y();
1932 return QgsPoint( p1.
x() + deltaX * offset, p1.
y() + deltaY * offset );
1938 for (
unsigned int iteration = 0; iteration < iterations; ++iteration )
1942 for (
int i = 0; i < result.
count() - 1; i++ )
1949 result = outputLine;
1958 for ( ; ringIt != polygon.
constEnd(); ++ringIt )
1961 for (
unsigned int iteration = 0; iteration < iterations; ++iteration )
1964 outputRing.
reserve( 2 * ( resultRing.
count() - 1 ) + 1 );
1965 for (
int i = 0; i < resultRing.
count() - 1; ++i )
1973 outputRing << outputRing.
at( 0 );
1975 resultRing = outputRing;
1977 resultPoly << resultRing;
1982 QgsGeometry* QgsGeometry::convertToPoint(
bool destMultipart )
const
1990 if (( destMultipart && srcIsMultipart ) ||
1991 ( !destMultipart && !srcIsMultipart ) )
1996 if ( destMultipart )
2005 if ( multiPoint.
count() == 1 )
2016 if ( !destMultipart )
2026 multiPoint << *lineIt;
2042 if ( !destMultipart )
2053 multiPoint << *lineIt;
2063 multiPoint << *lineIt;
2073 QgsGeometry* QgsGeometry::convertToLine(
bool destMultipart )
const
2083 if ( multiPoint.
count() < 2 )
2086 if ( destMultipart )
2096 if (( destMultipart && srcIsMultipart ) ||
2097 ( !destMultipart && ! srcIsMultipart ) )
2102 if ( destMultipart )
2113 if ( multiLine.
count() == 1 )
2128 multiLine << *multiLineIt;
2130 if ( destMultipart )
2135 else if ( multiLine.
count() == 1 )
2146 if ( polygon.
count() > 1 )
2150 if ( destMultipart )
2155 multiLine << *multiLineIt;
2160 else if ( polygon.
count() == 1 )
2162 if ( destMultipart )
2180 QgsGeometry* QgsGeometry::convertToPolygon(
bool destMultipart )
const
2190 if ( multiPoint.
count() < 3 )
2193 if ( multiPoint.
last() != multiPoint.
first() )
2194 multiPoint << multiPoint.
first();
2197 if ( destMultipart )
2213 if (( *multiLineIt ).count() < 3 )
2215 if (( *multiLineIt ).count() == 3 && ( *multiLineIt ).first() == ( *multiLineIt ).last() )
2219 if (( *multiLineIt ).first() != ( *multiLineIt ).last() )
2220 *multiLineIt << ( *multiLineIt ).
first();
2221 multiPolygon << (
QgsPolygon() << *multiLineIt );
2224 if ( !multiPolygon.
isEmpty() )
2226 if ( destMultipart )
2230 else if ( multiPolygon.
count() == 1 )
2243 if ( line.
count() < 3 )
2250 line << line.
first();
2253 if ( destMultipart )
2269 if (( destMultipart && srcIsMultipart ) ||
2270 ( !destMultipart && ! srcIsMultipart ) )
2275 if ( destMultipart )
2285 if ( multiPolygon.
count() == 1 )
2301 return new QgsGeos( geometry );
2315 if ( byteArray.isEmpty() )
2321 char *data =
new char[byteArray.size()];
2322 memcpy( data, byteArray.data(), byteArray.size() );
2323 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.
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.
QgsWKBTypes::Type wkbType() const
Returns the WKB type of the geometry.
double length(QString *errorMsg=0) const override
A rectangle specified with double values.
static bool isMultiType(Type type)
QgsPointV2 pointN(int i) const
bool intersects(const QgsAbstractGeometryV2 &geom, QString *errorMsg=0) const override
QgsGeometry * convexHull() const
Returns the smallest convex polygon that contains all the points in the geometry. ...
QgsAbstractGeometryV2 * interpolate(double distance, QString *errorMsg=0) const override
QDataStream & operator<<(QDataStream &out, const QgsGeometry &geometry)
Writes the geometry to stream out.
bool crosses(const QgsAbstractGeometryV2 &geom, QString *errorMsg=0) const override
QgsGeometry * symDifference(const QgsGeometry *geometry) const
Returns a Geometry representing the points making up this Geometry that do not make up other...
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().
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)
static bool compare(const QgsPolyline &p1, const QgsPolyline &p2, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compares two polylines for equality within a specified tolerance.
virtual bool moveVertex(const QgsVertexId &position, const QgsPointV2 &newPos)=0
Moves a vertex within the geometry.
QgsAbstractGeometryV2 * geometry() const
Returns the underlying geometry store.
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
bool centroid(QgsPointV2 &pt, QString *errorMsg=0) const override
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
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.
QgsGeometry * pointOnSurface() const
Returns a point within a geometry.
int addPart(const QList< QgsPoint > &points, QGis::GeometryType geomType=QGis::UnknownGeometry)
Adds a new part to a the geometry.
A geometry is the spatial representation of a feature.
static QgsAbstractGeometryV2 * fromGeos(const GEOSGeometry *geos)
Create a geometry from a GEOSGeometry.
bool pointOnSurface(QgsPointV2 &pt, QString *errorMsg=0) 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)
QgsGeometry()
Constructor.
Multi point geometry collection.
WkbType
Used for symbology operations.
bool disjoint(const QgsAbstractGeometryV2 &geom, QString *errorMsg=0) const override
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 contains(const QgsAbstractGeometryV2 &geom, QString *errorMsg=0) const override
QgsAbstractGeometryV2 * symDifference(const QgsAbstractGeometryV2 &geom, QString *errorMsg=0) const override
QgsGeometry & operator=(QgsGeometry const &rhs)
Assignments will prompt a deep copy of the object.
double area(QString *errorMsg=0) const override
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)
double x() const
Get the x value of the point.
bool deleteRing(int ringNum, int partNum=0)
Delete a ring in polygon or multipolygon.
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.
int splitGeometry(const QList< QgsPoint > &splitLine, QList< QgsGeometry * > &newGeometries, bool topological, QList< QgsPoint > &topologyTestPoints)
Splits this geometry according to a given line.
static Type flatType(Type type)
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.
int avoidIntersections(const QMap< QgsVectorLayer *, QSet< QgsFeatureId > > &ignoreFeatures=(QMap< QgsVectorLayer *, QSet< QgsFeatureId > >()))
Modifies geometry to avoid intersections with the layers specified in project properties.
bool overlaps(const QgsAbstractGeometryV2 &geom, QString *errorMsg=0) const override
static double sqrDistance2D(const QgsPointV2 &pt1, const QgsPointV2 &pt2)
Returns the squared 2D distance between two points.
bool convertToSingleType()
Converts multi type geometry into single type geometry e.g.
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.
Line string geometry type.
QgsPoint interpolatePointOnLine(const QgsPoint &p1, const QgsPoint &p2, const double offset)
QgsAbstractGeometryV2 * combine(const QgsAbstractGeometryV2 &geom, QString *errorMsg=0) const override
static void convertPointList(const QList< QgsPoint > &input, QList< QgsPointV2 > &output)
Upgrades a point list from QgsPoint to QgsPointV2.
bool overlaps(const QgsGeometry *geometry) const
Test for if geometry overlaps another (uses GEOS)
int splitGeometry(const QgsLineStringV2 &splitLine, QList< QgsAbstractGeometryV2 * > &newGeometries, bool topological, QList< QgsPointV2 > &topologyTestPoints, QString *errorMsg=0) const override
Splits this geometry according to a given line.
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
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 QgsPointV2 * clone() const override
Clones the geometry by performing a deep copy.
virtual QgsPolygonV2 * toPolygon() const
virtual void transform(const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection d=QgsCoordinateTransform::ForwardTransform)=0
Transforms the geometry using a coordinate transform.
QGis::WkbType wkbType() const
Returns type of the geometry as a WKB type (point / linestring / polygon etc.)
virtual int partCount() 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.
const GEOSGeometry * asGeos(double precision=0) const
Returns a geos geometry.
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.
QgsAbstractGeometryV2 * reshapeGeometry(const QgsLineStringV2 &reshapeWithLine, int *errorCode, QString *errorMsg=0) const
static QgsGeometryEngine * createGeometryEngine(const QgsAbstractGeometryV2 *geometry)
Creates and returns a new geometry engine.
static GEOSGeometry * asGeos(const QgsAbstractGeometryV2 *geom, double precision=0)
void setX(double x)
Sets the x value of the point.
virtual QgsPointV2 vertexAt(const QgsVertexId &id) const =0
Returns the point corresponding to a specified vertex id.
virtual QString geometryType() const =0
Returns a unique string representing the geometry type.
void setY(double y)
Sets the y value of the point.
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.
QgsAbstractGeometryV2 * difference(const QgsAbstractGeometryV2 &geom, QString *errorMsg=0) const override
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.
QgsAbstractGeometryV2 * convexHull(QString *errorMsg=0) const override
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.
QgsAbstractGeometryV2 * simplify(double tolerance, QString *errorMsg=0) const override
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
QgsAbstractGeometryV2 * buffer(double distance, int segments, QString *errorMsg=0) const override
virtual QgsLineStringV2 * curveToLine() const =0
Returns a new line string geometry corresponding to a segmentized approximation of the curve...
const_iterator constBegin() const
QgsAbstractGeometryV2 * intersection(const QgsAbstractGeometryV2 &geom, QString *errorMsg=0) const override
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.
bool within(const QgsAbstractGeometryV2 &geom, QString *errorMsg=0) const override
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.
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...
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.
bool isMultipart() const
Returns true if WKB of the geometry is of WKBMulti* type.
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.
bool isEqual(const QgsAbstractGeometryV2 &geom, QString *errorMsg=0) const override
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.
bool isEmpty(QString *errorMsg=0) const override
static QgsGeometry * fromMultiPoint(const QgsMultiPoint &multipoint)
Creates a new geometry from a QgsMultiPoint object.
QgsAbstractGeometryV2 * offsetCurve(double distance, int segments, int joinStyle, double mitreLimit, QString *errorMsg=0) const override
static QgsAbstractGeometryV2 * fromMultiPolyline(const QgsMultiPolyline &multiline)
Construct geometry from a multipolyline.
bool touches(const QgsAbstractGeometryV2 &geom, QString *errorMsg=0) const override
static QgsGeometry * fromPolyline(const QgsPolyline &polyline)
Creates a new geometry from a QgsPolyline object.
double y() const
Get the y value of the point.
static int addRing(QgsAbstractGeometryV2 *geom, QgsCurveV2 *ring)
Adds interior ring (taking ownership).
double distance(const QgsAbstractGeometryV2 &geom, QString *errorMsg=0) const override
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.
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.
static QgsGeometry * fromWkt(const QString &wkt)
Creates a new geometry from a WKT string.
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 isValid(QString *errorMsg=0) const override
QString exportToWkt(const int &precision=17) const
Exports the geometry to WKT.
QgsPoint vertexAt(int atVertex) const
Returns coordinates of a vertex.
double area() const
Returns the area of the geometry using GEOS.
QgsAbstractGeometryV2 * geometry
int numPoints() const override
Returns the number of points in the curve.
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.